babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863
  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/webRequest" {
  410. /**
  411. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  412. */
  413. export class WebRequest {
  414. private _xhr;
  415. /**
  416. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  417. * i.e. when loading files, where the server/service expects an Authorization header
  418. */
  419. static CustomRequestHeaders: {
  420. [key: string]: string;
  421. };
  422. /**
  423. * Add callback functions in this array to update all the requests before they get sent to the network
  424. */
  425. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  426. private _injectCustomRequestHeaders;
  427. /**
  428. * Gets or sets a function to be called when loading progress changes
  429. */
  430. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  431. /**
  432. * Returns client's state
  433. */
  434. readonly readyState: number;
  435. /**
  436. * Returns client's status
  437. */
  438. readonly status: number;
  439. /**
  440. * Returns client's status as a text
  441. */
  442. readonly statusText: string;
  443. /**
  444. * Returns client's response
  445. */
  446. readonly response: any;
  447. /**
  448. * Returns client's response url
  449. */
  450. readonly responseURL: string;
  451. /**
  452. * Returns client's response as text
  453. */
  454. readonly responseText: string;
  455. /**
  456. * Gets or sets the expected response type
  457. */
  458. responseType: XMLHttpRequestResponseType;
  459. /** @hidden */
  460. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  461. /** @hidden */
  462. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  463. /**
  464. * Cancels any network activity
  465. */
  466. abort(): void;
  467. /**
  468. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  469. * @param body defines an optional request body
  470. */
  471. send(body?: Document | BodyInit | null): void;
  472. /**
  473. * Sets the request method, request URL
  474. * @param method defines the method to use (GET, POST, etc..)
  475. * @param url defines the url to connect with
  476. */
  477. open(method: string, url: string): void;
  478. }
  479. }
  480. declare module "babylonjs/Misc/fileRequest" {
  481. import { Observable } from "babylonjs/Misc/observable";
  482. /**
  483. * File request interface
  484. */
  485. export interface IFileRequest {
  486. /**
  487. * Raised when the request is complete (success or error).
  488. */
  489. onCompleteObservable: Observable<IFileRequest>;
  490. /**
  491. * Aborts the request for a file.
  492. */
  493. abort: () => void;
  494. }
  495. }
  496. declare module "babylonjs/Maths/math.scalar" {
  497. /**
  498. * Scalar computation library
  499. */
  500. export class Scalar {
  501. /**
  502. * Two pi constants convenient for computation.
  503. */
  504. static TwoPi: number;
  505. /**
  506. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  507. * @param a number
  508. * @param b number
  509. * @param epsilon (default = 1.401298E-45)
  510. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  511. */
  512. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  513. /**
  514. * Returns a string : the upper case translation of the number i to hexadecimal.
  515. * @param i number
  516. * @returns the upper case translation of the number i to hexadecimal.
  517. */
  518. static ToHex(i: number): string;
  519. /**
  520. * Returns -1 if value is negative and +1 is value is positive.
  521. * @param value the value
  522. * @returns the value itself if it's equal to zero.
  523. */
  524. static Sign(value: number): number;
  525. /**
  526. * Returns the value itself if it's between min and max.
  527. * Returns min if the value is lower than min.
  528. * Returns max if the value is greater than max.
  529. * @param value the value to clmap
  530. * @param min the min value to clamp to (default: 0)
  531. * @param max the max value to clamp to (default: 1)
  532. * @returns the clamped value
  533. */
  534. static Clamp(value: number, min?: number, max?: number): number;
  535. /**
  536. * the log2 of value.
  537. * @param value the value to compute log2 of
  538. * @returns the log2 of value.
  539. */
  540. static Log2(value: number): number;
  541. /**
  542. * Loops the value, so that it is never larger than length and never smaller than 0.
  543. *
  544. * This is similar to the modulo operator but it works with floating point numbers.
  545. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  546. * With t = 5 and length = 2.5, the result would be 0.0.
  547. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  548. * @param value the value
  549. * @param length the length
  550. * @returns the looped value
  551. */
  552. static Repeat(value: number, length: number): number;
  553. /**
  554. * Normalize the value between 0.0 and 1.0 using min and max values
  555. * @param value value to normalize
  556. * @param min max to normalize between
  557. * @param max min to normalize between
  558. * @returns the normalized value
  559. */
  560. static Normalize(value: number, min: number, max: number): number;
  561. /**
  562. * Denormalize the value from 0.0 and 1.0 using min and max values
  563. * @param normalized value to denormalize
  564. * @param min max to denormalize between
  565. * @param max min to denormalize between
  566. * @returns the denormalized value
  567. */
  568. static Denormalize(normalized: number, min: number, max: number): number;
  569. /**
  570. * Calculates the shortest difference between two given angles given in degrees.
  571. * @param current current angle in degrees
  572. * @param target target angle in degrees
  573. * @returns the delta
  574. */
  575. static DeltaAngle(current: number, target: number): number;
  576. /**
  577. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  578. * @param tx value
  579. * @param length length
  580. * @returns The returned value will move back and forth between 0 and length
  581. */
  582. static PingPong(tx: number, length: number): number;
  583. /**
  584. * Interpolates between min and max with smoothing at the limits.
  585. *
  586. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  587. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  588. * @param from from
  589. * @param to to
  590. * @param tx value
  591. * @returns the smooth stepped value
  592. */
  593. static SmoothStep(from: number, to: number, tx: number): number;
  594. /**
  595. * Moves a value current towards target.
  596. *
  597. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  598. * Negative values of maxDelta pushes the value away from target.
  599. * @param current current value
  600. * @param target target value
  601. * @param maxDelta max distance to move
  602. * @returns resulting value
  603. */
  604. static MoveTowards(current: number, target: number, maxDelta: number): number;
  605. /**
  606. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  607. *
  608. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  609. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  610. * @param current current value
  611. * @param target target value
  612. * @param maxDelta max distance to move
  613. * @returns resulting angle
  614. */
  615. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  616. /**
  617. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  618. * @param start start value
  619. * @param end target value
  620. * @param amount amount to lerp between
  621. * @returns the lerped value
  622. */
  623. static Lerp(start: number, end: number, amount: number): number;
  624. /**
  625. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  626. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  627. * @param start start value
  628. * @param end target value
  629. * @param amount amount to lerp between
  630. * @returns the lerped value
  631. */
  632. static LerpAngle(start: number, end: number, amount: number): number;
  633. /**
  634. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  635. * @param a start value
  636. * @param b target value
  637. * @param value value between a and b
  638. * @returns the inverseLerp value
  639. */
  640. static InverseLerp(a: number, b: number, value: number): number;
  641. /**
  642. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  643. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  644. * @param value1 spline value
  645. * @param tangent1 spline value
  646. * @param value2 spline value
  647. * @param tangent2 spline value
  648. * @param amount input value
  649. * @returns hermite result
  650. */
  651. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  652. /**
  653. * Returns a random float number between and min and max values
  654. * @param min min value of random
  655. * @param max max value of random
  656. * @returns random value
  657. */
  658. static RandomRange(min: number, max: number): number;
  659. /**
  660. * This function returns percentage of a number in a given range.
  661. *
  662. * RangeToPercent(40,20,60) will return 0.5 (50%)
  663. * RangeToPercent(34,0,100) will return 0.34 (34%)
  664. * @param number to convert to percentage
  665. * @param min min range
  666. * @param max max range
  667. * @returns the percentage
  668. */
  669. static RangeToPercent(number: number, min: number, max: number): number;
  670. /**
  671. * This function returns number that corresponds to the percentage in a given range.
  672. *
  673. * PercentToRange(0.34,0,100) will return 34.
  674. * @param percent to convert to number
  675. * @param min min range
  676. * @param max max range
  677. * @returns the number
  678. */
  679. static PercentToRange(percent: number, min: number, max: number): number;
  680. /**
  681. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  682. * @param angle The angle to normalize in radian.
  683. * @return The converted angle.
  684. */
  685. static NormalizeRadians(angle: number): number;
  686. }
  687. }
  688. declare module "babylonjs/Maths/math.constants" {
  689. /**
  690. * Constant used to convert a value to gamma space
  691. * @ignorenaming
  692. */
  693. export const ToGammaSpace: number;
  694. /**
  695. * Constant used to convert a value to linear space
  696. * @ignorenaming
  697. */
  698. export const ToLinearSpace = 2.2;
  699. /**
  700. * Constant used to define the minimal number value in Babylon.js
  701. * @ignorenaming
  702. */
  703. let Epsilon: number;
  704. export { Epsilon };
  705. }
  706. declare module "babylonjs/Maths/math.viewport" {
  707. /**
  708. * Class used to represent a viewport on screen
  709. */
  710. export class Viewport {
  711. /** viewport left coordinate */
  712. x: number;
  713. /** viewport top coordinate */
  714. y: number;
  715. /**viewport width */
  716. width: number;
  717. /** viewport height */
  718. height: number;
  719. /**
  720. * Creates a Viewport object located at (x, y) and sized (width, height)
  721. * @param x defines viewport left coordinate
  722. * @param y defines viewport top coordinate
  723. * @param width defines the viewport width
  724. * @param height defines the viewport height
  725. */
  726. constructor(
  727. /** viewport left coordinate */
  728. x: number,
  729. /** viewport top coordinate */
  730. y: number,
  731. /**viewport width */
  732. width: number,
  733. /** viewport height */
  734. height: number);
  735. /**
  736. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  737. * @param renderWidth defines the rendering width
  738. * @param renderHeight defines the rendering height
  739. * @returns a new Viewport
  740. */
  741. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  742. /**
  743. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  744. * @param renderWidth defines the rendering width
  745. * @param renderHeight defines the rendering height
  746. * @param ref defines the target viewport
  747. * @returns the current viewport
  748. */
  749. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  750. /**
  751. * Returns a new Viewport copied from the current one
  752. * @returns a new Viewport
  753. */
  754. clone(): Viewport;
  755. }
  756. }
  757. declare module "babylonjs/Misc/arrayTools" {
  758. /**
  759. * Class containing a set of static utilities functions for arrays.
  760. */
  761. export class ArrayTools {
  762. /**
  763. * Returns an array of the given size filled with element built from the given constructor and the paramters
  764. * @param size the number of element to construct and put in the array
  765. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  766. * @returns a new array filled with new objects
  767. */
  768. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  769. }
  770. }
  771. declare module "babylonjs/Maths/math.like" {
  772. import { float, int, DeepImmutable } from "babylonjs/types";
  773. /**
  774. * @hidden
  775. */
  776. export interface IColor4Like {
  777. r: float;
  778. g: float;
  779. b: float;
  780. a: float;
  781. }
  782. /**
  783. * @hidden
  784. */
  785. export interface IColor3Like {
  786. r: float;
  787. g: float;
  788. b: float;
  789. }
  790. /**
  791. * @hidden
  792. */
  793. export interface IVector4Like {
  794. x: float;
  795. y: float;
  796. z: float;
  797. w: float;
  798. }
  799. /**
  800. * @hidden
  801. */
  802. export interface IVector3Like {
  803. x: float;
  804. y: float;
  805. z: float;
  806. }
  807. /**
  808. * @hidden
  809. */
  810. export interface IVector2Like {
  811. x: float;
  812. y: float;
  813. }
  814. /**
  815. * @hidden
  816. */
  817. export interface IMatrixLike {
  818. toArray(): DeepImmutable<Float32Array>;
  819. updateFlag: int;
  820. }
  821. /**
  822. * @hidden
  823. */
  824. export interface IViewportLike {
  825. x: float;
  826. y: float;
  827. width: float;
  828. height: float;
  829. }
  830. /**
  831. * @hidden
  832. */
  833. export interface IPlaneLike {
  834. normal: IVector3Like;
  835. d: float;
  836. normalize(): void;
  837. }
  838. }
  839. declare module "babylonjs/Maths/math.vector" {
  840. import { Viewport } from "babylonjs/Maths/math.viewport";
  841. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  842. import { IPlaneLike } from "babylonjs/Maths/math.like";
  843. /**
  844. * Class representing a vector containing 2 coordinates
  845. */
  846. export class Vector2 {
  847. /** defines the first coordinate */
  848. x: number;
  849. /** defines the second coordinate */
  850. y: number;
  851. /**
  852. * Creates a new Vector2 from the given x and y coordinates
  853. * @param x defines the first coordinate
  854. * @param y defines the second coordinate
  855. */
  856. constructor(
  857. /** defines the first coordinate */
  858. x?: number,
  859. /** defines the second coordinate */
  860. y?: number);
  861. /**
  862. * Gets a string with the Vector2 coordinates
  863. * @returns a string with the Vector2 coordinates
  864. */
  865. toString(): string;
  866. /**
  867. * Gets class name
  868. * @returns the string "Vector2"
  869. */
  870. getClassName(): string;
  871. /**
  872. * Gets current vector hash code
  873. * @returns the Vector2 hash code as a number
  874. */
  875. getHashCode(): number;
  876. /**
  877. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  878. * @param array defines the source array
  879. * @param index defines the offset in source array
  880. * @returns the current Vector2
  881. */
  882. toArray(array: FloatArray, index?: number): Vector2;
  883. /**
  884. * Copy the current vector to an array
  885. * @returns a new array with 2 elements: the Vector2 coordinates.
  886. */
  887. asArray(): number[];
  888. /**
  889. * Sets the Vector2 coordinates with the given Vector2 coordinates
  890. * @param source defines the source Vector2
  891. * @returns the current updated Vector2
  892. */
  893. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  894. /**
  895. * Sets the Vector2 coordinates with the given floats
  896. * @param x defines the first coordinate
  897. * @param y defines the second coordinate
  898. * @returns the current updated Vector2
  899. */
  900. copyFromFloats(x: number, y: number): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. set(x: number, y: number): Vector2;
  908. /**
  909. * Add another vector with the current one
  910. * @param otherVector defines the other vector
  911. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  912. */
  913. add(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  916. * @param otherVector defines the other vector
  917. * @param result defines the target vector
  918. * @returns the unmodified current Vector2
  919. */
  920. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  921. /**
  922. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  923. * @param otherVector defines the other vector
  924. * @returns the current updated Vector2
  925. */
  926. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  927. /**
  928. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  929. * @param otherVector defines the other vector
  930. * @returns a new Vector2
  931. */
  932. addVector3(otherVector: Vector3): Vector2;
  933. /**
  934. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  935. * @param otherVector defines the other vector
  936. * @returns a new Vector2
  937. */
  938. subtract(otherVector: Vector2): Vector2;
  939. /**
  940. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  941. * @param otherVector defines the other vector
  942. * @param result defines the target vector
  943. * @returns the unmodified current Vector2
  944. */
  945. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  946. /**
  947. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns the current updated Vector2
  950. */
  951. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Multiplies in place the current Vector2 coordinates by the given ones
  954. * @param otherVector defines the other vector
  955. * @returns the current updated Vector2
  956. */
  957. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  958. /**
  959. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  960. * @param otherVector defines the other vector
  961. * @returns a new Vector2
  962. */
  963. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  964. /**
  965. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  966. * @param otherVector defines the other vector
  967. * @param result defines the target vector
  968. * @returns the unmodified current Vector2
  969. */
  970. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  971. /**
  972. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  973. * @param x defines the first coordinate
  974. * @param y defines the second coordinate
  975. * @returns a new Vector2
  976. */
  977. multiplyByFloats(x: number, y: number): Vector2;
  978. /**
  979. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  980. * @param otherVector defines the other vector
  981. * @returns a new Vector2
  982. */
  983. divide(otherVector: Vector2): Vector2;
  984. /**
  985. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  986. * @param otherVector defines the other vector
  987. * @param result defines the target vector
  988. * @returns the unmodified current Vector2
  989. */
  990. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  991. /**
  992. * Divides the current Vector2 coordinates by the given ones
  993. * @param otherVector defines the other vector
  994. * @returns the current updated Vector2
  995. */
  996. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  997. /**
  998. * Gets a new Vector2 with current Vector2 negated coordinates
  999. * @returns a new Vector2
  1000. */
  1001. negate(): Vector2;
  1002. /**
  1003. * Multiply the Vector2 coordinates by scale
  1004. * @param scale defines the scaling factor
  1005. * @returns the current updated Vector2
  1006. */
  1007. scaleInPlace(scale: number): Vector2;
  1008. /**
  1009. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1010. * @param scale defines the scaling factor
  1011. * @returns a new Vector2
  1012. */
  1013. scale(scale: number): Vector2;
  1014. /**
  1015. * Scale the current Vector2 values by a factor to a given Vector2
  1016. * @param scale defines the scale factor
  1017. * @param result defines the Vector2 object where to store the result
  1018. * @returns the unmodified current Vector2
  1019. */
  1020. scaleToRef(scale: number, result: Vector2): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Gets a boolean if two vectors are equals
  1030. * @param otherVector defines the other vector
  1031. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1032. */
  1033. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1034. /**
  1035. * Gets a boolean if two vectors are equals (using an epsilon value)
  1036. * @param otherVector defines the other vector
  1037. * @param epsilon defines the minimal distance to consider equality
  1038. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1039. */
  1040. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1041. /**
  1042. * Gets a new Vector2 from current Vector2 floored values
  1043. * @returns a new Vector2
  1044. */
  1045. floor(): Vector2;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. fract(): Vector2;
  1051. /**
  1052. * Gets the length of the vector
  1053. * @returns the vector length (float)
  1054. */
  1055. length(): number;
  1056. /**
  1057. * Gets the vector squared length
  1058. * @returns the vector squared length (float)
  1059. */
  1060. lengthSquared(): number;
  1061. /**
  1062. * Normalize the vector
  1063. * @returns the current updated Vector2
  1064. */
  1065. normalize(): Vector2;
  1066. /**
  1067. * Gets a new Vector2 copied from the Vector2
  1068. * @returns a new Vector2
  1069. */
  1070. clone(): Vector2;
  1071. /**
  1072. * Gets a new Vector2(0, 0)
  1073. * @returns a new Vector2
  1074. */
  1075. static Zero(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(1, 1)
  1078. * @returns a new Vector2
  1079. */
  1080. static One(): Vector2;
  1081. /**
  1082. * Gets a new Vector2 set from the given index element of the given array
  1083. * @param array defines the data source
  1084. * @param offset defines the offset in the data source
  1085. * @returns a new Vector2
  1086. */
  1087. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1088. /**
  1089. * Sets "result" from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @param result defines the target vector
  1093. */
  1094. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1095. /**
  1096. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1097. * @param value1 defines 1st point of control
  1098. * @param value2 defines 2nd point of control
  1099. * @param value3 defines 3rd point of control
  1100. * @param value4 defines 4th point of control
  1101. * @param amount defines the interpolation factor
  1102. * @returns a new Vector2
  1103. */
  1104. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1105. /**
  1106. * 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".
  1107. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1108. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1109. * @param value defines the value to clamp
  1110. * @param min defines the lower limit
  1111. * @param max defines the upper limit
  1112. * @returns a new Vector2
  1113. */
  1114. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1115. /**
  1116. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1117. * @param value1 defines the 1st control point
  1118. * @param tangent1 defines the outgoing tangent
  1119. * @param value2 defines the 2nd control point
  1120. * @param tangent2 defines the incoming tangent
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1127. * @param start defines the start vector
  1128. * @param end defines the end vector
  1129. * @param amount defines the interpolation factor
  1130. * @returns a new Vector2
  1131. */
  1132. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1133. /**
  1134. * Gets the dot product of the vector "left" and the vector "right"
  1135. * @param left defines first vector
  1136. * @param right defines second vector
  1137. * @returns the dot product (float)
  1138. */
  1139. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1140. /**
  1141. * Returns a new Vector2 equal to the normalized given vector
  1142. * @param vector defines the vector to normalize
  1143. * @returns a new Vector2
  1144. */
  1145. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1146. /**
  1147. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1148. * @param left defines 1st vector
  1149. * @param right defines 2nd vector
  1150. * @returns a new Vector2
  1151. */
  1152. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1162. * @param vector defines the vector to transform
  1163. * @param transformation defines the matrix to apply
  1164. * @returns a new Vector2
  1165. */
  1166. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1167. /**
  1168. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @param result defines the target vector
  1172. */
  1173. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1174. /**
  1175. * Determines if a given vector is included in a triangle
  1176. * @param p defines the vector to test
  1177. * @param p0 defines 1st triangle point
  1178. * @param p1 defines 2nd triangle point
  1179. * @param p2 defines 3rd triangle point
  1180. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1181. */
  1182. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1183. /**
  1184. * Gets the distance between the vectors "value1" and "value2"
  1185. * @param value1 defines first vector
  1186. * @param value2 defines second vector
  1187. * @returns the distance between vectors
  1188. */
  1189. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1190. /**
  1191. * Returns the squared distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the squared distance between vectors
  1195. */
  1196. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns a new Vector2
  1202. */
  1203. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1204. /**
  1205. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1206. * @param p defines the middle point
  1207. * @param segA defines one point of the segment
  1208. * @param segB defines the other point of the segment
  1209. * @returns the shortest distance
  1210. */
  1211. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1212. }
  1213. /**
  1214. * Classed used to store (x,y,z) vector representation
  1215. * A Vector3 is the main object used in 3D geometry
  1216. * It can represent etiher the coordinates of a point the space, either a direction
  1217. * Reminder: js uses a left handed forward facing system
  1218. */
  1219. export class Vector3 {
  1220. /**
  1221. * Defines the first coordinates (on X axis)
  1222. */
  1223. x: number;
  1224. /**
  1225. * Defines the second coordinates (on Y axis)
  1226. */
  1227. y: number;
  1228. /**
  1229. * Defines the third coordinates (on Z axis)
  1230. */
  1231. z: number;
  1232. private static _UpReadOnly;
  1233. private static _ZeroReadOnly;
  1234. /**
  1235. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1236. * @param x defines the first coordinates (on X axis)
  1237. * @param y defines the second coordinates (on Y axis)
  1238. * @param z defines the third coordinates (on Z axis)
  1239. */
  1240. constructor(
  1241. /**
  1242. * Defines the first coordinates (on X axis)
  1243. */
  1244. x?: number,
  1245. /**
  1246. * Defines the second coordinates (on Y axis)
  1247. */
  1248. y?: number,
  1249. /**
  1250. * Defines the third coordinates (on Z axis)
  1251. */
  1252. z?: number);
  1253. /**
  1254. * Creates a string representation of the Vector3
  1255. * @returns a string with the Vector3 coordinates.
  1256. */
  1257. toString(): string;
  1258. /**
  1259. * Gets the class name
  1260. * @returns the string "Vector3"
  1261. */
  1262. getClassName(): string;
  1263. /**
  1264. * Creates the Vector3 hash code
  1265. * @returns a number which tends to be unique between Vector3 instances
  1266. */
  1267. getHashCode(): number;
  1268. /**
  1269. * Creates an array containing three elements : the coordinates of the Vector3
  1270. * @returns a new array of numbers
  1271. */
  1272. asArray(): number[];
  1273. /**
  1274. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1275. * @param array defines the destination array
  1276. * @param index defines the offset in the destination array
  1277. * @returns the current Vector3
  1278. */
  1279. toArray(array: FloatArray, index?: number): Vector3;
  1280. /**
  1281. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1282. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1283. */
  1284. toQuaternion(): Quaternion;
  1285. /**
  1286. * Adds the given vector to the current Vector3
  1287. * @param otherVector defines the second operand
  1288. * @returns the current updated Vector3
  1289. */
  1290. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the given coordinates to the current Vector3
  1293. * @param x defines the x coordinate of the operand
  1294. * @param y defines the y coordinate of the operand
  1295. * @param z defines the z coordinate of the operand
  1296. * @returns the current updated Vector3
  1297. */
  1298. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1299. /**
  1300. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1301. * @param otherVector defines the second operand
  1302. * @returns the resulting Vector3
  1303. */
  1304. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1307. * @param otherVector defines the second operand
  1308. * @param result defines the Vector3 object where to store the result
  1309. * @returns the current Vector3
  1310. */
  1311. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1312. /**
  1313. * Subtract the given vector from the current Vector3
  1314. * @param otherVector defines the second operand
  1315. * @returns the current updated Vector3
  1316. */
  1317. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1318. /**
  1319. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1320. * @param otherVector defines the second operand
  1321. * @returns the resulting Vector3
  1322. */
  1323. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1324. /**
  1325. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1326. * @param otherVector defines the second operand
  1327. * @param result defines the Vector3 object where to store the result
  1328. * @returns the current Vector3
  1329. */
  1330. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1331. /**
  1332. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1333. * @param x defines the x coordinate of the operand
  1334. * @param y defines the y coordinate of the operand
  1335. * @param z defines the z coordinate of the operand
  1336. * @returns the resulting Vector3
  1337. */
  1338. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1339. /**
  1340. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1341. * @param x defines the x coordinate of the operand
  1342. * @param y defines the y coordinate of the operand
  1343. * @param z defines the z coordinate of the operand
  1344. * @param result defines the Vector3 object where to store the result
  1345. * @returns the current Vector3
  1346. */
  1347. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1348. /**
  1349. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1350. * @returns a new Vector3
  1351. */
  1352. negate(): Vector3;
  1353. /**
  1354. * Multiplies the Vector3 coordinates by the float "scale"
  1355. * @param scale defines the multiplier factor
  1356. * @returns the current updated Vector3
  1357. */
  1358. scaleInPlace(scale: number): Vector3;
  1359. /**
  1360. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1361. * @param scale defines the multiplier factor
  1362. * @returns a new Vector3
  1363. */
  1364. scale(scale: number): Vector3;
  1365. /**
  1366. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1367. * @param scale defines the multiplier factor
  1368. * @param result defines the Vector3 object where to store the result
  1369. * @returns the current Vector3
  1370. */
  1371. scaleToRef(scale: number, result: Vector3): Vector3;
  1372. /**
  1373. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1374. * @param scale defines the scale factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the unmodified current Vector3
  1377. */
  1378. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1381. * @param otherVector defines the second operand
  1382. * @returns true if both vectors are equals
  1383. */
  1384. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1385. /**
  1386. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1387. * @param otherVector defines the second operand
  1388. * @param epsilon defines the minimal distance to define values as equals
  1389. * @returns true if both vectors are distant less than epsilon
  1390. */
  1391. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 coordinates equals the given floats
  1394. * @param x defines the x coordinate of the operand
  1395. * @param y defines the y coordinate of the operand
  1396. * @param z defines the z coordinate of the operand
  1397. * @returns true if both vectors are equals
  1398. */
  1399. equalsToFloats(x: number, y: number, z: number): boolean;
  1400. /**
  1401. * Multiplies the current Vector3 coordinates by the given ones
  1402. * @param otherVector defines the second operand
  1403. * @returns the current updated Vector3
  1404. */
  1405. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1406. /**
  1407. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1408. * @param otherVector defines the second operand
  1409. * @returns the new Vector3
  1410. */
  1411. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1412. /**
  1413. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1414. * @param otherVector defines the second operand
  1415. * @param result defines the Vector3 object where to store the result
  1416. * @returns the current Vector3
  1417. */
  1418. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1419. /**
  1420. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1421. * @param x defines the x coordinate of the operand
  1422. * @param y defines the y coordinate of the operand
  1423. * @param z defines the z coordinate of the operand
  1424. * @returns the new Vector3
  1425. */
  1426. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1427. /**
  1428. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1429. * @param otherVector defines the second operand
  1430. * @returns the new Vector3
  1431. */
  1432. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1433. /**
  1434. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1435. * @param otherVector defines the second operand
  1436. * @param result defines the Vector3 object where to store the result
  1437. * @returns the current Vector3
  1438. */
  1439. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones.
  1442. * @param otherVector defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. divideInPlace(otherVector: Vector3): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1448. * @param other defines the second operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1454. * @param other defines the second operand
  1455. * @returns the current updated Vector3
  1456. */
  1457. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1458. /**
  1459. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1460. * @param x defines the x coordinate of the operand
  1461. * @param y defines the y coordinate of the operand
  1462. * @param z defines the z coordinate of the operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1466. /**
  1467. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1468. * @param x defines the x coordinate of the operand
  1469. * @param y defines the y coordinate of the operand
  1470. * @param z defines the z coordinate of the operand
  1471. * @returns the current updated Vector3
  1472. */
  1473. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1474. /**
  1475. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1476. * Check if is non uniform within a certain amount of decimal places to account for this
  1477. * @param epsilon the amount the values can differ
  1478. * @returns if the the vector is non uniform to a certain number of decimal places
  1479. */
  1480. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1481. /**
  1482. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1483. */
  1484. readonly isNonUniform: boolean;
  1485. /**
  1486. * Gets a new Vector3 from current Vector3 floored values
  1487. * @returns a new Vector3
  1488. */
  1489. floor(): Vector3;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. fract(): Vector3;
  1495. /**
  1496. * Gets the length of the Vector3
  1497. * @returns the length of the Vector3
  1498. */
  1499. length(): number;
  1500. /**
  1501. * Gets the squared length of the Vector3
  1502. * @returns squared length of the Vector3
  1503. */
  1504. lengthSquared(): number;
  1505. /**
  1506. * Normalize the current Vector3.
  1507. * Please note that this is an in place operation.
  1508. * @returns the current updated Vector3
  1509. */
  1510. normalize(): Vector3;
  1511. /**
  1512. * Reorders the x y z properties of the vector in place
  1513. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1514. * @returns the current updated vector
  1515. */
  1516. reorderInPlace(order: string): this;
  1517. /**
  1518. * Rotates the vector around 0,0,0 by a quaternion
  1519. * @param quaternion the rotation quaternion
  1520. * @param result vector to store the result
  1521. * @returns the resulting vector
  1522. */
  1523. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1524. /**
  1525. * Rotates a vector around a given point
  1526. * @param quaternion the rotation quaternion
  1527. * @param point the point to rotate around
  1528. * @param result vector to store the result
  1529. * @returns the resulting vector
  1530. */
  1531. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1532. /**
  1533. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1534. * The cross product is then orthogonal to both current and "other"
  1535. * @param other defines the right operand
  1536. * @returns the cross product
  1537. */
  1538. cross(other: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Checks if a given vector is inside a specific range
  1777. * @param v defines the vector to test
  1778. * @param min defines the minimum range
  1779. * @param max defines the maximum range
  1780. */
  1781. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1782. /**
  1783. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1784. * @param value1 defines the first control point
  1785. * @param tangent1 defines the first tangent vector
  1786. * @param value2 defines the second control point
  1787. * @param tangent2 defines the second tangent vector
  1788. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1789. * @returns the new Vector3
  1790. */
  1791. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1792. /**
  1793. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1794. * @param start defines the start value
  1795. * @param end defines the end value
  1796. * @param amount max defines amount between both (between 0 and 1)
  1797. * @returns the new Vector3
  1798. */
  1799. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1800. /**
  1801. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1802. * @param start defines the start value
  1803. * @param end defines the end value
  1804. * @param amount max defines amount between both (between 0 and 1)
  1805. * @param result defines the Vector3 where to store the result
  1806. */
  1807. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1808. /**
  1809. * Returns the dot product (float) between the vectors "left" and "right"
  1810. * @param left defines the left operand
  1811. * @param right defines the right operand
  1812. * @returns the dot product
  1813. */
  1814. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1815. /**
  1816. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1817. * The cross product is then orthogonal to both "left" and "right"
  1818. * @param left defines the left operand
  1819. * @param right defines the right operand
  1820. * @returns the cross product
  1821. */
  1822. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1823. /**
  1824. * Sets the given vector "result" with the cross product of "left" and "right"
  1825. * The cross product is then orthogonal to both "left" and "right"
  1826. * @param left defines the left operand
  1827. * @param right defines the right operand
  1828. * @param result defines the Vector3 where to store the result
  1829. */
  1830. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1831. /**
  1832. * Returns a new Vector3 as the normalization of the given vector
  1833. * @param vector defines the Vector3 to normalize
  1834. * @returns the new Vector3
  1835. */
  1836. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1837. /**
  1838. * Sets the given vector "result" with the normalization of the given first vector
  1839. * @param vector defines the Vector3 to normalize
  1840. * @param result defines the Vector3 where to store the result
  1841. */
  1842. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1843. /**
  1844. * Project a Vector3 onto screen space
  1845. * @param vector defines the Vector3 to project
  1846. * @param world defines the world matrix to use
  1847. * @param transform defines the transform (view x projection) matrix to use
  1848. * @param viewport defines the screen viewport to use
  1849. * @returns the new Vector3
  1850. */
  1851. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1852. /** @hidden */
  1853. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param transform defines the transform (view x projection) matrix to use
  1861. * @returns the new Vector3
  1862. */
  1863. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1864. /**
  1865. * Unproject from screen space to object space
  1866. * @param source defines the screen space Vector3 to use
  1867. * @param viewportWidth defines the current width of the viewport
  1868. * @param viewportHeight defines the current height of the viewport
  1869. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1870. * @param view defines the view matrix to use
  1871. * @param projection defines the projection matrix to use
  1872. * @returns the new Vector3
  1873. */
  1874. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1875. /**
  1876. * Unproject from screen space to object space
  1877. * @param source defines the screen space Vector3 to use
  1878. * @param viewportWidth defines the current width of the viewport
  1879. * @param viewportHeight defines the current height of the viewport
  1880. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1881. * @param view defines the view matrix to use
  1882. * @param projection defines the projection matrix to use
  1883. * @param result defines the Vector3 where to store the result
  1884. */
  1885. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1886. /**
  1887. * Unproject from screen space to object space
  1888. * @param sourceX defines the screen space x coordinate to use
  1889. * @param sourceY defines the screen space y coordinate to use
  1890. * @param sourceZ defines the screen space z coordinate to use
  1891. * @param viewportWidth defines the current width of the viewport
  1892. * @param viewportHeight defines the current height of the viewport
  1893. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1894. * @param view defines the view matrix to use
  1895. * @param projection defines the projection matrix to use
  1896. * @param result defines the Vector3 where to store the result
  1897. */
  1898. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1899. /**
  1900. * Gets the minimal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Gets the maximal coordinate values between two Vector3
  1908. * @param left defines the first operand
  1909. * @param right defines the second operand
  1910. * @returns the new Vector3
  1911. */
  1912. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * Returns the distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the distance
  1918. */
  1919. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns the squared distance between the vectors "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the squared distance
  1925. */
  1926. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1927. /**
  1928. * Returns a new Vector3 located at the center between "value1" and "value2"
  1929. * @param value1 defines the first operand
  1930. * @param value2 defines the second operand
  1931. * @returns the new Vector3
  1932. */
  1933. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1934. /**
  1935. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1936. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1937. * to something in order to rotate it from its local system to the given target system
  1938. * Note: axis1, axis2 and axis3 are normalized during this operation
  1939. * @param axis1 defines the first axis
  1940. * @param axis2 defines the second axis
  1941. * @param axis3 defines the third axis
  1942. * @returns a new Vector3
  1943. */
  1944. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1947. * @param axis1 defines the first axis
  1948. * @param axis2 defines the second axis
  1949. * @param axis3 defines the third axis
  1950. * @param ref defines the Vector3 where to store the result
  1951. */
  1952. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1953. }
  1954. /**
  1955. * Vector4 class created for EulerAngle class conversion to Quaternion
  1956. */
  1957. export class Vector4 {
  1958. /** x value of the vector */
  1959. x: number;
  1960. /** y value of the vector */
  1961. y: number;
  1962. /** z value of the vector */
  1963. z: number;
  1964. /** w value of the vector */
  1965. w: number;
  1966. /**
  1967. * Creates a Vector4 object from the given floats.
  1968. * @param x x value of the vector
  1969. * @param y y value of the vector
  1970. * @param z z value of the vector
  1971. * @param w w value of the vector
  1972. */
  1973. constructor(
  1974. /** x value of the vector */
  1975. x: number,
  1976. /** y value of the vector */
  1977. y: number,
  1978. /** z value of the vector */
  1979. z: number,
  1980. /** w value of the vector */
  1981. w: number);
  1982. /**
  1983. * Returns the string with the Vector4 coordinates.
  1984. * @returns a string containing all the vector values
  1985. */
  1986. toString(): string;
  1987. /**
  1988. * Returns the string "Vector4".
  1989. * @returns "Vector4"
  1990. */
  1991. getClassName(): string;
  1992. /**
  1993. * Returns the Vector4 hash code.
  1994. * @returns a unique hash code
  1995. */
  1996. getHashCode(): number;
  1997. /**
  1998. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1999. * @returns the resulting array
  2000. */
  2001. asArray(): number[];
  2002. /**
  2003. * Populates the given array from the given index with the Vector4 coordinates.
  2004. * @param array array to populate
  2005. * @param index index of the array to start at (default: 0)
  2006. * @returns the Vector4.
  2007. */
  2008. toArray(array: FloatArray, index?: number): Vector4;
  2009. /**
  2010. * Adds the given vector to the current Vector4.
  2011. * @param otherVector the vector to add
  2012. * @returns the updated Vector4.
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2015. /**
  2016. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2017. * @param otherVector the vector to add
  2018. * @returns the resulting vector
  2019. */
  2020. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2021. /**
  2022. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2023. * @param otherVector the vector to add
  2024. * @param result the vector to store the result
  2025. * @returns the current Vector4.
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2028. /**
  2029. * Subtract in place the given vector from the current Vector4.
  2030. * @param otherVector the vector to subtract
  2031. * @returns the updated Vector4.
  2032. */
  2033. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2034. /**
  2035. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2036. * @param otherVector the vector to add
  2037. * @returns the new vector with the result
  2038. */
  2039. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2040. /**
  2041. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2042. * @param otherVector the vector to subtract
  2043. * @param result the vector to store the result
  2044. * @returns the current Vector4.
  2045. */
  2046. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2049. */
  2050. /**
  2051. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @returns new vector containing the result
  2057. */
  2058. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2059. /**
  2060. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2061. * @param x value to subtract
  2062. * @param y value to subtract
  2063. * @param z value to subtract
  2064. * @param w value to subtract
  2065. * @param result the vector to store the result in
  2066. * @returns the current Vector4.
  2067. */
  2068. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2069. /**
  2070. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2071. * @returns a new vector with the negated values
  2072. */
  2073. negate(): Vector4;
  2074. /**
  2075. * Multiplies the current Vector4 coordinates by scale (float).
  2076. * @param scale the number to scale with
  2077. * @returns the updated Vector4.
  2078. */
  2079. scaleInPlace(scale: number): Vector4;
  2080. /**
  2081. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2082. * @param scale the number to scale with
  2083. * @returns a new vector with the result
  2084. */
  2085. scale(scale: number): Vector4;
  2086. /**
  2087. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2088. * @param scale the number to scale with
  2089. * @param result a vector to store the result in
  2090. * @returns the current Vector4.
  2091. */
  2092. scaleToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2095. * @param scale defines the scale factor
  2096. * @param result defines the Vector4 object where to store the result
  2097. * @returns the unmodified current Vector4
  2098. */
  2099. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2100. /**
  2101. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2102. * @param otherVector the vector to compare against
  2103. * @returns true if they are equal
  2104. */
  2105. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2106. /**
  2107. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2108. * @param otherVector vector to compare against
  2109. * @param epsilon (Default: very small number)
  2110. * @returns true if they are equal
  2111. */
  2112. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2113. /**
  2114. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2115. * @param x x value to compare against
  2116. * @param y y value to compare against
  2117. * @param z z value to compare against
  2118. * @param w w value to compare against
  2119. * @returns true if equal
  2120. */
  2121. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2122. /**
  2123. * Multiplies in place the current Vector4 by the given one.
  2124. * @param otherVector vector to multiple with
  2125. * @returns the updated Vector4.
  2126. */
  2127. multiplyInPlace(otherVector: Vector4): Vector4;
  2128. /**
  2129. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2130. * @param otherVector vector to multiple with
  2131. * @returns resulting new vector
  2132. */
  2133. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2134. /**
  2135. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2136. * @param otherVector vector to multiple with
  2137. * @param result vector to store the result
  2138. * @returns the current Vector4.
  2139. */
  2140. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2143. * @param x x value multiply with
  2144. * @param y y value multiply with
  2145. * @param z z value multiply with
  2146. * @param w w value multiply with
  2147. * @returns resulting new vector
  2148. */
  2149. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2150. /**
  2151. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2152. * @param otherVector vector to devide with
  2153. * @returns resulting new vector
  2154. */
  2155. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2156. /**
  2157. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2158. * @param otherVector vector to devide with
  2159. * @param result vector to store the result
  2160. * @returns the current Vector4.
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2163. /**
  2164. * Divides the current Vector3 coordinates by the given ones.
  2165. * @param otherVector vector to devide with
  2166. * @returns the updated Vector3.
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2169. /**
  2170. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2171. * @param other defines the second operand
  2172. * @returns the current updated Vector4
  2173. */
  2174. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2175. /**
  2176. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2177. * @param other defines the second operand
  2178. * @returns the current updated Vector4
  2179. */
  2180. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2181. /**
  2182. * Gets a new Vector4 from current Vector4 floored values
  2183. * @returns a new Vector4
  2184. */
  2185. floor(): Vector4;
  2186. /**
  2187. * Gets a new Vector4 from current Vector3 floored values
  2188. * @returns a new Vector4
  2189. */
  2190. fract(): Vector4;
  2191. /**
  2192. * Returns the Vector4 length (float).
  2193. * @returns the length
  2194. */
  2195. length(): number;
  2196. /**
  2197. * Returns the Vector4 squared length (float).
  2198. * @returns the length squared
  2199. */
  2200. lengthSquared(): number;
  2201. /**
  2202. * Normalizes in place the Vector4.
  2203. * @returns the updated Vector4.
  2204. */
  2205. normalize(): Vector4;
  2206. /**
  2207. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2208. * @returns this converted to a new vector3
  2209. */
  2210. toVector3(): Vector3;
  2211. /**
  2212. * Returns a new Vector4 copied from the current one.
  2213. * @returns the new cloned vector
  2214. */
  2215. clone(): Vector4;
  2216. /**
  2217. * Updates the current Vector4 with the given one coordinates.
  2218. * @param source the source vector to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to copy from
  2225. * @param y float to copy from
  2226. * @param z float to copy from
  2227. * @param w float to copy from
  2228. * @returns the updated Vector4.
  2229. */
  2230. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Updates the current Vector4 coordinates with the given floats.
  2233. * @param x float to set from
  2234. * @param y float to set from
  2235. * @param z float to set from
  2236. * @param w float to set from
  2237. * @returns the updated Vector4.
  2238. */
  2239. set(x: number, y: number, z: number, w: number): Vector4;
  2240. /**
  2241. * Copies the given float to the current Vector3 coordinates
  2242. * @param v defines the x, y, z and w coordinates of the operand
  2243. * @returns the current updated Vector3
  2244. */
  2245. setAll(v: number): Vector4;
  2246. /**
  2247. * Returns a new Vector4 set from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @returns the new vector
  2251. */
  2252. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" from the starting index of the given Float32Array.
  2262. * @param array the array to pull values from
  2263. * @param offset the offset into the array to start at
  2264. * @param result the vector to store the result in
  2265. */
  2266. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2267. /**
  2268. * Updates the given vector "result" coordinates from the given floats.
  2269. * @param x float to set from
  2270. * @param y float to set from
  2271. * @param z float to set from
  2272. * @param w float to set from
  2273. * @param result the vector to the floats in
  2274. */
  2275. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2276. /**
  2277. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2278. * @returns the new vector
  2279. */
  2280. static Zero(): Vector4;
  2281. /**
  2282. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2283. * @returns the new vector
  2284. */
  2285. static One(): Vector4;
  2286. /**
  2287. * Returns a new normalized Vector4 from the given one.
  2288. * @param vector the vector to normalize
  2289. * @returns the vector
  2290. */
  2291. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2292. /**
  2293. * Updates the given vector "result" from the normalization of the given one.
  2294. * @param vector the vector to normalize
  2295. * @param result the vector to store the result in
  2296. */
  2297. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2298. /**
  2299. * Returns a vector with the minimum values from the left and right vectors
  2300. * @param left left vector to minimize
  2301. * @param right right vector to minimize
  2302. * @returns a new vector with the minimum of the left and right vector values
  2303. */
  2304. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns a vector with the maximum values from the left and right vectors
  2307. * @param left left vector to maximize
  2308. * @param right right vector to maximize
  2309. * @returns a new vector with the maximum of the left and right vector values
  2310. */
  2311. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2312. /**
  2313. * Returns the distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors
  2317. */
  2318. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the distance between
  2322. * @param value2 value to calulate the distance between
  2323. * @return the distance between the two vectors squared
  2324. */
  2325. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2326. /**
  2327. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2328. * @param value1 value to calulate the center between
  2329. * @param value2 value to calulate the center between
  2330. * @return the center between the two vectors
  2331. */
  2332. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2333. /**
  2334. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2335. * This methods computes transformed normalized direction vectors only.
  2336. * @param vector the vector to transform
  2337. * @param transformation the transformation matrix to apply
  2338. * @returns the new vector
  2339. */
  2340. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2341. /**
  2342. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2343. * This methods computes transformed normalized direction vectors only.
  2344. * @param vector the vector to transform
  2345. * @param transformation the transformation matrix to apply
  2346. * @param result the vector to store the result in
  2347. */
  2348. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2349. /**
  2350. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2351. * This methods computes transformed normalized direction vectors only.
  2352. * @param x value to transform
  2353. * @param y value to transform
  2354. * @param z value to transform
  2355. * @param w value to transform
  2356. * @param transformation the transformation matrix to apply
  2357. * @param result the vector to store the results in
  2358. */
  2359. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2360. /**
  2361. * Creates a new Vector4 from a Vector3
  2362. * @param source defines the source data
  2363. * @param w defines the 4th component (default is 0)
  2364. * @returns a new Vector4
  2365. */
  2366. static FromVector3(source: Vector3, w?: number): Vector4;
  2367. }
  2368. /**
  2369. * Class used to store quaternion data
  2370. * @see https://en.wikipedia.org/wiki/Quaternion
  2371. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2372. */
  2373. export class Quaternion {
  2374. /** defines the first component (0 by default) */
  2375. x: number;
  2376. /** defines the second component (0 by default) */
  2377. y: number;
  2378. /** defines the third component (0 by default) */
  2379. z: number;
  2380. /** defines the fourth component (1.0 by default) */
  2381. w: number;
  2382. /**
  2383. * Creates a new Quaternion from the given floats
  2384. * @param x defines the first component (0 by default)
  2385. * @param y defines the second component (0 by default)
  2386. * @param z defines the third component (0 by default)
  2387. * @param w defines the fourth component (1.0 by default)
  2388. */
  2389. constructor(
  2390. /** defines the first component (0 by default) */
  2391. x?: number,
  2392. /** defines the second component (0 by default) */
  2393. y?: number,
  2394. /** defines the third component (0 by default) */
  2395. z?: number,
  2396. /** defines the fourth component (1.0 by default) */
  2397. w?: number);
  2398. /**
  2399. * Gets a string representation for the current quaternion
  2400. * @returns a string with the Quaternion coordinates
  2401. */
  2402. toString(): string;
  2403. /**
  2404. * Gets the class name of the quaternion
  2405. * @returns the string "Quaternion"
  2406. */
  2407. getClassName(): string;
  2408. /**
  2409. * Gets a hash code for this quaternion
  2410. * @returns the quaternion hash code
  2411. */
  2412. getHashCode(): number;
  2413. /**
  2414. * Copy the quaternion to an array
  2415. * @returns a new array populated with 4 elements from the quaternion coordinates
  2416. */
  2417. asArray(): number[];
  2418. /**
  2419. * Check if two quaternions are equals
  2420. * @param otherQuaternion defines the second operand
  2421. * @return true if the current quaternion and the given one coordinates are strictly equals
  2422. */
  2423. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2424. /**
  2425. * Clone the current quaternion
  2426. * @returns a new quaternion copied from the current one
  2427. */
  2428. clone(): Quaternion;
  2429. /**
  2430. * Copy a quaternion to the current one
  2431. * @param other defines the other quaternion
  2432. * @returns the updated current quaternion
  2433. */
  2434. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2435. /**
  2436. * Updates the current quaternion with the given float coordinates
  2437. * @param x defines the x coordinate
  2438. * @param y defines the y coordinate
  2439. * @param z defines the z coordinate
  2440. * @param w defines the w coordinate
  2441. * @returns the updated current quaternion
  2442. */
  2443. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2444. /**
  2445. * Updates the current quaternion from the given float coordinates
  2446. * @param x defines the x coordinate
  2447. * @param y defines the y coordinate
  2448. * @param z defines the z coordinate
  2449. * @param w defines the w coordinate
  2450. * @returns the updated current quaternion
  2451. */
  2452. set(x: number, y: number, z: number, w: number): Quaternion;
  2453. /**
  2454. * Adds two quaternions
  2455. * @param other defines the second operand
  2456. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2457. */
  2458. add(other: DeepImmutable<Quaternion>): Quaternion;
  2459. /**
  2460. * Add a quaternion to the current one
  2461. * @param other defines the quaternion to add
  2462. * @returns the current quaternion
  2463. */
  2464. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2465. /**
  2466. * Subtract two quaternions
  2467. * @param other defines the second operand
  2468. * @returns a new quaternion as the subtraction result of the given one from the current one
  2469. */
  2470. subtract(other: Quaternion): Quaternion;
  2471. /**
  2472. * Multiplies the current quaternion by a scale factor
  2473. * @param value defines the scale factor
  2474. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2475. */
  2476. scale(value: number): Quaternion;
  2477. /**
  2478. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2479. * @param scale defines the scale factor
  2480. * @param result defines the Quaternion object where to store the result
  2481. * @returns the unmodified current quaternion
  2482. */
  2483. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2484. /**
  2485. * Multiplies in place the current quaternion by a scale factor
  2486. * @param value defines the scale factor
  2487. * @returns the current modified quaternion
  2488. */
  2489. scaleInPlace(value: number): Quaternion;
  2490. /**
  2491. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2492. * @param scale defines the scale factor
  2493. * @param result defines the Quaternion object where to store the result
  2494. * @returns the unmodified current quaternion
  2495. */
  2496. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2497. /**
  2498. * Multiplies two quaternions
  2499. * @param q1 defines the second operand
  2500. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2501. */
  2502. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2503. /**
  2504. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2505. * @param q1 defines the second operand
  2506. * @param result defines the target quaternion
  2507. * @returns the current quaternion
  2508. */
  2509. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2510. /**
  2511. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2512. * @param q1 defines the second operand
  2513. * @returns the currentupdated quaternion
  2514. */
  2515. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2518. * @param ref defines the target quaternion
  2519. * @returns the current quaternion
  2520. */
  2521. conjugateToRef(ref: Quaternion): Quaternion;
  2522. /**
  2523. * Conjugates in place (1-q) the current quaternion
  2524. * @returns the current updated quaternion
  2525. */
  2526. conjugateInPlace(): Quaternion;
  2527. /**
  2528. * Conjugates in place (1-q) the current quaternion
  2529. * @returns a new quaternion
  2530. */
  2531. conjugate(): Quaternion;
  2532. /**
  2533. * Gets length of current quaternion
  2534. * @returns the quaternion length (float)
  2535. */
  2536. length(): number;
  2537. /**
  2538. * Normalize in place the current quaternion
  2539. * @returns the current updated quaternion
  2540. */
  2541. normalize(): Quaternion;
  2542. /**
  2543. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2544. * @param order is a reserved parameter and is ignore for now
  2545. * @returns a new Vector3 containing the Euler angles
  2546. */
  2547. toEulerAngles(order?: string): Vector3;
  2548. /**
  2549. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2550. * @param result defines the vector which will be filled with the Euler angles
  2551. * @param order is a reserved parameter and is ignore for now
  2552. * @returns the current unchanged quaternion
  2553. */
  2554. toEulerAnglesToRef(result: Vector3): Quaternion;
  2555. /**
  2556. * Updates the given rotation matrix with the current quaternion values
  2557. * @param result defines the target matrix
  2558. * @returns the current unchanged quaternion
  2559. */
  2560. toRotationMatrix(result: Matrix): Quaternion;
  2561. /**
  2562. * Updates the current quaternion from the given rotation matrix values
  2563. * @param matrix defines the source matrix
  2564. * @returns the current updated quaternion
  2565. */
  2566. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2567. /**
  2568. * Creates a new quaternion from a rotation matrix
  2569. * @param matrix defines the source matrix
  2570. * @returns a new quaternion created from the given rotation matrix values
  2571. */
  2572. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2573. /**
  2574. * Updates the given quaternion with the given rotation matrix values
  2575. * @param matrix defines the source matrix
  2576. * @param result defines the target quaternion
  2577. */
  2578. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2579. /**
  2580. * Returns the dot product (float) between the quaternions "left" and "right"
  2581. * @param left defines the left operand
  2582. * @param right defines the right operand
  2583. * @returns the dot product
  2584. */
  2585. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2586. /**
  2587. * Checks if the two quaternions are close to each other
  2588. * @param quat0 defines the first quaternion to check
  2589. * @param quat1 defines the second quaternion to check
  2590. * @returns true if the two quaternions are close to each other
  2591. */
  2592. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2593. /**
  2594. * Creates an empty quaternion
  2595. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2596. */
  2597. static Zero(): Quaternion;
  2598. /**
  2599. * Inverse a given quaternion
  2600. * @param q defines the source quaternion
  2601. * @returns a new quaternion as the inverted current quaternion
  2602. */
  2603. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2604. /**
  2605. * Inverse a given quaternion
  2606. * @param q defines the source quaternion
  2607. * @param result the quaternion the result will be stored in
  2608. * @returns the result quaternion
  2609. */
  2610. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2611. /**
  2612. * Creates an identity quaternion
  2613. * @returns the identity quaternion
  2614. */
  2615. static Identity(): Quaternion;
  2616. /**
  2617. * Gets a boolean indicating if the given quaternion is identity
  2618. * @param quaternion defines the quaternion to check
  2619. * @returns true if the quaternion is identity
  2620. */
  2621. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2622. /**
  2623. * Creates a quaternion from a rotation around an axis
  2624. * @param axis defines the axis to use
  2625. * @param angle defines the angle to use
  2626. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2627. */
  2628. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2629. /**
  2630. * Creates a rotation around an axis and stores it into the given quaternion
  2631. * @param axis defines the axis to use
  2632. * @param angle defines the angle to use
  2633. * @param result defines the target quaternion
  2634. * @returns the target quaternion
  2635. */
  2636. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2637. /**
  2638. * Creates a new quaternion from data stored into an array
  2639. * @param array defines the data source
  2640. * @param offset defines the offset in the source array where the data starts
  2641. * @returns a new quaternion
  2642. */
  2643. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2644. /**
  2645. * Create a quaternion from Euler rotation angles
  2646. * @param x Pitch
  2647. * @param y Yaw
  2648. * @param z Roll
  2649. * @returns the new Quaternion
  2650. */
  2651. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2652. /**
  2653. * Updates a quaternion from Euler rotation angles
  2654. * @param x Pitch
  2655. * @param y Yaw
  2656. * @param z Roll
  2657. * @param result the quaternion to store the result
  2658. * @returns the updated quaternion
  2659. */
  2660. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2661. /**
  2662. * Create a quaternion from Euler rotation vector
  2663. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2664. * @returns the new Quaternion
  2665. */
  2666. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2667. /**
  2668. * Updates a quaternion from Euler rotation vector
  2669. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2670. * @param result the quaternion to store the result
  2671. * @returns the updated quaternion
  2672. */
  2673. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2674. /**
  2675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2676. * @param yaw defines the rotation around Y axis
  2677. * @param pitch defines the rotation around X axis
  2678. * @param roll defines the rotation around Z axis
  2679. * @returns the new quaternion
  2680. */
  2681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2682. /**
  2683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2684. * @param yaw defines the rotation around Y axis
  2685. * @param pitch defines the rotation around X axis
  2686. * @param roll defines the rotation around Z axis
  2687. * @param result defines the target quaternion
  2688. */
  2689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2690. /**
  2691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2692. * @param alpha defines the rotation around first axis
  2693. * @param beta defines the rotation around second axis
  2694. * @param gamma defines the rotation around third axis
  2695. * @returns the new quaternion
  2696. */
  2697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2698. /**
  2699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2700. * @param alpha defines the rotation around first axis
  2701. * @param beta defines the rotation around second axis
  2702. * @param gamma defines the rotation around third axis
  2703. * @param result defines the target quaternion
  2704. */
  2705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2706. /**
  2707. * 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)
  2708. * @param axis1 defines the first axis
  2709. * @param axis2 defines the second axis
  2710. * @param axis3 defines the third axis
  2711. * @returns the new quaternion
  2712. */
  2713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2714. /**
  2715. * 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
  2716. * @param axis1 defines the first axis
  2717. * @param axis2 defines the second axis
  2718. * @param axis3 defines the third axis
  2719. * @param ref defines the target quaternion
  2720. */
  2721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2722. /**
  2723. * Interpolates between two quaternions
  2724. * @param left defines first quaternion
  2725. * @param right defines second quaternion
  2726. * @param amount defines the gradient to use
  2727. * @returns the new interpolated quaternion
  2728. */
  2729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2730. /**
  2731. * Interpolates between two quaternions and stores it into a target quaternion
  2732. * @param left defines first quaternion
  2733. * @param right defines second quaternion
  2734. * @param amount defines the gradient to use
  2735. * @param result defines the target quaternion
  2736. */
  2737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2738. /**
  2739. * Interpolate between two quaternions using Hermite interpolation
  2740. * @param value1 defines first quaternion
  2741. * @param tangent1 defines the incoming tangent
  2742. * @param value2 defines second quaternion
  2743. * @param tangent2 defines the outgoing tangent
  2744. * @param amount defines the target quaternion
  2745. * @returns the new interpolated quaternion
  2746. */
  2747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2748. }
  2749. /**
  2750. * Class used to store matrix data (4x4)
  2751. */
  2752. export class Matrix {
  2753. private static _updateFlagSeed;
  2754. private static _identityReadOnly;
  2755. private _isIdentity;
  2756. private _isIdentityDirty;
  2757. private _isIdentity3x2;
  2758. private _isIdentity3x2Dirty;
  2759. /**
  2760. * Gets the update flag of the matrix which is an unique number for the matrix.
  2761. * It will be incremented every time the matrix data change.
  2762. * You can use it to speed the comparison between two versions of the same matrix.
  2763. */
  2764. updateFlag: number;
  2765. private readonly _m;
  2766. /**
  2767. * Gets the internal data of the matrix
  2768. */
  2769. readonly m: DeepImmutable<Float32Array>;
  2770. /** @hidden */
  2771. _markAsUpdated(): void;
  2772. /** @hidden */
  2773. private _updateIdentityStatus;
  2774. /**
  2775. * Creates an empty matrix (filled with zeros)
  2776. */
  2777. constructor();
  2778. /**
  2779. * Check if the current matrix is identity
  2780. * @returns true is the matrix is the identity matrix
  2781. */
  2782. isIdentity(): boolean;
  2783. /**
  2784. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2785. * @returns true is the matrix is the identity matrix
  2786. */
  2787. isIdentityAs3x2(): boolean;
  2788. /**
  2789. * Gets the determinant of the matrix
  2790. * @returns the matrix determinant
  2791. */
  2792. determinant(): number;
  2793. /**
  2794. * Returns the matrix as a Float32Array
  2795. * @returns the matrix underlying array
  2796. */
  2797. toArray(): DeepImmutable<Float32Array>;
  2798. /**
  2799. * Returns the matrix as a Float32Array
  2800. * @returns the matrix underlying array.
  2801. */
  2802. asArray(): DeepImmutable<Float32Array>;
  2803. /**
  2804. * Inverts the current matrix in place
  2805. * @returns the current inverted matrix
  2806. */
  2807. invert(): Matrix;
  2808. /**
  2809. * Sets all the matrix elements to zero
  2810. * @returns the current matrix
  2811. */
  2812. reset(): Matrix;
  2813. /**
  2814. * Adds the current matrix with a second one
  2815. * @param other defines the matrix to add
  2816. * @returns a new matrix as the addition of the current matrix and the given one
  2817. */
  2818. add(other: DeepImmutable<Matrix>): Matrix;
  2819. /**
  2820. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2821. * @param other defines the matrix to add
  2822. * @param result defines the target matrix
  2823. * @returns the current matrix
  2824. */
  2825. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2826. /**
  2827. * Adds in place the given matrix to the current matrix
  2828. * @param other defines the second operand
  2829. * @returns the current updated matrix
  2830. */
  2831. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2832. /**
  2833. * Sets the given matrix to the current inverted Matrix
  2834. * @param other defines the target matrix
  2835. * @returns the unmodified current matrix
  2836. */
  2837. invertToRef(other: Matrix): Matrix;
  2838. /**
  2839. * add a value at the specified position in the current Matrix
  2840. * @param index the index of the value within the matrix. between 0 and 15.
  2841. * @param value the value to be added
  2842. * @returns the current updated matrix
  2843. */
  2844. addAtIndex(index: number, value: number): Matrix;
  2845. /**
  2846. * mutiply the specified position in the current Matrix by a value
  2847. * @param index the index of the value within the matrix. between 0 and 15.
  2848. * @param value the value to be added
  2849. * @returns the current updated matrix
  2850. */
  2851. multiplyAtIndex(index: number, value: number): Matrix;
  2852. /**
  2853. * Inserts the translation vector (using 3 floats) in the current matrix
  2854. * @param x defines the 1st component of the translation
  2855. * @param y defines the 2nd component of the translation
  2856. * @param z defines the 3rd component of the translation
  2857. * @returns the current updated matrix
  2858. */
  2859. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2860. /**
  2861. * Adds the translation vector (using 3 floats) in the current matrix
  2862. * @param x defines the 1st component of the translation
  2863. * @param y defines the 2nd component of the translation
  2864. * @param z defines the 3rd component of the translation
  2865. * @returns the current updated matrix
  2866. */
  2867. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2868. /**
  2869. * Inserts the translation vector in the current matrix
  2870. * @param vector3 defines the translation to insert
  2871. * @returns the current updated matrix
  2872. */
  2873. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2874. /**
  2875. * Gets the translation value of the current matrix
  2876. * @returns a new Vector3 as the extracted translation from the matrix
  2877. */
  2878. getTranslation(): Vector3;
  2879. /**
  2880. * Fill a Vector3 with the extracted translation from the matrix
  2881. * @param result defines the Vector3 where to store the translation
  2882. * @returns the current matrix
  2883. */
  2884. getTranslationToRef(result: Vector3): Matrix;
  2885. /**
  2886. * Remove rotation and scaling part from the matrix
  2887. * @returns the updated matrix
  2888. */
  2889. removeRotationAndScaling(): Matrix;
  2890. /**
  2891. * Multiply two matrices
  2892. * @param other defines the second operand
  2893. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2894. */
  2895. multiply(other: DeepImmutable<Matrix>): Matrix;
  2896. /**
  2897. * Copy the current matrix from the given one
  2898. * @param other defines the source matrix
  2899. * @returns the current updated matrix
  2900. */
  2901. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Populates the given array from the starting index with the current matrix values
  2904. * @param array defines the target array
  2905. * @param offset defines the offset in the target array where to start storing values
  2906. * @returns the current matrix
  2907. */
  2908. copyToArray(array: Float32Array, offset?: number): Matrix;
  2909. /**
  2910. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2911. * @param other defines the second operand
  2912. * @param result defines the matrix where to store the multiplication
  2913. * @returns the current matrix
  2914. */
  2915. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2916. /**
  2917. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2918. * @param other defines the second operand
  2919. * @param result defines the array where to store the multiplication
  2920. * @param offset defines the offset in the target array where to start storing values
  2921. * @returns the current matrix
  2922. */
  2923. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2924. /**
  2925. * Check equality between this matrix and a second one
  2926. * @param value defines the second matrix to compare
  2927. * @returns true is the current matrix and the given one values are strictly equal
  2928. */
  2929. equals(value: DeepImmutable<Matrix>): boolean;
  2930. /**
  2931. * Clone the current matrix
  2932. * @returns a new matrix from the current matrix
  2933. */
  2934. clone(): Matrix;
  2935. /**
  2936. * Returns the name of the current matrix class
  2937. * @returns the string "Matrix"
  2938. */
  2939. getClassName(): string;
  2940. /**
  2941. * Gets the hash code of the current matrix
  2942. * @returns the hash code
  2943. */
  2944. getHashCode(): number;
  2945. /**
  2946. * Decomposes the current Matrix into a translation, rotation and scaling components
  2947. * @param scale defines the scale vector3 given as a reference to update
  2948. * @param rotation defines the rotation quaternion given as a reference to update
  2949. * @param translation defines the translation vector3 given as a reference to update
  2950. * @returns true if operation was successful
  2951. */
  2952. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2953. /**
  2954. * Gets specific row of the matrix
  2955. * @param index defines the number of the row to get
  2956. * @returns the index-th row of the current matrix as a new Vector4
  2957. */
  2958. getRow(index: number): Nullable<Vector4>;
  2959. /**
  2960. * Sets the index-th row of the current matrix to the vector4 values
  2961. * @param index defines the number of the row to set
  2962. * @param row defines the target vector4
  2963. * @returns the updated current matrix
  2964. */
  2965. setRow(index: number, row: Vector4): Matrix;
  2966. /**
  2967. * Compute the transpose of the matrix
  2968. * @returns the new transposed matrix
  2969. */
  2970. transpose(): Matrix;
  2971. /**
  2972. * Compute the transpose of the matrix and store it in a given matrix
  2973. * @param result defines the target matrix
  2974. * @returns the current matrix
  2975. */
  2976. transposeToRef(result: Matrix): Matrix;
  2977. /**
  2978. * Sets the index-th row of the current matrix with the given 4 x float values
  2979. * @param index defines the row index
  2980. * @param x defines the x component to set
  2981. * @param y defines the y component to set
  2982. * @param z defines the z component to set
  2983. * @param w defines the w component to set
  2984. * @returns the updated current matrix
  2985. */
  2986. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2987. /**
  2988. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2989. * @param scale defines the scale factor
  2990. * @returns a new matrix
  2991. */
  2992. scale(scale: number): Matrix;
  2993. /**
  2994. * Scale the current matrix values by a factor to a given result matrix
  2995. * @param scale defines the scale factor
  2996. * @param result defines the matrix to store the result
  2997. * @returns the current matrix
  2998. */
  2999. scaleToRef(scale: number, result: Matrix): Matrix;
  3000. /**
  3001. * Scale the current matrix values by a factor and add the result to a given matrix
  3002. * @param scale defines the scale factor
  3003. * @param result defines the Matrix to store the result
  3004. * @returns the current matrix
  3005. */
  3006. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3007. /**
  3008. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3009. * @param ref matrix to store the result
  3010. */
  3011. toNormalMatrix(ref: Matrix): void;
  3012. /**
  3013. * Gets only rotation part of the current matrix
  3014. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3015. */
  3016. getRotationMatrix(): Matrix;
  3017. /**
  3018. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3019. * @param result defines the target matrix to store data to
  3020. * @returns the current matrix
  3021. */
  3022. getRotationMatrixToRef(result: Matrix): Matrix;
  3023. /**
  3024. * Toggles model matrix from being right handed to left handed in place and vice versa
  3025. */
  3026. toggleModelMatrixHandInPlace(): void;
  3027. /**
  3028. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3029. */
  3030. toggleProjectionMatrixHandInPlace(): void;
  3031. /**
  3032. * Creates a matrix from an array
  3033. * @param array defines the source array
  3034. * @param offset defines an offset in the source array
  3035. * @returns a new Matrix set from the starting index of the given array
  3036. */
  3037. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3038. /**
  3039. * Copy the content of an array into a given matrix
  3040. * @param array defines the source array
  3041. * @param offset defines an offset in the source array
  3042. * @param result defines the target matrix
  3043. */
  3044. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3045. /**
  3046. * Stores an array into a matrix after having multiplied each component by a given factor
  3047. * @param array defines the source array
  3048. * @param offset defines the offset in the source array
  3049. * @param scale defines the scaling factor
  3050. * @param result defines the target matrix
  3051. */
  3052. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3053. /**
  3054. * Gets an identity matrix that must not be updated
  3055. */
  3056. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3057. /**
  3058. * Stores a list of values (16) inside a given matrix
  3059. * @param initialM11 defines 1st value of 1st row
  3060. * @param initialM12 defines 2nd value of 1st row
  3061. * @param initialM13 defines 3rd value of 1st row
  3062. * @param initialM14 defines 4th value of 1st row
  3063. * @param initialM21 defines 1st value of 2nd row
  3064. * @param initialM22 defines 2nd value of 2nd row
  3065. * @param initialM23 defines 3rd value of 2nd row
  3066. * @param initialM24 defines 4th value of 2nd row
  3067. * @param initialM31 defines 1st value of 3rd row
  3068. * @param initialM32 defines 2nd value of 3rd row
  3069. * @param initialM33 defines 3rd value of 3rd row
  3070. * @param initialM34 defines 4th value of 3rd row
  3071. * @param initialM41 defines 1st value of 4th row
  3072. * @param initialM42 defines 2nd value of 4th row
  3073. * @param initialM43 defines 3rd value of 4th row
  3074. * @param initialM44 defines 4th value of 4th row
  3075. * @param result defines the target matrix
  3076. */
  3077. 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;
  3078. /**
  3079. * Creates new matrix from a list of values (16)
  3080. * @param initialM11 defines 1st value of 1st row
  3081. * @param initialM12 defines 2nd value of 1st row
  3082. * @param initialM13 defines 3rd value of 1st row
  3083. * @param initialM14 defines 4th value of 1st row
  3084. * @param initialM21 defines 1st value of 2nd row
  3085. * @param initialM22 defines 2nd value of 2nd row
  3086. * @param initialM23 defines 3rd value of 2nd row
  3087. * @param initialM24 defines 4th value of 2nd row
  3088. * @param initialM31 defines 1st value of 3rd row
  3089. * @param initialM32 defines 2nd value of 3rd row
  3090. * @param initialM33 defines 3rd value of 3rd row
  3091. * @param initialM34 defines 4th value of 3rd row
  3092. * @param initialM41 defines 1st value of 4th row
  3093. * @param initialM42 defines 2nd value of 4th row
  3094. * @param initialM43 defines 3rd value of 4th row
  3095. * @param initialM44 defines 4th value of 4th row
  3096. * @returns the new matrix
  3097. */
  3098. 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;
  3099. /**
  3100. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3101. * @param scale defines the scale vector3
  3102. * @param rotation defines the rotation quaternion
  3103. * @param translation defines the translation vector3
  3104. * @returns a new matrix
  3105. */
  3106. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3107. /**
  3108. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3109. * @param scale defines the scale vector3
  3110. * @param rotation defines the rotation quaternion
  3111. * @param translation defines the translation vector3
  3112. * @param result defines the target matrix
  3113. */
  3114. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3115. /**
  3116. * Creates a new identity matrix
  3117. * @returns a new identity matrix
  3118. */
  3119. static Identity(): Matrix;
  3120. /**
  3121. * Creates a new identity matrix and stores the result in a given matrix
  3122. * @param result defines the target matrix
  3123. */
  3124. static IdentityToRef(result: Matrix): void;
  3125. /**
  3126. * Creates a new zero matrix
  3127. * @returns a new zero matrix
  3128. */
  3129. static Zero(): Matrix;
  3130. /**
  3131. * Creates a new rotation matrix for "angle" radians around the X axis
  3132. * @param angle defines the angle (in radians) to use
  3133. * @return the new matrix
  3134. */
  3135. static RotationX(angle: number): Matrix;
  3136. /**
  3137. * Creates a new matrix as the invert of a given matrix
  3138. * @param source defines the source matrix
  3139. * @returns the new matrix
  3140. */
  3141. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3142. /**
  3143. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3144. * @param angle defines the angle (in radians) to use
  3145. * @param result defines the target matrix
  3146. */
  3147. static RotationXToRef(angle: number, result: Matrix): void;
  3148. /**
  3149. * Creates a new rotation matrix for "angle" radians around the Y axis
  3150. * @param angle defines the angle (in radians) to use
  3151. * @return the new matrix
  3152. */
  3153. static RotationY(angle: number): Matrix;
  3154. /**
  3155. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3156. * @param angle defines the angle (in radians) to use
  3157. * @param result defines the target matrix
  3158. */
  3159. static RotationYToRef(angle: number, result: Matrix): void;
  3160. /**
  3161. * Creates a new rotation matrix for "angle" radians around the Z axis
  3162. * @param angle defines the angle (in radians) to use
  3163. * @return the new matrix
  3164. */
  3165. static RotationZ(angle: number): Matrix;
  3166. /**
  3167. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3168. * @param angle defines the angle (in radians) to use
  3169. * @param result defines the target matrix
  3170. */
  3171. static RotationZToRef(angle: number, result: Matrix): void;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the given axis
  3174. * @param axis defines the axis to use
  3175. * @param angle defines the angle (in radians) to use
  3176. * @return the new matrix
  3177. */
  3178. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3179. /**
  3180. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3181. * @param axis defines the axis to use
  3182. * @param angle defines the angle (in radians) to use
  3183. * @param result defines the target matrix
  3184. */
  3185. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3186. /**
  3187. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3188. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3189. * @param from defines the vector to align
  3190. * @param to defines the vector to align to
  3191. * @param result defines the target matrix
  3192. */
  3193. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a rotation matrix
  3196. * @param yaw defines the yaw angle in radians (Y axis)
  3197. * @param pitch defines the pitch angle in radians (X axis)
  3198. * @param roll defines the roll angle in radians (X axis)
  3199. * @returns the new rotation matrix
  3200. */
  3201. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3202. /**
  3203. * Creates a rotation matrix and stores it in a given matrix
  3204. * @param yaw defines the yaw angle in radians (Y axis)
  3205. * @param pitch defines the pitch angle in radians (X axis)
  3206. * @param roll defines the roll angle in radians (X axis)
  3207. * @param result defines the target matrix
  3208. */
  3209. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3210. /**
  3211. * Creates a scaling matrix
  3212. * @param x defines the scale factor on X axis
  3213. * @param y defines the scale factor on Y axis
  3214. * @param z defines the scale factor on Z axis
  3215. * @returns the new matrix
  3216. */
  3217. static Scaling(x: number, y: number, z: number): Matrix;
  3218. /**
  3219. * Creates a scaling matrix and stores it in a given matrix
  3220. * @param x defines the scale factor on X axis
  3221. * @param y defines the scale factor on Y axis
  3222. * @param z defines the scale factor on Z axis
  3223. * @param result defines the target matrix
  3224. */
  3225. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3226. /**
  3227. * Creates a translation matrix
  3228. * @param x defines the translation on X axis
  3229. * @param y defines the translation on Y axis
  3230. * @param z defines the translationon Z axis
  3231. * @returns the new matrix
  3232. */
  3233. static Translation(x: number, y: number, z: number): Matrix;
  3234. /**
  3235. * Creates a translation matrix and stores it in a given matrix
  3236. * @param x defines the translation on X axis
  3237. * @param y defines the translation on Y axis
  3238. * @param z defines the translationon Z axis
  3239. * @param result defines the target matrix
  3240. */
  3241. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3242. /**
  3243. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3244. * @param startValue defines the start value
  3245. * @param endValue defines the end value
  3246. * @param gradient defines the gradient factor
  3247. * @returns the new matrix
  3248. */
  3249. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3250. /**
  3251. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3252. * @param startValue defines the start value
  3253. * @param endValue defines the end value
  3254. * @param gradient defines the gradient factor
  3255. * @param result defines the Matrix object where to store data
  3256. */
  3257. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3258. /**
  3259. * Builds a new matrix whose values are computed by:
  3260. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3261. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3262. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3263. * @param startValue defines the first matrix
  3264. * @param endValue defines the second matrix
  3265. * @param gradient defines the gradient between the two matrices
  3266. * @returns the new matrix
  3267. */
  3268. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3269. /**
  3270. * Update a matrix to values which are computed by:
  3271. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3272. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3273. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3274. * @param startValue defines the first matrix
  3275. * @param endValue defines the second matrix
  3276. * @param gradient defines the gradient between the two matrices
  3277. * @param result defines the target matrix
  3278. */
  3279. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3280. /**
  3281. * 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"
  3282. * This function works in left handed mode
  3283. * @param eye defines the final position of the entity
  3284. * @param target defines where the entity should look at
  3285. * @param up defines the up vector for the entity
  3286. * @returns the new matrix
  3287. */
  3288. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3289. /**
  3290. * 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".
  3291. * This function works in left handed mode
  3292. * @param eye defines the final position of the entity
  3293. * @param target defines where the entity should look at
  3294. * @param up defines the up vector for the entity
  3295. * @param result defines the target matrix
  3296. */
  3297. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * 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"
  3300. * This function works in right handed mode
  3301. * @param eye defines the final position of the entity
  3302. * @param target defines where the entity should look at
  3303. * @param up defines the up vector for the entity
  3304. * @returns the new matrix
  3305. */
  3306. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3307. /**
  3308. * 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".
  3309. * This function works in right handed mode
  3310. * @param eye defines the final position of the entity
  3311. * @param target defines where the entity should look at
  3312. * @param up defines the up vector for the entity
  3313. * @param result defines the target matrix
  3314. */
  3315. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3316. /**
  3317. * Create a left-handed orthographic projection matrix
  3318. * @param width defines the viewport width
  3319. * @param height defines the viewport height
  3320. * @param znear defines the near clip plane
  3321. * @param zfar defines the far clip plane
  3322. * @returns a new matrix as a left-handed orthographic projection matrix
  3323. */
  3324. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3325. /**
  3326. * Store a left-handed orthographic projection to a given matrix
  3327. * @param width defines the viewport width
  3328. * @param height defines the viewport height
  3329. * @param znear defines the near clip plane
  3330. * @param zfar defines the far clip plane
  3331. * @param result defines the target matrix
  3332. */
  3333. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3334. /**
  3335. * Create a left-handed orthographic projection matrix
  3336. * @param left defines the viewport left coordinate
  3337. * @param right defines the viewport right coordinate
  3338. * @param bottom defines the viewport bottom coordinate
  3339. * @param top defines the viewport top coordinate
  3340. * @param znear defines the near clip plane
  3341. * @param zfar defines the far clip plane
  3342. * @returns a new matrix as a left-handed orthographic projection matrix
  3343. */
  3344. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3345. /**
  3346. * Stores a left-handed orthographic projection into a given matrix
  3347. * @param left defines the viewport left coordinate
  3348. * @param right defines the viewport right coordinate
  3349. * @param bottom defines the viewport bottom coordinate
  3350. * @param top defines the viewport top coordinate
  3351. * @param znear defines the near clip plane
  3352. * @param zfar defines the far clip plane
  3353. * @param result defines the target matrix
  3354. */
  3355. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3356. /**
  3357. * Creates a right-handed orthographic projection matrix
  3358. * @param left defines the viewport left coordinate
  3359. * @param right defines the viewport right coordinate
  3360. * @param bottom defines the viewport bottom coordinate
  3361. * @param top defines the viewport top coordinate
  3362. * @param znear defines the near clip plane
  3363. * @param zfar defines the far clip plane
  3364. * @returns a new matrix as a right-handed orthographic projection matrix
  3365. */
  3366. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3367. /**
  3368. * Stores a right-handed orthographic projection into a given matrix
  3369. * @param left defines the viewport left coordinate
  3370. * @param right defines the viewport right coordinate
  3371. * @param bottom defines the viewport bottom coordinate
  3372. * @param top defines the viewport top coordinate
  3373. * @param znear defines the near clip plane
  3374. * @param zfar defines the far clip plane
  3375. * @param result defines the target matrix
  3376. */
  3377. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3378. /**
  3379. * Creates a left-handed perspective projection matrix
  3380. * @param width defines the viewport width
  3381. * @param height defines the viewport height
  3382. * @param znear defines the near clip plane
  3383. * @param zfar defines the far clip plane
  3384. * @returns a new matrix as a left-handed perspective projection matrix
  3385. */
  3386. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3387. /**
  3388. * Creates a left-handed perspective projection matrix
  3389. * @param fov defines the horizontal field of view
  3390. * @param aspect defines the aspect ratio
  3391. * @param znear defines the near clip plane
  3392. * @param zfar defines the far clip plane
  3393. * @returns a new matrix as a left-handed perspective projection matrix
  3394. */
  3395. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3396. /**
  3397. * Stores a left-handed perspective projection into a given matrix
  3398. * @param fov defines the horizontal field of view
  3399. * @param aspect defines the aspect ratio
  3400. * @param znear defines the near clip plane
  3401. * @param zfar defines the far clip plane
  3402. * @param result defines the target matrix
  3403. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3404. */
  3405. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3406. /**
  3407. * Creates a right-handed perspective projection matrix
  3408. * @param fov defines the horizontal field of view
  3409. * @param aspect defines the aspect ratio
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @returns a new matrix as a right-handed perspective projection matrix
  3413. */
  3414. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3415. /**
  3416. * Stores a right-handed perspective projection into a given matrix
  3417. * @param fov defines the horizontal field of view
  3418. * @param aspect defines the aspect ratio
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @param result defines the target matrix
  3422. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3423. */
  3424. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3425. /**
  3426. * Stores a perspective projection for WebVR info a given matrix
  3427. * @param fov defines the field of view
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @param result defines the target matrix
  3431. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3432. */
  3433. static PerspectiveFovWebVRToRef(fov: {
  3434. upDegrees: number;
  3435. downDegrees: number;
  3436. leftDegrees: number;
  3437. rightDegrees: number;
  3438. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3439. /**
  3440. * Computes a complete transformation matrix
  3441. * @param viewport defines the viewport to use
  3442. * @param world defines the world matrix
  3443. * @param view defines the view matrix
  3444. * @param projection defines the projection matrix
  3445. * @param zmin defines the near clip plane
  3446. * @param zmax defines the far clip plane
  3447. * @returns the transformation matrix
  3448. */
  3449. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3450. /**
  3451. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3452. * @param matrix defines the matrix to use
  3453. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3454. */
  3455. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3456. /**
  3457. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3458. * @param matrix defines the matrix to use
  3459. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3460. */
  3461. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3462. /**
  3463. * Compute the transpose of a given matrix
  3464. * @param matrix defines the matrix to transpose
  3465. * @returns the new matrix
  3466. */
  3467. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3468. /**
  3469. * Compute the transpose of a matrix and store it in a target matrix
  3470. * @param matrix defines the matrix to transpose
  3471. * @param result defines the target matrix
  3472. */
  3473. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3474. /**
  3475. * Computes a reflection matrix from a plane
  3476. * @param plane defines the reflection plane
  3477. * @returns a new matrix
  3478. */
  3479. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3480. /**
  3481. * Computes a reflection matrix from a plane
  3482. * @param plane defines the reflection plane
  3483. * @param result defines the target matrix
  3484. */
  3485. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3486. /**
  3487. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3488. * @param xaxis defines the value of the 1st axis
  3489. * @param yaxis defines the value of the 2nd axis
  3490. * @param zaxis defines the value of the 3rd axis
  3491. * @param result defines the target matrix
  3492. */
  3493. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3494. /**
  3495. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3496. * @param quat defines the quaternion to use
  3497. * @param result defines the target matrix
  3498. */
  3499. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3500. }
  3501. /**
  3502. * @hidden
  3503. */
  3504. export class TmpVectors {
  3505. static Vector2: Vector2[];
  3506. static Vector3: Vector3[];
  3507. static Vector4: Vector4[];
  3508. static Quaternion: Quaternion[];
  3509. static Matrix: Matrix[];
  3510. }
  3511. }
  3512. declare module "babylonjs/Maths/math.color" {
  3513. import { DeepImmutable, FloatArray } from "babylonjs/types";
  3514. /**
  3515. * Class used to hold a RBG color
  3516. */
  3517. export class Color3 {
  3518. /**
  3519. * Defines the red component (between 0 and 1, default is 0)
  3520. */
  3521. r: number;
  3522. /**
  3523. * Defines the green component (between 0 and 1, default is 0)
  3524. */
  3525. g: number;
  3526. /**
  3527. * Defines the blue component (between 0 and 1, default is 0)
  3528. */
  3529. b: number;
  3530. /**
  3531. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3532. * @param r defines the red component (between 0 and 1, default is 0)
  3533. * @param g defines the green component (between 0 and 1, default is 0)
  3534. * @param b defines the blue component (between 0 and 1, default is 0)
  3535. */
  3536. constructor(
  3537. /**
  3538. * Defines the red component (between 0 and 1, default is 0)
  3539. */
  3540. r?: number,
  3541. /**
  3542. * Defines the green component (between 0 and 1, default is 0)
  3543. */
  3544. g?: number,
  3545. /**
  3546. * Defines the blue component (between 0 and 1, default is 0)
  3547. */
  3548. b?: number);
  3549. /**
  3550. * Creates a string with the Color3 current values
  3551. * @returns the string representation of the Color3 object
  3552. */
  3553. toString(): string;
  3554. /**
  3555. * Returns the string "Color3"
  3556. * @returns "Color3"
  3557. */
  3558. getClassName(): string;
  3559. /**
  3560. * Compute the Color3 hash code
  3561. * @returns an unique number that can be used to hash Color3 objects
  3562. */
  3563. getHashCode(): number;
  3564. /**
  3565. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3566. * @param array defines the array where to store the r,g,b components
  3567. * @param index defines an optional index in the target array to define where to start storing values
  3568. * @returns the current Color3 object
  3569. */
  3570. toArray(array: FloatArray, index?: number): Color3;
  3571. /**
  3572. * Returns a new Color4 object from the current Color3 and the given alpha
  3573. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3574. * @returns a new Color4 object
  3575. */
  3576. toColor4(alpha?: number): Color4;
  3577. /**
  3578. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3579. * @returns the new array
  3580. */
  3581. asArray(): number[];
  3582. /**
  3583. * Returns the luminance value
  3584. * @returns a float value
  3585. */
  3586. toLuminance(): number;
  3587. /**
  3588. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3589. * @param otherColor defines the second operand
  3590. * @returns the new Color3 object
  3591. */
  3592. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3593. /**
  3594. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3595. * @param otherColor defines the second operand
  3596. * @param result defines the Color3 object where to store the result
  3597. * @returns the current Color3
  3598. */
  3599. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3600. /**
  3601. * Determines equality between Color3 objects
  3602. * @param otherColor defines the second operand
  3603. * @returns true if the rgb values are equal to the given ones
  3604. */
  3605. equals(otherColor: DeepImmutable<Color3>): boolean;
  3606. /**
  3607. * Determines equality between the current Color3 object and a set of r,b,g values
  3608. * @param r defines the red component to check
  3609. * @param g defines the green component to check
  3610. * @param b defines the blue component to check
  3611. * @returns true if the rgb values are equal to the given ones
  3612. */
  3613. equalsFloats(r: number, g: number, b: number): boolean;
  3614. /**
  3615. * Multiplies in place each rgb value by scale
  3616. * @param scale defines the scaling factor
  3617. * @returns the updated Color3
  3618. */
  3619. scale(scale: number): Color3;
  3620. /**
  3621. * Multiplies the rgb values by scale and stores the result into "result"
  3622. * @param scale defines the scaling factor
  3623. * @param result defines the Color3 object where to store the result
  3624. * @returns the unmodified current Color3
  3625. */
  3626. scaleToRef(scale: number, result: Color3): Color3;
  3627. /**
  3628. * Scale the current Color3 values by a factor and add the result to a given Color3
  3629. * @param scale defines the scale factor
  3630. * @param result defines color to store the result into
  3631. * @returns the unmodified current Color3
  3632. */
  3633. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3634. /**
  3635. * Clamps the rgb values by the min and max values and stores the result into "result"
  3636. * @param min defines minimum clamping value (default is 0)
  3637. * @param max defines maximum clamping value (default is 1)
  3638. * @param result defines color to store the result into
  3639. * @returns the original Color3
  3640. */
  3641. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3642. /**
  3643. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3644. * @param otherColor defines the second operand
  3645. * @returns the new Color3
  3646. */
  3647. add(otherColor: DeepImmutable<Color3>): Color3;
  3648. /**
  3649. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3650. * @param otherColor defines the second operand
  3651. * @param result defines Color3 object to store the result into
  3652. * @returns the unmodified current Color3
  3653. */
  3654. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3655. /**
  3656. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3657. * @param otherColor defines the second operand
  3658. * @returns the new Color3
  3659. */
  3660. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3661. /**
  3662. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3663. * @param otherColor defines the second operand
  3664. * @param result defines Color3 object to store the result into
  3665. * @returns the unmodified current Color3
  3666. */
  3667. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3668. /**
  3669. * Copy the current object
  3670. * @returns a new Color3 copied the current one
  3671. */
  3672. clone(): Color3;
  3673. /**
  3674. * Copies the rgb values from the source in the current Color3
  3675. * @param source defines the source Color3 object
  3676. * @returns the updated Color3 object
  3677. */
  3678. copyFrom(source: DeepImmutable<Color3>): Color3;
  3679. /**
  3680. * Updates the Color3 rgb values from the given floats
  3681. * @param r defines the red component to read from
  3682. * @param g defines the green component to read from
  3683. * @param b defines the blue component to read from
  3684. * @returns the current Color3 object
  3685. */
  3686. copyFromFloats(r: number, g: number, b: number): Color3;
  3687. /**
  3688. * Updates the Color3 rgb values from the given floats
  3689. * @param r defines the red component to read from
  3690. * @param g defines the green component to read from
  3691. * @param b defines the blue component to read from
  3692. * @returns the current Color3 object
  3693. */
  3694. set(r: number, g: number, b: number): Color3;
  3695. /**
  3696. * Compute the Color3 hexadecimal code as a string
  3697. * @returns a string containing the hexadecimal representation of the Color3 object
  3698. */
  3699. toHexString(): string;
  3700. /**
  3701. * Computes a new Color3 converted from the current one to linear space
  3702. * @returns a new Color3 object
  3703. */
  3704. toLinearSpace(): Color3;
  3705. /**
  3706. * Converts current color in rgb space to HSV values
  3707. * @returns a new color3 representing the HSV values
  3708. */
  3709. toHSV(): Color3;
  3710. /**
  3711. * Converts current color in rgb space to HSV values
  3712. * @param result defines the Color3 where to store the HSV values
  3713. */
  3714. toHSVToRef(result: Color3): void;
  3715. /**
  3716. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3717. * @param convertedColor defines the Color3 object where to store the linear space version
  3718. * @returns the unmodified Color3
  3719. */
  3720. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3721. /**
  3722. * Computes a new Color3 converted from the current one to gamma space
  3723. * @returns a new Color3 object
  3724. */
  3725. toGammaSpace(): Color3;
  3726. /**
  3727. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3728. * @param convertedColor defines the Color3 object where to store the gamma space version
  3729. * @returns the unmodified Color3
  3730. */
  3731. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3732. private static _BlackReadOnly;
  3733. /**
  3734. * Convert Hue, saturation and value to a Color3 (RGB)
  3735. * @param hue defines the hue
  3736. * @param saturation defines the saturation
  3737. * @param value defines the value
  3738. * @param result defines the Color3 where to store the RGB values
  3739. */
  3740. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3741. /**
  3742. * Creates a new Color3 from the string containing valid hexadecimal values
  3743. * @param hex defines a string containing valid hexadecimal values
  3744. * @returns a new Color3 object
  3745. */
  3746. static FromHexString(hex: string): Color3;
  3747. /**
  3748. * Creates a new Color3 from the starting index of the given array
  3749. * @param array defines the source array
  3750. * @param offset defines an offset in the source array
  3751. * @returns a new Color3 object
  3752. */
  3753. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3754. /**
  3755. * Creates a new Color3 from integer values (< 256)
  3756. * @param r defines the red component to read from (value between 0 and 255)
  3757. * @param g defines the green component to read from (value between 0 and 255)
  3758. * @param b defines the blue component to read from (value between 0 and 255)
  3759. * @returns a new Color3 object
  3760. */
  3761. static FromInts(r: number, g: number, b: number): Color3;
  3762. /**
  3763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3764. * @param start defines the start Color3 value
  3765. * @param end defines the end Color3 value
  3766. * @param amount defines the gradient value between start and end
  3767. * @returns a new Color3 object
  3768. */
  3769. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3770. /**
  3771. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3772. * @param left defines the start value
  3773. * @param right defines the end value
  3774. * @param amount defines the gradient factor
  3775. * @param result defines the Color3 object where to store the result
  3776. */
  3777. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3778. /**
  3779. * Returns a Color3 value containing a red color
  3780. * @returns a new Color3 object
  3781. */
  3782. static Red(): Color3;
  3783. /**
  3784. * Returns a Color3 value containing a green color
  3785. * @returns a new Color3 object
  3786. */
  3787. static Green(): Color3;
  3788. /**
  3789. * Returns a Color3 value containing a blue color
  3790. * @returns a new Color3 object
  3791. */
  3792. static Blue(): Color3;
  3793. /**
  3794. * Returns a Color3 value containing a black color
  3795. * @returns a new Color3 object
  3796. */
  3797. static Black(): Color3;
  3798. /**
  3799. * Gets a Color3 value containing a black color that must not be updated
  3800. */
  3801. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3802. /**
  3803. * Returns a Color3 value containing a white color
  3804. * @returns a new Color3 object
  3805. */
  3806. static White(): Color3;
  3807. /**
  3808. * Returns a Color3 value containing a purple color
  3809. * @returns a new Color3 object
  3810. */
  3811. static Purple(): Color3;
  3812. /**
  3813. * Returns a Color3 value containing a magenta color
  3814. * @returns a new Color3 object
  3815. */
  3816. static Magenta(): Color3;
  3817. /**
  3818. * Returns a Color3 value containing a yellow color
  3819. * @returns a new Color3 object
  3820. */
  3821. static Yellow(): Color3;
  3822. /**
  3823. * Returns a Color3 value containing a gray color
  3824. * @returns a new Color3 object
  3825. */
  3826. static Gray(): Color3;
  3827. /**
  3828. * Returns a Color3 value containing a teal color
  3829. * @returns a new Color3 object
  3830. */
  3831. static Teal(): Color3;
  3832. /**
  3833. * Returns a Color3 value containing a random color
  3834. * @returns a new Color3 object
  3835. */
  3836. static Random(): Color3;
  3837. }
  3838. /**
  3839. * Class used to hold a RBGA color
  3840. */
  3841. export class Color4 {
  3842. /**
  3843. * Defines the red component (between 0 and 1, default is 0)
  3844. */
  3845. r: number;
  3846. /**
  3847. * Defines the green component (between 0 and 1, default is 0)
  3848. */
  3849. g: number;
  3850. /**
  3851. * Defines the blue component (between 0 and 1, default is 0)
  3852. */
  3853. b: number;
  3854. /**
  3855. * Defines the alpha component (between 0 and 1, default is 1)
  3856. */
  3857. a: number;
  3858. /**
  3859. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3860. * @param r defines the red component (between 0 and 1, default is 0)
  3861. * @param g defines the green component (between 0 and 1, default is 0)
  3862. * @param b defines the blue component (between 0 and 1, default is 0)
  3863. * @param a defines the alpha component (between 0 and 1, default is 1)
  3864. */
  3865. constructor(
  3866. /**
  3867. * Defines the red component (between 0 and 1, default is 0)
  3868. */
  3869. r?: number,
  3870. /**
  3871. * Defines the green component (between 0 and 1, default is 0)
  3872. */
  3873. g?: number,
  3874. /**
  3875. * Defines the blue component (between 0 and 1, default is 0)
  3876. */
  3877. b?: number,
  3878. /**
  3879. * Defines the alpha component (between 0 and 1, default is 1)
  3880. */
  3881. a?: number);
  3882. /**
  3883. * Adds in place the given Color4 values to the current Color4 object
  3884. * @param right defines the second operand
  3885. * @returns the current updated Color4 object
  3886. */
  3887. addInPlace(right: DeepImmutable<Color4>): Color4;
  3888. /**
  3889. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3890. * @returns the new array
  3891. */
  3892. asArray(): number[];
  3893. /**
  3894. * Stores from the starting index in the given array the Color4 successive values
  3895. * @param array defines the array where to store the r,g,b components
  3896. * @param index defines an optional index in the target array to define where to start storing values
  3897. * @returns the current Color4 object
  3898. */
  3899. toArray(array: number[], index?: number): Color4;
  3900. /**
  3901. * Determines equality between Color4 objects
  3902. * @param otherColor defines the second operand
  3903. * @returns true if the rgba values are equal to the given ones
  3904. */
  3905. equals(otherColor: DeepImmutable<Color4>): boolean;
  3906. /**
  3907. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3908. * @param right defines the second operand
  3909. * @returns a new Color4 object
  3910. */
  3911. add(right: DeepImmutable<Color4>): Color4;
  3912. /**
  3913. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3914. * @param right defines the second operand
  3915. * @returns a new Color4 object
  3916. */
  3917. subtract(right: DeepImmutable<Color4>): Color4;
  3918. /**
  3919. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3920. * @param right defines the second operand
  3921. * @param result defines the Color4 object where to store the result
  3922. * @returns the current Color4 object
  3923. */
  3924. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3925. /**
  3926. * Creates a new Color4 with the current Color4 values multiplied by scale
  3927. * @param scale defines the scaling factor to apply
  3928. * @returns a new Color4 object
  3929. */
  3930. scale(scale: number): Color4;
  3931. /**
  3932. * Multiplies the current Color4 values by scale and stores the result in "result"
  3933. * @param scale defines the scaling factor to apply
  3934. * @param result defines the Color4 object where to store the result
  3935. * @returns the current unmodified Color4
  3936. */
  3937. scaleToRef(scale: number, result: Color4): Color4;
  3938. /**
  3939. * Scale the current Color4 values by a factor and add the result to a given Color4
  3940. * @param scale defines the scale factor
  3941. * @param result defines the Color4 object where to store the result
  3942. * @returns the unmodified current Color4
  3943. */
  3944. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3945. /**
  3946. * Clamps the rgb values by the min and max values and stores the result into "result"
  3947. * @param min defines minimum clamping value (default is 0)
  3948. * @param max defines maximum clamping value (default is 1)
  3949. * @param result defines color to store the result into.
  3950. * @returns the cuurent Color4
  3951. */
  3952. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3953. /**
  3954. * Multipy an Color4 value by another and return a new Color4 object
  3955. * @param color defines the Color4 value to multiply by
  3956. * @returns a new Color4 object
  3957. */
  3958. multiply(color: Color4): Color4;
  3959. /**
  3960. * Multipy a Color4 value by another and push the result in a reference value
  3961. * @param color defines the Color4 value to multiply by
  3962. * @param result defines the Color4 to fill the result in
  3963. * @returns the result Color4
  3964. */
  3965. multiplyToRef(color: Color4, result: Color4): Color4;
  3966. /**
  3967. * Creates a string with the Color4 current values
  3968. * @returns the string representation of the Color4 object
  3969. */
  3970. toString(): string;
  3971. /**
  3972. * Returns the string "Color4"
  3973. * @returns "Color4"
  3974. */
  3975. getClassName(): string;
  3976. /**
  3977. * Compute the Color4 hash code
  3978. * @returns an unique number that can be used to hash Color4 objects
  3979. */
  3980. getHashCode(): number;
  3981. /**
  3982. * Creates a new Color4 copied from the current one
  3983. * @returns a new Color4 object
  3984. */
  3985. clone(): Color4;
  3986. /**
  3987. * Copies the given Color4 values into the current one
  3988. * @param source defines the source Color4 object
  3989. * @returns the current updated Color4 object
  3990. */
  3991. copyFrom(source: Color4): Color4;
  3992. /**
  3993. * Copies the given float values into the current one
  3994. * @param r defines the red component to read from
  3995. * @param g defines the green component to read from
  3996. * @param b defines the blue component to read from
  3997. * @param a defines the alpha component to read from
  3998. * @returns the current updated Color4 object
  3999. */
  4000. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4001. /**
  4002. * Copies the given float values into the current one
  4003. * @param r defines the red component to read from
  4004. * @param g defines the green component to read from
  4005. * @param b defines the blue component to read from
  4006. * @param a defines the alpha component to read from
  4007. * @returns the current updated Color4 object
  4008. */
  4009. set(r: number, g: number, b: number, a: number): Color4;
  4010. /**
  4011. * Compute the Color4 hexadecimal code as a string
  4012. * @returns a string containing the hexadecimal representation of the Color4 object
  4013. */
  4014. toHexString(): string;
  4015. /**
  4016. * Computes a new Color4 converted from the current one to linear space
  4017. * @returns a new Color4 object
  4018. */
  4019. toLinearSpace(): Color4;
  4020. /**
  4021. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4022. * @param convertedColor defines the Color4 object where to store the linear space version
  4023. * @returns the unmodified Color4
  4024. */
  4025. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4026. /**
  4027. * Computes a new Color4 converted from the current one to gamma space
  4028. * @returns a new Color4 object
  4029. */
  4030. toGammaSpace(): Color4;
  4031. /**
  4032. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4033. * @param convertedColor defines the Color4 object where to store the gamma space version
  4034. * @returns the unmodified Color4
  4035. */
  4036. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4037. /**
  4038. * Creates a new Color4 from the string containing valid hexadecimal values
  4039. * @param hex defines a string containing valid hexadecimal values
  4040. * @returns a new Color4 object
  4041. */
  4042. static FromHexString(hex: string): Color4;
  4043. /**
  4044. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4045. * @param left defines the start value
  4046. * @param right defines the end value
  4047. * @param amount defines the gradient factor
  4048. * @returns a new Color4 object
  4049. */
  4050. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4051. /**
  4052. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4053. * @param left defines the start value
  4054. * @param right defines the end value
  4055. * @param amount defines the gradient factor
  4056. * @param result defines the Color4 object where to store data
  4057. */
  4058. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4059. /**
  4060. * Creates a new Color4 from a Color3 and an alpha value
  4061. * @param color3 defines the source Color3 to read from
  4062. * @param alpha defines the alpha component (1.0 by default)
  4063. * @returns a new Color4 object
  4064. */
  4065. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4066. /**
  4067. * Creates a new Color4 from the starting index element of the given array
  4068. * @param array defines the source array to read from
  4069. * @param offset defines the offset in the source array
  4070. * @returns a new Color4 object
  4071. */
  4072. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4073. /**
  4074. * Creates a new Color3 from integer values (< 256)
  4075. * @param r defines the red component to read from (value between 0 and 255)
  4076. * @param g defines the green component to read from (value between 0 and 255)
  4077. * @param b defines the blue component to read from (value between 0 and 255)
  4078. * @param a defines the alpha component to read from (value between 0 and 255)
  4079. * @returns a new Color3 object
  4080. */
  4081. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4082. /**
  4083. * Check the content of a given array and convert it to an array containing RGBA data
  4084. * If the original array was already containing count * 4 values then it is returned directly
  4085. * @param colors defines the array to check
  4086. * @param count defines the number of RGBA data to expect
  4087. * @returns an array containing count * 4 values (RGBA)
  4088. */
  4089. static CheckColors4(colors: number[], count: number): number[];
  4090. }
  4091. /**
  4092. * @hidden
  4093. */
  4094. export class TmpColors {
  4095. static Color3: Color3[];
  4096. static Color4: Color4[];
  4097. }
  4098. }
  4099. declare module "babylonjs/Maths/sphericalPolynomial" {
  4100. import { Vector3 } from "babylonjs/Maths/math.vector";
  4101. import { Color3 } from "babylonjs/Maths/math.color";
  4102. /**
  4103. * Class representing spherical harmonics coefficients to the 3rd degree
  4104. */
  4105. export class SphericalHarmonics {
  4106. /**
  4107. * Defines whether or not the harmonics have been prescaled for rendering.
  4108. */
  4109. preScaled: boolean;
  4110. /**
  4111. * The l0,0 coefficients of the spherical harmonics
  4112. */
  4113. l00: Vector3;
  4114. /**
  4115. * The l1,-1 coefficients of the spherical harmonics
  4116. */
  4117. l1_1: Vector3;
  4118. /**
  4119. * The l1,0 coefficients of the spherical harmonics
  4120. */
  4121. l10: Vector3;
  4122. /**
  4123. * The l1,1 coefficients of the spherical harmonics
  4124. */
  4125. l11: Vector3;
  4126. /**
  4127. * The l2,-2 coefficients of the spherical harmonics
  4128. */
  4129. l2_2: Vector3;
  4130. /**
  4131. * The l2,-1 coefficients of the spherical harmonics
  4132. */
  4133. l2_1: Vector3;
  4134. /**
  4135. * The l2,0 coefficients of the spherical harmonics
  4136. */
  4137. l20: Vector3;
  4138. /**
  4139. * The l2,1 coefficients of the spherical harmonics
  4140. */
  4141. l21: Vector3;
  4142. /**
  4143. * The l2,2 coefficients of the spherical harmonics
  4144. */
  4145. l22: Vector3;
  4146. /**
  4147. * Adds a light to the spherical harmonics
  4148. * @param direction the direction of the light
  4149. * @param color the color of the light
  4150. * @param deltaSolidAngle the delta solid angle of the light
  4151. */
  4152. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4153. /**
  4154. * Scales the spherical harmonics by the given amount
  4155. * @param scale the amount to scale
  4156. */
  4157. scaleInPlace(scale: number): void;
  4158. /**
  4159. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4160. *
  4161. * ```
  4162. * E_lm = A_l * L_lm
  4163. * ```
  4164. *
  4165. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4166. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4167. * the scaling factors are given in equation 9.
  4168. */
  4169. convertIncidentRadianceToIrradiance(): void;
  4170. /**
  4171. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4172. *
  4173. * ```
  4174. * L = (1/pi) * E * rho
  4175. * ```
  4176. *
  4177. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4178. */
  4179. convertIrradianceToLambertianRadiance(): void;
  4180. /**
  4181. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4182. * required operations at run time.
  4183. *
  4184. * This is simply done by scaling back the SH with Ylm constants parameter.
  4185. * The trigonometric part being applied by the shader at run time.
  4186. */
  4187. preScaleForRendering(): void;
  4188. /**
  4189. * Constructs a spherical harmonics from an array.
  4190. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4191. * @returns the spherical harmonics
  4192. */
  4193. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4194. /**
  4195. * Gets the spherical harmonics from polynomial
  4196. * @param polynomial the spherical polynomial
  4197. * @returns the spherical harmonics
  4198. */
  4199. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4200. }
  4201. /**
  4202. * Class representing spherical polynomial coefficients to the 3rd degree
  4203. */
  4204. export class SphericalPolynomial {
  4205. private _harmonics;
  4206. /**
  4207. * The spherical harmonics used to create the polynomials.
  4208. */
  4209. readonly preScaledHarmonics: SphericalHarmonics;
  4210. /**
  4211. * The x coefficients of the spherical polynomial
  4212. */
  4213. x: Vector3;
  4214. /**
  4215. * The y coefficients of the spherical polynomial
  4216. */
  4217. y: Vector3;
  4218. /**
  4219. * The z coefficients of the spherical polynomial
  4220. */
  4221. z: Vector3;
  4222. /**
  4223. * The xx coefficients of the spherical polynomial
  4224. */
  4225. xx: Vector3;
  4226. /**
  4227. * The yy coefficients of the spherical polynomial
  4228. */
  4229. yy: Vector3;
  4230. /**
  4231. * The zz coefficients of the spherical polynomial
  4232. */
  4233. zz: Vector3;
  4234. /**
  4235. * The xy coefficients of the spherical polynomial
  4236. */
  4237. xy: Vector3;
  4238. /**
  4239. * The yz coefficients of the spherical polynomial
  4240. */
  4241. yz: Vector3;
  4242. /**
  4243. * The zx coefficients of the spherical polynomial
  4244. */
  4245. zx: Vector3;
  4246. /**
  4247. * Adds an ambient color to the spherical polynomial
  4248. * @param color the color to add
  4249. */
  4250. addAmbient(color: Color3): void;
  4251. /**
  4252. * Scales the spherical polynomial by the given amount
  4253. * @param scale the amount to scale
  4254. */
  4255. scaleInPlace(scale: number): void;
  4256. /**
  4257. * Gets the spherical polynomial from harmonics
  4258. * @param harmonics the spherical harmonics
  4259. * @returns the spherical polynomial
  4260. */
  4261. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4262. /**
  4263. * Constructs a spherical polynomial from an array.
  4264. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4265. * @returns the spherical polynomial
  4266. */
  4267. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4268. }
  4269. }
  4270. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  4271. /**
  4272. * Define options used to create a render target texture
  4273. */
  4274. export class RenderTargetCreationOptions {
  4275. /**
  4276. * Specifies is mipmaps must be generated
  4277. */
  4278. generateMipMaps?: boolean;
  4279. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4280. generateDepthBuffer?: boolean;
  4281. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4282. generateStencilBuffer?: boolean;
  4283. /** Defines texture type (int by default) */
  4284. type?: number;
  4285. /** Defines sampling mode (trilinear by default) */
  4286. samplingMode?: number;
  4287. /** Defines format (RGBA by default) */
  4288. format?: number;
  4289. }
  4290. }
  4291. declare module "babylonjs/Instrumentation/timeToken" {
  4292. import { Nullable } from "babylonjs/types";
  4293. /**
  4294. * @hidden
  4295. **/
  4296. export class _TimeToken {
  4297. _startTimeQuery: Nullable<WebGLQuery>;
  4298. _endTimeQuery: Nullable<WebGLQuery>;
  4299. _timeElapsedQuery: Nullable<WebGLQuery>;
  4300. _timeElapsedQueryEnded: boolean;
  4301. }
  4302. }
  4303. declare module "babylonjs/Engines/constants" {
  4304. /** Defines the cross module used constants to avoid circular dependncies */
  4305. export class Constants {
  4306. /** Defines that alpha blending is disabled */
  4307. static readonly ALPHA_DISABLE: number;
  4308. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4309. static readonly ALPHA_ADD: number;
  4310. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4311. static readonly ALPHA_COMBINE: number;
  4312. /** Defines that alpha blending to DEST - SRC * DEST */
  4313. static readonly ALPHA_SUBTRACT: number;
  4314. /** Defines that alpha blending to SRC * DEST */
  4315. static readonly ALPHA_MULTIPLY: number;
  4316. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4317. static readonly ALPHA_MAXIMIZED: number;
  4318. /** Defines that alpha blending to SRC + DEST */
  4319. static readonly ALPHA_ONEONE: number;
  4320. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4321. static readonly ALPHA_PREMULTIPLIED: number;
  4322. /**
  4323. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4324. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4325. */
  4326. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4327. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4328. static readonly ALPHA_INTERPOLATE: number;
  4329. /**
  4330. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4331. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4332. */
  4333. static readonly ALPHA_SCREENMODE: number;
  4334. /**
  4335. * Defines that alpha blending to SRC + DST
  4336. * Alpha will be set to SRC ALPHA + DST ALPHA
  4337. */
  4338. static readonly ALPHA_ONEONE_ONEONE: number;
  4339. /**
  4340. * Defines that alpha blending to SRC * DST ALPHA + DST
  4341. * Alpha will be set to 0
  4342. */
  4343. static readonly ALPHA_ALPHATOCOLOR: number;
  4344. /**
  4345. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4346. */
  4347. static readonly ALPHA_REVERSEONEMINUS: number;
  4348. /**
  4349. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4350. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4351. */
  4352. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4353. /**
  4354. * Defines that alpha blending to SRC + DST
  4355. * Alpha will be set to SRC ALPHA
  4356. */
  4357. static readonly ALPHA_ONEONE_ONEZERO: number;
  4358. /** Defines that alpha blending equation a SUM */
  4359. static readonly ALPHA_EQUATION_ADD: number;
  4360. /** Defines that alpha blending equation a SUBSTRACTION */
  4361. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4362. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4363. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4364. /** Defines that alpha blending equation a MAX operation */
  4365. static readonly ALPHA_EQUATION_MAX: number;
  4366. /** Defines that alpha blending equation a MIN operation */
  4367. static readonly ALPHA_EQUATION_MIN: number;
  4368. /**
  4369. * Defines that alpha blending equation a DARKEN operation:
  4370. * It takes the min of the src and sums the alpha channels.
  4371. */
  4372. static readonly ALPHA_EQUATION_DARKEN: number;
  4373. /** Defines that the ressource is not delayed*/
  4374. static readonly DELAYLOADSTATE_NONE: number;
  4375. /** Defines that the ressource was successfully delay loaded */
  4376. static readonly DELAYLOADSTATE_LOADED: number;
  4377. /** Defines that the ressource is currently delay loading */
  4378. static readonly DELAYLOADSTATE_LOADING: number;
  4379. /** Defines that the ressource is delayed and has not started loading */
  4380. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4381. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4382. static readonly NEVER: number;
  4383. /** 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 */
  4384. static readonly ALWAYS: number;
  4385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4386. static readonly LESS: number;
  4387. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4388. static readonly EQUAL: number;
  4389. /** 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 */
  4390. static readonly LEQUAL: number;
  4391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4392. static readonly GREATER: number;
  4393. /** 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 */
  4394. static readonly GEQUAL: number;
  4395. /** 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 */
  4396. static readonly NOTEQUAL: number;
  4397. /** Passed to stencilOperation to specify that stencil value must be kept */
  4398. static readonly KEEP: number;
  4399. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4400. static readonly REPLACE: number;
  4401. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4402. static readonly INCR: number;
  4403. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4404. static readonly DECR: number;
  4405. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4406. static readonly INVERT: number;
  4407. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4408. static readonly INCR_WRAP: number;
  4409. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4410. static readonly DECR_WRAP: number;
  4411. /** Texture is not repeating outside of 0..1 UVs */
  4412. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4413. /** Texture is repeating outside of 0..1 UVs */
  4414. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4415. /** Texture is repeating and mirrored */
  4416. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4417. /** ALPHA */
  4418. static readonly TEXTUREFORMAT_ALPHA: number;
  4419. /** LUMINANCE */
  4420. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4421. /** LUMINANCE_ALPHA */
  4422. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4423. /** RGB */
  4424. static readonly TEXTUREFORMAT_RGB: number;
  4425. /** RGBA */
  4426. static readonly TEXTUREFORMAT_RGBA: number;
  4427. /** RED */
  4428. static readonly TEXTUREFORMAT_RED: number;
  4429. /** RED (2nd reference) */
  4430. static readonly TEXTUREFORMAT_R: number;
  4431. /** RG */
  4432. static readonly TEXTUREFORMAT_RG: number;
  4433. /** RED_INTEGER */
  4434. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4435. /** RED_INTEGER (2nd reference) */
  4436. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4437. /** RG_INTEGER */
  4438. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4439. /** RGB_INTEGER */
  4440. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4441. /** RGBA_INTEGER */
  4442. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4443. /** UNSIGNED_BYTE */
  4444. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4445. /** UNSIGNED_BYTE (2nd reference) */
  4446. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4447. /** FLOAT */
  4448. static readonly TEXTURETYPE_FLOAT: number;
  4449. /** HALF_FLOAT */
  4450. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4451. /** BYTE */
  4452. static readonly TEXTURETYPE_BYTE: number;
  4453. /** SHORT */
  4454. static readonly TEXTURETYPE_SHORT: number;
  4455. /** UNSIGNED_SHORT */
  4456. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4457. /** INT */
  4458. static readonly TEXTURETYPE_INT: number;
  4459. /** UNSIGNED_INT */
  4460. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4461. /** UNSIGNED_SHORT_4_4_4_4 */
  4462. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4463. /** UNSIGNED_SHORT_5_5_5_1 */
  4464. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4465. /** UNSIGNED_SHORT_5_6_5 */
  4466. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4467. /** UNSIGNED_INT_2_10_10_10_REV */
  4468. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4469. /** UNSIGNED_INT_24_8 */
  4470. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4471. /** UNSIGNED_INT_10F_11F_11F_REV */
  4472. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4473. /** UNSIGNED_INT_5_9_9_9_REV */
  4474. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4475. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4476. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4477. /** nearest is mag = nearest and min = nearest and mip = linear */
  4478. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4479. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4480. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4481. /** Trilinear is mag = linear and min = linear and mip = linear */
  4482. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4483. /** nearest is mag = nearest and min = nearest and mip = linear */
  4484. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4485. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4486. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4487. /** Trilinear is mag = linear and min = linear and mip = linear */
  4488. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4489. /** mag = nearest and min = nearest and mip = nearest */
  4490. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4491. /** mag = nearest and min = linear and mip = nearest */
  4492. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4493. /** mag = nearest and min = linear and mip = linear */
  4494. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4495. /** mag = nearest and min = linear and mip = none */
  4496. static readonly TEXTURE_NEAREST_LINEAR: number;
  4497. /** mag = nearest and min = nearest and mip = none */
  4498. static readonly TEXTURE_NEAREST_NEAREST: number;
  4499. /** mag = linear and min = nearest and mip = nearest */
  4500. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4501. /** mag = linear and min = nearest and mip = linear */
  4502. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4503. /** mag = linear and min = linear and mip = none */
  4504. static readonly TEXTURE_LINEAR_LINEAR: number;
  4505. /** mag = linear and min = nearest and mip = none */
  4506. static readonly TEXTURE_LINEAR_NEAREST: number;
  4507. /** Explicit coordinates mode */
  4508. static readonly TEXTURE_EXPLICIT_MODE: number;
  4509. /** Spherical coordinates mode */
  4510. static readonly TEXTURE_SPHERICAL_MODE: number;
  4511. /** Planar coordinates mode */
  4512. static readonly TEXTURE_PLANAR_MODE: number;
  4513. /** Cubic coordinates mode */
  4514. static readonly TEXTURE_CUBIC_MODE: number;
  4515. /** Projection coordinates mode */
  4516. static readonly TEXTURE_PROJECTION_MODE: number;
  4517. /** Skybox coordinates mode */
  4518. static readonly TEXTURE_SKYBOX_MODE: number;
  4519. /** Inverse Cubic coordinates mode */
  4520. static readonly TEXTURE_INVCUBIC_MODE: number;
  4521. /** Equirectangular coordinates mode */
  4522. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4523. /** Equirectangular Fixed coordinates mode */
  4524. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4525. /** Equirectangular Fixed Mirrored coordinates mode */
  4526. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4527. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4528. static readonly SCALEMODE_FLOOR: number;
  4529. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4530. static readonly SCALEMODE_NEAREST: number;
  4531. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4532. static readonly SCALEMODE_CEILING: number;
  4533. /**
  4534. * The dirty texture flag value
  4535. */
  4536. static readonly MATERIAL_TextureDirtyFlag: number;
  4537. /**
  4538. * The dirty light flag value
  4539. */
  4540. static readonly MATERIAL_LightDirtyFlag: number;
  4541. /**
  4542. * The dirty fresnel flag value
  4543. */
  4544. static readonly MATERIAL_FresnelDirtyFlag: number;
  4545. /**
  4546. * The dirty attribute flag value
  4547. */
  4548. static readonly MATERIAL_AttributesDirtyFlag: number;
  4549. /**
  4550. * The dirty misc flag value
  4551. */
  4552. static readonly MATERIAL_MiscDirtyFlag: number;
  4553. /**
  4554. * The all dirty flag value
  4555. */
  4556. static readonly MATERIAL_AllDirtyFlag: number;
  4557. /**
  4558. * Returns the triangle fill mode
  4559. */
  4560. static readonly MATERIAL_TriangleFillMode: number;
  4561. /**
  4562. * Returns the wireframe mode
  4563. */
  4564. static readonly MATERIAL_WireFrameFillMode: number;
  4565. /**
  4566. * Returns the point fill mode
  4567. */
  4568. static readonly MATERIAL_PointFillMode: number;
  4569. /**
  4570. * Returns the point list draw mode
  4571. */
  4572. static readonly MATERIAL_PointListDrawMode: number;
  4573. /**
  4574. * Returns the line list draw mode
  4575. */
  4576. static readonly MATERIAL_LineListDrawMode: number;
  4577. /**
  4578. * Returns the line loop draw mode
  4579. */
  4580. static readonly MATERIAL_LineLoopDrawMode: number;
  4581. /**
  4582. * Returns the line strip draw mode
  4583. */
  4584. static readonly MATERIAL_LineStripDrawMode: number;
  4585. /**
  4586. * Returns the triangle strip draw mode
  4587. */
  4588. static readonly MATERIAL_TriangleStripDrawMode: number;
  4589. /**
  4590. * Returns the triangle fan draw mode
  4591. */
  4592. static readonly MATERIAL_TriangleFanDrawMode: number;
  4593. /**
  4594. * Stores the clock-wise side orientation
  4595. */
  4596. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4597. /**
  4598. * Stores the counter clock-wise side orientation
  4599. */
  4600. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4601. /**
  4602. * Nothing
  4603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4604. */
  4605. static readonly ACTION_NothingTrigger: number;
  4606. /**
  4607. * On pick
  4608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4609. */
  4610. static readonly ACTION_OnPickTrigger: number;
  4611. /**
  4612. * On left pick
  4613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4614. */
  4615. static readonly ACTION_OnLeftPickTrigger: number;
  4616. /**
  4617. * On right pick
  4618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4619. */
  4620. static readonly ACTION_OnRightPickTrigger: number;
  4621. /**
  4622. * On center pick
  4623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4624. */
  4625. static readonly ACTION_OnCenterPickTrigger: number;
  4626. /**
  4627. * On pick down
  4628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4629. */
  4630. static readonly ACTION_OnPickDownTrigger: number;
  4631. /**
  4632. * On double pick
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnDoublePickTrigger: number;
  4636. /**
  4637. * On pick up
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnPickUpTrigger: number;
  4641. /**
  4642. * On pick out.
  4643. * This trigger will only be raised if you also declared a OnPickDown
  4644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4645. */
  4646. static readonly ACTION_OnPickOutTrigger: number;
  4647. /**
  4648. * On long press
  4649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4650. */
  4651. static readonly ACTION_OnLongPressTrigger: number;
  4652. /**
  4653. * On pointer over
  4654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4655. */
  4656. static readonly ACTION_OnPointerOverTrigger: number;
  4657. /**
  4658. * On pointer out
  4659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4660. */
  4661. static readonly ACTION_OnPointerOutTrigger: number;
  4662. /**
  4663. * On every frame
  4664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4665. */
  4666. static readonly ACTION_OnEveryFrameTrigger: number;
  4667. /**
  4668. * On intersection enter
  4669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4670. */
  4671. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4672. /**
  4673. * On intersection exit
  4674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4675. */
  4676. static readonly ACTION_OnIntersectionExitTrigger: number;
  4677. /**
  4678. * On key down
  4679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4680. */
  4681. static readonly ACTION_OnKeyDownTrigger: number;
  4682. /**
  4683. * On key up
  4684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4685. */
  4686. static readonly ACTION_OnKeyUpTrigger: number;
  4687. /**
  4688. * Billboard mode will only apply to Y axis
  4689. */
  4690. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4691. /**
  4692. * Billboard mode will apply to all axes
  4693. */
  4694. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4695. /**
  4696. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4697. */
  4698. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4699. /**
  4700. * Gets or sets base Assets URL
  4701. */
  4702. static PARTICLES_BaseAssetsUrl: string;
  4703. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4704. * Test order :
  4705. * Is the bounding sphere outside the frustum ?
  4706. * If not, are the bounding box vertices outside the frustum ?
  4707. * It not, then the cullable object is in the frustum.
  4708. */
  4709. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4710. /** Culling strategy : Bounding Sphere Only.
  4711. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4712. * It's also less accurate than the standard because some not visible objects can still be selected.
  4713. * Test : is the bounding sphere outside the frustum ?
  4714. * If not, then the cullable object is in the frustum.
  4715. */
  4716. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4717. /** Culling strategy : Optimistic Inclusion.
  4718. * This in an inclusion test first, then the standard exclusion test.
  4719. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4720. * 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.
  4721. * Anyway, it's as accurate as the standard strategy.
  4722. * Test :
  4723. * Is the cullable object bounding sphere center in the frustum ?
  4724. * If not, apply the default culling strategy.
  4725. */
  4726. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4727. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4728. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4729. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4730. * 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.
  4731. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4732. * Test :
  4733. * Is the cullable object bounding sphere center in the frustum ?
  4734. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4735. */
  4736. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4737. /**
  4738. * No logging while loading
  4739. */
  4740. static readonly SCENELOADER_NO_LOGGING: number;
  4741. /**
  4742. * Minimal logging while loading
  4743. */
  4744. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4745. /**
  4746. * Summary logging while loading
  4747. */
  4748. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4749. /**
  4750. * Detailled logging while loading
  4751. */
  4752. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4753. }
  4754. }
  4755. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  4756. import { Nullable } from "babylonjs/types";
  4757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  4758. /**
  4759. * This represents the required contract to create a new type of texture loader.
  4760. */
  4761. export interface IInternalTextureLoader {
  4762. /**
  4763. * Defines wether the loader supports cascade loading the different faces.
  4764. */
  4765. supportCascades: boolean;
  4766. /**
  4767. * This returns if the loader support the current file information.
  4768. * @param extension defines the file extension of the file being loaded
  4769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4770. * @param fallback defines the fallback internal texture if any
  4771. * @param isBase64 defines whether the texture is encoded as a base64
  4772. * @param isBuffer defines whether the texture data are stored as a buffer
  4773. * @returns true if the loader can load the specified file
  4774. */
  4775. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4776. /**
  4777. * Transform the url before loading if required.
  4778. * @param rootUrl the url of the texture
  4779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4780. * @returns the transformed texture
  4781. */
  4782. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4783. /**
  4784. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4785. * @param rootUrl the url of the texture
  4786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4787. * @returns the fallback texture
  4788. */
  4789. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4790. /**
  4791. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4792. * @param data contains the texture data
  4793. * @param texture defines the BabylonJS internal texture
  4794. * @param createPolynomials will be true if polynomials have been requested
  4795. * @param onLoad defines the callback to trigger once the texture is ready
  4796. * @param onError defines the callback to trigger in case of error
  4797. */
  4798. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4799. /**
  4800. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4801. * @param data contains the texture data
  4802. * @param texture defines the BabylonJS internal texture
  4803. * @param callback defines the method to call once ready to upload
  4804. */
  4805. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/IPipelineContext" {
  4809. /**
  4810. * Class used to store and describe the pipeline context associated with an effect
  4811. */
  4812. export interface IPipelineContext {
  4813. /**
  4814. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4815. */
  4816. isAsync: boolean;
  4817. /**
  4818. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4819. */
  4820. isReady: boolean;
  4821. /** @hidden */
  4822. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4823. }
  4824. }
  4825. declare module "babylonjs/Meshes/dataBuffer" {
  4826. /**
  4827. * Class used to store gfx data (like WebGLBuffer)
  4828. */
  4829. export class DataBuffer {
  4830. /**
  4831. * Gets or sets the number of objects referencing this buffer
  4832. */
  4833. references: number;
  4834. /** Gets or sets the size of the underlying buffer */
  4835. capacity: number;
  4836. /**
  4837. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4838. */
  4839. is32Bits: boolean;
  4840. /**
  4841. * Gets the underlying buffer
  4842. */
  4843. readonly underlyingResource: any;
  4844. }
  4845. }
  4846. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4847. /** @hidden */
  4848. export interface IShaderProcessor {
  4849. attributeProcessor?: (attribute: string) => string;
  4850. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4851. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4852. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4853. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4854. lineProcessor?: (line: string, isFragment: boolean) => string;
  4855. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4856. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4857. }
  4858. }
  4859. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4860. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4861. /** @hidden */
  4862. export interface ProcessingOptions {
  4863. defines: string[];
  4864. indexParameters: any;
  4865. isFragment: boolean;
  4866. shouldUseHighPrecisionShader: boolean;
  4867. supportsUniformBuffers: boolean;
  4868. shadersRepository: string;
  4869. includesShadersStore: {
  4870. [key: string]: string;
  4871. };
  4872. processor?: IShaderProcessor;
  4873. version: string;
  4874. platformName: string;
  4875. lookForClosingBracketForUniformBuffer?: boolean;
  4876. }
  4877. }
  4878. declare module "babylonjs/Misc/stringTools" {
  4879. /**
  4880. * Helper to manipulate strings
  4881. */
  4882. export class StringTools {
  4883. /**
  4884. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4885. * @param str Source string
  4886. * @param suffix Suffix to search for in the source string
  4887. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4888. */
  4889. static EndsWith(str: string, suffix: string): boolean;
  4890. /**
  4891. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4892. * @param str Source string
  4893. * @param suffix Suffix to search for in the source string
  4894. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4895. */
  4896. static StartsWith(str: string, suffix: string): boolean;
  4897. }
  4898. }
  4899. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4900. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4901. /** @hidden */
  4902. export class ShaderCodeNode {
  4903. line: string;
  4904. children: ShaderCodeNode[];
  4905. additionalDefineKey?: string;
  4906. additionalDefineValue?: string;
  4907. isValid(preprocessors: {
  4908. [key: string]: string;
  4909. }): boolean;
  4910. process(preprocessors: {
  4911. [key: string]: string;
  4912. }, options: ProcessingOptions): string;
  4913. }
  4914. }
  4915. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4916. /** @hidden */
  4917. export class ShaderCodeCursor {
  4918. private _lines;
  4919. lineIndex: number;
  4920. readonly currentLine: string;
  4921. readonly canRead: boolean;
  4922. lines: string[];
  4923. }
  4924. }
  4925. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4926. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4927. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4928. /** @hidden */
  4929. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4930. process(preprocessors: {
  4931. [key: string]: string;
  4932. }, options: ProcessingOptions): string;
  4933. }
  4934. }
  4935. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4936. /** @hidden */
  4937. export class ShaderDefineExpression {
  4938. isTrue(preprocessors: {
  4939. [key: string]: string;
  4940. }): boolean;
  4941. }
  4942. }
  4943. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4944. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4945. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4946. /** @hidden */
  4947. export class ShaderCodeTestNode extends ShaderCodeNode {
  4948. testExpression: ShaderDefineExpression;
  4949. isValid(preprocessors: {
  4950. [key: string]: string;
  4951. }): boolean;
  4952. }
  4953. }
  4954. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4955. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4956. /** @hidden */
  4957. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4958. define: string;
  4959. not: boolean;
  4960. constructor(define: string, not?: boolean);
  4961. isTrue(preprocessors: {
  4962. [key: string]: string;
  4963. }): boolean;
  4964. }
  4965. }
  4966. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4967. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4968. /** @hidden */
  4969. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4970. leftOperand: ShaderDefineExpression;
  4971. rightOperand: ShaderDefineExpression;
  4972. isTrue(preprocessors: {
  4973. [key: string]: string;
  4974. }): boolean;
  4975. }
  4976. }
  4977. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4978. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4979. /** @hidden */
  4980. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4981. leftOperand: ShaderDefineExpression;
  4982. rightOperand: ShaderDefineExpression;
  4983. isTrue(preprocessors: {
  4984. [key: string]: string;
  4985. }): boolean;
  4986. }
  4987. }
  4988. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4989. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4990. /** @hidden */
  4991. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4992. define: string;
  4993. operand: string;
  4994. testValue: string;
  4995. constructor(define: string, operand: string, testValue: string);
  4996. isTrue(preprocessors: {
  4997. [key: string]: string;
  4998. }): boolean;
  4999. }
  5000. }
  5001. declare module "babylonjs/Misc/loadFileError" {
  5002. import { WebRequest } from "babylonjs/Misc/webRequest";
  5003. /**
  5004. * @ignore
  5005. * Application error to support additional information when loading a file
  5006. */
  5007. export class LoadFileError extends Error {
  5008. /** defines the optional web request */
  5009. request?: WebRequest | undefined;
  5010. private static _setPrototypeOf;
  5011. /**
  5012. * Creates a new LoadFileError
  5013. * @param message defines the message of the error
  5014. * @param request defines the optional web request
  5015. */
  5016. constructor(message: string,
  5017. /** defines the optional web request */
  5018. request?: WebRequest | undefined);
  5019. }
  5020. }
  5021. declare module "babylonjs/Offline/IOfflineProvider" {
  5022. /**
  5023. * Class used to enable access to offline support
  5024. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5025. */
  5026. export interface IOfflineProvider {
  5027. /**
  5028. * Gets a boolean indicating if scene must be saved in the database
  5029. */
  5030. enableSceneOffline: boolean;
  5031. /**
  5032. * Gets a boolean indicating if textures must be saved in the database
  5033. */
  5034. enableTexturesOffline: boolean;
  5035. /**
  5036. * Open the offline support and make it available
  5037. * @param successCallback defines the callback to call on success
  5038. * @param errorCallback defines the callback to call on error
  5039. */
  5040. open(successCallback: () => void, errorCallback: () => void): void;
  5041. /**
  5042. * Loads an image from the offline support
  5043. * @param url defines the url to load from
  5044. * @param image defines the target DOM image
  5045. */
  5046. loadImage(url: string, image: HTMLImageElement): void;
  5047. /**
  5048. * Loads a file from offline support
  5049. * @param url defines the URL to load from
  5050. * @param sceneLoaded defines a callback to call on success
  5051. * @param progressCallBack defines a callback to call when progress changed
  5052. * @param errorCallback defines a callback to call on error
  5053. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5054. */
  5055. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5056. }
  5057. }
  5058. declare module "babylonjs/Misc/filesInputStore" {
  5059. /**
  5060. * Class used to help managing file picking and drag'n'drop
  5061. * File Storage
  5062. */
  5063. export class FilesInputStore {
  5064. /**
  5065. * List of files ready to be loaded
  5066. */
  5067. static FilesToLoad: {
  5068. [key: string]: File;
  5069. };
  5070. }
  5071. }
  5072. declare module "babylonjs/Misc/retryStrategy" {
  5073. import { WebRequest } from "babylonjs/Misc/webRequest";
  5074. /**
  5075. * Class used to define a retry strategy when error happens while loading assets
  5076. */
  5077. export class RetryStrategy {
  5078. /**
  5079. * Function used to defines an exponential back off strategy
  5080. * @param maxRetries defines the maximum number of retries (3 by default)
  5081. * @param baseInterval defines the interval between retries
  5082. * @returns the strategy function to use
  5083. */
  5084. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/fileTools" {
  5088. import { WebRequest } from "babylonjs/Misc/webRequest";
  5089. import { Nullable } from "babylonjs/types";
  5090. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  5091. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  5092. /**
  5093. * @hidden
  5094. */
  5095. export class FileTools {
  5096. /**
  5097. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5098. */
  5099. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5100. /**
  5101. * Gets or sets the base URL to use to load assets
  5102. */
  5103. static BaseUrl: string;
  5104. /**
  5105. * Default behaviour for cors in the application.
  5106. * It can be a string if the expected behavior is identical in the entire app.
  5107. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5108. */
  5109. static CorsBehavior: string | ((url: string | string[]) => string);
  5110. /**
  5111. * Gets or sets a function used to pre-process url before using them to load assets
  5112. */
  5113. static PreprocessUrl: (url: string) => string;
  5114. /**
  5115. * Removes unwanted characters from an url
  5116. * @param url defines the url to clean
  5117. * @returns the cleaned url
  5118. */
  5119. private static _CleanUrl;
  5120. /**
  5121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5122. * @param url define the url we are trying
  5123. * @param element define the dom element where to configure the cors policy
  5124. */
  5125. static SetCorsBehavior(url: string | string[], element: {
  5126. crossOrigin: string | null;
  5127. }): void;
  5128. /**
  5129. * Loads an image as an HTMLImageElement.
  5130. * @param input url string, ArrayBuffer, or Blob to load
  5131. * @param onLoad callback called when the image successfully loads
  5132. * @param onError callback called when the image fails to load
  5133. * @param offlineProvider offline provider for caching
  5134. * @returns the HTMLImageElement of the loaded image
  5135. */
  5136. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5137. /**
  5138. * Loads a file
  5139. * @param fileToLoad defines the file to load
  5140. * @param callback defines the callback to call when data is loaded
  5141. * @param progressCallBack defines the callback to call during loading process
  5142. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5143. * @returns a file request object
  5144. */
  5145. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5146. /**
  5147. * Loads a file
  5148. * @param url url string, ArrayBuffer, or Blob to load
  5149. * @param onSuccess callback called when the file successfully loads
  5150. * @param onProgress callback called while file is loading (if the server supports this mode)
  5151. * @param offlineProvider defines the offline provider for caching
  5152. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5153. * @param onError callback called when the file fails to load
  5154. * @returns a file request object
  5155. */
  5156. 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;
  5157. /**
  5158. * Checks if the loaded document was accessed via `file:`-Protocol.
  5159. * @returns boolean
  5160. */
  5161. static IsFileURL(): boolean;
  5162. }
  5163. }
  5164. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5165. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5166. /** @hidden */
  5167. export class ShaderProcessor {
  5168. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5169. private static _ProcessPrecision;
  5170. private static _ExtractOperation;
  5171. private static _BuildSubExpression;
  5172. private static _BuildExpression;
  5173. private static _MoveCursorWithinIf;
  5174. private static _MoveCursor;
  5175. private static _EvaluatePreProcessors;
  5176. private static _PreparePreProcessors;
  5177. private static _ProcessShaderConversion;
  5178. private static _ProcessIncludes;
  5179. }
  5180. }
  5181. declare module "babylonjs/Materials/iEffectFallbacks" {
  5182. import { Effect } from "babylonjs/Materials/effect";
  5183. /**
  5184. * Interface used to define common properties for effect fallbacks
  5185. */
  5186. export interface IEffectFallbacks {
  5187. /**
  5188. * Removes the defines that should be removed when falling back.
  5189. * @param currentDefines defines the current define statements for the shader.
  5190. * @param effect defines the current effect we try to compile
  5191. * @returns The resulting defines with defines of the current rank removed.
  5192. */
  5193. reduce(currentDefines: string, effect: Effect): string;
  5194. /**
  5195. * Removes the fallback from the bound mesh.
  5196. */
  5197. unBindMesh(): void;
  5198. /**
  5199. * Checks to see if more fallbacks are still availible.
  5200. */
  5201. hasMoreFallbacks: boolean;
  5202. }
  5203. }
  5204. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5205. /**
  5206. * Class used to evalaute queries containing `and` and `or` operators
  5207. */
  5208. export class AndOrNotEvaluator {
  5209. /**
  5210. * Evaluate a query
  5211. * @param query defines the query to evaluate
  5212. * @param evaluateCallback defines the callback used to filter result
  5213. * @returns true if the query matches
  5214. */
  5215. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5216. private static _HandleParenthesisContent;
  5217. private static _SimplifyNegation;
  5218. }
  5219. }
  5220. declare module "babylonjs/Misc/tags" {
  5221. /**
  5222. * Class used to store custom tags
  5223. */
  5224. export class Tags {
  5225. /**
  5226. * Adds support for tags on the given object
  5227. * @param obj defines the object to use
  5228. */
  5229. static EnableFor(obj: any): void;
  5230. /**
  5231. * Removes tags support
  5232. * @param obj defines the object to use
  5233. */
  5234. static DisableFor(obj: any): void;
  5235. /**
  5236. * Gets a boolean indicating if the given object has tags
  5237. * @param obj defines the object to use
  5238. * @returns a boolean
  5239. */
  5240. static HasTags(obj: any): boolean;
  5241. /**
  5242. * Gets the tags available on a given object
  5243. * @param obj defines the object to use
  5244. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5245. * @returns the tags
  5246. */
  5247. static GetTags(obj: any, asString?: boolean): any;
  5248. /**
  5249. * Adds tags to an object
  5250. * @param obj defines the object to use
  5251. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5252. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5253. */
  5254. static AddTagsTo(obj: any, tagsString: string): void;
  5255. /**
  5256. * @hidden
  5257. */
  5258. static _AddTagTo(obj: any, tag: string): void;
  5259. /**
  5260. * Removes specific tags from a specific object
  5261. * @param obj defines the object to use
  5262. * @param tagsString defines the tags to remove
  5263. */
  5264. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5265. /**
  5266. * @hidden
  5267. */
  5268. static _RemoveTagFrom(obj: any, tag: string): void;
  5269. /**
  5270. * Defines if tags hosted on an object match a given query
  5271. * @param obj defines the object to use
  5272. * @param tagsQuery defines the tag query
  5273. * @returns a boolean
  5274. */
  5275. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5276. }
  5277. }
  5278. declare module "babylonjs/Maths/math.path" {
  5279. import { DeepImmutable, Nullable } from "babylonjs/types";
  5280. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5281. /**
  5282. * Defines potential orientation for back face culling
  5283. */
  5284. export enum Orientation {
  5285. /**
  5286. * Clockwise
  5287. */
  5288. CW = 0,
  5289. /** Counter clockwise */
  5290. CCW = 1
  5291. }
  5292. /** Class used to represent a Bezier curve */
  5293. export class BezierCurve {
  5294. /**
  5295. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5296. * @param t defines the time
  5297. * @param x1 defines the left coordinate on X axis
  5298. * @param y1 defines the left coordinate on Y axis
  5299. * @param x2 defines the right coordinate on X axis
  5300. * @param y2 defines the right coordinate on Y axis
  5301. * @returns the interpolated value
  5302. */
  5303. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5304. }
  5305. /**
  5306. * Defines angle representation
  5307. */
  5308. export class Angle {
  5309. private _radians;
  5310. /**
  5311. * Creates an Angle object of "radians" radians (float).
  5312. * @param radians the angle in radians
  5313. */
  5314. constructor(radians: number);
  5315. /**
  5316. * Get value in degrees
  5317. * @returns the Angle value in degrees (float)
  5318. */
  5319. degrees(): number;
  5320. /**
  5321. * Get value in radians
  5322. * @returns the Angle value in radians (float)
  5323. */
  5324. radians(): number;
  5325. /**
  5326. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5327. * @param a defines first vector
  5328. * @param b defines second vector
  5329. * @returns a new Angle
  5330. */
  5331. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5332. /**
  5333. * Gets a new Angle object from the given float in radians
  5334. * @param radians defines the angle value in radians
  5335. * @returns a new Angle
  5336. */
  5337. static FromRadians(radians: number): Angle;
  5338. /**
  5339. * Gets a new Angle object from the given float in degrees
  5340. * @param degrees defines the angle value in degrees
  5341. * @returns a new Angle
  5342. */
  5343. static FromDegrees(degrees: number): Angle;
  5344. }
  5345. /**
  5346. * This represents an arc in a 2d space.
  5347. */
  5348. export class Arc2 {
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2;
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2;
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2;
  5355. /**
  5356. * Defines the center point of the arc.
  5357. */
  5358. centerPoint: Vector2;
  5359. /**
  5360. * Defines the radius of the arc.
  5361. */
  5362. radius: number;
  5363. /**
  5364. * Defines the angle of the arc (from mid point to end point).
  5365. */
  5366. angle: Angle;
  5367. /**
  5368. * Defines the start angle of the arc (from start point to middle point).
  5369. */
  5370. startAngle: Angle;
  5371. /**
  5372. * Defines the orientation of the arc (clock wise/counter clock wise).
  5373. */
  5374. orientation: Orientation;
  5375. /**
  5376. * Creates an Arc object from the three given points : start, middle and end.
  5377. * @param startPoint Defines the start point of the arc
  5378. * @param midPoint Defines the midlle point of the arc
  5379. * @param endPoint Defines the end point of the arc
  5380. */
  5381. constructor(
  5382. /** Defines the start point of the arc */
  5383. startPoint: Vector2,
  5384. /** Defines the mid point of the arc */
  5385. midPoint: Vector2,
  5386. /** Defines the end point of the arc */
  5387. endPoint: Vector2);
  5388. }
  5389. /**
  5390. * Represents a 2D path made up of multiple 2D points
  5391. */
  5392. export class Path2 {
  5393. private _points;
  5394. private _length;
  5395. /**
  5396. * If the path start and end point are the same
  5397. */
  5398. closed: boolean;
  5399. /**
  5400. * Creates a Path2 object from the starting 2D coordinates x and y.
  5401. * @param x the starting points x value
  5402. * @param y the starting points y value
  5403. */
  5404. constructor(x: number, y: number);
  5405. /**
  5406. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5407. * @param x the added points x value
  5408. * @param y the added points y value
  5409. * @returns the updated Path2.
  5410. */
  5411. addLineTo(x: number, y: number): Path2;
  5412. /**
  5413. * 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.
  5414. * @param midX middle point x value
  5415. * @param midY middle point y value
  5416. * @param endX end point x value
  5417. * @param endY end point y value
  5418. * @param numberOfSegments (default: 36)
  5419. * @returns the updated Path2.
  5420. */
  5421. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5422. /**
  5423. * Closes the Path2.
  5424. * @returns the Path2.
  5425. */
  5426. close(): Path2;
  5427. /**
  5428. * Gets the sum of the distance between each sequential point in the path
  5429. * @returns the Path2 total length (float).
  5430. */
  5431. length(): number;
  5432. /**
  5433. * Gets the points which construct the path
  5434. * @returns the Path2 internal array of points.
  5435. */
  5436. getPoints(): Vector2[];
  5437. /**
  5438. * Retreives the point at the distance aways from the starting point
  5439. * @param normalizedLengthPosition the length along the path to retreive the point from
  5440. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5441. */
  5442. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5443. /**
  5444. * Creates a new path starting from an x and y position
  5445. * @param x starting x value
  5446. * @param y starting y value
  5447. * @returns a new Path2 starting at the coordinates (x, y).
  5448. */
  5449. static StartingAt(x: number, y: number): Path2;
  5450. }
  5451. /**
  5452. * Represents a 3D path made up of multiple 3D points
  5453. */
  5454. export class Path3D {
  5455. /**
  5456. * an array of Vector3, the curve axis of the Path3D
  5457. */
  5458. path: Vector3[];
  5459. private _curve;
  5460. private _distances;
  5461. private _tangents;
  5462. private _normals;
  5463. private _binormals;
  5464. private _raw;
  5465. /**
  5466. * new Path3D(path, normal, raw)
  5467. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5468. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5469. * @param path an array of Vector3, the curve axis of the Path3D
  5470. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5471. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5472. */
  5473. constructor(
  5474. /**
  5475. * an array of Vector3, the curve axis of the Path3D
  5476. */
  5477. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5478. /**
  5479. * Returns the Path3D array of successive Vector3 designing its curve.
  5480. * @returns the Path3D array of successive Vector3 designing its curve.
  5481. */
  5482. getCurve(): Vector3[];
  5483. /**
  5484. * Returns an array populated with tangent vectors on each Path3D curve point.
  5485. * @returns an array populated with tangent vectors on each Path3D curve point.
  5486. */
  5487. getTangents(): Vector3[];
  5488. /**
  5489. * Returns an array populated with normal vectors on each Path3D curve point.
  5490. * @returns an array populated with normal vectors on each Path3D curve point.
  5491. */
  5492. getNormals(): Vector3[];
  5493. /**
  5494. * Returns an array populated with binormal vectors on each Path3D curve point.
  5495. * @returns an array populated with binormal vectors on each Path3D curve point.
  5496. */
  5497. getBinormals(): Vector3[];
  5498. /**
  5499. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5500. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5501. */
  5502. getDistances(): number[];
  5503. /**
  5504. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5505. * @param path path which all values are copied into the curves points
  5506. * @param firstNormal which should be projected onto the curve
  5507. * @returns the same object updated.
  5508. */
  5509. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5510. private _compute;
  5511. private _getFirstNonNullVector;
  5512. private _getLastNonNullVector;
  5513. private _normalVector;
  5514. }
  5515. /**
  5516. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5517. * A Curve3 is designed from a series of successive Vector3.
  5518. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5519. */
  5520. export class Curve3 {
  5521. private _points;
  5522. private _length;
  5523. /**
  5524. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5525. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5526. * @param v1 (Vector3) the control point
  5527. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5528. * @param nbPoints (integer) the wanted number of points in the curve
  5529. * @returns the created Curve3
  5530. */
  5531. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5532. /**
  5533. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5534. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5535. * @param v1 (Vector3) the first control point
  5536. * @param v2 (Vector3) the second control point
  5537. * @param v3 (Vector3) the end point of the Cubic Bezier
  5538. * @param nbPoints (integer) the wanted number of points in the curve
  5539. * @returns the created Curve3
  5540. */
  5541. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5542. /**
  5543. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5544. * @param p1 (Vector3) the origin point of the Hermite Spline
  5545. * @param t1 (Vector3) the tangent vector at the origin point
  5546. * @param p2 (Vector3) the end point of the Hermite Spline
  5547. * @param t2 (Vector3) the tangent vector at the end point
  5548. * @param nbPoints (integer) the wanted number of points in the curve
  5549. * @returns the created Curve3
  5550. */
  5551. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5552. /**
  5553. * Returns a Curve3 object along a CatmullRom Spline curve :
  5554. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5555. * @param nbPoints (integer) the wanted number of points between each curve control points
  5556. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5557. * @returns the created Curve3
  5558. */
  5559. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5560. /**
  5561. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5562. * A Curve3 is designed from a series of successive Vector3.
  5563. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5564. * @param points points which make up the curve
  5565. */
  5566. constructor(points: Vector3[]);
  5567. /**
  5568. * @returns the Curve3 stored array of successive Vector3
  5569. */
  5570. getPoints(): Vector3[];
  5571. /**
  5572. * @returns the computed length (float) of the curve.
  5573. */
  5574. length(): number;
  5575. /**
  5576. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5577. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5578. * curveA and curveB keep unchanged.
  5579. * @param curve the curve to continue from this curve
  5580. * @returns the newly constructed curve
  5581. */
  5582. continue(curve: DeepImmutable<Curve3>): Curve3;
  5583. private _computeLength;
  5584. }
  5585. }
  5586. declare module "babylonjs/Animations/easing" {
  5587. /**
  5588. * This represents the main contract an easing function should follow.
  5589. * Easing functions are used throughout the animation system.
  5590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5591. */
  5592. export interface IEasingFunction {
  5593. /**
  5594. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5595. * of the easing function.
  5596. * The link below provides some of the most common examples of easing functions.
  5597. * @see https://easings.net/
  5598. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5599. * @returns the corresponding value on the curve defined by the easing function
  5600. */
  5601. ease(gradient: number): number;
  5602. }
  5603. /**
  5604. * Base class used for every default easing function.
  5605. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5606. */
  5607. export class EasingFunction implements IEasingFunction {
  5608. /**
  5609. * Interpolation follows the mathematical formula associated with the easing function.
  5610. */
  5611. static readonly EASINGMODE_EASEIN: number;
  5612. /**
  5613. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5614. */
  5615. static readonly EASINGMODE_EASEOUT: number;
  5616. /**
  5617. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5618. */
  5619. static readonly EASINGMODE_EASEINOUT: number;
  5620. private _easingMode;
  5621. /**
  5622. * Sets the easing mode of the current function.
  5623. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5624. */
  5625. setEasingMode(easingMode: number): void;
  5626. /**
  5627. * Gets the current easing mode.
  5628. * @returns the easing mode
  5629. */
  5630. getEasingMode(): number;
  5631. /**
  5632. * @hidden
  5633. */
  5634. easeInCore(gradient: number): number;
  5635. /**
  5636. * Given an input gradient between 0 and 1, this returns the corresponding value
  5637. * of the easing function.
  5638. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5639. * @returns the corresponding value on the curve defined by the easing function
  5640. */
  5641. ease(gradient: number): number;
  5642. }
  5643. /**
  5644. * Easing function with a circle shape (see link below).
  5645. * @see https://easings.net/#easeInCirc
  5646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5647. */
  5648. export class CircleEase extends EasingFunction implements IEasingFunction {
  5649. /** @hidden */
  5650. easeInCore(gradient: number): number;
  5651. }
  5652. /**
  5653. * Easing function with a ease back shape (see link below).
  5654. * @see https://easings.net/#easeInBack
  5655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5656. */
  5657. export class BackEase extends EasingFunction implements IEasingFunction {
  5658. /** Defines the amplitude of the function */
  5659. amplitude: number;
  5660. /**
  5661. * Instantiates a back ease easing
  5662. * @see https://easings.net/#easeInBack
  5663. * @param amplitude Defines the amplitude of the function
  5664. */
  5665. constructor(
  5666. /** Defines the amplitude of the function */
  5667. amplitude?: number);
  5668. /** @hidden */
  5669. easeInCore(gradient: number): number;
  5670. }
  5671. /**
  5672. * Easing function with a bouncing shape (see link below).
  5673. * @see https://easings.net/#easeInBounce
  5674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class BounceEase extends EasingFunction implements IEasingFunction {
  5677. /** Defines the number of bounces */
  5678. bounces: number;
  5679. /** Defines the amplitude of the bounce */
  5680. bounciness: number;
  5681. /**
  5682. * Instantiates a bounce easing
  5683. * @see https://easings.net/#easeInBounce
  5684. * @param bounces Defines the number of bounces
  5685. * @param bounciness Defines the amplitude of the bounce
  5686. */
  5687. constructor(
  5688. /** Defines the number of bounces */
  5689. bounces?: number,
  5690. /** Defines the amplitude of the bounce */
  5691. bounciness?: number);
  5692. /** @hidden */
  5693. easeInCore(gradient: number): number;
  5694. }
  5695. /**
  5696. * Easing function with a power of 3 shape (see link below).
  5697. * @see https://easings.net/#easeInCubic
  5698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5699. */
  5700. export class CubicEase extends EasingFunction implements IEasingFunction {
  5701. /** @hidden */
  5702. easeInCore(gradient: number): number;
  5703. }
  5704. /**
  5705. * Easing function with an elastic shape (see link below).
  5706. * @see https://easings.net/#easeInElastic
  5707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5708. */
  5709. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5710. /** Defines the number of oscillations*/
  5711. oscillations: number;
  5712. /** Defines the amplitude of the oscillations*/
  5713. springiness: number;
  5714. /**
  5715. * Instantiates an elastic easing function
  5716. * @see https://easings.net/#easeInElastic
  5717. * @param oscillations Defines the number of oscillations
  5718. * @param springiness Defines the amplitude of the oscillations
  5719. */
  5720. constructor(
  5721. /** Defines the number of oscillations*/
  5722. oscillations?: number,
  5723. /** Defines the amplitude of the oscillations*/
  5724. springiness?: number);
  5725. /** @hidden */
  5726. easeInCore(gradient: number): number;
  5727. }
  5728. /**
  5729. * Easing function with an exponential shape (see link below).
  5730. * @see https://easings.net/#easeInExpo
  5731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5732. */
  5733. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5734. /** Defines the exponent of the function */
  5735. exponent: number;
  5736. /**
  5737. * Instantiates an exponential easing function
  5738. * @see https://easings.net/#easeInExpo
  5739. * @param exponent Defines the exponent of the function
  5740. */
  5741. constructor(
  5742. /** Defines the exponent of the function */
  5743. exponent?: number);
  5744. /** @hidden */
  5745. easeInCore(gradient: number): number;
  5746. }
  5747. /**
  5748. * Easing function with a power shape (see link below).
  5749. * @see https://easings.net/#easeInQuad
  5750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5751. */
  5752. export class PowerEase extends EasingFunction implements IEasingFunction {
  5753. /** Defines the power of the function */
  5754. power: number;
  5755. /**
  5756. * Instantiates an power base easing function
  5757. * @see https://easings.net/#easeInQuad
  5758. * @param power Defines the power of the function
  5759. */
  5760. constructor(
  5761. /** Defines the power of the function */
  5762. power?: number);
  5763. /** @hidden */
  5764. easeInCore(gradient: number): number;
  5765. }
  5766. /**
  5767. * Easing function with a power of 2 shape (see link below).
  5768. * @see https://easings.net/#easeInQuad
  5769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5770. */
  5771. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5772. /** @hidden */
  5773. easeInCore(gradient: number): number;
  5774. }
  5775. /**
  5776. * Easing function with a power of 4 shape (see link below).
  5777. * @see https://easings.net/#easeInQuart
  5778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5779. */
  5780. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with a power of 5 shape (see link below).
  5786. * @see https://easings.net/#easeInQuint
  5787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5790. /** @hidden */
  5791. easeInCore(gradient: number): number;
  5792. }
  5793. /**
  5794. * Easing function with a sin shape (see link below).
  5795. * @see https://easings.net/#easeInSine
  5796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5797. */
  5798. export class SineEase extends EasingFunction implements IEasingFunction {
  5799. /** @hidden */
  5800. easeInCore(gradient: number): number;
  5801. }
  5802. /**
  5803. * Easing function with a bezier shape (see link below).
  5804. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5806. */
  5807. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5808. /** Defines the x component of the start tangent in the bezier curve */
  5809. x1: number;
  5810. /** Defines the y component of the start tangent in the bezier curve */
  5811. y1: number;
  5812. /** Defines the x component of the end tangent in the bezier curve */
  5813. x2: number;
  5814. /** Defines the y component of the end tangent in the bezier curve */
  5815. y2: number;
  5816. /**
  5817. * Instantiates a bezier function
  5818. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5819. * @param x1 Defines the x component of the start tangent in the bezier curve
  5820. * @param y1 Defines the y component of the start tangent in the bezier curve
  5821. * @param x2 Defines the x component of the end tangent in the bezier curve
  5822. * @param y2 Defines the y component of the end tangent in the bezier curve
  5823. */
  5824. constructor(
  5825. /** Defines the x component of the start tangent in the bezier curve */
  5826. x1?: number,
  5827. /** Defines the y component of the start tangent in the bezier curve */
  5828. y1?: number,
  5829. /** Defines the x component of the end tangent in the bezier curve */
  5830. x2?: number,
  5831. /** Defines the y component of the end tangent in the bezier curve */
  5832. y2?: number);
  5833. /** @hidden */
  5834. easeInCore(gradient: number): number;
  5835. }
  5836. }
  5837. declare module "babylonjs/Animations/animationKey" {
  5838. /**
  5839. * Defines an interface which represents an animation key frame
  5840. */
  5841. export interface IAnimationKey {
  5842. /**
  5843. * Frame of the key frame
  5844. */
  5845. frame: number;
  5846. /**
  5847. * Value at the specifies key frame
  5848. */
  5849. value: any;
  5850. /**
  5851. * The input tangent for the cubic hermite spline
  5852. */
  5853. inTangent?: any;
  5854. /**
  5855. * The output tangent for the cubic hermite spline
  5856. */
  5857. outTangent?: any;
  5858. /**
  5859. * The animation interpolation type
  5860. */
  5861. interpolation?: AnimationKeyInterpolation;
  5862. }
  5863. /**
  5864. * Enum for the animation key frame interpolation type
  5865. */
  5866. export enum AnimationKeyInterpolation {
  5867. /**
  5868. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5869. */
  5870. STEP = 1
  5871. }
  5872. }
  5873. declare module "babylonjs/Animations/animationRange" {
  5874. /**
  5875. * Represents the range of an animation
  5876. */
  5877. export class AnimationRange {
  5878. /**The name of the animation range**/
  5879. name: string;
  5880. /**The starting frame of the animation */
  5881. from: number;
  5882. /**The ending frame of the animation*/
  5883. to: number;
  5884. /**
  5885. * Initializes the range of an animation
  5886. * @param name The name of the animation range
  5887. * @param from The starting frame of the animation
  5888. * @param to The ending frame of the animation
  5889. */
  5890. constructor(
  5891. /**The name of the animation range**/
  5892. name: string,
  5893. /**The starting frame of the animation */
  5894. from: number,
  5895. /**The ending frame of the animation*/
  5896. to: number);
  5897. /**
  5898. * Makes a copy of the animation range
  5899. * @returns A copy of the animation range
  5900. */
  5901. clone(): AnimationRange;
  5902. }
  5903. }
  5904. declare module "babylonjs/Animations/animationEvent" {
  5905. /**
  5906. * Composed of a frame, and an action function
  5907. */
  5908. export class AnimationEvent {
  5909. /** The frame for which the event is triggered **/
  5910. frame: number;
  5911. /** The event to perform when triggered **/
  5912. action: (currentFrame: number) => void;
  5913. /** Specifies if the event should be triggered only once**/
  5914. onlyOnce?: boolean | undefined;
  5915. /**
  5916. * Specifies if the animation event is done
  5917. */
  5918. isDone: boolean;
  5919. /**
  5920. * Initializes the animation event
  5921. * @param frame The frame for which the event is triggered
  5922. * @param action The event to perform when triggered
  5923. * @param onlyOnce Specifies if the event should be triggered only once
  5924. */
  5925. constructor(
  5926. /** The frame for which the event is triggered **/
  5927. frame: number,
  5928. /** The event to perform when triggered **/
  5929. action: (currentFrame: number) => void,
  5930. /** Specifies if the event should be triggered only once**/
  5931. onlyOnce?: boolean | undefined);
  5932. /** @hidden */
  5933. _clone(): AnimationEvent;
  5934. }
  5935. }
  5936. declare module "babylonjs/Behaviors/behavior" {
  5937. import { Nullable } from "babylonjs/types";
  5938. /**
  5939. * Interface used to define a behavior
  5940. */
  5941. export interface Behavior<T> {
  5942. /** gets or sets behavior's name */
  5943. name: string;
  5944. /**
  5945. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5946. */
  5947. init(): void;
  5948. /**
  5949. * Called when the behavior is attached to a target
  5950. * @param target defines the target where the behavior is attached to
  5951. */
  5952. attach(target: T): void;
  5953. /**
  5954. * Called when the behavior is detached from its target
  5955. */
  5956. detach(): void;
  5957. }
  5958. /**
  5959. * Interface implemented by classes supporting behaviors
  5960. */
  5961. export interface IBehaviorAware<T> {
  5962. /**
  5963. * Attach a behavior
  5964. * @param behavior defines the behavior to attach
  5965. * @returns the current host
  5966. */
  5967. addBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Remove a behavior from the current object
  5970. * @param behavior defines the behavior to detach
  5971. * @returns the current host
  5972. */
  5973. removeBehavior(behavior: Behavior<T>): T;
  5974. /**
  5975. * Gets a behavior using its name to search
  5976. * @param name defines the name to search
  5977. * @returns the behavior or null if not found
  5978. */
  5979. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/smartArray" {
  5983. /**
  5984. * Defines an array and its length.
  5985. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5986. */
  5987. export interface ISmartArrayLike<T> {
  5988. /**
  5989. * The data of the array.
  5990. */
  5991. data: Array<T>;
  5992. /**
  5993. * The active length of the array.
  5994. */
  5995. length: number;
  5996. }
  5997. /**
  5998. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5999. */
  6000. export class SmartArray<T> implements ISmartArrayLike<T> {
  6001. /**
  6002. * The full set of data from the array.
  6003. */
  6004. data: Array<T>;
  6005. /**
  6006. * The active length of the array.
  6007. */
  6008. length: number;
  6009. protected _id: number;
  6010. /**
  6011. * Instantiates a Smart Array.
  6012. * @param capacity defines the default capacity of the array.
  6013. */
  6014. constructor(capacity: number);
  6015. /**
  6016. * Pushes a value at the end of the active data.
  6017. * @param value defines the object to push in the array.
  6018. */
  6019. push(value: T): void;
  6020. /**
  6021. * Iterates over the active data and apply the lambda to them.
  6022. * @param func defines the action to apply on each value.
  6023. */
  6024. forEach(func: (content: T) => void): void;
  6025. /**
  6026. * Sorts the full sets of data.
  6027. * @param compareFn defines the comparison function to apply.
  6028. */
  6029. sort(compareFn: (a: T, b: T) => number): void;
  6030. /**
  6031. * Resets the active data to an empty array.
  6032. */
  6033. reset(): void;
  6034. /**
  6035. * Releases all the data from the array as well as the array.
  6036. */
  6037. dispose(): void;
  6038. /**
  6039. * Concats the active data with a given array.
  6040. * @param array defines the data to concatenate with.
  6041. */
  6042. concat(array: any): void;
  6043. /**
  6044. * Returns the position of a value in the active data.
  6045. * @param value defines the value to find the index for
  6046. * @returns the index if found in the active data otherwise -1
  6047. */
  6048. indexOf(value: T): number;
  6049. /**
  6050. * Returns whether an element is part of the active data.
  6051. * @param value defines the value to look for
  6052. * @returns true if found in the active data otherwise false
  6053. */
  6054. contains(value: T): boolean;
  6055. private static _GlobalId;
  6056. }
  6057. /**
  6058. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6059. * The data in this array can only be present once
  6060. */
  6061. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6062. private _duplicateId;
  6063. /**
  6064. * Pushes a value at the end of the active data.
  6065. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Pushes a value at the end of the active data.
  6071. * If the data is already present, it won t be added again
  6072. * @param value defines the object to push in the array.
  6073. * @returns true if added false if it was already present
  6074. */
  6075. pushNoDuplicate(value: T): boolean;
  6076. /**
  6077. * Resets the active data to an empty array.
  6078. */
  6079. reset(): void;
  6080. /**
  6081. * Concats the active data with a given array.
  6082. * This ensures no dupplicate will be present in the result.
  6083. * @param array defines the data to concatenate with.
  6084. */
  6085. concatWithNoDuplicate(array: any): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/Cameras/cameraInputsManager" {
  6089. import { Nullable } from "babylonjs/types";
  6090. import { Camera } from "babylonjs/Cameras/camera";
  6091. /**
  6092. * @ignore
  6093. * This is a list of all the different input types that are available in the application.
  6094. * Fo instance: ArcRotateCameraGamepadInput...
  6095. */
  6096. export var CameraInputTypes: {};
  6097. /**
  6098. * This is the contract to implement in order to create a new input class.
  6099. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6100. */
  6101. export interface ICameraInput<TCamera extends Camera> {
  6102. /**
  6103. * Defines the camera the input is attached to.
  6104. */
  6105. camera: Nullable<TCamera>;
  6106. /**
  6107. * Gets the class name of the current intput.
  6108. * @returns the class name
  6109. */
  6110. getClassName(): string;
  6111. /**
  6112. * Get the friendly name associated with the input class.
  6113. * @returns the input friendly name
  6114. */
  6115. getSimpleName(): string;
  6116. /**
  6117. * Attach the input controls to a specific dom element to get the input from.
  6118. * @param element Defines the element the controls should be listened from
  6119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6120. */
  6121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6122. /**
  6123. * Detach the current controls from the specified dom element.
  6124. * @param element Defines the element to stop listening the inputs from
  6125. */
  6126. detachControl(element: Nullable<HTMLElement>): void;
  6127. /**
  6128. * Update the current camera state depending on the inputs that have been used this frame.
  6129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6130. */
  6131. checkInputs?: () => void;
  6132. }
  6133. /**
  6134. * Represents a map of input types to input instance or input index to input instance.
  6135. */
  6136. export interface CameraInputsMap<TCamera extends Camera> {
  6137. /**
  6138. * Accessor to the input by input type.
  6139. */
  6140. [name: string]: ICameraInput<TCamera>;
  6141. /**
  6142. * Accessor to the input by input index.
  6143. */
  6144. [idx: number]: ICameraInput<TCamera>;
  6145. }
  6146. /**
  6147. * This represents the input manager used within a camera.
  6148. * It helps dealing with all the different kind of input attached to a camera.
  6149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6150. */
  6151. export class CameraInputsManager<TCamera extends Camera> {
  6152. /**
  6153. * Defines the list of inputs attahed to the camera.
  6154. */
  6155. attached: CameraInputsMap<TCamera>;
  6156. /**
  6157. * Defines the dom element the camera is collecting inputs from.
  6158. * This is null if the controls have not been attached.
  6159. */
  6160. attachedElement: Nullable<HTMLElement>;
  6161. /**
  6162. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6163. */
  6164. noPreventDefault: boolean;
  6165. /**
  6166. * Defined the camera the input manager belongs to.
  6167. */
  6168. camera: TCamera;
  6169. /**
  6170. * Update the current camera state depending on the inputs that have been used this frame.
  6171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6172. */
  6173. checkInputs: () => void;
  6174. /**
  6175. * Instantiate a new Camera Input Manager.
  6176. * @param camera Defines the camera the input manager blongs to
  6177. */
  6178. constructor(camera: TCamera);
  6179. /**
  6180. * Add an input method to a camera
  6181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6182. * @param input camera input method
  6183. */
  6184. add(input: ICameraInput<TCamera>): void;
  6185. /**
  6186. * Remove a specific input method from a camera
  6187. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6188. * @param inputToRemove camera input method
  6189. */
  6190. remove(inputToRemove: ICameraInput<TCamera>): void;
  6191. /**
  6192. * Remove a specific input type from a camera
  6193. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6194. * @param inputType the type of the input to remove
  6195. */
  6196. removeByType(inputType: string): void;
  6197. private _addCheckInputs;
  6198. /**
  6199. * Attach the input controls to the currently attached dom element to listen the events from.
  6200. * @param input Defines the input to attach
  6201. */
  6202. attachInput(input: ICameraInput<TCamera>): void;
  6203. /**
  6204. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6205. * @param element Defines the dom element to collect the events from
  6206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6207. */
  6208. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6209. /**
  6210. * Detach the current manager inputs controls from a specific dom element.
  6211. * @param element Defines the dom element to collect the events from
  6212. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6213. */
  6214. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6215. /**
  6216. * Rebuild the dynamic inputCheck function from the current list of
  6217. * defined inputs in the manager.
  6218. */
  6219. rebuildInputCheck(): void;
  6220. /**
  6221. * Remove all attached input methods from a camera
  6222. */
  6223. clear(): void;
  6224. /**
  6225. * Serialize the current input manager attached to a camera.
  6226. * This ensures than once parsed,
  6227. * the input associated to the camera will be identical to the current ones
  6228. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6229. */
  6230. serialize(serializedCamera: any): void;
  6231. /**
  6232. * Parses an input manager serialized JSON to restore the previous list of inputs
  6233. * and states associated to a camera.
  6234. * @param parsedCamera Defines the JSON to parse
  6235. */
  6236. parse(parsedCamera: any): void;
  6237. }
  6238. }
  6239. declare module "babylonjs/Meshes/buffer" {
  6240. import { Nullable, DataArray } from "babylonjs/types";
  6241. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6242. /**
  6243. * Class used to store data that will be store in GPU memory
  6244. */
  6245. export class Buffer {
  6246. private _engine;
  6247. private _buffer;
  6248. /** @hidden */
  6249. _data: Nullable<DataArray>;
  6250. private _updatable;
  6251. private _instanced;
  6252. /**
  6253. * Gets the byte stride.
  6254. */
  6255. readonly byteStride: number;
  6256. /**
  6257. * Constructor
  6258. * @param engine the engine
  6259. * @param data the data to use for this buffer
  6260. * @param updatable whether the data is updatable
  6261. * @param stride the stride (optional)
  6262. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6263. * @param instanced whether the buffer is instanced (optional)
  6264. * @param useBytes set to true if the stride in in bytes (optional)
  6265. */
  6266. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6267. /**
  6268. * Create a new VertexBuffer based on the current buffer
  6269. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6270. * @param offset defines offset in the buffer (0 by default)
  6271. * @param size defines the size in floats of attributes (position is 3 for instance)
  6272. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6273. * @param instanced defines if the vertex buffer contains indexed data
  6274. * @param useBytes defines if the offset and stride are in bytes
  6275. * @returns the new vertex buffer
  6276. */
  6277. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6278. /**
  6279. * Gets a boolean indicating if the Buffer is updatable?
  6280. * @returns true if the buffer is updatable
  6281. */
  6282. isUpdatable(): boolean;
  6283. /**
  6284. * Gets current buffer's data
  6285. * @returns a DataArray or null
  6286. */
  6287. getData(): Nullable<DataArray>;
  6288. /**
  6289. * Gets underlying native buffer
  6290. * @returns underlying native buffer
  6291. */
  6292. getBuffer(): Nullable<DataBuffer>;
  6293. /**
  6294. * Gets the stride in float32 units (i.e. byte stride / 4).
  6295. * May not be an integer if the byte stride is not divisible by 4.
  6296. * DEPRECATED. Use byteStride instead.
  6297. * @returns the stride in float32 units
  6298. */
  6299. getStrideSize(): number;
  6300. /**
  6301. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6302. * @param data defines the data to store
  6303. */
  6304. create(data?: Nullable<DataArray>): void;
  6305. /** @hidden */
  6306. _rebuild(): void;
  6307. /**
  6308. * Update current buffer data
  6309. * @param data defines the data to store
  6310. */
  6311. update(data: DataArray): void;
  6312. /**
  6313. * Updates the data directly.
  6314. * @param data the new data
  6315. * @param offset the new offset
  6316. * @param vertexCount the vertex count (optional)
  6317. * @param useBytes set to true if the offset is in bytes
  6318. */
  6319. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6320. /**
  6321. * Release all resources
  6322. */
  6323. dispose(): void;
  6324. }
  6325. /**
  6326. * Specialized buffer used to store vertex data
  6327. */
  6328. export class VertexBuffer {
  6329. /** @hidden */
  6330. _buffer: Buffer;
  6331. private _kind;
  6332. private _size;
  6333. private _ownsBuffer;
  6334. private _instanced;
  6335. private _instanceDivisor;
  6336. /**
  6337. * The byte type.
  6338. */
  6339. static readonly BYTE: number;
  6340. /**
  6341. * The unsigned byte type.
  6342. */
  6343. static readonly UNSIGNED_BYTE: number;
  6344. /**
  6345. * The short type.
  6346. */
  6347. static readonly SHORT: number;
  6348. /**
  6349. * The unsigned short type.
  6350. */
  6351. static readonly UNSIGNED_SHORT: number;
  6352. /**
  6353. * The integer type.
  6354. */
  6355. static readonly INT: number;
  6356. /**
  6357. * The unsigned integer type.
  6358. */
  6359. static readonly UNSIGNED_INT: number;
  6360. /**
  6361. * The float type.
  6362. */
  6363. static readonly FLOAT: number;
  6364. /**
  6365. * Gets or sets the instance divisor when in instanced mode
  6366. */
  6367. instanceDivisor: number;
  6368. /**
  6369. * Gets the byte stride.
  6370. */
  6371. readonly byteStride: number;
  6372. /**
  6373. * Gets the byte offset.
  6374. */
  6375. readonly byteOffset: number;
  6376. /**
  6377. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6378. */
  6379. readonly normalized: boolean;
  6380. /**
  6381. * Gets the data type of each component in the array.
  6382. */
  6383. readonly type: number;
  6384. /**
  6385. * Constructor
  6386. * @param engine the engine
  6387. * @param data the data to use for this vertex buffer
  6388. * @param kind the vertex buffer kind
  6389. * @param updatable whether the data is updatable
  6390. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6391. * @param stride the stride (optional)
  6392. * @param instanced whether the buffer is instanced (optional)
  6393. * @param offset the offset of the data (optional)
  6394. * @param size the number of components (optional)
  6395. * @param type the type of the component (optional)
  6396. * @param normalized whether the data contains normalized data (optional)
  6397. * @param useBytes set to true if stride and offset are in bytes (optional)
  6398. */
  6399. 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);
  6400. /** @hidden */
  6401. _rebuild(): void;
  6402. /**
  6403. * Returns the kind of the VertexBuffer (string)
  6404. * @returns a string
  6405. */
  6406. getKind(): string;
  6407. /**
  6408. * Gets a boolean indicating if the VertexBuffer is updatable?
  6409. * @returns true if the buffer is updatable
  6410. */
  6411. isUpdatable(): boolean;
  6412. /**
  6413. * Gets current buffer's data
  6414. * @returns a DataArray or null
  6415. */
  6416. getData(): Nullable<DataArray>;
  6417. /**
  6418. * Gets underlying native buffer
  6419. * @returns underlying native buffer
  6420. */
  6421. getBuffer(): Nullable<DataBuffer>;
  6422. /**
  6423. * Gets the stride in float32 units (i.e. byte stride / 4).
  6424. * May not be an integer if the byte stride is not divisible by 4.
  6425. * DEPRECATED. Use byteStride instead.
  6426. * @returns the stride in float32 units
  6427. */
  6428. getStrideSize(): number;
  6429. /**
  6430. * Returns the offset as a multiple of the type byte length.
  6431. * DEPRECATED. Use byteOffset instead.
  6432. * @returns the offset in bytes
  6433. */
  6434. getOffset(): number;
  6435. /**
  6436. * Returns the number of components per vertex attribute (integer)
  6437. * @returns the size in float
  6438. */
  6439. getSize(): number;
  6440. /**
  6441. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6442. * @returns true if this buffer is instanced
  6443. */
  6444. getIsInstanced(): boolean;
  6445. /**
  6446. * Returns the instancing divisor, zero for non-instanced (integer).
  6447. * @returns a number
  6448. */
  6449. getInstanceDivisor(): number;
  6450. /**
  6451. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6452. * @param data defines the data to store
  6453. */
  6454. create(data?: DataArray): void;
  6455. /**
  6456. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6457. * This function will create a new buffer if the current one is not updatable
  6458. * @param data defines the data to store
  6459. */
  6460. update(data: DataArray): void;
  6461. /**
  6462. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6463. * Returns the directly updated WebGLBuffer.
  6464. * @param data the new data
  6465. * @param offset the new offset
  6466. * @param useBytes set to true if the offset is in bytes
  6467. */
  6468. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6469. /**
  6470. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6471. */
  6472. dispose(): void;
  6473. /**
  6474. * Enumerates each value of this vertex buffer as numbers.
  6475. * @param count the number of values to enumerate
  6476. * @param callback the callback function called for each value
  6477. */
  6478. forEach(count: number, callback: (value: number, index: number) => void): void;
  6479. /**
  6480. * Positions
  6481. */
  6482. static readonly PositionKind: string;
  6483. /**
  6484. * Normals
  6485. */
  6486. static readonly NormalKind: string;
  6487. /**
  6488. * Tangents
  6489. */
  6490. static readonly TangentKind: string;
  6491. /**
  6492. * Texture coordinates
  6493. */
  6494. static readonly UVKind: string;
  6495. /**
  6496. * Texture coordinates 2
  6497. */
  6498. static readonly UV2Kind: string;
  6499. /**
  6500. * Texture coordinates 3
  6501. */
  6502. static readonly UV3Kind: string;
  6503. /**
  6504. * Texture coordinates 4
  6505. */
  6506. static readonly UV4Kind: string;
  6507. /**
  6508. * Texture coordinates 5
  6509. */
  6510. static readonly UV5Kind: string;
  6511. /**
  6512. * Texture coordinates 6
  6513. */
  6514. static readonly UV6Kind: string;
  6515. /**
  6516. * Colors
  6517. */
  6518. static readonly ColorKind: string;
  6519. /**
  6520. * Matrix indices (for bones)
  6521. */
  6522. static readonly MatricesIndicesKind: string;
  6523. /**
  6524. * Matrix weights (for bones)
  6525. */
  6526. static readonly MatricesWeightsKind: string;
  6527. /**
  6528. * Additional matrix indices (for bones)
  6529. */
  6530. static readonly MatricesIndicesExtraKind: string;
  6531. /**
  6532. * Additional matrix weights (for bones)
  6533. */
  6534. static readonly MatricesWeightsExtraKind: string;
  6535. /**
  6536. * Deduces the stride given a kind.
  6537. * @param kind The kind string to deduce
  6538. * @returns The deduced stride
  6539. */
  6540. static DeduceStride(kind: string): number;
  6541. /**
  6542. * Gets the byte length of the given type.
  6543. * @param type the type
  6544. * @returns the number of bytes
  6545. */
  6546. static GetTypeByteLength(type: number): number;
  6547. /**
  6548. * Enumerates each value of the given parameters as numbers.
  6549. * @param data the data to enumerate
  6550. * @param byteOffset the byte offset of the data
  6551. * @param byteStride the byte stride of the data
  6552. * @param componentCount the number of components per element
  6553. * @param componentType the type of the component
  6554. * @param count the number of values to enumerate
  6555. * @param normalized whether the data is normalized
  6556. * @param callback the callback function called for each value
  6557. */
  6558. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6559. private static _GetFloatValue;
  6560. }
  6561. }
  6562. declare module "babylonjs/Collisions/intersectionInfo" {
  6563. import { Nullable } from "babylonjs/types";
  6564. /**
  6565. * @hidden
  6566. */
  6567. export class IntersectionInfo {
  6568. bu: Nullable<number>;
  6569. bv: Nullable<number>;
  6570. distance: number;
  6571. faceId: number;
  6572. subMeshId: number;
  6573. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6574. }
  6575. }
  6576. declare module "babylonjs/Maths/math.plane" {
  6577. import { DeepImmutable } from "babylonjs/types";
  6578. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6579. /**
  6580. * Represens a plane by the equation ax + by + cz + d = 0
  6581. */
  6582. export class Plane {
  6583. private static _TmpMatrix;
  6584. /**
  6585. * Normal of the plane (a,b,c)
  6586. */
  6587. normal: Vector3;
  6588. /**
  6589. * d component of the plane
  6590. */
  6591. d: number;
  6592. /**
  6593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6594. * @param a a component of the plane
  6595. * @param b b component of the plane
  6596. * @param c c component of the plane
  6597. * @param d d component of the plane
  6598. */
  6599. constructor(a: number, b: number, c: number, d: number);
  6600. /**
  6601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6602. */
  6603. asArray(): number[];
  6604. /**
  6605. * @returns a new plane copied from the current Plane.
  6606. */
  6607. clone(): Plane;
  6608. /**
  6609. * @returns the string "Plane".
  6610. */
  6611. getClassName(): string;
  6612. /**
  6613. * @returns the Plane hash code.
  6614. */
  6615. getHashCode(): number;
  6616. /**
  6617. * Normalize the current Plane in place.
  6618. * @returns the updated Plane.
  6619. */
  6620. normalize(): Plane;
  6621. /**
  6622. * Applies a transformation the plane and returns the result
  6623. * @param transformation the transformation matrix to be applied to the plane
  6624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6625. */
  6626. transform(transformation: DeepImmutable<Matrix>): Plane;
  6627. /**
  6628. * Calcualtte the dot product between the point and the plane normal
  6629. * @param point point to calculate the dot product with
  6630. * @returns the dot product (float) of the point coordinates and the plane normal.
  6631. */
  6632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6633. /**
  6634. * Updates the current Plane from the plane defined by the three given points.
  6635. * @param point1 one of the points used to contruct the plane
  6636. * @param point2 one of the points used to contruct the plane
  6637. * @param point3 one of the points used to contruct the plane
  6638. * @returns the updated Plane.
  6639. */
  6640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6641. /**
  6642. * Checks if the plane is facing a given direction
  6643. * @param direction the direction to check if the plane is facing
  6644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6645. * @returns True is the vector "direction" is the same side than the plane normal.
  6646. */
  6647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6648. /**
  6649. * Calculates the distance to a point
  6650. * @param point point to calculate distance to
  6651. * @returns the signed distance (float) from the given point to the Plane.
  6652. */
  6653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6654. /**
  6655. * Creates a plane from an array
  6656. * @param array the array to create a plane from
  6657. * @returns a new Plane from the given array.
  6658. */
  6659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6660. /**
  6661. * Creates a plane from three points
  6662. * @param point1 point used to create the plane
  6663. * @param point2 point used to create the plane
  6664. * @param point3 point used to create the plane
  6665. * @returns a new Plane defined by the three given points.
  6666. */
  6667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6668. /**
  6669. * Creates a plane from an origin point and a normal
  6670. * @param origin origin of the plane to be constructed
  6671. * @param normal normal of the plane to be constructed
  6672. * @returns a new Plane the normal vector to this plane at the given origin point.
  6673. * Note : the vector "normal" is updated because normalized.
  6674. */
  6675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6676. /**
  6677. * Calculates the distance from a plane and a point
  6678. * @param origin origin of the plane to be constructed
  6679. * @param normal normal of the plane to be constructed
  6680. * @param point point to calculate distance to
  6681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6682. */
  6683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6684. }
  6685. }
  6686. declare module "babylonjs/Culling/boundingSphere" {
  6687. import { DeepImmutable } from "babylonjs/types";
  6688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding sphere information
  6692. */
  6693. export class BoundingSphere {
  6694. /**
  6695. * Gets the center of the bounding sphere in local space
  6696. */
  6697. readonly center: Vector3;
  6698. /**
  6699. * Radius of the bounding sphere in local space
  6700. */
  6701. radius: number;
  6702. /**
  6703. * Gets the center of the bounding sphere in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Radius of the bounding sphere in world space
  6708. */
  6709. radiusWorld: number;
  6710. /**
  6711. * Gets the minimum vector in local space
  6712. */
  6713. readonly minimum: Vector3;
  6714. /**
  6715. * Gets the maximum vector in local space
  6716. */
  6717. readonly maximum: Vector3;
  6718. private _worldMatrix;
  6719. private static readonly TmpVector3;
  6720. /**
  6721. * Creates a new bounding sphere
  6722. * @param min defines the minimum vector (in local space)
  6723. * @param max defines the maximum vector (in local space)
  6724. * @param worldMatrix defines the new world matrix
  6725. */
  6726. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6727. /**
  6728. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6729. * @param min defines the new minimum vector (in local space)
  6730. * @param max defines the new maximum vector (in local space)
  6731. * @param worldMatrix defines the new world matrix
  6732. */
  6733. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6734. /**
  6735. * Scale the current bounding sphere by applying a scale factor
  6736. * @param factor defines the scale factor to apply
  6737. * @returns the current bounding box
  6738. */
  6739. scale(factor: number): BoundingSphere;
  6740. /**
  6741. * Gets the world matrix of the bounding box
  6742. * @returns a matrix
  6743. */
  6744. getWorldMatrix(): DeepImmutable<Matrix>;
  6745. /** @hidden */
  6746. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6747. /**
  6748. * Tests if the bounding sphere is intersecting the frustum planes
  6749. * @param frustumPlanes defines the frustum planes to test
  6750. * @returns true if there is an intersection
  6751. */
  6752. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6753. /**
  6754. * Tests if the bounding sphere center is in between the frustum planes.
  6755. * Used for optimistic fast inclusion.
  6756. * @param frustumPlanes defines the frustum planes to test
  6757. * @returns true if the sphere center is in between the frustum planes
  6758. */
  6759. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6760. /**
  6761. * Tests if a point is inside the bounding sphere
  6762. * @param point defines the point to test
  6763. * @returns true if the point is inside the bounding sphere
  6764. */
  6765. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6766. /**
  6767. * Checks if two sphere intersct
  6768. * @param sphere0 sphere 0
  6769. * @param sphere1 sphere 1
  6770. * @returns true if the speres intersect
  6771. */
  6772. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6773. }
  6774. }
  6775. declare module "babylonjs/Culling/boundingBox" {
  6776. import { DeepImmutable } from "babylonjs/types";
  6777. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6778. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6779. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6780. import { Plane } from "babylonjs/Maths/math.plane";
  6781. /**
  6782. * Class used to store bounding box information
  6783. */
  6784. export class BoundingBox implements ICullable {
  6785. /**
  6786. * Gets the 8 vectors representing the bounding box in local space
  6787. */
  6788. readonly vectors: Vector3[];
  6789. /**
  6790. * Gets the center of the bounding box in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Gets the center of the bounding box in world space
  6795. */
  6796. readonly centerWorld: Vector3;
  6797. /**
  6798. * Gets the extend size in local space
  6799. */
  6800. readonly extendSize: Vector3;
  6801. /**
  6802. * Gets the extend size in world space
  6803. */
  6804. readonly extendSizeWorld: Vector3;
  6805. /**
  6806. * Gets the OBB (object bounding box) directions
  6807. */
  6808. readonly directions: Vector3[];
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in world space
  6811. */
  6812. readonly vectorsWorld: Vector3[];
  6813. /**
  6814. * Gets the minimum vector in world space
  6815. */
  6816. readonly minimumWorld: Vector3;
  6817. /**
  6818. * Gets the maximum vector in world space
  6819. */
  6820. readonly maximumWorld: Vector3;
  6821. /**
  6822. * Gets the minimum vector in local space
  6823. */
  6824. readonly minimum: Vector3;
  6825. /**
  6826. * Gets the maximum vector in local space
  6827. */
  6828. readonly maximum: Vector3;
  6829. private _worldMatrix;
  6830. private static readonly TmpVector3;
  6831. /**
  6832. * @hidden
  6833. */
  6834. _tag: number;
  6835. /**
  6836. * Creates a new bounding box
  6837. * @param min defines the minimum vector (in local space)
  6838. * @param max defines the maximum vector (in local space)
  6839. * @param worldMatrix defines the new world matrix
  6840. */
  6841. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6842. /**
  6843. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6844. * @param min defines the new minimum vector (in local space)
  6845. * @param max defines the new maximum vector (in local space)
  6846. * @param worldMatrix defines the new world matrix
  6847. */
  6848. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6849. /**
  6850. * Scale the current bounding box by applying a scale factor
  6851. * @param factor defines the scale factor to apply
  6852. * @returns the current bounding box
  6853. */
  6854. scale(factor: number): BoundingBox;
  6855. /**
  6856. * Gets the world matrix of the bounding box
  6857. * @returns a matrix
  6858. */
  6859. getWorldMatrix(): DeepImmutable<Matrix>;
  6860. /** @hidden */
  6861. _update(world: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Tests if the bounding box is intersecting the frustum planes
  6864. * @param frustumPlanes defines the frustum planes to test
  6865. * @returns true if there is an intersection
  6866. */
  6867. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6868. /**
  6869. * Tests if the bounding box is entirely inside the frustum planes
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @returns true if there is an inclusion
  6872. */
  6873. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. /**
  6875. * Tests if a point is inside the bounding box
  6876. * @param point defines the point to test
  6877. * @returns true if the point is inside the bounding box
  6878. */
  6879. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6880. /**
  6881. * Tests if the bounding box intersects with a bounding sphere
  6882. * @param sphere defines the sphere to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6886. /**
  6887. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6888. * @param min defines the min vector to use
  6889. * @param max defines the max vector to use
  6890. * @returns true if there is an intersection
  6891. */
  6892. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Tests if two bounding boxes are intersections
  6895. * @param box0 defines the first box to test
  6896. * @param box1 defines the second box to test
  6897. * @returns true if there is an intersection
  6898. */
  6899. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6900. /**
  6901. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6902. * @param minPoint defines the minimum vector of the bounding box
  6903. * @param maxPoint defines the maximum vector of the bounding box
  6904. * @param sphereCenter defines the sphere center
  6905. * @param sphereRadius defines the sphere radius
  6906. * @returns true if there is an intersection
  6907. */
  6908. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6909. /**
  6910. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6911. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6912. * @param frustumPlanes defines the frustum planes to test
  6913. * @return true if there is an inclusion
  6914. */
  6915. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6916. /**
  6917. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6918. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6919. * @param frustumPlanes defines the frustum planes to test
  6920. * @return true if there is an intersection
  6921. */
  6922. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/collider" {
  6926. import { Nullable, IndicesArray } from "babylonjs/types";
  6927. import { Vector3 } from "babylonjs/Maths/math.vector";
  6928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6929. import { Plane } from "babylonjs/Maths/math.plane";
  6930. /** @hidden */
  6931. export class Collider {
  6932. /** Define if a collision was found */
  6933. collisionFound: boolean;
  6934. /**
  6935. * Define last intersection point in local space
  6936. */
  6937. intersectionPoint: Vector3;
  6938. /**
  6939. * Define last collided mesh
  6940. */
  6941. collidedMesh: Nullable<AbstractMesh>;
  6942. private _collisionPoint;
  6943. private _planeIntersectionPoint;
  6944. private _tempVector;
  6945. private _tempVector2;
  6946. private _tempVector3;
  6947. private _tempVector4;
  6948. private _edge;
  6949. private _baseToVertex;
  6950. private _destinationPoint;
  6951. private _slidePlaneNormal;
  6952. private _displacementVector;
  6953. /** @hidden */
  6954. _radius: Vector3;
  6955. /** @hidden */
  6956. _retry: number;
  6957. private _velocity;
  6958. private _basePoint;
  6959. private _epsilon;
  6960. /** @hidden */
  6961. _velocityWorldLength: number;
  6962. /** @hidden */
  6963. _basePointWorld: Vector3;
  6964. private _velocityWorld;
  6965. private _normalizedVelocity;
  6966. /** @hidden */
  6967. _initialVelocity: Vector3;
  6968. /** @hidden */
  6969. _initialPosition: Vector3;
  6970. private _nearestDistance;
  6971. private _collisionMask;
  6972. collisionMask: number;
  6973. /**
  6974. * Gets the plane normal used to compute the sliding response (in local space)
  6975. */
  6976. readonly slidePlaneNormal: Vector3;
  6977. /** @hidden */
  6978. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6979. /** @hidden */
  6980. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6981. /** @hidden */
  6982. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6983. /** @hidden */
  6984. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6987. /** @hidden */
  6988. _getResponse(pos: Vector3, vel: Vector3): void;
  6989. }
  6990. }
  6991. declare module "babylonjs/Culling/boundingInfo" {
  6992. import { DeepImmutable } from "babylonjs/types";
  6993. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6994. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6995. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6996. import { Plane } from "babylonjs/Maths/math.plane";
  6997. import { Collider } from "babylonjs/Collisions/collider";
  6998. /**
  6999. * Interface for cullable objects
  7000. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7001. */
  7002. export interface ICullable {
  7003. /**
  7004. * Checks if the object or part of the object is in the frustum
  7005. * @param frustumPlanes Camera near/planes
  7006. * @returns true if the object is in frustum otherwise false
  7007. */
  7008. isInFrustum(frustumPlanes: Plane[]): boolean;
  7009. /**
  7010. * Checks if a cullable object (mesh...) is in the camera frustum
  7011. * Unlike isInFrustum this cheks the full bounding box
  7012. * @param frustumPlanes Camera near/planes
  7013. * @returns true if the object is in frustum otherwise false
  7014. */
  7015. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7016. }
  7017. /**
  7018. * Info for a bounding data of a mesh
  7019. */
  7020. export class BoundingInfo implements ICullable {
  7021. /**
  7022. * Bounding box for the mesh
  7023. */
  7024. readonly boundingBox: BoundingBox;
  7025. /**
  7026. * Bounding sphere for the mesh
  7027. */
  7028. readonly boundingSphere: BoundingSphere;
  7029. private _isLocked;
  7030. private static readonly TmpVector3;
  7031. /**
  7032. * Constructs bounding info
  7033. * @param minimum min vector of the bounding box/sphere
  7034. * @param maximum max vector of the bounding box/sphere
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7038. /**
  7039. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7040. * @param min defines the new minimum vector (in local space)
  7041. * @param max defines the new maximum vector (in local space)
  7042. * @param worldMatrix defines the new world matrix
  7043. */
  7044. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7045. /**
  7046. * min vector of the bounding box/sphere
  7047. */
  7048. readonly minimum: Vector3;
  7049. /**
  7050. * max vector of the bounding box/sphere
  7051. */
  7052. readonly maximum: Vector3;
  7053. /**
  7054. * If the info is locked and won't be updated to avoid perf overhead
  7055. */
  7056. isLocked: boolean;
  7057. /**
  7058. * Updates the bounding sphere and box
  7059. * @param world world matrix to be used to update
  7060. */
  7061. update(world: DeepImmutable<Matrix>): void;
  7062. /**
  7063. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7064. * @param center New center of the bounding info
  7065. * @param extend New extend of the bounding info
  7066. * @returns the current bounding info
  7067. */
  7068. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7069. /**
  7070. * Scale the current bounding info by applying a scale factor
  7071. * @param factor defines the scale factor to apply
  7072. * @returns the current bounding info
  7073. */
  7074. scale(factor: number): BoundingInfo;
  7075. /**
  7076. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7077. * @param frustumPlanes defines the frustum to test
  7078. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7079. * @returns true if the bounding info is in the frustum planes
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7082. /**
  7083. * Gets the world distance between the min and max points of the bounding box
  7084. */
  7085. readonly diagonalLength: number;
  7086. /**
  7087. * Checks if a cullable object (mesh...) is in the camera frustum
  7088. * Unlike isInFrustum this cheks the full bounding box
  7089. * @param frustumPlanes Camera near/planes
  7090. * @returns true if the object is in frustum otherwise false
  7091. */
  7092. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7093. /** @hidden */
  7094. _checkCollision(collider: Collider): boolean;
  7095. /**
  7096. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7097. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7098. * @param point the point to check intersection with
  7099. * @returns if the point intersects
  7100. */
  7101. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7102. /**
  7103. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7104. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7105. * @param boundingInfo the bounding info to check intersection with
  7106. * @param precise if the intersection should be done using OBB
  7107. * @returns if the bounding info intersects
  7108. */
  7109. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7110. }
  7111. }
  7112. declare module "babylonjs/Maths/math.functions" {
  7113. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7114. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7115. /**
  7116. * Extracts minimum and maximum values from a list of indexed positions
  7117. * @param positions defines the positions to use
  7118. * @param indices defines the indices to the positions
  7119. * @param indexStart defines the start index
  7120. * @param indexCount defines the end index
  7121. * @param bias defines bias value to add to the result
  7122. * @return minimum and maximum values
  7123. */
  7124. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7125. minimum: Vector3;
  7126. maximum: Vector3;
  7127. };
  7128. /**
  7129. * Extracts minimum and maximum values from a list of positions
  7130. * @param positions defines the positions to use
  7131. * @param start defines the start index in the positions array
  7132. * @param count defines the number of positions to handle
  7133. * @param bias defines bias value to add to the result
  7134. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7135. * @return minimum and maximum values
  7136. */
  7137. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7138. minimum: Vector3;
  7139. maximum: Vector3;
  7140. };
  7141. }
  7142. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7143. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7144. /** @hidden */
  7145. export class WebGLDataBuffer extends DataBuffer {
  7146. private _buffer;
  7147. constructor(resource: WebGLBuffer);
  7148. readonly underlyingResource: any;
  7149. }
  7150. }
  7151. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7152. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7153. import { Nullable } from "babylonjs/types";
  7154. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7155. /** @hidden */
  7156. export class WebGLPipelineContext implements IPipelineContext {
  7157. engine: ThinEngine;
  7158. program: Nullable<WebGLProgram>;
  7159. context?: WebGLRenderingContext;
  7160. vertexShader?: WebGLShader;
  7161. fragmentShader?: WebGLShader;
  7162. isParallelCompiled: boolean;
  7163. onCompiled?: () => void;
  7164. transformFeedback?: WebGLTransformFeedback | null;
  7165. readonly isAsync: boolean;
  7166. readonly isReady: boolean;
  7167. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7168. }
  7169. }
  7170. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7171. import { FloatArray, Nullable } from "babylonjs/types";
  7172. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7173. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7174. module "babylonjs/Engines/thinEngine" {
  7175. interface ThinEngine {
  7176. /**
  7177. * Create an uniform buffer
  7178. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7179. * @param elements defines the content of the uniform buffer
  7180. * @returns the webGL uniform buffer
  7181. */
  7182. createUniformBuffer(elements: FloatArray): DataBuffer;
  7183. /**
  7184. * Create a dynamic uniform buffer
  7185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7186. * @param elements defines the content of the uniform buffer
  7187. * @returns the webGL uniform buffer
  7188. */
  7189. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7190. /**
  7191. * Update an existing uniform buffer
  7192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7193. * @param uniformBuffer defines the target uniform buffer
  7194. * @param elements defines the content to update
  7195. * @param offset defines the offset in the uniform buffer where update should start
  7196. * @param count defines the size of the data to update
  7197. */
  7198. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7199. /**
  7200. * Bind an uniform buffer to the current webGL context
  7201. * @param buffer defines the buffer to bind
  7202. */
  7203. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7204. /**
  7205. * Bind a buffer to the current webGL context at a given location
  7206. * @param buffer defines the buffer to bind
  7207. * @param location defines the index where to bind the buffer
  7208. */
  7209. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7210. /**
  7211. * Bind a specific block at a given index in a specific shader program
  7212. * @param pipelineContext defines the pipeline context to use
  7213. * @param blockName defines the block name
  7214. * @param index defines the index where to bind the block
  7215. */
  7216. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7217. }
  7218. }
  7219. }
  7220. declare module "babylonjs/Materials/uniformBuffer" {
  7221. import { Nullable, FloatArray } from "babylonjs/types";
  7222. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7223. import { Engine } from "babylonjs/Engines/engine";
  7224. import { Effect } from "babylonjs/Materials/effect";
  7225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7226. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7227. import { Color3 } from "babylonjs/Maths/math.color";
  7228. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7229. /**
  7230. * Uniform buffer objects.
  7231. *
  7232. * Handles blocks of uniform on the GPU.
  7233. *
  7234. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7235. *
  7236. * For more information, please refer to :
  7237. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7238. */
  7239. export class UniformBuffer {
  7240. private _engine;
  7241. private _buffer;
  7242. private _data;
  7243. private _bufferData;
  7244. private _dynamic?;
  7245. private _uniformLocations;
  7246. private _uniformSizes;
  7247. private _uniformLocationPointer;
  7248. private _needSync;
  7249. private _noUBO;
  7250. private _currentEffect;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. readonly useUbo: boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. readonly isSync: boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module "babylonjs/Misc/iInspectable" {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/timingTools" {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module "babylonjs/Misc/instantiationTools" {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7602. import { Nullable } from "babylonjs/types";
  7603. import { Scene } from "babylonjs/scene";
  7604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7605. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7606. module "babylonjs/Engines/thinEngine" {
  7607. interface ThinEngine {
  7608. /**
  7609. * Creates a depth stencil cube texture.
  7610. * This is only available in WebGL 2.
  7611. * @param size The size of face edge in the cube texture.
  7612. * @param options The options defining the cube texture.
  7613. * @returns The cube texture
  7614. */
  7615. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7616. /**
  7617. * Creates a cube texture
  7618. * @param rootUrl defines the url where the files to load is located
  7619. * @param scene defines the current scene
  7620. * @param files defines the list of files to load (1 per face)
  7621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7622. * @param onLoad defines an optional callback raised when the texture is loaded
  7623. * @param onError defines an optional callback raised if there is an issue to load the texture
  7624. * @param format defines the format of the data
  7625. * @param forcedExtension defines the extension to use to pick the right loader
  7626. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7630. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7631. * @returns the cube texture as an InternalTexture
  7632. */
  7633. 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;
  7634. /**
  7635. * Creates a cube texture
  7636. * @param rootUrl defines the url where the files to load is located
  7637. * @param scene defines the current scene
  7638. * @param files defines the list of files to load (1 per face)
  7639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7640. * @param onLoad defines an optional callback raised when the texture is loaded
  7641. * @param onError defines an optional callback raised if there is an issue to load the texture
  7642. * @param format defines the format of the data
  7643. * @param forcedExtension defines the extension to use to pick the right loader
  7644. * @returns the cube texture as an InternalTexture
  7645. */
  7646. 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;
  7647. /**
  7648. * Creates a cube texture
  7649. * @param rootUrl defines the url where the files to load is located
  7650. * @param scene defines the current scene
  7651. * @param files defines the list of files to load (1 per face)
  7652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7653. * @param onLoad defines an optional callback raised when the texture is loaded
  7654. * @param onError defines an optional callback raised if there is an issue to load the texture
  7655. * @param format defines the format of the data
  7656. * @param forcedExtension defines the extension to use to pick the right loader
  7657. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. 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;
  7663. /** @hidden */
  7664. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7665. /** @hidden */
  7666. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7671. }
  7672. }
  7673. }
  7674. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7675. import { Nullable } from "babylonjs/types";
  7676. import { Scene } from "babylonjs/scene";
  7677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7679. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * The url of the texture
  7687. */
  7688. url: string;
  7689. /**
  7690. * Gets or sets the center of the bounding box associated with the cube texture.
  7691. * It must define where the camera used to render the texture was set
  7692. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7693. */
  7694. boundingBoxPosition: Vector3;
  7695. private _boundingBoxSize;
  7696. /**
  7697. * Gets or sets the size of the bounding box associated with the cube texture
  7698. * When defined, the cubemap will switch to local mode
  7699. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7700. * @example https://www.babylonjs-playground.com/#RNASML
  7701. */
  7702. /**
  7703. * Returns the bounding box size
  7704. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7705. */
  7706. boundingBoxSize: Vector3;
  7707. protected _rotationY: number;
  7708. /**
  7709. * Sets texture matrix rotation angle around Y axis in radians.
  7710. */
  7711. /**
  7712. * Gets texture matrix rotation angle around Y axis radians.
  7713. */
  7714. rotationY: number;
  7715. /**
  7716. * Are mip maps generated for this texture or not.
  7717. */
  7718. readonly noMipmap: boolean;
  7719. private _noMipmap;
  7720. private _files;
  7721. private _extensions;
  7722. private _textureMatrix;
  7723. private _format;
  7724. private _createPolynomials;
  7725. /** @hidden */
  7726. _prefiltered: boolean;
  7727. /**
  7728. * Creates a cube texture from an array of image urls
  7729. * @param files defines an array of image urls
  7730. * @param scene defines the hosting scene
  7731. * @param noMipmap specifies if mip maps are not used
  7732. * @returns a cube texture
  7733. */
  7734. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7735. /**
  7736. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7737. * @param url defines the url of the prefiltered texture
  7738. * @param scene defines the scene the texture is attached to
  7739. * @param forcedExtension defines the extension of the file if different from the url
  7740. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7741. * @return the prefiltered texture
  7742. */
  7743. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7744. /**
  7745. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7746. * as prefiltered data.
  7747. * @param rootUrl defines the url of the texture or the root name of the six images
  7748. * @param scene defines the scene the texture is attached to
  7749. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7750. * @param noMipmap defines if mipmaps should be created or not
  7751. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7752. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7753. * @param onError defines a callback triggered in case of error during load
  7754. * @param format defines the internal format to use for the texture once loaded
  7755. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7756. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7757. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7758. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7759. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7760. * @return the cube texture
  7761. */
  7762. 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);
  7763. /**
  7764. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7765. */
  7766. readonly isPrefiltered: boolean;
  7767. /**
  7768. * Get the current class name of the texture useful for serialization or dynamic coding.
  7769. * @returns "CubeTexture"
  7770. */
  7771. getClassName(): string;
  7772. /**
  7773. * Update the url (and optional buffer) of this texture if url was null during construction.
  7774. * @param url the url of the texture
  7775. * @param forcedExtension defines the extension to use
  7776. * @param onLoad callback called when the texture is loaded (defaults to null)
  7777. */
  7778. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7779. /**
  7780. * Delays loading of the cube texture
  7781. * @param forcedExtension defines the extension to use
  7782. */
  7783. delayLoad(forcedExtension?: string): void;
  7784. /**
  7785. * Returns the reflection texture matrix
  7786. * @returns the reflection texture matrix
  7787. */
  7788. getReflectionTextureMatrix(): Matrix;
  7789. /**
  7790. * Sets the reflection texture matrix
  7791. * @param value Reflection texture matrix
  7792. */
  7793. setReflectionTextureMatrix(value: Matrix): void;
  7794. /**
  7795. * Parses text to create a cube texture
  7796. * @param parsedTexture define the serialized text to read from
  7797. * @param scene defines the hosting scene
  7798. * @param rootUrl defines the root url of the cube texture
  7799. * @returns a cube texture
  7800. */
  7801. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7802. /**
  7803. * Makes a clone, or deep copy, of the cube texture
  7804. * @returns a new cube texture
  7805. */
  7806. clone(): CubeTexture;
  7807. }
  7808. }
  7809. declare module "babylonjs/Materials/materialDefines" {
  7810. /**
  7811. * Manages the defines for the Material
  7812. */
  7813. export class MaterialDefines {
  7814. /** @hidden */
  7815. protected _keys: string[];
  7816. private _isDirty;
  7817. /** @hidden */
  7818. _renderId: number;
  7819. /** @hidden */
  7820. _areLightsDirty: boolean;
  7821. /** @hidden */
  7822. _areLightsDisposed: boolean;
  7823. /** @hidden */
  7824. _areAttributesDirty: boolean;
  7825. /** @hidden */
  7826. _areTexturesDirty: boolean;
  7827. /** @hidden */
  7828. _areFresnelDirty: boolean;
  7829. /** @hidden */
  7830. _areMiscDirty: boolean;
  7831. /** @hidden */
  7832. _areImageProcessingDirty: boolean;
  7833. /** @hidden */
  7834. _normals: boolean;
  7835. /** @hidden */
  7836. _uvs: boolean;
  7837. /** @hidden */
  7838. _needNormals: boolean;
  7839. /** @hidden */
  7840. _needUVs: boolean;
  7841. [id: string]: any;
  7842. /**
  7843. * Specifies if the material needs to be re-calculated
  7844. */
  7845. readonly isDirty: boolean;
  7846. /**
  7847. * Marks the material to indicate that it has been re-calculated
  7848. */
  7849. markAsProcessed(): void;
  7850. /**
  7851. * Marks the material to indicate that it needs to be re-calculated
  7852. */
  7853. markAsUnprocessed(): void;
  7854. /**
  7855. * Marks the material to indicate all of its defines need to be re-calculated
  7856. */
  7857. markAllAsDirty(): void;
  7858. /**
  7859. * Marks the material to indicate that image processing needs to be re-calculated
  7860. */
  7861. markAsImageProcessingDirty(): void;
  7862. /**
  7863. * Marks the material to indicate the lights need to be re-calculated
  7864. * @param disposed Defines whether the light is dirty due to dispose or not
  7865. */
  7866. markAsLightDirty(disposed?: boolean): void;
  7867. /**
  7868. * Marks the attribute state as changed
  7869. */
  7870. markAsAttributesDirty(): void;
  7871. /**
  7872. * Marks the texture state as changed
  7873. */
  7874. markAsTexturesDirty(): void;
  7875. /**
  7876. * Marks the fresnel state as changed
  7877. */
  7878. markAsFresnelDirty(): void;
  7879. /**
  7880. * Marks the misc state as changed
  7881. */
  7882. markAsMiscDirty(): void;
  7883. /**
  7884. * Rebuilds the material defines
  7885. */
  7886. rebuild(): void;
  7887. /**
  7888. * Specifies if two material defines are equal
  7889. * @param other - A material define instance to compare to
  7890. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7891. */
  7892. isEqual(other: MaterialDefines): boolean;
  7893. /**
  7894. * Clones this instance's defines to another instance
  7895. * @param other - material defines to clone values to
  7896. */
  7897. cloneTo(other: MaterialDefines): void;
  7898. /**
  7899. * Resets the material define values
  7900. */
  7901. reset(): void;
  7902. /**
  7903. * Converts the material define values to a string
  7904. * @returns - String of material define information
  7905. */
  7906. toString(): string;
  7907. }
  7908. }
  7909. declare module "babylonjs/Materials/colorCurves" {
  7910. import { Effect } from "babylonjs/Materials/effect";
  7911. /**
  7912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7914. * 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;
  7915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7916. */
  7917. export class ColorCurves {
  7918. private _dirty;
  7919. private _tempColor;
  7920. private _globalCurve;
  7921. private _highlightsCurve;
  7922. private _midtonesCurve;
  7923. private _shadowsCurve;
  7924. private _positiveCurve;
  7925. private _negativeCurve;
  7926. private _globalHue;
  7927. private _globalDensity;
  7928. private _globalSaturation;
  7929. private _globalExposure;
  7930. /**
  7931. * Gets the global 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 global 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. globalHue: number;
  7939. /**
  7940. * Gets the global 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 global 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. globalDensity: number;
  7950. /**
  7951. * Gets the global 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 global 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. globalSaturation: number;
  7959. /**
  7960. * Gets the global 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 global 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. globalExposure: number;
  7968. private _highlightsHue;
  7969. private _highlightsDensity;
  7970. private _highlightsSaturation;
  7971. private _highlightsExposure;
  7972. /**
  7973. * Gets the highlights 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 highlights 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. highlightsHue: number;
  7981. /**
  7982. * Gets the highlights 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 highlights 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. highlightsDensity: number;
  7992. /**
  7993. * Gets the highlights 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 highlights 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. highlightsSaturation: number;
  8001. /**
  8002. * Gets the highlights 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 highlights 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. highlightsExposure: number;
  8010. private _midtonesHue;
  8011. private _midtonesDensity;
  8012. private _midtonesSaturation;
  8013. private _midtonesExposure;
  8014. /**
  8015. * Gets the midtones Hue value.
  8016. * 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).
  8017. */
  8018. /**
  8019. * Sets the midtones Hue value.
  8020. * 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).
  8021. */
  8022. midtonesHue: number;
  8023. /**
  8024. * Gets the midtones Density value.
  8025. * 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.
  8026. * Values less than zero provide a filter of opposite hue.
  8027. */
  8028. /**
  8029. * Sets the midtones Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. midtonesDensity: number;
  8034. /**
  8035. * Gets the midtones Saturation value.
  8036. * 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.
  8037. */
  8038. /**
  8039. * Sets the midtones Saturation value.
  8040. * 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.
  8041. */
  8042. midtonesSaturation: number;
  8043. /**
  8044. * Gets the midtones Exposure value.
  8045. * 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.
  8046. */
  8047. /**
  8048. * Sets the midtones Exposure value.
  8049. * 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.
  8050. */
  8051. midtonesExposure: number;
  8052. private _shadowsHue;
  8053. private _shadowsDensity;
  8054. private _shadowsSaturation;
  8055. private _shadowsExposure;
  8056. /**
  8057. * Gets the shadows Hue value.
  8058. * 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).
  8059. */
  8060. /**
  8061. * Sets the shadows Hue value.
  8062. * 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).
  8063. */
  8064. shadowsHue: number;
  8065. /**
  8066. * Gets the shadows Density value.
  8067. * 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.
  8068. * Values less than zero provide a filter of opposite hue.
  8069. */
  8070. /**
  8071. * Sets the shadows Density value.
  8072. * 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.
  8073. * Values less than zero provide a filter of opposite hue.
  8074. */
  8075. shadowsDensity: number;
  8076. /**
  8077. * Gets the shadows Saturation value.
  8078. * 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.
  8079. */
  8080. /**
  8081. * Sets the shadows Saturation value.
  8082. * 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.
  8083. */
  8084. shadowsSaturation: number;
  8085. /**
  8086. * Gets the shadows Exposure value.
  8087. * 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.
  8088. */
  8089. /**
  8090. * Sets the shadows Exposure value.
  8091. * 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.
  8092. */
  8093. shadowsExposure: number;
  8094. /**
  8095. * Returns the class name
  8096. * @returns The class name
  8097. */
  8098. getClassName(): string;
  8099. /**
  8100. * Binds the color curves to the shader.
  8101. * @param colorCurves The color curve to bind
  8102. * @param effect The effect to bind to
  8103. * @param positiveUniform The positive uniform shader parameter
  8104. * @param neutralUniform The neutral uniform shader parameter
  8105. * @param negativeUniform The negative uniform shader parameter
  8106. */
  8107. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8108. /**
  8109. * Prepare the list of uniforms associated with the ColorCurves effects.
  8110. * @param uniformsList The list of uniforms used in the effect
  8111. */
  8112. static PrepareUniforms(uniformsList: string[]): void;
  8113. /**
  8114. * Returns color grading data based on a hue, density, saturation and exposure value.
  8115. * @param filterHue The hue of the color filter.
  8116. * @param filterDensity The density of the color filter.
  8117. * @param saturation The saturation.
  8118. * @param exposure The exposure.
  8119. * @param result The result data container.
  8120. */
  8121. private getColorGradingDataToRef;
  8122. /**
  8123. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8124. * @param value The input slider value in range [-100,100].
  8125. * @returns Adjusted value.
  8126. */
  8127. private static applyColorGradingSliderNonlinear;
  8128. /**
  8129. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8130. * @param hue The hue (H) input.
  8131. * @param saturation The saturation (S) input.
  8132. * @param brightness The brightness (B) input.
  8133. * @result An RGBA color represented as Vector4.
  8134. */
  8135. private static fromHSBToRef;
  8136. /**
  8137. * Returns a value clamped between min and max
  8138. * @param value The value to clamp
  8139. * @param min The minimum of value
  8140. * @param max The maximum of value
  8141. * @returns The clamped value.
  8142. */
  8143. private static clamp;
  8144. /**
  8145. * Clones the current color curve instance.
  8146. * @return The cloned curves
  8147. */
  8148. clone(): ColorCurves;
  8149. /**
  8150. * Serializes the current color curve instance to a json representation.
  8151. * @return a JSON representation
  8152. */
  8153. serialize(): any;
  8154. /**
  8155. * Parses the color curve from a json representation.
  8156. * @param source the JSON source to parse
  8157. * @return The parsed curves
  8158. */
  8159. static Parse(source: any): ColorCurves;
  8160. }
  8161. }
  8162. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8163. import { Observable } from "babylonjs/Misc/observable";
  8164. import { Nullable } from "babylonjs/types";
  8165. import { Color4 } from "babylonjs/Maths/math.color";
  8166. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8167. import { Effect } from "babylonjs/Materials/effect";
  8168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8169. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8170. /**
  8171. * Interface to follow in your material defines to integrate easily the
  8172. * Image proccessing functions.
  8173. * @hidden
  8174. */
  8175. export interface IImageProcessingConfigurationDefines {
  8176. IMAGEPROCESSING: boolean;
  8177. VIGNETTE: boolean;
  8178. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8179. VIGNETTEBLENDMODEOPAQUE: boolean;
  8180. TONEMAPPING: boolean;
  8181. TONEMAPPING_ACES: boolean;
  8182. CONTRAST: boolean;
  8183. EXPOSURE: boolean;
  8184. COLORCURVES: boolean;
  8185. COLORGRADING: boolean;
  8186. COLORGRADING3D: boolean;
  8187. SAMPLER3DGREENDEPTH: boolean;
  8188. SAMPLER3DBGRMAP: boolean;
  8189. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8190. }
  8191. /**
  8192. * @hidden
  8193. */
  8194. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8195. IMAGEPROCESSING: boolean;
  8196. VIGNETTE: boolean;
  8197. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8198. VIGNETTEBLENDMODEOPAQUE: boolean;
  8199. TONEMAPPING: boolean;
  8200. TONEMAPPING_ACES: boolean;
  8201. CONTRAST: boolean;
  8202. COLORCURVES: boolean;
  8203. COLORGRADING: boolean;
  8204. COLORGRADING3D: boolean;
  8205. SAMPLER3DGREENDEPTH: boolean;
  8206. SAMPLER3DBGRMAP: boolean;
  8207. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8208. EXPOSURE: boolean;
  8209. constructor();
  8210. }
  8211. /**
  8212. * This groups together the common properties used for image processing either in direct forward pass
  8213. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8214. * or not.
  8215. */
  8216. export class ImageProcessingConfiguration {
  8217. /**
  8218. * Default tone mapping applied in BabylonJS.
  8219. */
  8220. static readonly TONEMAPPING_STANDARD: number;
  8221. /**
  8222. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8223. * to other engines rendering to increase portability.
  8224. */
  8225. static readonly TONEMAPPING_ACES: number;
  8226. /**
  8227. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8228. */
  8229. colorCurves: Nullable<ColorCurves>;
  8230. private _colorCurvesEnabled;
  8231. /**
  8232. * Gets wether the color curves effect is enabled.
  8233. */
  8234. /**
  8235. * Sets wether the color curves effect is enabled.
  8236. */
  8237. colorCurvesEnabled: boolean;
  8238. private _colorGradingTexture;
  8239. /**
  8240. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8241. */
  8242. /**
  8243. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8244. */
  8245. colorGradingTexture: Nullable<BaseTexture>;
  8246. private _colorGradingEnabled;
  8247. /**
  8248. * Gets wether the color grading effect is enabled.
  8249. */
  8250. /**
  8251. * Sets wether the color grading effect is enabled.
  8252. */
  8253. colorGradingEnabled: boolean;
  8254. private _colorGradingWithGreenDepth;
  8255. /**
  8256. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8257. */
  8258. /**
  8259. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8260. */
  8261. colorGradingWithGreenDepth: boolean;
  8262. private _colorGradingBGR;
  8263. /**
  8264. * Gets wether the color grading texture contains BGR values.
  8265. */
  8266. /**
  8267. * Sets wether the color grading texture contains BGR values.
  8268. */
  8269. colorGradingBGR: boolean;
  8270. /** @hidden */
  8271. _exposure: number;
  8272. /**
  8273. * Gets the Exposure used in the effect.
  8274. */
  8275. /**
  8276. * Sets the Exposure used in the effect.
  8277. */
  8278. exposure: number;
  8279. private _toneMappingEnabled;
  8280. /**
  8281. * Gets wether the tone mapping effect is enabled.
  8282. */
  8283. /**
  8284. * Sets wether the tone mapping effect is enabled.
  8285. */
  8286. toneMappingEnabled: boolean;
  8287. private _toneMappingType;
  8288. /**
  8289. * Gets the type of tone mapping effect.
  8290. */
  8291. /**
  8292. * Sets the type of tone mapping effect used in BabylonJS.
  8293. */
  8294. toneMappingType: number;
  8295. protected _contrast: number;
  8296. /**
  8297. * Gets the contrast used in the effect.
  8298. */
  8299. /**
  8300. * Sets the contrast used in the effect.
  8301. */
  8302. contrast: number;
  8303. /**
  8304. * Vignette stretch size.
  8305. */
  8306. vignetteStretch: number;
  8307. /**
  8308. * Vignette centre X Offset.
  8309. */
  8310. vignetteCentreX: number;
  8311. /**
  8312. * Vignette centre Y Offset.
  8313. */
  8314. vignetteCentreY: number;
  8315. /**
  8316. * Vignette weight or intensity of the vignette effect.
  8317. */
  8318. vignetteWeight: number;
  8319. /**
  8320. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8321. * if vignetteEnabled is set to true.
  8322. */
  8323. vignetteColor: Color4;
  8324. /**
  8325. * Camera field of view used by the Vignette effect.
  8326. */
  8327. vignetteCameraFov: number;
  8328. private _vignetteBlendMode;
  8329. /**
  8330. * Gets the vignette blend mode allowing different kind of effect.
  8331. */
  8332. /**
  8333. * Sets the vignette blend mode allowing different kind of effect.
  8334. */
  8335. vignetteBlendMode: number;
  8336. private _vignetteEnabled;
  8337. /**
  8338. * Gets wether the vignette effect is enabled.
  8339. */
  8340. /**
  8341. * Sets wether the vignette effect is enabled.
  8342. */
  8343. vignetteEnabled: boolean;
  8344. private _applyByPostProcess;
  8345. /**
  8346. * Gets wether the image processing is applied through a post process or not.
  8347. */
  8348. /**
  8349. * Sets wether the image processing is applied through a post process or not.
  8350. */
  8351. applyByPostProcess: boolean;
  8352. private _isEnabled;
  8353. /**
  8354. * Gets wether the image processing is enabled or not.
  8355. */
  8356. /**
  8357. * Sets wether the image processing is enabled or not.
  8358. */
  8359. isEnabled: boolean;
  8360. /**
  8361. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8362. */
  8363. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8364. /**
  8365. * Method called each time the image processing information changes requires to recompile the effect.
  8366. */
  8367. protected _updateParameters(): void;
  8368. /**
  8369. * Gets the current class name.
  8370. * @return "ImageProcessingConfiguration"
  8371. */
  8372. getClassName(): string;
  8373. /**
  8374. * Prepare the list of uniforms associated with the Image Processing effects.
  8375. * @param uniforms The list of uniforms used in the effect
  8376. * @param defines the list of defines currently in use
  8377. */
  8378. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8379. /**
  8380. * Prepare the list of samplers associated with the Image Processing effects.
  8381. * @param samplersList The list of uniforms used in the effect
  8382. * @param defines the list of defines currently in use
  8383. */
  8384. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8385. /**
  8386. * Prepare the list of defines associated to the shader.
  8387. * @param defines the list of defines to complete
  8388. * @param forPostProcess Define if we are currently in post process mode or not
  8389. */
  8390. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8391. /**
  8392. * Returns true if all the image processing information are ready.
  8393. * @returns True if ready, otherwise, false
  8394. */
  8395. isReady(): boolean;
  8396. /**
  8397. * Binds the image processing to the shader.
  8398. * @param effect The effect to bind to
  8399. * @param aspectRatio Define the current aspect ratio of the effect
  8400. */
  8401. bind(effect: Effect, aspectRatio?: number): void;
  8402. /**
  8403. * Clones the current image processing instance.
  8404. * @return The cloned image processing
  8405. */
  8406. clone(): ImageProcessingConfiguration;
  8407. /**
  8408. * Serializes the current image processing instance to a json representation.
  8409. * @return a JSON representation
  8410. */
  8411. serialize(): any;
  8412. /**
  8413. * Parses the image processing from a json representation.
  8414. * @param source the JSON source to parse
  8415. * @return The parsed image processing
  8416. */
  8417. static Parse(source: any): ImageProcessingConfiguration;
  8418. private static _VIGNETTEMODE_MULTIPLY;
  8419. private static _VIGNETTEMODE_OPAQUE;
  8420. /**
  8421. * Used to apply the vignette as a mix with the pixel color.
  8422. */
  8423. static readonly VIGNETTEMODE_MULTIPLY: number;
  8424. /**
  8425. * Used to apply the vignette as a replacement of the pixel color.
  8426. */
  8427. static readonly VIGNETTEMODE_OPAQUE: number;
  8428. }
  8429. }
  8430. declare module "babylonjs/Shaders/postprocess.vertex" {
  8431. /** @hidden */
  8432. export var postprocessVertexShader: {
  8433. name: string;
  8434. shader: string;
  8435. };
  8436. }
  8437. declare module "babylonjs/Maths/math.axis" {
  8438. import { Vector3 } from "babylonjs/Maths/math.vector";
  8439. /** Defines supported spaces */
  8440. export enum Space {
  8441. /** Local (object) space */
  8442. LOCAL = 0,
  8443. /** World space */
  8444. WORLD = 1,
  8445. /** Bone space */
  8446. BONE = 2
  8447. }
  8448. /** Defines the 3 main axes */
  8449. export class Axis {
  8450. /** X axis */
  8451. static X: Vector3;
  8452. /** Y axis */
  8453. static Y: Vector3;
  8454. /** Z axis */
  8455. static Z: Vector3;
  8456. }
  8457. }
  8458. declare module "babylonjs/Cameras/targetCamera" {
  8459. import { Nullable } from "babylonjs/types";
  8460. import { Camera } from "babylonjs/Cameras/camera";
  8461. import { Scene } from "babylonjs/scene";
  8462. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8463. /**
  8464. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8465. * This is the base of the follow, arc rotate cameras and Free camera
  8466. * @see http://doc.babylonjs.com/features/cameras
  8467. */
  8468. export class TargetCamera extends Camera {
  8469. private static _RigCamTransformMatrix;
  8470. private static _TargetTransformMatrix;
  8471. private static _TargetFocalPoint;
  8472. /**
  8473. * Define the current direction the camera is moving to
  8474. */
  8475. cameraDirection: Vector3;
  8476. /**
  8477. * Define the current rotation the camera is rotating to
  8478. */
  8479. cameraRotation: Vector2;
  8480. /**
  8481. * When set, the up vector of the camera will be updated by the rotation of the camera
  8482. */
  8483. updateUpVectorFromRotation: boolean;
  8484. private _tmpQuaternion;
  8485. /**
  8486. * Define the current rotation of the camera
  8487. */
  8488. rotation: Vector3;
  8489. /**
  8490. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8491. */
  8492. rotationQuaternion: Quaternion;
  8493. /**
  8494. * Define the current speed of the camera
  8495. */
  8496. speed: number;
  8497. /**
  8498. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8499. * around all axis.
  8500. */
  8501. noRotationConstraint: boolean;
  8502. /**
  8503. * Define the current target of the camera as an object or a position.
  8504. */
  8505. lockedTarget: any;
  8506. /** @hidden */
  8507. _currentTarget: Vector3;
  8508. /** @hidden */
  8509. _initialFocalDistance: number;
  8510. /** @hidden */
  8511. _viewMatrix: Matrix;
  8512. /** @hidden */
  8513. _camMatrix: Matrix;
  8514. /** @hidden */
  8515. _cameraTransformMatrix: Matrix;
  8516. /** @hidden */
  8517. _cameraRotationMatrix: Matrix;
  8518. /** @hidden */
  8519. _referencePoint: Vector3;
  8520. /** @hidden */
  8521. _transformedReferencePoint: Vector3;
  8522. protected _globalCurrentTarget: Vector3;
  8523. protected _globalCurrentUpVector: Vector3;
  8524. /** @hidden */
  8525. _reset: () => void;
  8526. private _defaultUp;
  8527. /**
  8528. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8529. * This is the base of the follow, arc rotate cameras and Free camera
  8530. * @see http://doc.babylonjs.com/features/cameras
  8531. * @param name Defines the name of the camera in the scene
  8532. * @param position Defines the start position of the camera in the scene
  8533. * @param scene Defines the scene the camera belongs to
  8534. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8535. */
  8536. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8537. /**
  8538. * Gets the position in front of the camera at a given distance.
  8539. * @param distance The distance from the camera we want the position to be
  8540. * @returns the position
  8541. */
  8542. getFrontPosition(distance: number): Vector3;
  8543. /** @hidden */
  8544. _getLockedTargetPosition(): Nullable<Vector3>;
  8545. private _storedPosition;
  8546. private _storedRotation;
  8547. private _storedRotationQuaternion;
  8548. /**
  8549. * Store current camera state of the camera (fov, position, rotation, etc..)
  8550. * @returns the camera
  8551. */
  8552. storeState(): Camera;
  8553. /**
  8554. * Restored camera state. You must call storeState() first
  8555. * @returns whether it was successful or not
  8556. * @hidden
  8557. */
  8558. _restoreStateValues(): boolean;
  8559. /** @hidden */
  8560. _initCache(): void;
  8561. /** @hidden */
  8562. _updateCache(ignoreParentClass?: boolean): void;
  8563. /** @hidden */
  8564. _isSynchronizedViewMatrix(): boolean;
  8565. /** @hidden */
  8566. _computeLocalCameraSpeed(): number;
  8567. /**
  8568. * Defines the target the camera should look at.
  8569. * @param target Defines the new target as a Vector or a mesh
  8570. */
  8571. setTarget(target: Vector3): void;
  8572. /**
  8573. * Return the current target position of the camera. This value is expressed in local space.
  8574. * @returns the target position
  8575. */
  8576. getTarget(): Vector3;
  8577. /** @hidden */
  8578. _decideIfNeedsToMove(): boolean;
  8579. /** @hidden */
  8580. _updatePosition(): void;
  8581. /** @hidden */
  8582. _checkInputs(): void;
  8583. protected _updateCameraRotationMatrix(): void;
  8584. /**
  8585. * 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)
  8586. * @returns the current camera
  8587. */
  8588. private _rotateUpVectorWithCameraRotationMatrix;
  8589. private _cachedRotationZ;
  8590. private _cachedQuaternionRotationZ;
  8591. /** @hidden */
  8592. _getViewMatrix(): Matrix;
  8593. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8594. /**
  8595. * @hidden
  8596. */
  8597. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8598. /**
  8599. * @hidden
  8600. */
  8601. _updateRigCameras(): void;
  8602. private _getRigCamPositionAndTarget;
  8603. /**
  8604. * Gets the current object class name.
  8605. * @return the class name
  8606. */
  8607. getClassName(): string;
  8608. }
  8609. }
  8610. declare module "babylonjs/Events/keyboardEvents" {
  8611. /**
  8612. * Gather the list of keyboard event types as constants.
  8613. */
  8614. export class KeyboardEventTypes {
  8615. /**
  8616. * The keydown event is fired when a key becomes active (pressed).
  8617. */
  8618. static readonly KEYDOWN: number;
  8619. /**
  8620. * The keyup event is fired when a key has been released.
  8621. */
  8622. static readonly KEYUP: number;
  8623. }
  8624. /**
  8625. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8626. */
  8627. export class KeyboardInfo {
  8628. /**
  8629. * Defines the type of event (KeyboardEventTypes)
  8630. */
  8631. type: number;
  8632. /**
  8633. * Defines the related dom event
  8634. */
  8635. event: KeyboardEvent;
  8636. /**
  8637. * Instantiates a new keyboard info.
  8638. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8639. * @param type Defines the type of event (KeyboardEventTypes)
  8640. * @param event Defines the related dom event
  8641. */
  8642. constructor(
  8643. /**
  8644. * Defines the type of event (KeyboardEventTypes)
  8645. */
  8646. type: number,
  8647. /**
  8648. * Defines the related dom event
  8649. */
  8650. event: KeyboardEvent);
  8651. }
  8652. /**
  8653. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8654. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8655. */
  8656. export class KeyboardInfoPre extends KeyboardInfo {
  8657. /**
  8658. * Defines the type of event (KeyboardEventTypes)
  8659. */
  8660. type: number;
  8661. /**
  8662. * Defines the related dom event
  8663. */
  8664. event: KeyboardEvent;
  8665. /**
  8666. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8667. */
  8668. skipOnPointerObservable: boolean;
  8669. /**
  8670. * Instantiates a new keyboard pre info.
  8671. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8672. * @param type Defines the type of event (KeyboardEventTypes)
  8673. * @param event Defines the related dom event
  8674. */
  8675. constructor(
  8676. /**
  8677. * Defines the type of event (KeyboardEventTypes)
  8678. */
  8679. type: number,
  8680. /**
  8681. * Defines the related dom event
  8682. */
  8683. event: KeyboardEvent);
  8684. }
  8685. }
  8686. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8687. import { Nullable } from "babylonjs/types";
  8688. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8689. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8690. /**
  8691. * Manage the keyboard inputs to control the movement of a free camera.
  8692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8693. */
  8694. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8695. /**
  8696. * Defines the camera the input is attached to.
  8697. */
  8698. camera: FreeCamera;
  8699. /**
  8700. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8701. */
  8702. keysUp: number[];
  8703. /**
  8704. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8705. */
  8706. keysDown: number[];
  8707. /**
  8708. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8709. */
  8710. keysLeft: number[];
  8711. /**
  8712. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8713. */
  8714. keysRight: number[];
  8715. private _keys;
  8716. private _onCanvasBlurObserver;
  8717. private _onKeyboardObserver;
  8718. private _engine;
  8719. private _scene;
  8720. /**
  8721. * Attach the input controls to a specific dom element to get the input from.
  8722. * @param element Defines the element the controls should be listened from
  8723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8724. */
  8725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8726. /**
  8727. * Detach the current controls from the specified dom element.
  8728. * @param element Defines the element to stop listening the inputs from
  8729. */
  8730. detachControl(element: Nullable<HTMLElement>): void;
  8731. /**
  8732. * Update the current camera state depending on the inputs that have been used this frame.
  8733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8734. */
  8735. checkInputs(): void;
  8736. /**
  8737. * Gets the class name of the current intput.
  8738. * @returns the class name
  8739. */
  8740. getClassName(): string;
  8741. /** @hidden */
  8742. _onLostFocus(): void;
  8743. /**
  8744. * Get the friendly name associated with the input class.
  8745. * @returns the input friendly name
  8746. */
  8747. getSimpleName(): string;
  8748. }
  8749. }
  8750. declare module "babylonjs/Lights/shadowLight" {
  8751. import { Camera } from "babylonjs/Cameras/camera";
  8752. import { Scene } from "babylonjs/scene";
  8753. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8755. import { Light } from "babylonjs/Lights/light";
  8756. /**
  8757. * Interface describing all the common properties and methods a shadow light needs to implement.
  8758. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8759. * as well as binding the different shadow properties to the effects.
  8760. */
  8761. export interface IShadowLight extends Light {
  8762. /**
  8763. * The light id in the scene (used in scene.findLighById for instance)
  8764. */
  8765. id: string;
  8766. /**
  8767. * The position the shdow will be casted from.
  8768. */
  8769. position: Vector3;
  8770. /**
  8771. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8772. */
  8773. direction: Vector3;
  8774. /**
  8775. * The transformed position. Position of the light in world space taking parenting in account.
  8776. */
  8777. transformedPosition: Vector3;
  8778. /**
  8779. * The transformed direction. Direction of the light in world space taking parenting in account.
  8780. */
  8781. transformedDirection: Vector3;
  8782. /**
  8783. * The friendly name of the light in the scene.
  8784. */
  8785. name: string;
  8786. /**
  8787. * Defines the shadow projection clipping minimum z value.
  8788. */
  8789. shadowMinZ: number;
  8790. /**
  8791. * Defines the shadow projection clipping maximum z value.
  8792. */
  8793. shadowMaxZ: number;
  8794. /**
  8795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8797. */
  8798. computeTransformedInformation(): boolean;
  8799. /**
  8800. * Gets the scene the light belongs to.
  8801. * @returns The scene
  8802. */
  8803. getScene(): Scene;
  8804. /**
  8805. * Callback defining a custom Projection Matrix Builder.
  8806. * This can be used to override the default projection matrix computation.
  8807. */
  8808. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8809. /**
  8810. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8811. * @param matrix The materix to updated with the projection information
  8812. * @param viewMatrix The transform matrix of the light
  8813. * @param renderList The list of mesh to render in the map
  8814. * @returns The current light
  8815. */
  8816. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8817. /**
  8818. * Gets the current depth scale used in ESM.
  8819. * @returns The scale
  8820. */
  8821. getDepthScale(): number;
  8822. /**
  8823. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8824. * @returns true if a cube texture needs to be use
  8825. */
  8826. needCube(): boolean;
  8827. /**
  8828. * Detects if the projection matrix requires to be recomputed this frame.
  8829. * @returns true if it requires to be recomputed otherwise, false.
  8830. */
  8831. needProjectionMatrixCompute(): boolean;
  8832. /**
  8833. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8834. */
  8835. forceProjectionMatrixCompute(): void;
  8836. /**
  8837. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8838. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8839. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8840. */
  8841. getShadowDirection(faceIndex?: number): Vector3;
  8842. /**
  8843. * Gets the minZ used for shadow according to both the scene and the light.
  8844. * @param activeCamera The camera we are returning the min for
  8845. * @returns the depth min z
  8846. */
  8847. getDepthMinZ(activeCamera: Camera): number;
  8848. /**
  8849. * Gets the maxZ used for shadow according to both the scene and the light.
  8850. * @param activeCamera The camera we are returning the max for
  8851. * @returns the depth max z
  8852. */
  8853. getDepthMaxZ(activeCamera: Camera): number;
  8854. }
  8855. /**
  8856. * Base implementation IShadowLight
  8857. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8858. */
  8859. export abstract class ShadowLight extends Light implements IShadowLight {
  8860. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8861. protected _position: Vector3;
  8862. protected _setPosition(value: Vector3): void;
  8863. /**
  8864. * Sets the position the shadow will be casted from. Also use as the light position for both
  8865. * point and spot lights.
  8866. */
  8867. /**
  8868. * Sets the position the shadow will be casted from. Also use as the light position for both
  8869. * point and spot lights.
  8870. */
  8871. position: Vector3;
  8872. protected _direction: Vector3;
  8873. protected _setDirection(value: Vector3): void;
  8874. /**
  8875. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8876. * Also use as the light direction on spot and directional lights.
  8877. */
  8878. /**
  8879. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8880. * Also use as the light direction on spot and directional lights.
  8881. */
  8882. direction: Vector3;
  8883. private _shadowMinZ;
  8884. /**
  8885. * Gets the shadow projection clipping minimum z value.
  8886. */
  8887. /**
  8888. * Sets the shadow projection clipping minimum z value.
  8889. */
  8890. shadowMinZ: number;
  8891. private _shadowMaxZ;
  8892. /**
  8893. * Sets the shadow projection clipping maximum z value.
  8894. */
  8895. /**
  8896. * Gets the shadow projection clipping maximum z value.
  8897. */
  8898. shadowMaxZ: number;
  8899. /**
  8900. * Callback defining a custom Projection Matrix Builder.
  8901. * This can be used to override the default projection matrix computation.
  8902. */
  8903. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8904. /**
  8905. * The transformed position. Position of the light in world space taking parenting in account.
  8906. */
  8907. transformedPosition: Vector3;
  8908. /**
  8909. * The transformed direction. Direction of the light in world space taking parenting in account.
  8910. */
  8911. transformedDirection: Vector3;
  8912. private _needProjectionMatrixCompute;
  8913. /**
  8914. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8915. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8916. */
  8917. computeTransformedInformation(): boolean;
  8918. /**
  8919. * Return the depth scale used for the shadow map.
  8920. * @returns the depth scale.
  8921. */
  8922. getDepthScale(): number;
  8923. /**
  8924. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8925. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8926. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8927. */
  8928. getShadowDirection(faceIndex?: number): Vector3;
  8929. /**
  8930. * Returns the ShadowLight absolute position in the World.
  8931. * @returns the position vector in world space
  8932. */
  8933. getAbsolutePosition(): Vector3;
  8934. /**
  8935. * Sets the ShadowLight direction toward the passed target.
  8936. * @param target The point to target in local space
  8937. * @returns the updated ShadowLight direction
  8938. */
  8939. setDirectionToTarget(target: Vector3): Vector3;
  8940. /**
  8941. * Returns the light rotation in euler definition.
  8942. * @returns the x y z rotation in local space.
  8943. */
  8944. getRotation(): Vector3;
  8945. /**
  8946. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8947. * @returns true if a cube texture needs to be use
  8948. */
  8949. needCube(): boolean;
  8950. /**
  8951. * Detects if the projection matrix requires to be recomputed this frame.
  8952. * @returns true if it requires to be recomputed otherwise, false.
  8953. */
  8954. needProjectionMatrixCompute(): boolean;
  8955. /**
  8956. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8957. */
  8958. forceProjectionMatrixCompute(): void;
  8959. /** @hidden */
  8960. _initCache(): void;
  8961. /** @hidden */
  8962. _isSynchronized(): boolean;
  8963. /**
  8964. * Computes the world matrix of the node
  8965. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8966. * @returns the world matrix
  8967. */
  8968. computeWorldMatrix(force?: boolean): Matrix;
  8969. /**
  8970. * Gets the minZ used for shadow according to both the scene and the light.
  8971. * @param activeCamera The camera we are returning the min for
  8972. * @returns the depth min z
  8973. */
  8974. getDepthMinZ(activeCamera: Camera): number;
  8975. /**
  8976. * Gets the maxZ used for shadow according to both the scene and the light.
  8977. * @param activeCamera The camera we are returning the max for
  8978. * @returns the depth max z
  8979. */
  8980. getDepthMaxZ(activeCamera: Camera): number;
  8981. /**
  8982. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8983. * @param matrix The materix to updated with the projection information
  8984. * @param viewMatrix The transform matrix of the light
  8985. * @param renderList The list of mesh to render in the map
  8986. * @returns The current light
  8987. */
  8988. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8989. }
  8990. }
  8991. declare module "babylonjs/Materials/effectFallbacks" {
  8992. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8993. import { Effect } from "babylonjs/Materials/effect";
  8994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8995. /**
  8996. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8997. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8998. */
  8999. export class EffectFallbacks implements IEffectFallbacks {
  9000. private _defines;
  9001. private _currentRank;
  9002. private _maxRank;
  9003. private _mesh;
  9004. /**
  9005. * Removes the fallback from the bound mesh.
  9006. */
  9007. unBindMesh(): void;
  9008. /**
  9009. * Adds a fallback on the specified property.
  9010. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9011. * @param define The name of the define in the shader
  9012. */
  9013. addFallback(rank: number, define: string): void;
  9014. /**
  9015. * Sets the mesh to use CPU skinning when needing to fallback.
  9016. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9017. * @param mesh The mesh to use the fallbacks.
  9018. */
  9019. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9020. /**
  9021. * Checks to see if more fallbacks are still availible.
  9022. */
  9023. readonly hasMoreFallbacks: boolean;
  9024. /**
  9025. * Removes the defines that should be removed when falling back.
  9026. * @param currentDefines defines the current define statements for the shader.
  9027. * @param effect defines the current effect we try to compile
  9028. * @returns The resulting defines with defines of the current rank removed.
  9029. */
  9030. reduce(currentDefines: string, effect: Effect): string;
  9031. }
  9032. }
  9033. declare module "babylonjs/Materials/materialHelper" {
  9034. import { Nullable } from "babylonjs/types";
  9035. import { Scene } from "babylonjs/scene";
  9036. import { Engine } from "babylonjs/Engines/engine";
  9037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9038. import { Light } from "babylonjs/Lights/light";
  9039. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9040. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  9041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9042. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9043. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9044. /**
  9045. * "Static Class" containing the most commonly used helper while dealing with material for
  9046. * rendering purpose.
  9047. *
  9048. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9049. *
  9050. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9051. */
  9052. export class MaterialHelper {
  9053. /**
  9054. * Bind the current view position to an effect.
  9055. * @param effect The effect to be bound
  9056. * @param scene The scene the eyes position is used from
  9057. */
  9058. static BindEyePosition(effect: Effect, scene: Scene): void;
  9059. /**
  9060. * Helps preparing the defines values about the UVs in used in the effect.
  9061. * UVs are shared as much as we can accross channels in the shaders.
  9062. * @param texture The texture we are preparing the UVs for
  9063. * @param defines The defines to update
  9064. * @param key The channel key "diffuse", "specular"... used in the shader
  9065. */
  9066. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9067. /**
  9068. * Binds a texture matrix value to its corrsponding uniform
  9069. * @param texture The texture to bind the matrix for
  9070. * @param uniformBuffer The uniform buffer receivin the data
  9071. * @param key The channel key "diffuse", "specular"... used in the shader
  9072. */
  9073. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9074. /**
  9075. * Gets the current status of the fog (should it be enabled?)
  9076. * @param mesh defines the mesh to evaluate for fog support
  9077. * @param scene defines the hosting scene
  9078. * @returns true if fog must be enabled
  9079. */
  9080. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9081. /**
  9082. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9083. * @param mesh defines the current mesh
  9084. * @param scene defines the current scene
  9085. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9086. * @param pointsCloud defines if point cloud rendering has to be turned on
  9087. * @param fogEnabled defines if fog has to be turned on
  9088. * @param alphaTest defines if alpha testing has to be turned on
  9089. * @param defines defines the current list of defines
  9090. */
  9091. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9092. /**
  9093. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9094. * @param scene defines the current scene
  9095. * @param engine defines the current engine
  9096. * @param defines specifies the list of active defines
  9097. * @param useInstances defines if instances have to be turned on
  9098. * @param useClipPlane defines if clip plane have to be turned on
  9099. */
  9100. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9101. /**
  9102. * Prepares the defines for bones
  9103. * @param mesh The mesh containing the geometry data we will draw
  9104. * @param defines The defines to update
  9105. */
  9106. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9107. /**
  9108. * Prepares the defines for morph targets
  9109. * @param mesh The mesh containing the geometry data we will draw
  9110. * @param defines The defines to update
  9111. */
  9112. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9113. /**
  9114. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9115. * @param mesh The mesh containing the geometry data we will draw
  9116. * @param defines The defines to update
  9117. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9118. * @param useBones Precise whether bones should be used or not (override mesh info)
  9119. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9120. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9121. * @returns false if defines are considered not dirty and have not been checked
  9122. */
  9123. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9124. /**
  9125. * Prepares the defines related to multiview
  9126. * @param scene The scene we are intending to draw
  9127. * @param defines The defines to update
  9128. */
  9129. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9130. /**
  9131. * Prepares the defines related to the light information passed in parameter
  9132. * @param scene The scene we are intending to draw
  9133. * @param mesh The mesh the effect is compiling for
  9134. * @param light The light the effect is compiling for
  9135. * @param lightIndex The index of the light
  9136. * @param defines The defines to update
  9137. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9138. * @param state Defines the current state regarding what is needed (normals, etc...)
  9139. */
  9140. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9141. needNormals: boolean;
  9142. needRebuild: boolean;
  9143. shadowEnabled: boolean;
  9144. specularEnabled: boolean;
  9145. lightmapMode: boolean;
  9146. }): void;
  9147. /**
  9148. * Prepares the defines related to the light information passed in parameter
  9149. * @param scene The scene we are intending to draw
  9150. * @param mesh The mesh the effect is compiling for
  9151. * @param defines The defines to update
  9152. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9153. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9154. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9155. * @returns true if normals will be required for the rest of the effect
  9156. */
  9157. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9158. /**
  9159. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9160. * @param lightIndex defines the light index
  9161. * @param uniformsList The uniform list
  9162. * @param samplersList The sampler list
  9163. * @param projectedLightTexture defines if projected texture must be used
  9164. * @param uniformBuffersList defines an optional list of uniform buffers
  9165. */
  9166. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9167. /**
  9168. * Prepares the uniforms and samplers list to be used in the effect
  9169. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9170. * @param samplersList The sampler list
  9171. * @param defines The defines helping in the list generation
  9172. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9173. */
  9174. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9175. /**
  9176. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9177. * @param defines The defines to update while falling back
  9178. * @param fallbacks The authorized effect fallbacks
  9179. * @param maxSimultaneousLights The maximum number of lights allowed
  9180. * @param rank the current rank of the Effect
  9181. * @returns The newly affected rank
  9182. */
  9183. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9184. private static _TmpMorphInfluencers;
  9185. /**
  9186. * Prepares the list of attributes required for morph targets according to the effect defines.
  9187. * @param attribs The current list of supported attribs
  9188. * @param mesh The mesh to prepare the morph targets attributes for
  9189. * @param influencers The number of influencers
  9190. */
  9191. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9192. /**
  9193. * Prepares the list of attributes required for morph targets according to the effect defines.
  9194. * @param attribs The current list of supported attribs
  9195. * @param mesh The mesh to prepare the morph targets attributes for
  9196. * @param defines The current Defines of the effect
  9197. */
  9198. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9199. /**
  9200. * Prepares the list of attributes required for bones according to the effect defines.
  9201. * @param attribs The current list of supported attribs
  9202. * @param mesh The mesh to prepare the bones attributes for
  9203. * @param defines The current Defines of the effect
  9204. * @param fallbacks The current efffect fallback strategy
  9205. */
  9206. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9207. /**
  9208. * Check and prepare the list of attributes required for instances according to the effect defines.
  9209. * @param attribs The current list of supported attribs
  9210. * @param defines The current MaterialDefines of the effect
  9211. */
  9212. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9213. /**
  9214. * Add the list of attributes required for instances to the attribs array.
  9215. * @param attribs The current list of supported attribs
  9216. */
  9217. static PushAttributesForInstances(attribs: string[]): void;
  9218. /**
  9219. * Binds the light shadow information to the effect for the given mesh.
  9220. * @param light The light containing the generator
  9221. * @param scene The scene the lights belongs to
  9222. * @param mesh The mesh we are binding the information to render
  9223. * @param lightIndex The light index in the effect used to render the mesh
  9224. * @param effect The effect we are binding the data to
  9225. */
  9226. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9227. /**
  9228. * Binds the light information to the effect.
  9229. * @param light The light containing the generator
  9230. * @param effect The effect we are binding the data to
  9231. * @param lightIndex The light index in the effect used to render
  9232. */
  9233. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9234. /**
  9235. * Binds the lights information from the scene to the effect for the given mesh.
  9236. * @param light Light to bind
  9237. * @param lightIndex Light index
  9238. * @param scene The scene where the light belongs to
  9239. * @param mesh The mesh we are binding the information to render
  9240. * @param effect The effect we are binding the data to
  9241. * @param useSpecular Defines if specular is supported
  9242. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9243. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9244. */
  9245. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9246. /**
  9247. * Binds the lights information from the scene to the effect for the given mesh.
  9248. * @param scene The scene the lights belongs to
  9249. * @param mesh The mesh we are binding the information to render
  9250. * @param effect The effect we are binding the data to
  9251. * @param defines The generated defines for the effect
  9252. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9253. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9254. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9255. */
  9256. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9257. private static _tempFogColor;
  9258. /**
  9259. * Binds the fog information from the scene to the effect for the given mesh.
  9260. * @param scene The scene the lights belongs to
  9261. * @param mesh The mesh we are binding the information to render
  9262. * @param effect The effect we are binding the data to
  9263. * @param linearSpace Defines if the fog effect is applied in linear space
  9264. */
  9265. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9266. /**
  9267. * Binds the bones information from the mesh to the effect.
  9268. * @param mesh The mesh we are binding the information to render
  9269. * @param effect The effect we are binding the data to
  9270. */
  9271. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9272. /**
  9273. * Binds the morph targets information from the mesh to the effect.
  9274. * @param abstractMesh The mesh we are binding the information to render
  9275. * @param effect The effect we are binding the data to
  9276. */
  9277. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9278. /**
  9279. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9280. * @param defines The generated defines used in the effect
  9281. * @param effect The effect we are binding the data to
  9282. * @param scene The scene we are willing to render with logarithmic scale for
  9283. */
  9284. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9285. /**
  9286. * Binds the clip plane information from the scene to the effect.
  9287. * @param scene The scene the clip plane information are extracted from
  9288. * @param effect The effect we are binding the data to
  9289. */
  9290. static BindClipPlane(effect: Effect, scene: Scene): void;
  9291. }
  9292. }
  9293. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9294. /** @hidden */
  9295. export var packingFunctions: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9301. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9302. /** @hidden */
  9303. export var shadowMapPixelShader: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9309. /** @hidden */
  9310. export var bonesDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9316. /** @hidden */
  9317. export var morphTargetsVertexGlobalDeclaration: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9323. /** @hidden */
  9324. export var morphTargetsVertexDeclaration: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9330. /** @hidden */
  9331. export var instancesDeclaration: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9337. /** @hidden */
  9338. export var helperFunctions: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9344. /** @hidden */
  9345. export var morphTargetsVertex: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9351. /** @hidden */
  9352. export var instancesVertex: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9358. /** @hidden */
  9359. export var bonesVertex: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9365. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9368. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9369. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9371. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9372. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9373. /** @hidden */
  9374. export var shadowMapVertexShader: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9380. /** @hidden */
  9381. export var depthBoxBlurPixelShader: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9387. import { Nullable } from "babylonjs/types";
  9388. import { Scene } from "babylonjs/scene";
  9389. import { Matrix } from "babylonjs/Maths/math.vector";
  9390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9392. import { Mesh } from "babylonjs/Meshes/mesh";
  9393. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9394. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9395. import { Effect } from "babylonjs/Materials/effect";
  9396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9397. import "babylonjs/Shaders/shadowMap.fragment";
  9398. import "babylonjs/Shaders/shadowMap.vertex";
  9399. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9400. import { Observable } from "babylonjs/Misc/observable";
  9401. /**
  9402. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9403. */
  9404. export interface ICustomShaderOptions {
  9405. /**
  9406. * Gets or sets the custom shader name to use
  9407. */
  9408. shaderName: string;
  9409. /**
  9410. * The list of attribute names used in the shader
  9411. */
  9412. attributes?: string[];
  9413. /**
  9414. * The list of unifrom names used in the shader
  9415. */
  9416. uniforms?: string[];
  9417. /**
  9418. * The list of sampler names used in the shader
  9419. */
  9420. samplers?: string[];
  9421. /**
  9422. * The list of defines used in the shader
  9423. */
  9424. defines?: string[];
  9425. }
  9426. /**
  9427. * Interface to implement to create a shadow generator compatible with BJS.
  9428. */
  9429. export interface IShadowGenerator {
  9430. /**
  9431. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9432. * @returns The render target texture if present otherwise, null
  9433. */
  9434. getShadowMap(): Nullable<RenderTargetTexture>;
  9435. /**
  9436. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9437. * @returns The render target texture if the shadow map is present otherwise, null
  9438. */
  9439. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9440. /**
  9441. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9442. * @param subMesh The submesh we want to render in the shadow map
  9443. * @param useInstances Defines wether will draw in the map using instances
  9444. * @returns true if ready otherwise, false
  9445. */
  9446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9447. /**
  9448. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9449. * @param defines Defines of the material we want to update
  9450. * @param lightIndex Index of the light in the enabled light list of the material
  9451. */
  9452. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9453. /**
  9454. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9455. * defined in the generator but impacting the effect).
  9456. * It implies the unifroms available on the materials are the standard BJS ones.
  9457. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9458. * @param effect The effect we are binfing the information for
  9459. */
  9460. bindShadowLight(lightIndex: string, effect: Effect): void;
  9461. /**
  9462. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9463. * (eq to shadow prjection matrix * light transform matrix)
  9464. * @returns The transform matrix used to create the shadow map
  9465. */
  9466. getTransformMatrix(): Matrix;
  9467. /**
  9468. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9469. * Cube and 2D textures for instance.
  9470. */
  9471. recreateShadowMap(): void;
  9472. /**
  9473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9474. * @param onCompiled Callback triggered at the and of the effects compilation
  9475. * @param options Sets of optional options forcing the compilation with different modes
  9476. */
  9477. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9478. useInstances: boolean;
  9479. }>): void;
  9480. /**
  9481. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9482. * @param options Sets of optional options forcing the compilation with different modes
  9483. * @returns A promise that resolves when the compilation completes
  9484. */
  9485. forceCompilationAsync(options?: Partial<{
  9486. useInstances: boolean;
  9487. }>): Promise<void>;
  9488. /**
  9489. * Serializes the shadow generator setup to a json object.
  9490. * @returns The serialized JSON object
  9491. */
  9492. serialize(): any;
  9493. /**
  9494. * Disposes the Shadow map and related Textures and effects.
  9495. */
  9496. dispose(): void;
  9497. }
  9498. /**
  9499. * Default implementation IShadowGenerator.
  9500. * This is the main object responsible of generating shadows in the framework.
  9501. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9502. */
  9503. export class ShadowGenerator implements IShadowGenerator {
  9504. /**
  9505. * Shadow generator mode None: no filtering applied.
  9506. */
  9507. static readonly FILTER_NONE: number;
  9508. /**
  9509. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9511. */
  9512. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9513. /**
  9514. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9515. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9516. */
  9517. static readonly FILTER_POISSONSAMPLING: number;
  9518. /**
  9519. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9521. */
  9522. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9523. /**
  9524. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9525. * edge artifacts on steep falloff.
  9526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9527. */
  9528. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9529. /**
  9530. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9531. * edge artifacts on steep falloff.
  9532. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9533. */
  9534. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9535. /**
  9536. * Shadow generator mode PCF: Percentage Closer Filtering
  9537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9538. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9539. */
  9540. static readonly FILTER_PCF: number;
  9541. /**
  9542. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9543. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9544. * Contact Hardening
  9545. */
  9546. static readonly FILTER_PCSS: number;
  9547. /**
  9548. * Reserved for PCF and PCSS
  9549. * Highest Quality.
  9550. *
  9551. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9552. *
  9553. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9554. */
  9555. static readonly QUALITY_HIGH: number;
  9556. /**
  9557. * Reserved for PCF and PCSS
  9558. * Good tradeoff for quality/perf cross devices
  9559. *
  9560. * Execute PCF on a 3*3 kernel.
  9561. *
  9562. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9563. */
  9564. static readonly QUALITY_MEDIUM: number;
  9565. /**
  9566. * Reserved for PCF and PCSS
  9567. * The lowest quality but the fastest.
  9568. *
  9569. * Execute PCF on a 1*1 kernel.
  9570. *
  9571. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9572. */
  9573. static readonly QUALITY_LOW: number;
  9574. /** Gets or sets the custom shader name to use */
  9575. customShaderOptions: ICustomShaderOptions;
  9576. /**
  9577. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9578. */
  9579. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9580. /**
  9581. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9582. */
  9583. onAfterShadowMapRenderObservable: Observable<Effect>;
  9584. /**
  9585. * Observable triggered before a mesh is rendered in the shadow map.
  9586. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9587. */
  9588. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9589. /**
  9590. * Observable triggered after a mesh is rendered in the shadow map.
  9591. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9592. */
  9593. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9594. private _bias;
  9595. /**
  9596. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9597. */
  9598. /**
  9599. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9600. */
  9601. bias: number;
  9602. private _normalBias;
  9603. /**
  9604. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9605. */
  9606. /**
  9607. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9608. */
  9609. normalBias: number;
  9610. private _blurBoxOffset;
  9611. /**
  9612. * Gets the blur box offset: offset applied during the blur pass.
  9613. * Only useful if useKernelBlur = false
  9614. */
  9615. /**
  9616. * Sets the blur box offset: offset applied during the blur pass.
  9617. * Only useful if useKernelBlur = false
  9618. */
  9619. blurBoxOffset: number;
  9620. private _blurScale;
  9621. /**
  9622. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9623. * 2 means half of the size.
  9624. */
  9625. /**
  9626. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9627. * 2 means half of the size.
  9628. */
  9629. blurScale: number;
  9630. private _blurKernel;
  9631. /**
  9632. * Gets the blur kernel: kernel size of the blur pass.
  9633. * Only useful if useKernelBlur = true
  9634. */
  9635. /**
  9636. * Sets the blur kernel: kernel size of the blur pass.
  9637. * Only useful if useKernelBlur = true
  9638. */
  9639. blurKernel: number;
  9640. private _useKernelBlur;
  9641. /**
  9642. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9644. */
  9645. /**
  9646. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9648. */
  9649. useKernelBlur: boolean;
  9650. private _depthScale;
  9651. /**
  9652. * Gets the depth scale used in ESM mode.
  9653. */
  9654. /**
  9655. * Sets the depth scale used in ESM mode.
  9656. * This can override the scale stored on the light.
  9657. */
  9658. depthScale: number;
  9659. private _filter;
  9660. /**
  9661. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9662. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9663. */
  9664. /**
  9665. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9666. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9667. */
  9668. filter: number;
  9669. /**
  9670. * Gets if the current filter is set to Poisson Sampling.
  9671. */
  9672. /**
  9673. * Sets the current filter to Poisson Sampling.
  9674. */
  9675. usePoissonSampling: boolean;
  9676. /**
  9677. * Gets if the current filter is set to ESM.
  9678. */
  9679. /**
  9680. * Sets the current filter is to ESM.
  9681. */
  9682. useExponentialShadowMap: boolean;
  9683. /**
  9684. * Gets if the current filter is set to filtered ESM.
  9685. */
  9686. /**
  9687. * Gets if the current filter is set to filtered ESM.
  9688. */
  9689. useBlurExponentialShadowMap: boolean;
  9690. /**
  9691. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9692. * exponential to prevent steep falloff artifacts).
  9693. */
  9694. /**
  9695. * Sets the current filter to "close ESM" (using the inverse of the
  9696. * exponential to prevent steep falloff artifacts).
  9697. */
  9698. useCloseExponentialShadowMap: boolean;
  9699. /**
  9700. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9701. * exponential to prevent steep falloff artifacts).
  9702. */
  9703. /**
  9704. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9705. * exponential to prevent steep falloff artifacts).
  9706. */
  9707. useBlurCloseExponentialShadowMap: boolean;
  9708. /**
  9709. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9710. */
  9711. /**
  9712. * Sets the current filter to "PCF" (percentage closer filtering).
  9713. */
  9714. usePercentageCloserFiltering: boolean;
  9715. private _filteringQuality;
  9716. /**
  9717. * Gets the PCF or PCSS Quality.
  9718. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9719. */
  9720. /**
  9721. * Sets the PCF or PCSS Quality.
  9722. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9723. */
  9724. filteringQuality: number;
  9725. /**
  9726. * Gets if the current filter is set to "PCSS" (contact hardening).
  9727. */
  9728. /**
  9729. * Sets the current filter to "PCSS" (contact hardening).
  9730. */
  9731. useContactHardeningShadow: boolean;
  9732. private _contactHardeningLightSizeUVRatio;
  9733. /**
  9734. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9735. * Using a ratio helps keeping shape stability independently of the map size.
  9736. *
  9737. * It does not account for the light projection as it was having too much
  9738. * instability during the light setup or during light position changes.
  9739. *
  9740. * Only valid if useContactHardeningShadow is true.
  9741. */
  9742. /**
  9743. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9744. * Using a ratio helps keeping shape stability independently of the map size.
  9745. *
  9746. * It does not account for the light projection as it was having too much
  9747. * instability during the light setup or during light position changes.
  9748. *
  9749. * Only valid if useContactHardeningShadow is true.
  9750. */
  9751. contactHardeningLightSizeUVRatio: number;
  9752. private _darkness;
  9753. /** Gets or sets the actual darkness of a shadow */
  9754. darkness: number;
  9755. /**
  9756. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9757. * 0 means strongest and 1 would means no shadow.
  9758. * @returns the darkness.
  9759. */
  9760. getDarkness(): number;
  9761. /**
  9762. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9763. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9764. * @returns the shadow generator allowing fluent coding.
  9765. */
  9766. setDarkness(darkness: number): ShadowGenerator;
  9767. private _transparencyShadow;
  9768. /** Gets or sets the ability to have transparent shadow */
  9769. transparencyShadow: boolean;
  9770. /**
  9771. * Sets the ability to have transparent shadow (boolean).
  9772. * @param transparent True if transparent else False
  9773. * @returns the shadow generator allowing fluent coding
  9774. */
  9775. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9776. private _shadowMap;
  9777. private _shadowMap2;
  9778. /**
  9779. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9780. * @returns The render target texture if present otherwise, null
  9781. */
  9782. getShadowMap(): Nullable<RenderTargetTexture>;
  9783. /**
  9784. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9785. * @returns The render target texture if the shadow map is present otherwise, null
  9786. */
  9787. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9788. /**
  9789. * Gets the class name of that object
  9790. * @returns "ShadowGenerator"
  9791. */
  9792. getClassName(): string;
  9793. /**
  9794. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9795. * @param mesh Mesh to add
  9796. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9797. * @returns the Shadow Generator itself
  9798. */
  9799. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9800. /**
  9801. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9802. * @param mesh Mesh to remove
  9803. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9804. * @returns the Shadow Generator itself
  9805. */
  9806. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9807. /**
  9808. * Controls the extent to which the shadows fade out at the edge of the frustum
  9809. * Used only by directionals and spots
  9810. */
  9811. frustumEdgeFalloff: number;
  9812. private _light;
  9813. /**
  9814. * Returns the associated light object.
  9815. * @returns the light generating the shadow
  9816. */
  9817. getLight(): IShadowLight;
  9818. /**
  9819. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9820. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9821. * It might on the other hand introduce peter panning.
  9822. */
  9823. forceBackFacesOnly: boolean;
  9824. private _scene;
  9825. private _lightDirection;
  9826. private _effect;
  9827. private _viewMatrix;
  9828. private _projectionMatrix;
  9829. private _transformMatrix;
  9830. private _cachedPosition;
  9831. private _cachedDirection;
  9832. private _cachedDefines;
  9833. private _currentRenderID;
  9834. private _boxBlurPostprocess;
  9835. private _kernelBlurXPostprocess;
  9836. private _kernelBlurYPostprocess;
  9837. private _blurPostProcesses;
  9838. private _mapSize;
  9839. private _currentFaceIndex;
  9840. private _currentFaceIndexCache;
  9841. private _textureType;
  9842. private _defaultTextureMatrix;
  9843. /** @hidden */
  9844. static _SceneComponentInitialization: (scene: Scene) => void;
  9845. /**
  9846. * Creates a ShadowGenerator object.
  9847. * A ShadowGenerator is the required tool to use the shadows.
  9848. * Each light casting shadows needs to use its own ShadowGenerator.
  9849. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9850. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9851. * @param light The light object generating the shadows.
  9852. * @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.
  9853. */
  9854. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9855. private _initializeGenerator;
  9856. private _initializeShadowMap;
  9857. private _initializeBlurRTTAndPostProcesses;
  9858. private _renderForShadowMap;
  9859. private _renderSubMeshForShadowMap;
  9860. private _applyFilterValues;
  9861. /**
  9862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9863. * @param onCompiled Callback triggered at the and of the effects compilation
  9864. * @param options Sets of optional options forcing the compilation with different modes
  9865. */
  9866. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9867. useInstances: boolean;
  9868. }>): void;
  9869. /**
  9870. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9871. * @param options Sets of optional options forcing the compilation with different modes
  9872. * @returns A promise that resolves when the compilation completes
  9873. */
  9874. forceCompilationAsync(options?: Partial<{
  9875. useInstances: boolean;
  9876. }>): Promise<void>;
  9877. /**
  9878. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9879. * @param subMesh The submesh we want to render in the shadow map
  9880. * @param useInstances Defines wether will draw in the map using instances
  9881. * @returns true if ready otherwise, false
  9882. */
  9883. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9884. /**
  9885. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9886. * @param defines Defines of the material we want to update
  9887. * @param lightIndex Index of the light in the enabled light list of the material
  9888. */
  9889. prepareDefines(defines: any, lightIndex: number): void;
  9890. /**
  9891. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9892. * defined in the generator but impacting the effect).
  9893. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9894. * @param effect The effect we are binfing the information for
  9895. */
  9896. bindShadowLight(lightIndex: string, effect: Effect): void;
  9897. /**
  9898. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9899. * (eq to shadow prjection matrix * light transform matrix)
  9900. * @returns The transform matrix used to create the shadow map
  9901. */
  9902. getTransformMatrix(): Matrix;
  9903. /**
  9904. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9905. * Cube and 2D textures for instance.
  9906. */
  9907. recreateShadowMap(): void;
  9908. private _disposeBlurPostProcesses;
  9909. private _disposeRTTandPostProcesses;
  9910. /**
  9911. * Disposes the ShadowGenerator.
  9912. * Returns nothing.
  9913. */
  9914. dispose(): void;
  9915. /**
  9916. * Serializes the shadow generator setup to a json object.
  9917. * @returns The serialized JSON object
  9918. */
  9919. serialize(): any;
  9920. /**
  9921. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9922. * @param parsedShadowGenerator The JSON object to parse
  9923. * @param scene The scene to create the shadow map for
  9924. * @returns The parsed shadow generator
  9925. */
  9926. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9927. }
  9928. }
  9929. declare module "babylonjs/Lights/light" {
  9930. import { Nullable } from "babylonjs/types";
  9931. import { Scene } from "babylonjs/scene";
  9932. import { Vector3 } from "babylonjs/Maths/math.vector";
  9933. import { Color3 } from "babylonjs/Maths/math.color";
  9934. import { Node } from "babylonjs/node";
  9935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9936. import { Effect } from "babylonjs/Materials/effect";
  9937. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9938. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9939. /**
  9940. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9941. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9942. * 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.
  9943. */
  9944. export abstract class Light extends Node {
  9945. /**
  9946. * Falloff Default: light is falling off following the material specification:
  9947. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9948. */
  9949. static readonly FALLOFF_DEFAULT: number;
  9950. /**
  9951. * Falloff Physical: light is falling off following the inverse squared distance law.
  9952. */
  9953. static readonly FALLOFF_PHYSICAL: number;
  9954. /**
  9955. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9956. * to enhance interoperability with other engines.
  9957. */
  9958. static readonly FALLOFF_GLTF: number;
  9959. /**
  9960. * Falloff Standard: light is falling off like in the standard material
  9961. * to enhance interoperability with other materials.
  9962. */
  9963. static readonly FALLOFF_STANDARD: number;
  9964. /**
  9965. * If every light affecting the material is in this lightmapMode,
  9966. * material.lightmapTexture adds or multiplies
  9967. * (depends on material.useLightmapAsShadowmap)
  9968. * after every other light calculations.
  9969. */
  9970. static readonly LIGHTMAP_DEFAULT: number;
  9971. /**
  9972. * material.lightmapTexture as only diffuse lighting from this light
  9973. * adds only specular lighting from this light
  9974. * adds dynamic shadows
  9975. */
  9976. static readonly LIGHTMAP_SPECULAR: number;
  9977. /**
  9978. * material.lightmapTexture as only lighting
  9979. * no light calculation from this light
  9980. * only adds dynamic shadows from this light
  9981. */
  9982. static readonly LIGHTMAP_SHADOWSONLY: number;
  9983. /**
  9984. * Each light type uses the default quantity according to its type:
  9985. * point/spot lights use luminous intensity
  9986. * directional lights use illuminance
  9987. */
  9988. static readonly INTENSITYMODE_AUTOMATIC: number;
  9989. /**
  9990. * lumen (lm)
  9991. */
  9992. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9993. /**
  9994. * candela (lm/sr)
  9995. */
  9996. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9997. /**
  9998. * lux (lm/m^2)
  9999. */
  10000. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10001. /**
  10002. * nit (cd/m^2)
  10003. */
  10004. static readonly INTENSITYMODE_LUMINANCE: number;
  10005. /**
  10006. * Light type const id of the point light.
  10007. */
  10008. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10009. /**
  10010. * Light type const id of the directional light.
  10011. */
  10012. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10013. /**
  10014. * Light type const id of the spot light.
  10015. */
  10016. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10017. /**
  10018. * Light type const id of the hemispheric light.
  10019. */
  10020. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10021. /**
  10022. * Diffuse gives the basic color to an object.
  10023. */
  10024. diffuse: Color3;
  10025. /**
  10026. * Specular produces a highlight color on an object.
  10027. * Note: This is note affecting PBR materials.
  10028. */
  10029. specular: Color3;
  10030. /**
  10031. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10032. * falling off base on range or angle.
  10033. * This can be set to any values in Light.FALLOFF_x.
  10034. *
  10035. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10036. * other types of materials.
  10037. */
  10038. falloffType: number;
  10039. /**
  10040. * Strength of the light.
  10041. * Note: By default it is define in the framework own unit.
  10042. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10043. */
  10044. intensity: number;
  10045. private _range;
  10046. protected _inverseSquaredRange: number;
  10047. /**
  10048. * Defines how far from the source the light is impacting in scene units.
  10049. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10050. */
  10051. /**
  10052. * Defines how far from the source the light is impacting in scene units.
  10053. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10054. */
  10055. range: number;
  10056. /**
  10057. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10058. * of light.
  10059. */
  10060. private _photometricScale;
  10061. private _intensityMode;
  10062. /**
  10063. * Gets the photometric scale used to interpret the intensity.
  10064. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10065. */
  10066. /**
  10067. * Sets the photometric scale used to interpret the intensity.
  10068. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10069. */
  10070. intensityMode: number;
  10071. private _radius;
  10072. /**
  10073. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10074. */
  10075. /**
  10076. * sets the light radius used by PBR Materials to simulate soft area lights.
  10077. */
  10078. radius: number;
  10079. private _renderPriority;
  10080. /**
  10081. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10082. * exceeding the number allowed of the materials.
  10083. */
  10084. renderPriority: number;
  10085. private _shadowEnabled;
  10086. /**
  10087. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10088. * the current shadow generator.
  10089. */
  10090. /**
  10091. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10092. * the current shadow generator.
  10093. */
  10094. shadowEnabled: boolean;
  10095. private _includedOnlyMeshes;
  10096. /**
  10097. * Gets the only meshes impacted by this light.
  10098. */
  10099. /**
  10100. * Sets the only meshes impacted by this light.
  10101. */
  10102. includedOnlyMeshes: AbstractMesh[];
  10103. private _excludedMeshes;
  10104. /**
  10105. * Gets the meshes not impacted by this light.
  10106. */
  10107. /**
  10108. * Sets the meshes not impacted by this light.
  10109. */
  10110. excludedMeshes: AbstractMesh[];
  10111. private _excludeWithLayerMask;
  10112. /**
  10113. * Gets the layer id use to find what meshes are not impacted by the light.
  10114. * Inactive if 0
  10115. */
  10116. /**
  10117. * Sets the layer id use to find what meshes are not impacted by the light.
  10118. * Inactive if 0
  10119. */
  10120. excludeWithLayerMask: number;
  10121. private _includeOnlyWithLayerMask;
  10122. /**
  10123. * Gets the layer id use to find what meshes are impacted by the light.
  10124. * Inactive if 0
  10125. */
  10126. /**
  10127. * Sets the layer id use to find what meshes are impacted by the light.
  10128. * Inactive if 0
  10129. */
  10130. includeOnlyWithLayerMask: number;
  10131. private _lightmapMode;
  10132. /**
  10133. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10134. */
  10135. /**
  10136. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10137. */
  10138. lightmapMode: number;
  10139. /**
  10140. * Shadow generator associted to the light.
  10141. * @hidden Internal use only.
  10142. */
  10143. _shadowGenerator: Nullable<IShadowGenerator>;
  10144. /**
  10145. * @hidden Internal use only.
  10146. */
  10147. _excludedMeshesIds: string[];
  10148. /**
  10149. * @hidden Internal use only.
  10150. */
  10151. _includedOnlyMeshesIds: string[];
  10152. /**
  10153. * The current light unifom buffer.
  10154. * @hidden Internal use only.
  10155. */
  10156. _uniformBuffer: UniformBuffer;
  10157. /**
  10158. * Creates a Light object in the scene.
  10159. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10160. * @param name The firendly name of the light
  10161. * @param scene The scene the light belongs too
  10162. */
  10163. constructor(name: string, scene: Scene);
  10164. protected abstract _buildUniformLayout(): void;
  10165. /**
  10166. * Sets the passed Effect "effect" with the Light information.
  10167. * @param effect The effect to update
  10168. * @param lightIndex The index of the light in the effect to update
  10169. * @returns The light
  10170. */
  10171. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10172. /**
  10173. * Sets the passed Effect "effect" with the Light information.
  10174. * @param effect The effect to update
  10175. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10176. * @returns The light
  10177. */
  10178. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10179. /**
  10180. * Returns the string "Light".
  10181. * @returns the class name
  10182. */
  10183. getClassName(): string;
  10184. /** @hidden */
  10185. readonly _isLight: boolean;
  10186. /**
  10187. * Converts the light information to a readable string for debug purpose.
  10188. * @param fullDetails Supports for multiple levels of logging within scene loading
  10189. * @returns the human readable light info
  10190. */
  10191. toString(fullDetails?: boolean): string;
  10192. /** @hidden */
  10193. protected _syncParentEnabledState(): void;
  10194. /**
  10195. * Set the enabled state of this node.
  10196. * @param value - the new enabled state
  10197. */
  10198. setEnabled(value: boolean): void;
  10199. /**
  10200. * Returns the Light associated shadow generator if any.
  10201. * @return the associated shadow generator.
  10202. */
  10203. getShadowGenerator(): Nullable<IShadowGenerator>;
  10204. /**
  10205. * Returns a Vector3, the absolute light position in the World.
  10206. * @returns the world space position of the light
  10207. */
  10208. getAbsolutePosition(): Vector3;
  10209. /**
  10210. * Specifies if the light will affect the passed mesh.
  10211. * @param mesh The mesh to test against the light
  10212. * @return true the mesh is affected otherwise, false.
  10213. */
  10214. canAffectMesh(mesh: AbstractMesh): boolean;
  10215. /**
  10216. * Sort function to order lights for rendering.
  10217. * @param a First Light object to compare to second.
  10218. * @param b Second Light object to compare first.
  10219. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10220. */
  10221. static CompareLightsPriority(a: Light, b: Light): number;
  10222. /**
  10223. * Releases resources associated with this node.
  10224. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10225. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10226. */
  10227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10228. /**
  10229. * Returns the light type ID (integer).
  10230. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10231. */
  10232. getTypeID(): number;
  10233. /**
  10234. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10235. * @returns the scaled intensity in intensity mode unit
  10236. */
  10237. getScaledIntensity(): number;
  10238. /**
  10239. * Returns a new Light object, named "name", from the current one.
  10240. * @param name The name of the cloned light
  10241. * @returns the new created light
  10242. */
  10243. clone(name: string): Nullable<Light>;
  10244. /**
  10245. * Serializes the current light into a Serialization object.
  10246. * @returns the serialized object.
  10247. */
  10248. serialize(): any;
  10249. /**
  10250. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10251. * This new light is named "name" and added to the passed scene.
  10252. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10253. * @param name The friendly name of the light
  10254. * @param scene The scene the new light will belong to
  10255. * @returns the constructor function
  10256. */
  10257. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10258. /**
  10259. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10260. * @param parsedLight The JSON representation of the light
  10261. * @param scene The scene to create the parsed light in
  10262. * @returns the created light after parsing
  10263. */
  10264. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10265. private _hookArrayForExcluded;
  10266. private _hookArrayForIncludedOnly;
  10267. private _resyncMeshes;
  10268. /**
  10269. * Forces the meshes to update their light related information in their rendering used effects
  10270. * @hidden Internal Use Only
  10271. */
  10272. _markMeshesAsLightDirty(): void;
  10273. /**
  10274. * Recomputes the cached photometric scale if needed.
  10275. */
  10276. private _computePhotometricScale;
  10277. /**
  10278. * Returns the Photometric Scale according to the light type and intensity mode.
  10279. */
  10280. private _getPhotometricScale;
  10281. /**
  10282. * Reorder the light in the scene according to their defined priority.
  10283. * @hidden Internal Use Only
  10284. */
  10285. _reorderLightsInScene(): void;
  10286. /**
  10287. * Prepares the list of defines specific to the light type.
  10288. * @param defines the list of defines
  10289. * @param lightIndex defines the index of the light for the effect
  10290. */
  10291. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10292. }
  10293. }
  10294. declare module "babylonjs/Actions/action" {
  10295. import { Observable } from "babylonjs/Misc/observable";
  10296. import { Condition } from "babylonjs/Actions/condition";
  10297. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10298. import { ActionManager } from "babylonjs/Actions/actionManager";
  10299. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10300. /**
  10301. * Interface used to define Action
  10302. */
  10303. export interface IAction {
  10304. /**
  10305. * Trigger for the action
  10306. */
  10307. trigger: number;
  10308. /** Options of the trigger */
  10309. triggerOptions: any;
  10310. /**
  10311. * Gets the trigger parameters
  10312. * @returns the trigger parameters
  10313. */
  10314. getTriggerParameter(): any;
  10315. /**
  10316. * Internal only - executes current action event
  10317. * @hidden
  10318. */
  10319. _executeCurrent(evt?: ActionEvent): void;
  10320. /**
  10321. * Serialize placeholder for child classes
  10322. * @param parent of child
  10323. * @returns the serialized object
  10324. */
  10325. serialize(parent: any): any;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. _prepare(): void;
  10331. /**
  10332. * Internal only - manager for action
  10333. * @hidden
  10334. */
  10335. _actionManager: AbstractActionManager;
  10336. /**
  10337. * Adds action to chain of actions, may be a DoNothingAction
  10338. * @param action defines the next action to execute
  10339. * @returns The action passed in
  10340. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10341. */
  10342. then(action: IAction): IAction;
  10343. }
  10344. /**
  10345. * The action to be carried out following a trigger
  10346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10347. */
  10348. export class Action implements IAction {
  10349. /** the trigger, with or without parameters, for the action */
  10350. triggerOptions: any;
  10351. /**
  10352. * Trigger for the action
  10353. */
  10354. trigger: number;
  10355. /**
  10356. * Internal only - manager for action
  10357. * @hidden
  10358. */
  10359. _actionManager: ActionManager;
  10360. private _nextActiveAction;
  10361. private _child;
  10362. private _condition?;
  10363. private _triggerParameter;
  10364. /**
  10365. * An event triggered prior to action being executed.
  10366. */
  10367. onBeforeExecuteObservable: Observable<Action>;
  10368. /**
  10369. * Creates a new Action
  10370. * @param triggerOptions the trigger, with or without parameters, for the action
  10371. * @param condition an optional determinant of action
  10372. */
  10373. constructor(
  10374. /** the trigger, with or without parameters, for the action */
  10375. triggerOptions: any, condition?: Condition);
  10376. /**
  10377. * Internal only
  10378. * @hidden
  10379. */
  10380. _prepare(): void;
  10381. /**
  10382. * Gets the trigger parameters
  10383. * @returns the trigger parameters
  10384. */
  10385. getTriggerParameter(): any;
  10386. /**
  10387. * Internal only - executes current action event
  10388. * @hidden
  10389. */
  10390. _executeCurrent(evt?: ActionEvent): void;
  10391. /**
  10392. * Execute placeholder for child classes
  10393. * @param evt optional action event
  10394. */
  10395. execute(evt?: ActionEvent): void;
  10396. /**
  10397. * Skips to next active action
  10398. */
  10399. skipToNextActiveAction(): void;
  10400. /**
  10401. * Adds action to chain of actions, may be a DoNothingAction
  10402. * @param action defines the next action to execute
  10403. * @returns The action passed in
  10404. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10405. */
  10406. then(action: Action): Action;
  10407. /**
  10408. * Internal only
  10409. * @hidden
  10410. */
  10411. _getProperty(propertyPath: string): string;
  10412. /**
  10413. * Internal only
  10414. * @hidden
  10415. */
  10416. _getEffectiveTarget(target: any, propertyPath: string): any;
  10417. /**
  10418. * Serialize placeholder for child classes
  10419. * @param parent of child
  10420. * @returns the serialized object
  10421. */
  10422. serialize(parent: any): any;
  10423. /**
  10424. * Internal only called by serialize
  10425. * @hidden
  10426. */
  10427. protected _serialize(serializedAction: any, parent?: any): any;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. static _SerializeValueAsString: (value: any) => string;
  10433. /**
  10434. * Internal only
  10435. * @hidden
  10436. */
  10437. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10438. name: string;
  10439. targetType: string;
  10440. value: string;
  10441. };
  10442. }
  10443. }
  10444. declare module "babylonjs/Actions/condition" {
  10445. import { ActionManager } from "babylonjs/Actions/actionManager";
  10446. /**
  10447. * A Condition applied to an Action
  10448. */
  10449. export class Condition {
  10450. /**
  10451. * Internal only - manager for action
  10452. * @hidden
  10453. */
  10454. _actionManager: ActionManager;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _evaluationId: number;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _currentResult: boolean;
  10465. /**
  10466. * Creates a new Condition
  10467. * @param actionManager the manager of the action the condition is applied to
  10468. */
  10469. constructor(actionManager: ActionManager);
  10470. /**
  10471. * Check if the current condition is valid
  10472. * @returns a boolean
  10473. */
  10474. isValid(): boolean;
  10475. /**
  10476. * Internal only
  10477. * @hidden
  10478. */
  10479. _getProperty(propertyPath: string): string;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. _getEffectiveTarget(target: any, propertyPath: string): any;
  10485. /**
  10486. * Serialize placeholder for child classes
  10487. * @returns the serialized object
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Internal only
  10492. * @hidden
  10493. */
  10494. protected _serialize(serializedCondition: any): any;
  10495. }
  10496. /**
  10497. * Defines specific conditional operators as extensions of Condition
  10498. */
  10499. export class ValueCondition extends Condition {
  10500. /** path to specify the property of the target the conditional operator uses */
  10501. propertyPath: string;
  10502. /** the value compared by the conditional operator against the current value of the property */
  10503. value: any;
  10504. /** the conditional operator, default ValueCondition.IsEqual */
  10505. operator: number;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. private static _IsEqual;
  10511. /**
  10512. * Internal only
  10513. * @hidden
  10514. */
  10515. private static _IsDifferent;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. private static _IsGreater;
  10521. /**
  10522. * Internal only
  10523. * @hidden
  10524. */
  10525. private static _IsLesser;
  10526. /**
  10527. * returns the number for IsEqual
  10528. */
  10529. static readonly IsEqual: number;
  10530. /**
  10531. * Returns the number for IsDifferent
  10532. */
  10533. static readonly IsDifferent: number;
  10534. /**
  10535. * Returns the number for IsGreater
  10536. */
  10537. static readonly IsGreater: number;
  10538. /**
  10539. * Returns the number for IsLesser
  10540. */
  10541. static readonly IsLesser: number;
  10542. /**
  10543. * Internal only The action manager for the condition
  10544. * @hidden
  10545. */
  10546. _actionManager: ActionManager;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private _target;
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. private _effectiveTarget;
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. private _property;
  10562. /**
  10563. * Creates a new ValueCondition
  10564. * @param actionManager manager for the action the condition applies to
  10565. * @param target for the action
  10566. * @param propertyPath path to specify the property of the target the conditional operator uses
  10567. * @param value the value compared by the conditional operator against the current value of the property
  10568. * @param operator the conditional operator, default ValueCondition.IsEqual
  10569. */
  10570. constructor(actionManager: ActionManager, target: any,
  10571. /** path to specify the property of the target the conditional operator uses */
  10572. propertyPath: string,
  10573. /** the value compared by the conditional operator against the current value of the property */
  10574. value: any,
  10575. /** the conditional operator, default ValueCondition.IsEqual */
  10576. operator?: number);
  10577. /**
  10578. * Compares the given value with the property value for the specified conditional operator
  10579. * @returns the result of the comparison
  10580. */
  10581. isValid(): boolean;
  10582. /**
  10583. * Serialize the ValueCondition into a JSON compatible object
  10584. * @returns serialization object
  10585. */
  10586. serialize(): any;
  10587. /**
  10588. * Gets the name of the conditional operator for the ValueCondition
  10589. * @param operator the conditional operator
  10590. * @returns the name
  10591. */
  10592. static GetOperatorName(operator: number): string;
  10593. }
  10594. /**
  10595. * Defines a predicate condition as an extension of Condition
  10596. */
  10597. export class PredicateCondition extends Condition {
  10598. /** defines the predicate function used to validate the condition */
  10599. predicate: () => boolean;
  10600. /**
  10601. * Internal only - manager for action
  10602. * @hidden
  10603. */
  10604. _actionManager: ActionManager;
  10605. /**
  10606. * Creates a new PredicateCondition
  10607. * @param actionManager manager for the action the condition applies to
  10608. * @param predicate defines the predicate function used to validate the condition
  10609. */
  10610. constructor(actionManager: ActionManager,
  10611. /** defines the predicate function used to validate the condition */
  10612. predicate: () => boolean);
  10613. /**
  10614. * @returns the validity of the predicate condition
  10615. */
  10616. isValid(): boolean;
  10617. }
  10618. /**
  10619. * Defines a state condition as an extension of Condition
  10620. */
  10621. export class StateCondition extends Condition {
  10622. /** Value to compare with target state */
  10623. value: string;
  10624. /**
  10625. * Internal only - manager for action
  10626. * @hidden
  10627. */
  10628. _actionManager: ActionManager;
  10629. /**
  10630. * Internal only
  10631. * @hidden
  10632. */
  10633. private _target;
  10634. /**
  10635. * Creates a new StateCondition
  10636. * @param actionManager manager for the action the condition applies to
  10637. * @param target of the condition
  10638. * @param value to compare with target state
  10639. */
  10640. constructor(actionManager: ActionManager, target: any,
  10641. /** Value to compare with target state */
  10642. value: string);
  10643. /**
  10644. * Gets a boolean indicating if the current condition is met
  10645. * @returns the validity of the state
  10646. */
  10647. isValid(): boolean;
  10648. /**
  10649. * Serialize the StateCondition into a JSON compatible object
  10650. * @returns serialization object
  10651. */
  10652. serialize(): any;
  10653. }
  10654. }
  10655. declare module "babylonjs/Actions/directActions" {
  10656. import { Action } from "babylonjs/Actions/action";
  10657. import { Condition } from "babylonjs/Actions/condition";
  10658. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10659. /**
  10660. * This defines an action responsible to toggle a boolean once triggered.
  10661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10662. */
  10663. export class SwitchBooleanAction extends Action {
  10664. /**
  10665. * The path to the boolean property in the target object
  10666. */
  10667. propertyPath: string;
  10668. private _target;
  10669. private _effectiveTarget;
  10670. private _property;
  10671. /**
  10672. * Instantiate the action
  10673. * @param triggerOptions defines the trigger options
  10674. * @param target defines the object containing the boolean
  10675. * @param propertyPath defines the path to the boolean property in the target object
  10676. * @param condition defines the trigger related conditions
  10677. */
  10678. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10679. /** @hidden */
  10680. _prepare(): void;
  10681. /**
  10682. * Execute the action toggle the boolean value.
  10683. */
  10684. execute(): void;
  10685. /**
  10686. * Serializes the actions and its related information.
  10687. * @param parent defines the object to serialize in
  10688. * @returns the serialized object
  10689. */
  10690. serialize(parent: any): any;
  10691. }
  10692. /**
  10693. * This defines an action responsible to set a the state field of the target
  10694. * to a desired value once triggered.
  10695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10696. */
  10697. export class SetStateAction extends Action {
  10698. /**
  10699. * The value to store in the state field.
  10700. */
  10701. value: string;
  10702. private _target;
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param target defines the object containing the state property
  10707. * @param value defines the value to store in the state field
  10708. * @param condition defines the trigger related conditions
  10709. */
  10710. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10711. /**
  10712. * Execute the action and store the value on the target state property.
  10713. */
  10714. execute(): void;
  10715. /**
  10716. * Serializes the actions and its related information.
  10717. * @param parent defines the object to serialize in
  10718. * @returns the serialized object
  10719. */
  10720. serialize(parent: any): any;
  10721. }
  10722. /**
  10723. * This defines an action responsible to set a property of the target
  10724. * to a desired value once triggered.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class SetValueAction extends Action {
  10728. /**
  10729. * The path of the property to set in the target.
  10730. */
  10731. propertyPath: string;
  10732. /**
  10733. * The value to set in the property
  10734. */
  10735. value: any;
  10736. private _target;
  10737. private _effectiveTarget;
  10738. private _property;
  10739. /**
  10740. * Instantiate the action
  10741. * @param triggerOptions defines the trigger options
  10742. * @param target defines the object containing the property
  10743. * @param propertyPath defines the path of the property to set in the target
  10744. * @param value defines the value to set in the property
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10748. /** @hidden */
  10749. _prepare(): void;
  10750. /**
  10751. * Execute the action and set the targetted property to the desired value.
  10752. */
  10753. execute(): void;
  10754. /**
  10755. * Serializes the actions and its related information.
  10756. * @param parent defines the object to serialize in
  10757. * @returns the serialized object
  10758. */
  10759. serialize(parent: any): any;
  10760. }
  10761. /**
  10762. * This defines an action responsible to increment the target value
  10763. * to a desired value once triggered.
  10764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10765. */
  10766. export class IncrementValueAction extends Action {
  10767. /**
  10768. * The path of the property to increment in the target.
  10769. */
  10770. propertyPath: string;
  10771. /**
  10772. * The value we should increment the property by.
  10773. */
  10774. value: any;
  10775. private _target;
  10776. private _effectiveTarget;
  10777. private _property;
  10778. /**
  10779. * Instantiate the action
  10780. * @param triggerOptions defines the trigger options
  10781. * @param target defines the object containing the property
  10782. * @param propertyPath defines the path of the property to increment in the target
  10783. * @param value defines the value value we should increment the property by
  10784. * @param condition defines the trigger related conditions
  10785. */
  10786. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10787. /** @hidden */
  10788. _prepare(): void;
  10789. /**
  10790. * Execute the action and increment the target of the value amount.
  10791. */
  10792. execute(): void;
  10793. /**
  10794. * Serializes the actions and its related information.
  10795. * @param parent defines the object to serialize in
  10796. * @returns the serialized object
  10797. */
  10798. serialize(parent: any): any;
  10799. }
  10800. /**
  10801. * This defines an action responsible to start an animation once triggered.
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10803. */
  10804. export class PlayAnimationAction extends Action {
  10805. /**
  10806. * Where the animation should start (animation frame)
  10807. */
  10808. from: number;
  10809. /**
  10810. * Where the animation should stop (animation frame)
  10811. */
  10812. to: number;
  10813. /**
  10814. * Define if the animation should loop or stop after the first play.
  10815. */
  10816. loop?: boolean;
  10817. private _target;
  10818. /**
  10819. * Instantiate the action
  10820. * @param triggerOptions defines the trigger options
  10821. * @param target defines the target animation or animation name
  10822. * @param from defines from where the animation should start (animation frame)
  10823. * @param end defines where the animation should stop (animation frame)
  10824. * @param loop defines if the animation should loop or stop after the first play
  10825. * @param condition defines the trigger related conditions
  10826. */
  10827. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10828. /** @hidden */
  10829. _prepare(): void;
  10830. /**
  10831. * Execute the action and play the animation.
  10832. */
  10833. execute(): void;
  10834. /**
  10835. * Serializes the actions and its related information.
  10836. * @param parent defines the object to serialize in
  10837. * @returns the serialized object
  10838. */
  10839. serialize(parent: any): any;
  10840. }
  10841. /**
  10842. * This defines an action responsible to stop an animation once triggered.
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10844. */
  10845. export class StopAnimationAction extends Action {
  10846. private _target;
  10847. /**
  10848. * Instantiate the action
  10849. * @param triggerOptions defines the trigger options
  10850. * @param target defines the target animation or animation name
  10851. * @param condition defines the trigger related conditions
  10852. */
  10853. constructor(triggerOptions: any, target: any, condition?: Condition);
  10854. /** @hidden */
  10855. _prepare(): void;
  10856. /**
  10857. * Execute the action and stop the animation.
  10858. */
  10859. execute(): void;
  10860. /**
  10861. * Serializes the actions and its related information.
  10862. * @param parent defines the object to serialize in
  10863. * @returns the serialized object
  10864. */
  10865. serialize(parent: any): any;
  10866. }
  10867. /**
  10868. * This defines an action responsible that does nothing once triggered.
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10870. */
  10871. export class DoNothingAction extends Action {
  10872. /**
  10873. * Instantiate the action
  10874. * @param triggerOptions defines the trigger options
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions?: any, condition?: Condition);
  10878. /**
  10879. * Execute the action and do nothing.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to trigger several actions once triggered.
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10892. */
  10893. export class CombineAction extends Action {
  10894. /**
  10895. * The list of aggregated animations to run.
  10896. */
  10897. children: Action[];
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param children defines the list of aggregated animations to run
  10902. * @param condition defines the trigger related conditions
  10903. */
  10904. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10905. /** @hidden */
  10906. _prepare(): void;
  10907. /**
  10908. * Execute the action and executes all the aggregated actions.
  10909. */
  10910. execute(evt: ActionEvent): void;
  10911. /**
  10912. * Serializes the actions and its related information.
  10913. * @param parent defines the object to serialize in
  10914. * @returns the serialized object
  10915. */
  10916. serialize(parent: any): any;
  10917. }
  10918. /**
  10919. * This defines an action responsible to run code (external event) once triggered.
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10921. */
  10922. export class ExecuteCodeAction extends Action {
  10923. /**
  10924. * The callback function to run.
  10925. */
  10926. func: (evt: ActionEvent) => void;
  10927. /**
  10928. * Instantiate the action
  10929. * @param triggerOptions defines the trigger options
  10930. * @param func defines the callback function to run
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10934. /**
  10935. * Execute the action and run the attached code.
  10936. */
  10937. execute(evt: ActionEvent): void;
  10938. }
  10939. /**
  10940. * This defines an action responsible to set the parent property of the target once triggered.
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10942. */
  10943. export class SetParentAction extends Action {
  10944. private _parent;
  10945. private _target;
  10946. /**
  10947. * Instantiate the action
  10948. * @param triggerOptions defines the trigger options
  10949. * @param target defines the target containing the parent property
  10950. * @param parent defines from where the animation should start (animation frame)
  10951. * @param condition defines the trigger related conditions
  10952. */
  10953. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10954. /** @hidden */
  10955. _prepare(): void;
  10956. /**
  10957. * Execute the action and set the parent property.
  10958. */
  10959. execute(): void;
  10960. /**
  10961. * Serializes the actions and its related information.
  10962. * @param parent defines the object to serialize in
  10963. * @returns the serialized object
  10964. */
  10965. serialize(parent: any): any;
  10966. }
  10967. }
  10968. declare module "babylonjs/Actions/actionManager" {
  10969. import { Nullable } from "babylonjs/types";
  10970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10971. import { Scene } from "babylonjs/scene";
  10972. import { IAction } from "babylonjs/Actions/action";
  10973. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10974. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10975. /**
  10976. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10977. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10979. */
  10980. export class ActionManager extends AbstractActionManager {
  10981. /**
  10982. * Nothing
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly NothingTrigger: number;
  10986. /**
  10987. * On pick
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnPickTrigger: number;
  10991. /**
  10992. * On left pick
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnLeftPickTrigger: number;
  10996. /**
  10997. * On right pick
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnRightPickTrigger: number;
  11001. /**
  11002. * On center pick
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnCenterPickTrigger: number;
  11006. /**
  11007. * On pick down
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnPickDownTrigger: number;
  11011. /**
  11012. * On double pick
  11013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11014. */
  11015. static readonly OnDoublePickTrigger: number;
  11016. /**
  11017. * On pick up
  11018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11019. */
  11020. static readonly OnPickUpTrigger: number;
  11021. /**
  11022. * On pick out.
  11023. * This trigger will only be raised if you also declared a OnPickDown
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly OnPickOutTrigger: number;
  11027. /**
  11028. * On long press
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnLongPressTrigger: number;
  11032. /**
  11033. * On pointer over
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnPointerOverTrigger: number;
  11037. /**
  11038. * On pointer out
  11039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11040. */
  11041. static readonly OnPointerOutTrigger: number;
  11042. /**
  11043. * On every frame
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11045. */
  11046. static readonly OnEveryFrameTrigger: number;
  11047. /**
  11048. * On intersection enter
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11050. */
  11051. static readonly OnIntersectionEnterTrigger: number;
  11052. /**
  11053. * On intersection exit
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11055. */
  11056. static readonly OnIntersectionExitTrigger: number;
  11057. /**
  11058. * On key down
  11059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11060. */
  11061. static readonly OnKeyDownTrigger: number;
  11062. /**
  11063. * On key up
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11065. */
  11066. static readonly OnKeyUpTrigger: number;
  11067. private _scene;
  11068. /**
  11069. * Creates a new action manager
  11070. * @param scene defines the hosting scene
  11071. */
  11072. constructor(scene: Scene);
  11073. /**
  11074. * Releases all associated resources
  11075. */
  11076. dispose(): void;
  11077. /**
  11078. * Gets hosting scene
  11079. * @returns the hosting scene
  11080. */
  11081. getScene(): Scene;
  11082. /**
  11083. * Does this action manager handles actions of any of the given triggers
  11084. * @param triggers defines the triggers to be tested
  11085. * @return a boolean indicating whether one (or more) of the triggers is handled
  11086. */
  11087. hasSpecificTriggers(triggers: number[]): boolean;
  11088. /**
  11089. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11090. * speed.
  11091. * @param triggerA defines the trigger to be tested
  11092. * @param triggerB defines the trigger to be tested
  11093. * @return a boolean indicating whether one (or more) of the triggers is handled
  11094. */
  11095. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11096. /**
  11097. * Does this action manager handles actions of a given trigger
  11098. * @param trigger defines the trigger to be tested
  11099. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11100. * @return whether the trigger is handled
  11101. */
  11102. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11103. /**
  11104. * Does this action manager has pointer triggers
  11105. */
  11106. readonly hasPointerTriggers: boolean;
  11107. /**
  11108. * Does this action manager has pick triggers
  11109. */
  11110. readonly hasPickTriggers: boolean;
  11111. /**
  11112. * Registers an action to this action manager
  11113. * @param action defines the action to be registered
  11114. * @return the action amended (prepared) after registration
  11115. */
  11116. registerAction(action: IAction): Nullable<IAction>;
  11117. /**
  11118. * Unregisters an action to this action manager
  11119. * @param action defines the action to be unregistered
  11120. * @return a boolean indicating whether the action has been unregistered
  11121. */
  11122. unregisterAction(action: IAction): Boolean;
  11123. /**
  11124. * Process a specific trigger
  11125. * @param trigger defines the trigger to process
  11126. * @param evt defines the event details to be processed
  11127. */
  11128. processTrigger(trigger: number, evt?: IActionEvent): void;
  11129. /** @hidden */
  11130. _getEffectiveTarget(target: any, propertyPath: string): any;
  11131. /** @hidden */
  11132. _getProperty(propertyPath: string): string;
  11133. /**
  11134. * Serialize this manager to a JSON object
  11135. * @param name defines the property name to store this manager
  11136. * @returns a JSON representation of this manager
  11137. */
  11138. serialize(name: string): any;
  11139. /**
  11140. * Creates a new ActionManager from a JSON data
  11141. * @param parsedActions defines the JSON data to read from
  11142. * @param object defines the hosting mesh
  11143. * @param scene defines the hosting scene
  11144. */
  11145. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11146. /**
  11147. * Get a trigger name by index
  11148. * @param trigger defines the trigger index
  11149. * @returns a trigger name
  11150. */
  11151. static GetTriggerName(trigger: number): string;
  11152. }
  11153. }
  11154. declare module "babylonjs/Culling/ray" {
  11155. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11156. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11158. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11159. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11160. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11161. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11162. import { Plane } from "babylonjs/Maths/math.plane";
  11163. /**
  11164. * Class representing a ray with position and direction
  11165. */
  11166. export class Ray {
  11167. /** origin point */
  11168. origin: Vector3;
  11169. /** direction */
  11170. direction: Vector3;
  11171. /** length of the ray */
  11172. length: number;
  11173. private static readonly TmpVector3;
  11174. private _tmpRay;
  11175. /**
  11176. * Creates a new ray
  11177. * @param origin origin point
  11178. * @param direction direction
  11179. * @param length length of the ray
  11180. */
  11181. constructor(
  11182. /** origin point */
  11183. origin: Vector3,
  11184. /** direction */
  11185. direction: Vector3,
  11186. /** length of the ray */
  11187. length?: number);
  11188. /**
  11189. * Checks if the ray intersects a box
  11190. * @param minimum bound of the box
  11191. * @param maximum bound of the box
  11192. * @param intersectionTreshold extra extend to be added to the box in all direction
  11193. * @returns if the box was hit
  11194. */
  11195. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11196. /**
  11197. * Checks if the ray intersects a box
  11198. * @param box the bounding box to check
  11199. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11200. * @returns if the box was hit
  11201. */
  11202. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11203. /**
  11204. * If the ray hits a sphere
  11205. * @param sphere the bounding sphere to check
  11206. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11207. * @returns true if it hits the sphere
  11208. */
  11209. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11210. /**
  11211. * If the ray hits a triange
  11212. * @param vertex0 triangle vertex
  11213. * @param vertex1 triangle vertex
  11214. * @param vertex2 triangle vertex
  11215. * @returns intersection information if hit
  11216. */
  11217. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11218. /**
  11219. * Checks if ray intersects a plane
  11220. * @param plane the plane to check
  11221. * @returns the distance away it was hit
  11222. */
  11223. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11224. /**
  11225. * Calculate the intercept of a ray on a given axis
  11226. * @param axis to check 'x' | 'y' | 'z'
  11227. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11228. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11229. */
  11230. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11231. /**
  11232. * Checks if ray intersects a mesh
  11233. * @param mesh the mesh to check
  11234. * @param fastCheck if only the bounding box should checked
  11235. * @returns picking info of the intersecton
  11236. */
  11237. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11238. /**
  11239. * Checks if ray intersects a mesh
  11240. * @param meshes the meshes to check
  11241. * @param fastCheck if only the bounding box should checked
  11242. * @param results array to store result in
  11243. * @returns Array of picking infos
  11244. */
  11245. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11246. private _comparePickingInfo;
  11247. private static smallnum;
  11248. private static rayl;
  11249. /**
  11250. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11251. * @param sega the first point of the segment to test the intersection against
  11252. * @param segb the second point of the segment to test the intersection against
  11253. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11254. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11255. */
  11256. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11257. /**
  11258. * Update the ray from viewport position
  11259. * @param x position
  11260. * @param y y position
  11261. * @param viewportWidth viewport width
  11262. * @param viewportHeight viewport height
  11263. * @param world world matrix
  11264. * @param view view matrix
  11265. * @param projection projection matrix
  11266. * @returns this ray updated
  11267. */
  11268. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11269. /**
  11270. * Creates a ray with origin and direction of 0,0,0
  11271. * @returns the new ray
  11272. */
  11273. static Zero(): Ray;
  11274. /**
  11275. * Creates a new ray from screen space and viewport
  11276. * @param x position
  11277. * @param y y position
  11278. * @param viewportWidth viewport width
  11279. * @param viewportHeight viewport height
  11280. * @param world world matrix
  11281. * @param view view matrix
  11282. * @param projection projection matrix
  11283. * @returns new ray
  11284. */
  11285. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11286. /**
  11287. * 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
  11288. * transformed to the given world matrix.
  11289. * @param origin The origin point
  11290. * @param end The end point
  11291. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11292. * @returns the new ray
  11293. */
  11294. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11295. /**
  11296. * Transforms a ray by a matrix
  11297. * @param ray ray to transform
  11298. * @param matrix matrix to apply
  11299. * @returns the resulting new ray
  11300. */
  11301. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11302. /**
  11303. * Transforms a ray by a matrix
  11304. * @param ray ray to transform
  11305. * @param matrix matrix to apply
  11306. * @param result ray to store result in
  11307. */
  11308. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11309. /**
  11310. * Unproject a ray from screen space to object space
  11311. * @param sourceX defines the screen space x coordinate to use
  11312. * @param sourceY defines the screen space y coordinate to use
  11313. * @param viewportWidth defines the current width of the viewport
  11314. * @param viewportHeight defines the current height of the viewport
  11315. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11316. * @param view defines the view matrix to use
  11317. * @param projection defines the projection matrix to use
  11318. */
  11319. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11320. }
  11321. /**
  11322. * Type used to define predicate used to select faces when a mesh intersection is detected
  11323. */
  11324. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11325. module "babylonjs/scene" {
  11326. interface Scene {
  11327. /** @hidden */
  11328. _tempPickingRay: Nullable<Ray>;
  11329. /** @hidden */
  11330. _cachedRayForTransform: Ray;
  11331. /** @hidden */
  11332. _pickWithRayInverseMatrix: Matrix;
  11333. /** @hidden */
  11334. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11335. /** @hidden */
  11336. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11337. }
  11338. }
  11339. }
  11340. declare module "babylonjs/sceneComponent" {
  11341. import { Scene } from "babylonjs/scene";
  11342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11344. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11345. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11346. import { Nullable } from "babylonjs/types";
  11347. import { Camera } from "babylonjs/Cameras/camera";
  11348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11349. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11350. import { AbstractScene } from "babylonjs/abstractScene";
  11351. /**
  11352. * Groups all the scene component constants in one place to ease maintenance.
  11353. * @hidden
  11354. */
  11355. export class SceneComponentConstants {
  11356. static readonly NAME_EFFECTLAYER: string;
  11357. static readonly NAME_LAYER: string;
  11358. static readonly NAME_LENSFLARESYSTEM: string;
  11359. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11360. static readonly NAME_PARTICLESYSTEM: string;
  11361. static readonly NAME_GAMEPAD: string;
  11362. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11363. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11364. static readonly NAME_DEPTHRENDERER: string;
  11365. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11366. static readonly NAME_SPRITE: string;
  11367. static readonly NAME_OUTLINERENDERER: string;
  11368. static readonly NAME_PROCEDURALTEXTURE: string;
  11369. static readonly NAME_SHADOWGENERATOR: string;
  11370. static readonly NAME_OCTREE: string;
  11371. static readonly NAME_PHYSICSENGINE: string;
  11372. static readonly NAME_AUDIO: string;
  11373. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11374. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11375. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11376. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11377. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11378. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11379. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11380. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11381. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11382. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11383. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11384. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11385. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11386. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11387. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11388. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11389. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11390. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11391. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11392. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11393. static readonly STEP_AFTERRENDER_AUDIO: number;
  11394. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11395. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11396. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11397. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11398. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11399. static readonly STEP_POINTERMOVE_SPRITE: number;
  11400. static readonly STEP_POINTERDOWN_SPRITE: number;
  11401. static readonly STEP_POINTERUP_SPRITE: number;
  11402. }
  11403. /**
  11404. * This represents a scene component.
  11405. *
  11406. * This is used to decouple the dependency the scene is having on the different workloads like
  11407. * layers, post processes...
  11408. */
  11409. export interface ISceneComponent {
  11410. /**
  11411. * The name of the component. Each component must have a unique name.
  11412. */
  11413. name: string;
  11414. /**
  11415. * The scene the component belongs to.
  11416. */
  11417. scene: Scene;
  11418. /**
  11419. * Register the component to one instance of a scene.
  11420. */
  11421. register(): void;
  11422. /**
  11423. * Rebuilds the elements related to this component in case of
  11424. * context lost for instance.
  11425. */
  11426. rebuild(): void;
  11427. /**
  11428. * Disposes the component and the associated ressources.
  11429. */
  11430. dispose(): void;
  11431. }
  11432. /**
  11433. * This represents a SERIALIZABLE scene component.
  11434. *
  11435. * This extends Scene Component to add Serialization methods on top.
  11436. */
  11437. export interface ISceneSerializableComponent extends ISceneComponent {
  11438. /**
  11439. * Adds all the elements from the container to the scene
  11440. * @param container the container holding the elements
  11441. */
  11442. addFromContainer(container: AbstractScene): void;
  11443. /**
  11444. * Removes all the elements in the container from the scene
  11445. * @param container contains the elements to remove
  11446. * @param dispose if the removed element should be disposed (default: false)
  11447. */
  11448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11449. /**
  11450. * Serializes the component data to the specified json object
  11451. * @param serializationObject The object to serialize to
  11452. */
  11453. serialize(serializationObject: any): void;
  11454. }
  11455. /**
  11456. * Strong typing of a Mesh related stage step action
  11457. */
  11458. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11459. /**
  11460. * Strong typing of a Evaluate Sub Mesh related stage step action
  11461. */
  11462. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11463. /**
  11464. * Strong typing of a Active Mesh related stage step action
  11465. */
  11466. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11467. /**
  11468. * Strong typing of a Camera related stage step action
  11469. */
  11470. export type CameraStageAction = (camera: Camera) => void;
  11471. /**
  11472. * Strong typing of a Camera Frame buffer related stage step action
  11473. */
  11474. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11475. /**
  11476. * Strong typing of a Render Target related stage step action
  11477. */
  11478. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11479. /**
  11480. * Strong typing of a RenderingGroup related stage step action
  11481. */
  11482. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11483. /**
  11484. * Strong typing of a Mesh Render related stage step action
  11485. */
  11486. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11487. /**
  11488. * Strong typing of a simple stage step action
  11489. */
  11490. export type SimpleStageAction = () => void;
  11491. /**
  11492. * Strong typing of a render target action.
  11493. */
  11494. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11495. /**
  11496. * Strong typing of a pointer move action.
  11497. */
  11498. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11499. /**
  11500. * Strong typing of a pointer up/down action.
  11501. */
  11502. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11503. /**
  11504. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11505. * @hidden
  11506. */
  11507. export class Stage<T extends Function> extends Array<{
  11508. index: number;
  11509. component: ISceneComponent;
  11510. action: T;
  11511. }> {
  11512. /**
  11513. * Hide ctor from the rest of the world.
  11514. * @param items The items to add.
  11515. */
  11516. private constructor();
  11517. /**
  11518. * Creates a new Stage.
  11519. * @returns A new instance of a Stage
  11520. */
  11521. static Create<T extends Function>(): Stage<T>;
  11522. /**
  11523. * Registers a step in an ordered way in the targeted stage.
  11524. * @param index Defines the position to register the step in
  11525. * @param component Defines the component attached to the step
  11526. * @param action Defines the action to launch during the step
  11527. */
  11528. registerStep(index: number, component: ISceneComponent, action: T): void;
  11529. /**
  11530. * Clears all the steps from the stage.
  11531. */
  11532. clear(): void;
  11533. }
  11534. }
  11535. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11536. import { Nullable } from "babylonjs/types";
  11537. import { Observable } from "babylonjs/Misc/observable";
  11538. import { Scene } from "babylonjs/scene";
  11539. import { Sprite } from "babylonjs/Sprites/sprite";
  11540. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11541. import { Ray } from "babylonjs/Culling/ray";
  11542. import { Camera } from "babylonjs/Cameras/camera";
  11543. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11544. import { ISceneComponent } from "babylonjs/sceneComponent";
  11545. module "babylonjs/scene" {
  11546. interface Scene {
  11547. /** @hidden */
  11548. _pointerOverSprite: Nullable<Sprite>;
  11549. /** @hidden */
  11550. _pickedDownSprite: Nullable<Sprite>;
  11551. /** @hidden */
  11552. _tempSpritePickingRay: Nullable<Ray>;
  11553. /**
  11554. * All of the sprite managers added to this scene
  11555. * @see http://doc.babylonjs.com/babylon101/sprites
  11556. */
  11557. spriteManagers: Array<ISpriteManager>;
  11558. /**
  11559. * An event triggered when sprites rendering is about to start
  11560. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11561. */
  11562. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11563. /**
  11564. * An event triggered when sprites rendering is done
  11565. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11566. */
  11567. onAfterSpritesRenderingObservable: Observable<Scene>;
  11568. /** @hidden */
  11569. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11570. /** Launch a ray to try to pick a sprite in the scene
  11571. * @param x position on screen
  11572. * @param y position on screen
  11573. * @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
  11574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11575. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11576. * @returns a PickingInfo
  11577. */
  11578. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11579. /** Use the given ray to pick a sprite in the scene
  11580. * @param ray The ray (in world space) to use to pick meshes
  11581. * @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
  11582. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11583. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11584. * @returns a PickingInfo
  11585. */
  11586. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11587. /** @hidden */
  11588. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11589. /** Launch a ray to try to pick sprites in the scene
  11590. * @param x position on screen
  11591. * @param y position on screen
  11592. * @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
  11593. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11594. * @returns a PickingInfo array
  11595. */
  11596. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11597. /** Use the given ray to pick sprites in the scene
  11598. * @param ray The ray (in world space) to use to pick meshes
  11599. * @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
  11600. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11601. * @returns a PickingInfo array
  11602. */
  11603. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11604. /**
  11605. * Force the sprite under the pointer
  11606. * @param sprite defines the sprite to use
  11607. */
  11608. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11609. /**
  11610. * Gets the sprite under the pointer
  11611. * @returns a Sprite or null if no sprite is under the pointer
  11612. */
  11613. getPointerOverSprite(): Nullable<Sprite>;
  11614. }
  11615. }
  11616. /**
  11617. * Defines the sprite scene component responsible to manage sprites
  11618. * in a given scene.
  11619. */
  11620. export class SpriteSceneComponent implements ISceneComponent {
  11621. /**
  11622. * The component name helpfull to identify the component in the list of scene components.
  11623. */
  11624. readonly name: string;
  11625. /**
  11626. * The scene the component belongs to.
  11627. */
  11628. scene: Scene;
  11629. /** @hidden */
  11630. private _spritePredicate;
  11631. /**
  11632. * Creates a new instance of the component for the given scene
  11633. * @param scene Defines the scene to register the component in
  11634. */
  11635. constructor(scene: Scene);
  11636. /**
  11637. * Registers the component in a given scene
  11638. */
  11639. register(): void;
  11640. /**
  11641. * Rebuilds the elements related to this component in case of
  11642. * context lost for instance.
  11643. */
  11644. rebuild(): void;
  11645. /**
  11646. * Disposes the component and the associated ressources.
  11647. */
  11648. dispose(): void;
  11649. private _pickSpriteButKeepRay;
  11650. private _pointerMove;
  11651. private _pointerDown;
  11652. private _pointerUp;
  11653. }
  11654. }
  11655. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11656. /** @hidden */
  11657. export var fogFragmentDeclaration: {
  11658. name: string;
  11659. shader: string;
  11660. };
  11661. }
  11662. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11663. /** @hidden */
  11664. export var fogFragment: {
  11665. name: string;
  11666. shader: string;
  11667. };
  11668. }
  11669. declare module "babylonjs/Shaders/sprites.fragment" {
  11670. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11671. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11672. /** @hidden */
  11673. export var spritesPixelShader: {
  11674. name: string;
  11675. shader: string;
  11676. };
  11677. }
  11678. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11679. /** @hidden */
  11680. export var fogVertexDeclaration: {
  11681. name: string;
  11682. shader: string;
  11683. };
  11684. }
  11685. declare module "babylonjs/Shaders/sprites.vertex" {
  11686. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11687. /** @hidden */
  11688. export var spritesVertexShader: {
  11689. name: string;
  11690. shader: string;
  11691. };
  11692. }
  11693. declare module "babylonjs/Sprites/spriteManager" {
  11694. import { IDisposable, Scene } from "babylonjs/scene";
  11695. import { Nullable } from "babylonjs/types";
  11696. import { Observable } from "babylonjs/Misc/observable";
  11697. import { Sprite } from "babylonjs/Sprites/sprite";
  11698. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11699. import { Camera } from "babylonjs/Cameras/camera";
  11700. import { Texture } from "babylonjs/Materials/Textures/texture";
  11701. import "babylonjs/Shaders/sprites.fragment";
  11702. import "babylonjs/Shaders/sprites.vertex";
  11703. import { Ray } from "babylonjs/Culling/ray";
  11704. /**
  11705. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11706. */
  11707. export interface ISpriteManager extends IDisposable {
  11708. /**
  11709. * Restricts the camera to viewing objects with the same layerMask.
  11710. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11711. */
  11712. layerMask: number;
  11713. /**
  11714. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11715. */
  11716. isPickable: boolean;
  11717. /**
  11718. * Specifies the rendering group id for this mesh (0 by default)
  11719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11720. */
  11721. renderingGroupId: number;
  11722. /**
  11723. * Defines the list of sprites managed by the manager.
  11724. */
  11725. sprites: Array<Sprite>;
  11726. /**
  11727. * Tests the intersection of a sprite with a specific ray.
  11728. * @param ray The ray we are sending to test the collision
  11729. * @param camera The camera space we are sending rays in
  11730. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11731. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11732. * @returns picking info or null.
  11733. */
  11734. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11735. /**
  11736. * Intersects the sprites with a ray
  11737. * @param ray defines the ray to intersect with
  11738. * @param camera defines the current active camera
  11739. * @param predicate defines a predicate used to select candidate sprites
  11740. * @returns null if no hit or a PickingInfo array
  11741. */
  11742. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11743. /**
  11744. * Renders the list of sprites on screen.
  11745. */
  11746. render(): void;
  11747. }
  11748. /**
  11749. * Class used to manage multiple sprites on the same spritesheet
  11750. * @see http://doc.babylonjs.com/babylon101/sprites
  11751. */
  11752. export class SpriteManager implements ISpriteManager {
  11753. /** defines the manager's name */
  11754. name: string;
  11755. /** Gets the list of sprites */
  11756. sprites: Sprite[];
  11757. /** Gets or sets the rendering group id (0 by default) */
  11758. renderingGroupId: number;
  11759. /** Gets or sets camera layer mask */
  11760. layerMask: number;
  11761. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11762. fogEnabled: boolean;
  11763. /** Gets or sets a boolean indicating if the sprites are pickable */
  11764. isPickable: boolean;
  11765. /** Defines the default width of a cell in the spritesheet */
  11766. cellWidth: number;
  11767. /** Defines the default height of a cell in the spritesheet */
  11768. cellHeight: number;
  11769. /** Associative array from JSON sprite data file */
  11770. private _cellData;
  11771. /** Array of sprite names from JSON sprite data file */
  11772. private _spriteMap;
  11773. /** True when packed cell data from JSON file is ready*/
  11774. private _packedAndReady;
  11775. /**
  11776. * An event triggered when the manager is disposed.
  11777. */
  11778. onDisposeObservable: Observable<SpriteManager>;
  11779. private _onDisposeObserver;
  11780. /**
  11781. * Callback called when the manager is disposed
  11782. */
  11783. onDispose: () => void;
  11784. private _capacity;
  11785. private _fromPacked;
  11786. private _spriteTexture;
  11787. private _epsilon;
  11788. private _scene;
  11789. private _vertexData;
  11790. private _buffer;
  11791. private _vertexBuffers;
  11792. private _indexBuffer;
  11793. private _effectBase;
  11794. private _effectFog;
  11795. /**
  11796. * Gets or sets the spritesheet texture
  11797. */
  11798. texture: Texture;
  11799. /**
  11800. * Creates a new sprite manager
  11801. * @param name defines the manager's name
  11802. * @param imgUrl defines the sprite sheet url
  11803. * @param capacity defines the maximum allowed number of sprites
  11804. * @param cellSize defines the size of a sprite cell
  11805. * @param scene defines the hosting scene
  11806. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11807. * @param samplingMode defines the smapling mode to use with spritesheet
  11808. * @param fromPacked set to false; do not alter
  11809. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11810. */
  11811. constructor(
  11812. /** defines the manager's name */
  11813. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11814. private _makePacked;
  11815. private _appendSpriteVertex;
  11816. /**
  11817. * Intersects the sprites with a ray
  11818. * @param ray defines the ray to intersect with
  11819. * @param camera defines the current active camera
  11820. * @param predicate defines a predicate used to select candidate sprites
  11821. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11822. * @returns null if no hit or a PickingInfo
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Intersects the sprites with a ray
  11827. * @param ray defines the ray to intersect with
  11828. * @param camera defines the current active camera
  11829. * @param predicate defines a predicate used to select candidate sprites
  11830. * @returns null if no hit or a PickingInfo array
  11831. */
  11832. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11833. /**
  11834. * Render all child sprites
  11835. */
  11836. render(): void;
  11837. /**
  11838. * Release associated resources
  11839. */
  11840. dispose(): void;
  11841. }
  11842. }
  11843. declare module "babylonjs/Sprites/sprite" {
  11844. import { Vector3 } from "babylonjs/Maths/math.vector";
  11845. import { Nullable } from "babylonjs/types";
  11846. import { ActionManager } from "babylonjs/Actions/actionManager";
  11847. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11848. import { Color4 } from "babylonjs/Maths/math.color";
  11849. /**
  11850. * Class used to represent a sprite
  11851. * @see http://doc.babylonjs.com/babylon101/sprites
  11852. */
  11853. export class Sprite {
  11854. /** defines the name */
  11855. name: string;
  11856. /** Gets or sets the current world position */
  11857. position: Vector3;
  11858. /** Gets or sets the main color */
  11859. color: Color4;
  11860. /** Gets or sets the width */
  11861. width: number;
  11862. /** Gets or sets the height */
  11863. height: number;
  11864. /** Gets or sets rotation angle */
  11865. angle: number;
  11866. /** Gets or sets the cell index in the sprite sheet */
  11867. cellIndex: number;
  11868. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11869. cellRef: string;
  11870. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11871. invertU: number;
  11872. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11873. invertV: number;
  11874. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11875. disposeWhenFinishedAnimating: boolean;
  11876. /** Gets the list of attached animations */
  11877. animations: Animation[];
  11878. /** Gets or sets a boolean indicating if the sprite can be picked */
  11879. isPickable: boolean;
  11880. /**
  11881. * Gets or sets the associated action manager
  11882. */
  11883. actionManager: Nullable<ActionManager>;
  11884. private _animationStarted;
  11885. private _loopAnimation;
  11886. private _fromIndex;
  11887. private _toIndex;
  11888. private _delay;
  11889. private _direction;
  11890. private _manager;
  11891. private _time;
  11892. private _onAnimationEnd;
  11893. /**
  11894. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11895. */
  11896. isVisible: boolean;
  11897. /**
  11898. * Gets or sets the sprite size
  11899. */
  11900. size: number;
  11901. /**
  11902. * Creates a new Sprite
  11903. * @param name defines the name
  11904. * @param manager defines the manager
  11905. */
  11906. constructor(
  11907. /** defines the name */
  11908. name: string, manager: ISpriteManager);
  11909. /**
  11910. * Starts an animation
  11911. * @param from defines the initial key
  11912. * @param to defines the end key
  11913. * @param loop defines if the animation must loop
  11914. * @param delay defines the start delay (in ms)
  11915. * @param onAnimationEnd defines a callback to call when animation ends
  11916. */
  11917. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11918. /** Stops current animation (if any) */
  11919. stopAnimation(): void;
  11920. /** @hidden */
  11921. _animate(deltaTime: number): void;
  11922. /** Release associated resources */
  11923. dispose(): void;
  11924. }
  11925. }
  11926. declare module "babylonjs/Collisions/pickingInfo" {
  11927. import { Nullable } from "babylonjs/types";
  11928. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11930. import { Sprite } from "babylonjs/Sprites/sprite";
  11931. import { Ray } from "babylonjs/Culling/ray";
  11932. /**
  11933. * Information about the result of picking within a scene
  11934. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11935. */
  11936. export class PickingInfo {
  11937. /** @hidden */
  11938. _pickingUnavailable: boolean;
  11939. /**
  11940. * If the pick collided with an object
  11941. */
  11942. hit: boolean;
  11943. /**
  11944. * Distance away where the pick collided
  11945. */
  11946. distance: number;
  11947. /**
  11948. * The location of pick collision
  11949. */
  11950. pickedPoint: Nullable<Vector3>;
  11951. /**
  11952. * The mesh corresponding the the pick collision
  11953. */
  11954. pickedMesh: Nullable<AbstractMesh>;
  11955. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11956. bu: number;
  11957. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11958. bv: number;
  11959. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11960. faceId: number;
  11961. /** Id of the the submesh that was picked */
  11962. subMeshId: number;
  11963. /** If a sprite was picked, this will be the sprite the pick collided with */
  11964. pickedSprite: Nullable<Sprite>;
  11965. /**
  11966. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11967. */
  11968. originMesh: Nullable<AbstractMesh>;
  11969. /**
  11970. * The ray that was used to perform the picking.
  11971. */
  11972. ray: Nullable<Ray>;
  11973. /**
  11974. * Gets the normal correspodning to the face the pick collided with
  11975. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11976. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11977. * @returns The normal correspodning to the face the pick collided with
  11978. */
  11979. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11980. /**
  11981. * Gets the texture coordinates of where the pick occured
  11982. * @returns the vector containing the coordnates of the texture
  11983. */
  11984. getTextureCoordinates(): Nullable<Vector2>;
  11985. }
  11986. }
  11987. declare module "babylonjs/Events/pointerEvents" {
  11988. import { Nullable } from "babylonjs/types";
  11989. import { Vector2 } from "babylonjs/Maths/math.vector";
  11990. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11991. import { Ray } from "babylonjs/Culling/ray";
  11992. /**
  11993. * Gather the list of pointer event types as constants.
  11994. */
  11995. export class PointerEventTypes {
  11996. /**
  11997. * 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.
  11998. */
  11999. static readonly POINTERDOWN: number;
  12000. /**
  12001. * The pointerup event is fired when a pointer is no longer active.
  12002. */
  12003. static readonly POINTERUP: number;
  12004. /**
  12005. * The pointermove event is fired when a pointer changes coordinates.
  12006. */
  12007. static readonly POINTERMOVE: number;
  12008. /**
  12009. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12010. */
  12011. static readonly POINTERWHEEL: number;
  12012. /**
  12013. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12014. */
  12015. static readonly POINTERPICK: number;
  12016. /**
  12017. * The pointertap event is fired when a the object has been touched and released without drag.
  12018. */
  12019. static readonly POINTERTAP: number;
  12020. /**
  12021. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12022. */
  12023. static readonly POINTERDOUBLETAP: number;
  12024. }
  12025. /**
  12026. * Base class of pointer info types.
  12027. */
  12028. export class PointerInfoBase {
  12029. /**
  12030. * Defines the type of event (PointerEventTypes)
  12031. */
  12032. type: number;
  12033. /**
  12034. * Defines the related dom event
  12035. */
  12036. event: PointerEvent | MouseWheelEvent;
  12037. /**
  12038. * Instantiates the base class of pointers info.
  12039. * @param type Defines the type of event (PointerEventTypes)
  12040. * @param event Defines the related dom event
  12041. */
  12042. constructor(
  12043. /**
  12044. * Defines the type of event (PointerEventTypes)
  12045. */
  12046. type: number,
  12047. /**
  12048. * Defines the related dom event
  12049. */
  12050. event: PointerEvent | MouseWheelEvent);
  12051. }
  12052. /**
  12053. * This class is used to store pointer related info for the onPrePointerObservable event.
  12054. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12055. */
  12056. export class PointerInfoPre extends PointerInfoBase {
  12057. /**
  12058. * Ray from a pointer if availible (eg. 6dof controller)
  12059. */
  12060. ray: Nullable<Ray>;
  12061. /**
  12062. * Defines the local position of the pointer on the canvas.
  12063. */
  12064. localPosition: Vector2;
  12065. /**
  12066. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12067. */
  12068. skipOnPointerObservable: boolean;
  12069. /**
  12070. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12071. * @param type Defines the type of event (PointerEventTypes)
  12072. * @param event Defines the related dom event
  12073. * @param localX Defines the local x coordinates of the pointer when the event occured
  12074. * @param localY Defines the local y coordinates of the pointer when the event occured
  12075. */
  12076. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12077. }
  12078. /**
  12079. * This type contains all the data related to a pointer event in Babylon.js.
  12080. * 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.
  12081. */
  12082. export class PointerInfo extends PointerInfoBase {
  12083. /**
  12084. * Defines the picking info associated to the info (if any)\
  12085. */
  12086. pickInfo: Nullable<PickingInfo>;
  12087. /**
  12088. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12089. * @param type Defines the type of event (PointerEventTypes)
  12090. * @param event Defines the related dom event
  12091. * @param pickInfo Defines the picking info associated to the info (if any)\
  12092. */
  12093. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12094. /**
  12095. * Defines the picking info associated to the info (if any)\
  12096. */
  12097. pickInfo: Nullable<PickingInfo>);
  12098. }
  12099. /**
  12100. * Data relating to a touch event on the screen.
  12101. */
  12102. export interface PointerTouch {
  12103. /**
  12104. * X coordinate of touch.
  12105. */
  12106. x: number;
  12107. /**
  12108. * Y coordinate of touch.
  12109. */
  12110. y: number;
  12111. /**
  12112. * Id of touch. Unique for each finger.
  12113. */
  12114. pointerId: number;
  12115. /**
  12116. * Event type passed from DOM.
  12117. */
  12118. type: any;
  12119. }
  12120. }
  12121. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12122. import { Observable } from "babylonjs/Misc/observable";
  12123. import { Nullable } from "babylonjs/types";
  12124. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12126. /**
  12127. * Manage the mouse inputs to control the movement of a free camera.
  12128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12129. */
  12130. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12131. /**
  12132. * Define if touch is enabled in the mouse input
  12133. */
  12134. touchEnabled: boolean;
  12135. /**
  12136. * Defines the camera the input is attached to.
  12137. */
  12138. camera: FreeCamera;
  12139. /**
  12140. * Defines the buttons associated with the input to handle camera move.
  12141. */
  12142. buttons: number[];
  12143. /**
  12144. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12145. */
  12146. angularSensibility: number;
  12147. private _pointerInput;
  12148. private _onMouseMove;
  12149. private _observer;
  12150. private previousPosition;
  12151. /**
  12152. * Observable for when a pointer move event occurs containing the move offset
  12153. */
  12154. onPointerMovedObservable: Observable<{
  12155. offsetX: number;
  12156. offsetY: number;
  12157. }>;
  12158. /**
  12159. * @hidden
  12160. * If the camera should be rotated automatically based on pointer movement
  12161. */
  12162. _allowCameraRotation: boolean;
  12163. /**
  12164. * Manage the mouse inputs to control the movement of a free camera.
  12165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12166. * @param touchEnabled Defines if touch is enabled or not
  12167. */
  12168. constructor(
  12169. /**
  12170. * Define if touch is enabled in the mouse input
  12171. */
  12172. touchEnabled?: boolean);
  12173. /**
  12174. * Attach the input controls to a specific dom element to get the input from.
  12175. * @param element Defines the element the controls should be listened from
  12176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12177. */
  12178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12179. /**
  12180. * Called on JS contextmenu event.
  12181. * Override this method to provide functionality.
  12182. */
  12183. protected onContextMenu(evt: PointerEvent): void;
  12184. /**
  12185. * Detach the current controls from the specified dom element.
  12186. * @param element Defines the element to stop listening the inputs from
  12187. */
  12188. detachControl(element: Nullable<HTMLElement>): void;
  12189. /**
  12190. * Gets the class name of the current intput.
  12191. * @returns the class name
  12192. */
  12193. getClassName(): string;
  12194. /**
  12195. * Get the friendly name associated with the input class.
  12196. * @returns the input friendly name
  12197. */
  12198. getSimpleName(): string;
  12199. }
  12200. }
  12201. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12202. import { Nullable } from "babylonjs/types";
  12203. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. /**
  12206. * Manage the touch inputs to control the movement of a free camera.
  12207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12208. */
  12209. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12210. /**
  12211. * Defines the camera the input is attached to.
  12212. */
  12213. camera: FreeCamera;
  12214. /**
  12215. * Defines the touch sensibility for rotation.
  12216. * The higher the faster.
  12217. */
  12218. touchAngularSensibility: number;
  12219. /**
  12220. * Defines the touch sensibility for move.
  12221. * The higher the faster.
  12222. */
  12223. touchMoveSensibility: number;
  12224. private _offsetX;
  12225. private _offsetY;
  12226. private _pointerPressed;
  12227. private _pointerInput;
  12228. private _observer;
  12229. private _onLostFocus;
  12230. /**
  12231. * Attach the input controls to a specific dom element to get the input from.
  12232. * @param element Defines the element the controls should be listened from
  12233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12234. */
  12235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12236. /**
  12237. * Detach the current controls from the specified dom element.
  12238. * @param element Defines the element to stop listening the inputs from
  12239. */
  12240. detachControl(element: Nullable<HTMLElement>): void;
  12241. /**
  12242. * Update the current camera state depending on the inputs that have been used this frame.
  12243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12244. */
  12245. checkInputs(): void;
  12246. /**
  12247. * Gets the class name of the current intput.
  12248. * @returns the class name
  12249. */
  12250. getClassName(): string;
  12251. /**
  12252. * Get the friendly name associated with the input class.
  12253. * @returns the input friendly name
  12254. */
  12255. getSimpleName(): string;
  12256. }
  12257. }
  12258. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12259. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12260. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12261. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12262. import { Nullable } from "babylonjs/types";
  12263. /**
  12264. * Default Inputs manager for the FreeCamera.
  12265. * It groups all the default supported inputs for ease of use.
  12266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12267. */
  12268. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12269. /**
  12270. * @hidden
  12271. */
  12272. _mouseInput: Nullable<FreeCameraMouseInput>;
  12273. /**
  12274. * Instantiates a new FreeCameraInputsManager.
  12275. * @param camera Defines the camera the inputs belong to
  12276. */
  12277. constructor(camera: FreeCamera);
  12278. /**
  12279. * Add keyboard input support to the input manager.
  12280. * @returns the current input manager
  12281. */
  12282. addKeyboard(): FreeCameraInputsManager;
  12283. /**
  12284. * Add mouse input support to the input manager.
  12285. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12286. * @returns the current input manager
  12287. */
  12288. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12289. /**
  12290. * Removes the mouse input support from the manager
  12291. * @returns the current input manager
  12292. */
  12293. removeMouse(): FreeCameraInputsManager;
  12294. /**
  12295. * Add touch input support to the input manager.
  12296. * @returns the current input manager
  12297. */
  12298. addTouch(): FreeCameraInputsManager;
  12299. /**
  12300. * Remove all attached input methods from a camera
  12301. */
  12302. clear(): void;
  12303. }
  12304. }
  12305. declare module "babylonjs/Cameras/freeCamera" {
  12306. import { Vector3 } from "babylonjs/Maths/math.vector";
  12307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12308. import { Scene } from "babylonjs/scene";
  12309. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12310. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12311. /**
  12312. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12313. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12314. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12315. */
  12316. export class FreeCamera extends TargetCamera {
  12317. /**
  12318. * Define the collision ellipsoid of the camera.
  12319. * This is helpful to simulate a camera body like the player body around the camera
  12320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12321. */
  12322. ellipsoid: Vector3;
  12323. /**
  12324. * Define an offset for the position of the ellipsoid around the camera.
  12325. * This can be helpful to determine the center of the body near the gravity center of the body
  12326. * instead of its head.
  12327. */
  12328. ellipsoidOffset: Vector3;
  12329. /**
  12330. * Enable or disable collisions of the camera with the rest of the scene objects.
  12331. */
  12332. checkCollisions: boolean;
  12333. /**
  12334. * Enable or disable gravity on the camera.
  12335. */
  12336. applyGravity: boolean;
  12337. /**
  12338. * Define the input manager associated to the camera.
  12339. */
  12340. inputs: FreeCameraInputsManager;
  12341. /**
  12342. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12343. * Higher values reduce sensitivity.
  12344. */
  12345. /**
  12346. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12347. * Higher values reduce sensitivity.
  12348. */
  12349. angularSensibility: number;
  12350. /**
  12351. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12352. */
  12353. keysUp: number[];
  12354. /**
  12355. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12356. */
  12357. keysDown: number[];
  12358. /**
  12359. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12360. */
  12361. keysLeft: number[];
  12362. /**
  12363. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12364. */
  12365. keysRight: number[];
  12366. /**
  12367. * Event raised when the camera collide with a mesh in the scene.
  12368. */
  12369. onCollide: (collidedMesh: AbstractMesh) => void;
  12370. private _collider;
  12371. private _needMoveForGravity;
  12372. private _oldPosition;
  12373. private _diffPosition;
  12374. private _newPosition;
  12375. /** @hidden */
  12376. _localDirection: Vector3;
  12377. /** @hidden */
  12378. _transformedDirection: Vector3;
  12379. /**
  12380. * Instantiates a Free Camera.
  12381. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12382. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12383. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12384. * @param name Define the name of the camera in the scene
  12385. * @param position Define the start position of the camera in the scene
  12386. * @param scene Define the scene the camera belongs to
  12387. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12388. */
  12389. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12390. /**
  12391. * Attached controls to the current camera.
  12392. * @param element Defines the element the controls should be listened from
  12393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12394. */
  12395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12396. /**
  12397. * Detach the current controls from the camera.
  12398. * The camera will stop reacting to inputs.
  12399. * @param element Defines the element to stop listening the inputs from
  12400. */
  12401. detachControl(element: HTMLElement): void;
  12402. private _collisionMask;
  12403. /**
  12404. * Define a collision mask to limit the list of object the camera can collide with
  12405. */
  12406. collisionMask: number;
  12407. /** @hidden */
  12408. _collideWithWorld(displacement: Vector3): void;
  12409. private _onCollisionPositionChange;
  12410. /** @hidden */
  12411. _checkInputs(): void;
  12412. /** @hidden */
  12413. _decideIfNeedsToMove(): boolean;
  12414. /** @hidden */
  12415. _updatePosition(): void;
  12416. /**
  12417. * Destroy the camera and release the current resources hold by it.
  12418. */
  12419. dispose(): void;
  12420. /**
  12421. * Gets the current object class name.
  12422. * @return the class name
  12423. */
  12424. getClassName(): string;
  12425. }
  12426. }
  12427. declare module "babylonjs/Gamepads/gamepad" {
  12428. import { Observable } from "babylonjs/Misc/observable";
  12429. /**
  12430. * Represents a gamepad control stick position
  12431. */
  12432. export class StickValues {
  12433. /**
  12434. * The x component of the control stick
  12435. */
  12436. x: number;
  12437. /**
  12438. * The y component of the control stick
  12439. */
  12440. y: number;
  12441. /**
  12442. * Initializes the gamepad x and y control stick values
  12443. * @param x The x component of the gamepad control stick value
  12444. * @param y The y component of the gamepad control stick value
  12445. */
  12446. constructor(
  12447. /**
  12448. * The x component of the control stick
  12449. */
  12450. x: number,
  12451. /**
  12452. * The y component of the control stick
  12453. */
  12454. y: number);
  12455. }
  12456. /**
  12457. * An interface which manages callbacks for gamepad button changes
  12458. */
  12459. export interface GamepadButtonChanges {
  12460. /**
  12461. * Called when a gamepad has been changed
  12462. */
  12463. changed: boolean;
  12464. /**
  12465. * Called when a gamepad press event has been triggered
  12466. */
  12467. pressChanged: boolean;
  12468. /**
  12469. * Called when a touch event has been triggered
  12470. */
  12471. touchChanged: boolean;
  12472. /**
  12473. * Called when a value has changed
  12474. */
  12475. valueChanged: boolean;
  12476. }
  12477. /**
  12478. * Represents a gamepad
  12479. */
  12480. export class Gamepad {
  12481. /**
  12482. * The id of the gamepad
  12483. */
  12484. id: string;
  12485. /**
  12486. * The index of the gamepad
  12487. */
  12488. index: number;
  12489. /**
  12490. * The browser gamepad
  12491. */
  12492. browserGamepad: any;
  12493. /**
  12494. * Specifies what type of gamepad this represents
  12495. */
  12496. type: number;
  12497. private _leftStick;
  12498. private _rightStick;
  12499. /** @hidden */
  12500. _isConnected: boolean;
  12501. private _leftStickAxisX;
  12502. private _leftStickAxisY;
  12503. private _rightStickAxisX;
  12504. private _rightStickAxisY;
  12505. /**
  12506. * Triggered when the left control stick has been changed
  12507. */
  12508. private _onleftstickchanged;
  12509. /**
  12510. * Triggered when the right control stick has been changed
  12511. */
  12512. private _onrightstickchanged;
  12513. /**
  12514. * Represents a gamepad controller
  12515. */
  12516. static GAMEPAD: number;
  12517. /**
  12518. * Represents a generic controller
  12519. */
  12520. static GENERIC: number;
  12521. /**
  12522. * Represents an XBox controller
  12523. */
  12524. static XBOX: number;
  12525. /**
  12526. * Represents a pose-enabled controller
  12527. */
  12528. static POSE_ENABLED: number;
  12529. /**
  12530. * Represents an Dual Shock controller
  12531. */
  12532. static DUALSHOCK: number;
  12533. /**
  12534. * Specifies whether the left control stick should be Y-inverted
  12535. */
  12536. protected _invertLeftStickY: boolean;
  12537. /**
  12538. * Specifies if the gamepad has been connected
  12539. */
  12540. readonly isConnected: boolean;
  12541. /**
  12542. * Initializes the gamepad
  12543. * @param id The id of the gamepad
  12544. * @param index The index of the gamepad
  12545. * @param browserGamepad The browser gamepad
  12546. * @param leftStickX The x component of the left joystick
  12547. * @param leftStickY The y component of the left joystick
  12548. * @param rightStickX The x component of the right joystick
  12549. * @param rightStickY The y component of the right joystick
  12550. */
  12551. constructor(
  12552. /**
  12553. * The id of the gamepad
  12554. */
  12555. id: string,
  12556. /**
  12557. * The index of the gamepad
  12558. */
  12559. index: number,
  12560. /**
  12561. * The browser gamepad
  12562. */
  12563. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12564. /**
  12565. * Callback triggered when the left joystick has changed
  12566. * @param callback
  12567. */
  12568. onleftstickchanged(callback: (values: StickValues) => void): void;
  12569. /**
  12570. * Callback triggered when the right joystick has changed
  12571. * @param callback
  12572. */
  12573. onrightstickchanged(callback: (values: StickValues) => void): void;
  12574. /**
  12575. * Gets the left joystick
  12576. */
  12577. /**
  12578. * Sets the left joystick values
  12579. */
  12580. leftStick: StickValues;
  12581. /**
  12582. * Gets the right joystick
  12583. */
  12584. /**
  12585. * Sets the right joystick value
  12586. */
  12587. rightStick: StickValues;
  12588. /**
  12589. * Updates the gamepad joystick positions
  12590. */
  12591. update(): void;
  12592. /**
  12593. * Disposes the gamepad
  12594. */
  12595. dispose(): void;
  12596. }
  12597. /**
  12598. * Represents a generic gamepad
  12599. */
  12600. export class GenericPad extends Gamepad {
  12601. private _buttons;
  12602. private _onbuttondown;
  12603. private _onbuttonup;
  12604. /**
  12605. * Observable triggered when a button has been pressed
  12606. */
  12607. onButtonDownObservable: Observable<number>;
  12608. /**
  12609. * Observable triggered when a button has been released
  12610. */
  12611. onButtonUpObservable: Observable<number>;
  12612. /**
  12613. * Callback triggered when a button has been pressed
  12614. * @param callback Called when a button has been pressed
  12615. */
  12616. onbuttondown(callback: (buttonPressed: number) => void): void;
  12617. /**
  12618. * Callback triggered when a button has been released
  12619. * @param callback Called when a button has been released
  12620. */
  12621. onbuttonup(callback: (buttonReleased: number) => void): void;
  12622. /**
  12623. * Initializes the generic gamepad
  12624. * @param id The id of the generic gamepad
  12625. * @param index The index of the generic gamepad
  12626. * @param browserGamepad The browser gamepad
  12627. */
  12628. constructor(id: string, index: number, browserGamepad: any);
  12629. private _setButtonValue;
  12630. /**
  12631. * Updates the generic gamepad
  12632. */
  12633. update(): void;
  12634. /**
  12635. * Disposes the generic gamepad
  12636. */
  12637. dispose(): void;
  12638. }
  12639. }
  12640. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12641. import { Nullable } from "babylonjs/types";
  12642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12643. import { Scene } from "babylonjs/scene";
  12644. module "babylonjs/Engines/engine" {
  12645. interface Engine {
  12646. /**
  12647. * Creates a raw texture
  12648. * @param data defines the data to store in the texture
  12649. * @param width defines the width of the texture
  12650. * @param height defines the height of the texture
  12651. * @param format defines the format of the data
  12652. * @param generateMipMaps defines if the engine should generate the mip levels
  12653. * @param invertY defines if data must be stored with Y axis inverted
  12654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12655. * @param compression defines the compression used (null by default)
  12656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12657. * @returns the raw texture inside an InternalTexture
  12658. */
  12659. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12660. /**
  12661. * Update a raw texture
  12662. * @param texture defines the texture to update
  12663. * @param data defines the data to store in the texture
  12664. * @param format defines the format of the data
  12665. * @param invertY defines if data must be stored with Y axis inverted
  12666. */
  12667. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12668. /**
  12669. * Update a raw texture
  12670. * @param texture defines the texture to update
  12671. * @param data defines the data to store in the texture
  12672. * @param format defines the format of the data
  12673. * @param invertY defines if data must be stored with Y axis inverted
  12674. * @param compression defines the compression used (null by default)
  12675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12676. */
  12677. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12678. /**
  12679. * Creates a new raw cube texture
  12680. * @param data defines the array of data to use to create each face
  12681. * @param size defines the size of the textures
  12682. * @param format defines the format of the data
  12683. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12684. * @param generateMipMaps defines if the engine should generate the mip levels
  12685. * @param invertY defines if data must be stored with Y axis inverted
  12686. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12687. * @param compression defines the compression used (null by default)
  12688. * @returns the cube texture as an InternalTexture
  12689. */
  12690. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12691. /**
  12692. * Update a raw cube texture
  12693. * @param texture defines the texture to udpdate
  12694. * @param data defines the data to store
  12695. * @param format defines the data format
  12696. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12697. * @param invertY defines if data must be stored with Y axis inverted
  12698. */
  12699. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12700. /**
  12701. * Update a raw cube texture
  12702. * @param texture defines the texture to udpdate
  12703. * @param data defines the data to store
  12704. * @param format defines the data format
  12705. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param compression defines the compression used (null by default)
  12708. */
  12709. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12710. /**
  12711. * Update a raw cube texture
  12712. * @param texture defines the texture to udpdate
  12713. * @param data defines the data to store
  12714. * @param format defines the data format
  12715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12716. * @param invertY defines if data must be stored with Y axis inverted
  12717. * @param compression defines the compression used (null by default)
  12718. * @param level defines which level of the texture to update
  12719. */
  12720. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12721. /**
  12722. * Creates a new raw cube texture from a specified url
  12723. * @param url defines the url where the data is located
  12724. * @param scene defines the current scene
  12725. * @param size defines the size of the textures
  12726. * @param format defines the format of the data
  12727. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12728. * @param noMipmap defines if the engine should avoid generating the mip levels
  12729. * @param callback defines a callback used to extract texture data from loaded data
  12730. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12731. * @param onLoad defines a callback called when texture is loaded
  12732. * @param onError defines a callback called if there is an error
  12733. * @returns the cube texture as an InternalTexture
  12734. */
  12735. 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;
  12736. /**
  12737. * Creates a new raw cube texture from a specified url
  12738. * @param url defines the url where the data is located
  12739. * @param scene defines the current scene
  12740. * @param size defines the size of the textures
  12741. * @param format defines the format of the data
  12742. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12743. * @param noMipmap defines if the engine should avoid generating the mip levels
  12744. * @param callback defines a callback used to extract texture data from loaded data
  12745. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12746. * @param onLoad defines a callback called when texture is loaded
  12747. * @param onError defines a callback called if there is an error
  12748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12749. * @param invertY defines if data must be stored with Y axis inverted
  12750. * @returns the cube texture as an InternalTexture
  12751. */
  12752. 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;
  12753. /**
  12754. * Creates a new raw 3D texture
  12755. * @param data defines the data used to create the texture
  12756. * @param width defines the width of the texture
  12757. * @param height defines the height of the texture
  12758. * @param depth defines the depth of the texture
  12759. * @param format defines the format of the texture
  12760. * @param generateMipMaps defines if the engine must generate mip levels
  12761. * @param invertY defines if data must be stored with Y axis inverted
  12762. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12763. * @param compression defines the compressed used (can be null)
  12764. * @param textureType defines the compressed used (can be null)
  12765. * @returns a new raw 3D texture (stored in an InternalTexture)
  12766. */
  12767. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12768. /**
  12769. * Update a raw 3D texture
  12770. * @param texture defines the texture to update
  12771. * @param data defines the data to store
  12772. * @param format defines the data format
  12773. * @param invertY defines if data must be stored with Y axis inverted
  12774. */
  12775. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12776. /**
  12777. * Update a raw 3D texture
  12778. * @param texture defines the texture to update
  12779. * @param data defines the data to store
  12780. * @param format defines the data format
  12781. * @param invertY defines if data must be stored with Y axis inverted
  12782. * @param compression defines the used compression (can be null)
  12783. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12784. */
  12785. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12786. }
  12787. }
  12788. }
  12789. declare module "babylonjs/Materials/Textures/rawTexture" {
  12790. import { Scene } from "babylonjs/scene";
  12791. import { Texture } from "babylonjs/Materials/Textures/texture";
  12792. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12793. /**
  12794. * Raw texture can help creating a texture directly from an array of data.
  12795. * This can be super useful if you either get the data from an uncompressed source or
  12796. * if you wish to create your texture pixel by pixel.
  12797. */
  12798. export class RawTexture extends Texture {
  12799. /**
  12800. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12801. */
  12802. format: number;
  12803. private _engine;
  12804. /**
  12805. * Instantiates a new RawTexture.
  12806. * Raw texture can help creating a texture directly from an array of data.
  12807. * This can be super useful if you either get the data from an uncompressed source or
  12808. * if you wish to create your texture pixel by pixel.
  12809. * @param data define the array of data to use to create the texture
  12810. * @param width define the width of the texture
  12811. * @param height define the height of the texture
  12812. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12813. * @param scene define the scene the texture belongs to
  12814. * @param generateMipMaps define whether mip maps should be generated or not
  12815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12817. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12818. */
  12819. constructor(data: ArrayBufferView, width: number, height: number,
  12820. /**
  12821. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12822. */
  12823. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12824. /**
  12825. * Updates the texture underlying data.
  12826. * @param data Define the new data of the texture
  12827. */
  12828. update(data: ArrayBufferView): void;
  12829. /**
  12830. * Creates a luminance texture from some data.
  12831. * @param data Define the texture data
  12832. * @param width Define the width of the texture
  12833. * @param height Define the height of the texture
  12834. * @param scene Define the scene the texture belongs to
  12835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12838. * @returns the luminance texture
  12839. */
  12840. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12841. /**
  12842. * Creates a luminance alpha texture from some data.
  12843. * @param data Define the texture data
  12844. * @param width Define the width of the texture
  12845. * @param height Define the height of the texture
  12846. * @param scene Define the scene the texture belongs to
  12847. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12848. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12849. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12850. * @returns the luminance alpha texture
  12851. */
  12852. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12853. /**
  12854. * Creates an alpha texture from some data.
  12855. * @param data Define the texture data
  12856. * @param width Define the width of the texture
  12857. * @param height Define the height of the texture
  12858. * @param scene Define the scene the texture belongs to
  12859. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12860. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12861. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12862. * @returns the alpha texture
  12863. */
  12864. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12865. /**
  12866. * Creates a RGB texture from some data.
  12867. * @param data Define the texture data
  12868. * @param width Define the width of the texture
  12869. * @param height Define the height of the texture
  12870. * @param scene Define the scene the texture belongs to
  12871. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12872. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12873. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12874. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12875. * @returns the RGB alpha texture
  12876. */
  12877. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12878. /**
  12879. * Creates a RGBA texture from some data.
  12880. * @param data Define the texture data
  12881. * @param width Define the width of the texture
  12882. * @param height Define the height of the texture
  12883. * @param scene Define the scene the texture belongs to
  12884. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12885. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12886. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12887. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12888. * @returns the RGBA texture
  12889. */
  12890. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12891. /**
  12892. * Creates a R texture from some data.
  12893. * @param data Define the texture data
  12894. * @param width Define the width of the texture
  12895. * @param height Define the height of the texture
  12896. * @param scene Define the scene the texture belongs to
  12897. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12898. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12899. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12900. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12901. * @returns the R texture
  12902. */
  12903. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12904. }
  12905. }
  12906. declare module "babylonjs/Maths/math.size" {
  12907. /**
  12908. * Interface for the size containing width and height
  12909. */
  12910. export interface ISize {
  12911. /**
  12912. * Width
  12913. */
  12914. width: number;
  12915. /**
  12916. * Heighht
  12917. */
  12918. height: number;
  12919. }
  12920. /**
  12921. * Size containing widht and height
  12922. */
  12923. export class Size implements ISize {
  12924. /**
  12925. * Width
  12926. */
  12927. width: number;
  12928. /**
  12929. * Height
  12930. */
  12931. height: number;
  12932. /**
  12933. * Creates a Size object from the given width and height (floats).
  12934. * @param width width of the new size
  12935. * @param height height of the new size
  12936. */
  12937. constructor(width: number, height: number);
  12938. /**
  12939. * Returns a string with the Size width and height
  12940. * @returns a string with the Size width and height
  12941. */
  12942. toString(): string;
  12943. /**
  12944. * "Size"
  12945. * @returns the string "Size"
  12946. */
  12947. getClassName(): string;
  12948. /**
  12949. * Returns the Size hash code.
  12950. * @returns a hash code for a unique width and height
  12951. */
  12952. getHashCode(): number;
  12953. /**
  12954. * Updates the current size from the given one.
  12955. * @param src the given size
  12956. */
  12957. copyFrom(src: Size): void;
  12958. /**
  12959. * Updates in place the current Size from the given floats.
  12960. * @param width width of the new size
  12961. * @param height height of the new size
  12962. * @returns the updated Size.
  12963. */
  12964. copyFromFloats(width: number, height: number): Size;
  12965. /**
  12966. * Updates in place the current Size from the given floats.
  12967. * @param width width to set
  12968. * @param height height to set
  12969. * @returns the updated Size.
  12970. */
  12971. set(width: number, height: number): Size;
  12972. /**
  12973. * Multiplies the width and height by numbers
  12974. * @param w factor to multiple the width by
  12975. * @param h factor to multiple the height by
  12976. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12977. */
  12978. multiplyByFloats(w: number, h: number): Size;
  12979. /**
  12980. * Clones the size
  12981. * @returns a new Size copied from the given one.
  12982. */
  12983. clone(): Size;
  12984. /**
  12985. * True if the current Size and the given one width and height are strictly equal.
  12986. * @param other the other size to compare against
  12987. * @returns True if the current Size and the given one width and height are strictly equal.
  12988. */
  12989. equals(other: Size): boolean;
  12990. /**
  12991. * The surface of the Size : width * height (float).
  12992. */
  12993. readonly surface: number;
  12994. /**
  12995. * Create a new size of zero
  12996. * @returns a new Size set to (0.0, 0.0)
  12997. */
  12998. static Zero(): Size;
  12999. /**
  13000. * Sums the width and height of two sizes
  13001. * @param otherSize size to add to this size
  13002. * @returns a new Size set as the addition result of the current Size and the given one.
  13003. */
  13004. add(otherSize: Size): Size;
  13005. /**
  13006. * Subtracts the width and height of two
  13007. * @param otherSize size to subtract to this size
  13008. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13009. */
  13010. subtract(otherSize: Size): Size;
  13011. /**
  13012. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13013. * @param start starting size to lerp between
  13014. * @param end end size to lerp between
  13015. * @param amount amount to lerp between the start and end values
  13016. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13017. */
  13018. static Lerp(start: Size, end: Size, amount: number): Size;
  13019. }
  13020. }
  13021. declare module "babylonjs/Animations/runtimeAnimation" {
  13022. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13023. import { Animatable } from "babylonjs/Animations/animatable";
  13024. import { Scene } from "babylonjs/scene";
  13025. /**
  13026. * Defines a runtime animation
  13027. */
  13028. export class RuntimeAnimation {
  13029. private _events;
  13030. /**
  13031. * The current frame of the runtime animation
  13032. */
  13033. private _currentFrame;
  13034. /**
  13035. * The animation used by the runtime animation
  13036. */
  13037. private _animation;
  13038. /**
  13039. * The target of the runtime animation
  13040. */
  13041. private _target;
  13042. /**
  13043. * The initiating animatable
  13044. */
  13045. private _host;
  13046. /**
  13047. * The original value of the runtime animation
  13048. */
  13049. private _originalValue;
  13050. /**
  13051. * The original blend value of the runtime animation
  13052. */
  13053. private _originalBlendValue;
  13054. /**
  13055. * The offsets cache of the runtime animation
  13056. */
  13057. private _offsetsCache;
  13058. /**
  13059. * The high limits cache of the runtime animation
  13060. */
  13061. private _highLimitsCache;
  13062. /**
  13063. * Specifies if the runtime animation has been stopped
  13064. */
  13065. private _stopped;
  13066. /**
  13067. * The blending factor of the runtime animation
  13068. */
  13069. private _blendingFactor;
  13070. /**
  13071. * The BabylonJS scene
  13072. */
  13073. private _scene;
  13074. /**
  13075. * The current value of the runtime animation
  13076. */
  13077. private _currentValue;
  13078. /** @hidden */
  13079. _animationState: _IAnimationState;
  13080. /**
  13081. * The active target of the runtime animation
  13082. */
  13083. private _activeTargets;
  13084. private _currentActiveTarget;
  13085. private _directTarget;
  13086. /**
  13087. * The target path of the runtime animation
  13088. */
  13089. private _targetPath;
  13090. /**
  13091. * The weight of the runtime animation
  13092. */
  13093. private _weight;
  13094. /**
  13095. * The ratio offset of the runtime animation
  13096. */
  13097. private _ratioOffset;
  13098. /**
  13099. * The previous delay of the runtime animation
  13100. */
  13101. private _previousDelay;
  13102. /**
  13103. * The previous ratio of the runtime animation
  13104. */
  13105. private _previousRatio;
  13106. private _enableBlending;
  13107. private _keys;
  13108. private _minFrame;
  13109. private _maxFrame;
  13110. private _minValue;
  13111. private _maxValue;
  13112. private _targetIsArray;
  13113. /**
  13114. * Gets the current frame of the runtime animation
  13115. */
  13116. readonly currentFrame: number;
  13117. /**
  13118. * Gets the weight of the runtime animation
  13119. */
  13120. readonly weight: number;
  13121. /**
  13122. * Gets the current value of the runtime animation
  13123. */
  13124. readonly currentValue: any;
  13125. /**
  13126. * Gets the target path of the runtime animation
  13127. */
  13128. readonly targetPath: string;
  13129. /**
  13130. * Gets the actual target of the runtime animation
  13131. */
  13132. readonly target: any;
  13133. /** @hidden */
  13134. _onLoop: () => void;
  13135. /**
  13136. * Create a new RuntimeAnimation object
  13137. * @param target defines the target of the animation
  13138. * @param animation defines the source animation object
  13139. * @param scene defines the hosting scene
  13140. * @param host defines the initiating Animatable
  13141. */
  13142. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13143. private _preparePath;
  13144. /**
  13145. * Gets the animation from the runtime animation
  13146. */
  13147. readonly animation: Animation;
  13148. /**
  13149. * Resets the runtime animation to the beginning
  13150. * @param restoreOriginal defines whether to restore the target property to the original value
  13151. */
  13152. reset(restoreOriginal?: boolean): void;
  13153. /**
  13154. * Specifies if the runtime animation is stopped
  13155. * @returns Boolean specifying if the runtime animation is stopped
  13156. */
  13157. isStopped(): boolean;
  13158. /**
  13159. * Disposes of the runtime animation
  13160. */
  13161. dispose(): void;
  13162. /**
  13163. * Apply the interpolated value to the target
  13164. * @param currentValue defines the value computed by the animation
  13165. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13166. */
  13167. setValue(currentValue: any, weight: number): void;
  13168. private _getOriginalValues;
  13169. private _setValue;
  13170. /**
  13171. * Gets the loop pmode of the runtime animation
  13172. * @returns Loop Mode
  13173. */
  13174. private _getCorrectLoopMode;
  13175. /**
  13176. * Move the current animation to a given frame
  13177. * @param frame defines the frame to move to
  13178. */
  13179. goToFrame(frame: number): void;
  13180. /**
  13181. * @hidden Internal use only
  13182. */
  13183. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13184. /**
  13185. * Execute the current animation
  13186. * @param delay defines the delay to add to the current frame
  13187. * @param from defines the lower bound of the animation range
  13188. * @param to defines the upper bound of the animation range
  13189. * @param loop defines if the current animation must loop
  13190. * @param speedRatio defines the current speed ratio
  13191. * @param weight defines the weight of the animation (default is -1 so no weight)
  13192. * @param onLoop optional callback called when animation loops
  13193. * @returns a boolean indicating if the animation is running
  13194. */
  13195. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13196. }
  13197. }
  13198. declare module "babylonjs/Animations/animatable" {
  13199. import { Animation } from "babylonjs/Animations/animation";
  13200. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13201. import { Nullable } from "babylonjs/types";
  13202. import { Observable } from "babylonjs/Misc/observable";
  13203. import { Scene } from "babylonjs/scene";
  13204. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13205. import { Node } from "babylonjs/node";
  13206. /**
  13207. * Class used to store an actual running animation
  13208. */
  13209. export class Animatable {
  13210. /** defines the target object */
  13211. target: any;
  13212. /** defines the starting frame number (default is 0) */
  13213. fromFrame: number;
  13214. /** defines the ending frame number (default is 100) */
  13215. toFrame: number;
  13216. /** defines if the animation must loop (default is false) */
  13217. loopAnimation: boolean;
  13218. /** defines a callback to call when animation ends if it is not looping */
  13219. onAnimationEnd?: (() => void) | null | undefined;
  13220. /** defines a callback to call when animation loops */
  13221. onAnimationLoop?: (() => void) | null | undefined;
  13222. private _localDelayOffset;
  13223. private _pausedDelay;
  13224. private _runtimeAnimations;
  13225. private _paused;
  13226. private _scene;
  13227. private _speedRatio;
  13228. private _weight;
  13229. private _syncRoot;
  13230. /**
  13231. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13232. * This will only apply for non looping animation (default is true)
  13233. */
  13234. disposeOnEnd: boolean;
  13235. /**
  13236. * Gets a boolean indicating if the animation has started
  13237. */
  13238. animationStarted: boolean;
  13239. /**
  13240. * Observer raised when the animation ends
  13241. */
  13242. onAnimationEndObservable: Observable<Animatable>;
  13243. /**
  13244. * Observer raised when the animation loops
  13245. */
  13246. onAnimationLoopObservable: Observable<Animatable>;
  13247. /**
  13248. * Gets the root Animatable used to synchronize and normalize animations
  13249. */
  13250. readonly syncRoot: Nullable<Animatable>;
  13251. /**
  13252. * Gets the current frame of the first RuntimeAnimation
  13253. * Used to synchronize Animatables
  13254. */
  13255. readonly masterFrame: number;
  13256. /**
  13257. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13258. */
  13259. weight: number;
  13260. /**
  13261. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13262. */
  13263. speedRatio: number;
  13264. /**
  13265. * Creates a new Animatable
  13266. * @param scene defines the hosting scene
  13267. * @param target defines the target object
  13268. * @param fromFrame defines the starting frame number (default is 0)
  13269. * @param toFrame defines the ending frame number (default is 100)
  13270. * @param loopAnimation defines if the animation must loop (default is false)
  13271. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13272. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13273. * @param animations defines a group of animation to add to the new Animatable
  13274. * @param onAnimationLoop defines a callback to call when animation loops
  13275. */
  13276. constructor(scene: Scene,
  13277. /** defines the target object */
  13278. target: any,
  13279. /** defines the starting frame number (default is 0) */
  13280. fromFrame?: number,
  13281. /** defines the ending frame number (default is 100) */
  13282. toFrame?: number,
  13283. /** defines if the animation must loop (default is false) */
  13284. loopAnimation?: boolean, speedRatio?: number,
  13285. /** defines a callback to call when animation ends if it is not looping */
  13286. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13287. /** defines a callback to call when animation loops */
  13288. onAnimationLoop?: (() => void) | null | undefined);
  13289. /**
  13290. * Synchronize and normalize current Animatable with a source Animatable
  13291. * This is useful when using animation weights and when animations are not of the same length
  13292. * @param root defines the root Animatable to synchronize with
  13293. * @returns the current Animatable
  13294. */
  13295. syncWith(root: Animatable): Animatable;
  13296. /**
  13297. * Gets the list of runtime animations
  13298. * @returns an array of RuntimeAnimation
  13299. */
  13300. getAnimations(): RuntimeAnimation[];
  13301. /**
  13302. * Adds more animations to the current animatable
  13303. * @param target defines the target of the animations
  13304. * @param animations defines the new animations to add
  13305. */
  13306. appendAnimations(target: any, animations: Animation[]): void;
  13307. /**
  13308. * Gets the source animation for a specific property
  13309. * @param property defines the propertyu to look for
  13310. * @returns null or the source animation for the given property
  13311. */
  13312. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13313. /**
  13314. * Gets the runtime animation for a specific property
  13315. * @param property defines the propertyu to look for
  13316. * @returns null or the runtime animation for the given property
  13317. */
  13318. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13319. /**
  13320. * Resets the animatable to its original state
  13321. */
  13322. reset(): void;
  13323. /**
  13324. * Allows the animatable to blend with current running animations
  13325. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13326. * @param blendingSpeed defines the blending speed to use
  13327. */
  13328. enableBlending(blendingSpeed: number): void;
  13329. /**
  13330. * Disable animation blending
  13331. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13332. */
  13333. disableBlending(): void;
  13334. /**
  13335. * Jump directly to a given frame
  13336. * @param frame defines the frame to jump to
  13337. */
  13338. goToFrame(frame: number): void;
  13339. /**
  13340. * Pause the animation
  13341. */
  13342. pause(): void;
  13343. /**
  13344. * Restart the animation
  13345. */
  13346. restart(): void;
  13347. private _raiseOnAnimationEnd;
  13348. /**
  13349. * Stop and delete the current animation
  13350. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13351. * @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)
  13352. */
  13353. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13354. /**
  13355. * Wait asynchronously for the animation to end
  13356. * @returns a promise which will be fullfilled when the animation ends
  13357. */
  13358. waitAsync(): Promise<Animatable>;
  13359. /** @hidden */
  13360. _animate(delay: number): boolean;
  13361. }
  13362. module "babylonjs/scene" {
  13363. interface Scene {
  13364. /** @hidden */
  13365. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13366. /** @hidden */
  13367. _processLateAnimationBindingsForMatrices(holder: {
  13368. totalWeight: number;
  13369. animations: RuntimeAnimation[];
  13370. originalValue: Matrix;
  13371. }): any;
  13372. /** @hidden */
  13373. _processLateAnimationBindingsForQuaternions(holder: {
  13374. totalWeight: number;
  13375. animations: RuntimeAnimation[];
  13376. originalValue: Quaternion;
  13377. }, refQuaternion: Quaternion): Quaternion;
  13378. /** @hidden */
  13379. _processLateAnimationBindings(): void;
  13380. /**
  13381. * Will start the animation sequence of a given target
  13382. * @param target defines the target
  13383. * @param from defines from which frame should animation start
  13384. * @param to defines until which frame should animation run.
  13385. * @param weight defines the weight to apply to the animation (1.0 by default)
  13386. * @param loop defines if the animation loops
  13387. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13388. * @param onAnimationEnd defines the function to be executed when the animation ends
  13389. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13390. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13391. * @param onAnimationLoop defines the callback to call when an animation loops
  13392. * @returns the animatable object created for this animation
  13393. */
  13394. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13395. /**
  13396. * Will start the animation sequence of a given target
  13397. * @param target defines the target
  13398. * @param from defines from which frame should animation start
  13399. * @param to defines until which frame should animation run.
  13400. * @param loop defines if the animation loops
  13401. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13402. * @param onAnimationEnd defines the function to be executed when the animation ends
  13403. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13404. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13405. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13406. * @param onAnimationLoop defines the callback to call when an animation loops
  13407. * @returns the animatable object created for this animation
  13408. */
  13409. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13410. /**
  13411. * Will start the animation sequence of a given target and its hierarchy
  13412. * @param target defines the target
  13413. * @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.
  13414. * @param from defines from which frame should animation start
  13415. * @param to defines until which frame should animation run.
  13416. * @param loop defines if the animation loops
  13417. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13418. * @param onAnimationEnd defines the function to be executed when the animation ends
  13419. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13420. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13421. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13422. * @param onAnimationLoop defines the callback to call when an animation loops
  13423. * @returns the list of created animatables
  13424. */
  13425. 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[];
  13426. /**
  13427. * Begin a new animation on a given node
  13428. * @param target defines the target where the animation will take place
  13429. * @param animations defines the list of animations to start
  13430. * @param from defines the initial value
  13431. * @param to defines the final value
  13432. * @param loop defines if you want animation to loop (off by default)
  13433. * @param speedRatio defines the speed ratio to apply to all animations
  13434. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13435. * @param onAnimationLoop defines the callback to call when an animation loops
  13436. * @returns the list of created animatables
  13437. */
  13438. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13439. /**
  13440. * Begin a new animation on a given node and its hierarchy
  13441. * @param target defines the root node where the animation will take place
  13442. * @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.
  13443. * @param animations defines the list of animations to start
  13444. * @param from defines the initial value
  13445. * @param to defines the final value
  13446. * @param loop defines if you want animation to loop (off by default)
  13447. * @param speedRatio defines the speed ratio to apply to all animations
  13448. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13449. * @param onAnimationLoop defines the callback to call when an animation loops
  13450. * @returns the list of animatables created for all nodes
  13451. */
  13452. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13453. /**
  13454. * Gets the animatable associated with a specific target
  13455. * @param target defines the target of the animatable
  13456. * @returns the required animatable if found
  13457. */
  13458. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13459. /**
  13460. * Gets all animatables associated with a given target
  13461. * @param target defines the target to look animatables for
  13462. * @returns an array of Animatables
  13463. */
  13464. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13465. /**
  13466. * Stops and removes all animations that have been applied to the scene
  13467. */
  13468. stopAllAnimations(): void;
  13469. }
  13470. }
  13471. module "babylonjs/Bones/bone" {
  13472. interface Bone {
  13473. /**
  13474. * Copy an animation range from another bone
  13475. * @param source defines the source bone
  13476. * @param rangeName defines the range name to copy
  13477. * @param frameOffset defines the frame offset
  13478. * @param rescaleAsRequired defines if rescaling must be applied if required
  13479. * @param skelDimensionsRatio defines the scaling ratio
  13480. * @returns true if operation was successful
  13481. */
  13482. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13483. }
  13484. }
  13485. }
  13486. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13487. /**
  13488. * Class used to override all child animations of a given target
  13489. */
  13490. export class AnimationPropertiesOverride {
  13491. /**
  13492. * Gets or sets a value indicating if animation blending must be used
  13493. */
  13494. enableBlending: boolean;
  13495. /**
  13496. * Gets or sets the blending speed to use when enableBlending is true
  13497. */
  13498. blendingSpeed: number;
  13499. /**
  13500. * Gets or sets the default loop mode to use
  13501. */
  13502. loopMode: number;
  13503. }
  13504. }
  13505. declare module "babylonjs/Bones/skeleton" {
  13506. import { Bone } from "babylonjs/Bones/bone";
  13507. import { Observable } from "babylonjs/Misc/observable";
  13508. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13509. import { Scene } from "babylonjs/scene";
  13510. import { Nullable } from "babylonjs/types";
  13511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13512. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13513. import { Animatable } from "babylonjs/Animations/animatable";
  13514. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13515. import { Animation } from "babylonjs/Animations/animation";
  13516. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13517. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13518. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13519. /**
  13520. * Class used to handle skinning animations
  13521. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13522. */
  13523. export class Skeleton implements IAnimatable {
  13524. /** defines the skeleton name */
  13525. name: string;
  13526. /** defines the skeleton Id */
  13527. id: string;
  13528. /**
  13529. * Defines the list of child bones
  13530. */
  13531. bones: Bone[];
  13532. /**
  13533. * Defines an estimate of the dimension of the skeleton at rest
  13534. */
  13535. dimensionsAtRest: Vector3;
  13536. /**
  13537. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13538. */
  13539. needInitialSkinMatrix: boolean;
  13540. /**
  13541. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13542. */
  13543. overrideMesh: Nullable<AbstractMesh>;
  13544. /**
  13545. * Gets the list of animations attached to this skeleton
  13546. */
  13547. animations: Array<Animation>;
  13548. private _scene;
  13549. private _isDirty;
  13550. private _transformMatrices;
  13551. private _transformMatrixTexture;
  13552. private _meshesWithPoseMatrix;
  13553. private _animatables;
  13554. private _identity;
  13555. private _synchronizedWithMesh;
  13556. private _ranges;
  13557. private _lastAbsoluteTransformsUpdateId;
  13558. private _canUseTextureForBones;
  13559. private _uniqueId;
  13560. /** @hidden */
  13561. _numBonesWithLinkedTransformNode: number;
  13562. /** @hidden */
  13563. _hasWaitingData: Nullable<boolean>;
  13564. /**
  13565. * Specifies if the skeleton should be serialized
  13566. */
  13567. doNotSerialize: boolean;
  13568. private _useTextureToStoreBoneMatrices;
  13569. /**
  13570. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13571. * Please note that this option is not available if the hardware does not support it
  13572. */
  13573. useTextureToStoreBoneMatrices: boolean;
  13574. private _animationPropertiesOverride;
  13575. /**
  13576. * Gets or sets the animation properties override
  13577. */
  13578. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13579. /**
  13580. * List of inspectable custom properties (used by the Inspector)
  13581. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13582. */
  13583. inspectableCustomProperties: IInspectable[];
  13584. /**
  13585. * An observable triggered before computing the skeleton's matrices
  13586. */
  13587. onBeforeComputeObservable: Observable<Skeleton>;
  13588. /**
  13589. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13590. */
  13591. readonly isUsingTextureForMatrices: boolean;
  13592. /**
  13593. * Gets the unique ID of this skeleton
  13594. */
  13595. readonly uniqueId: number;
  13596. /**
  13597. * Creates a new skeleton
  13598. * @param name defines the skeleton name
  13599. * @param id defines the skeleton Id
  13600. * @param scene defines the hosting scene
  13601. */
  13602. constructor(
  13603. /** defines the skeleton name */
  13604. name: string,
  13605. /** defines the skeleton Id */
  13606. id: string, scene: Scene);
  13607. /**
  13608. * Gets the current object class name.
  13609. * @return the class name
  13610. */
  13611. getClassName(): string;
  13612. /**
  13613. * Returns an array containing the root bones
  13614. * @returns an array containing the root bones
  13615. */
  13616. getChildren(): Array<Bone>;
  13617. /**
  13618. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13619. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13620. * @returns a Float32Array containing matrices data
  13621. */
  13622. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13623. /**
  13624. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13625. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13626. * @returns a raw texture containing the data
  13627. */
  13628. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13629. /**
  13630. * Gets the current hosting scene
  13631. * @returns a scene object
  13632. */
  13633. getScene(): Scene;
  13634. /**
  13635. * Gets a string representing the current skeleton data
  13636. * @param fullDetails defines a boolean indicating if we want a verbose version
  13637. * @returns a string representing the current skeleton data
  13638. */
  13639. toString(fullDetails?: boolean): string;
  13640. /**
  13641. * Get bone's index searching by name
  13642. * @param name defines bone's name to search for
  13643. * @return the indice of the bone. Returns -1 if not found
  13644. */
  13645. getBoneIndexByName(name: string): number;
  13646. /**
  13647. * Creater a new animation range
  13648. * @param name defines the name of the range
  13649. * @param from defines the start key
  13650. * @param to defines the end key
  13651. */
  13652. createAnimationRange(name: string, from: number, to: number): void;
  13653. /**
  13654. * Delete a specific animation range
  13655. * @param name defines the name of the range
  13656. * @param deleteFrames defines if frames must be removed as well
  13657. */
  13658. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13659. /**
  13660. * Gets a specific animation range
  13661. * @param name defines the name of the range to look for
  13662. * @returns the requested animation range or null if not found
  13663. */
  13664. getAnimationRange(name: string): Nullable<AnimationRange>;
  13665. /**
  13666. * Gets the list of all animation ranges defined on this skeleton
  13667. * @returns an array
  13668. */
  13669. getAnimationRanges(): Nullable<AnimationRange>[];
  13670. /**
  13671. * Copy animation range from a source skeleton.
  13672. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13673. * @param source defines the source skeleton
  13674. * @param name defines the name of the range to copy
  13675. * @param rescaleAsRequired defines if rescaling must be applied if required
  13676. * @returns true if operation was successful
  13677. */
  13678. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13679. /**
  13680. * Forces the skeleton to go to rest pose
  13681. */
  13682. returnToRest(): void;
  13683. private _getHighestAnimationFrame;
  13684. /**
  13685. * Begin a specific animation range
  13686. * @param name defines the name of the range to start
  13687. * @param loop defines if looping must be turned on (false by default)
  13688. * @param speedRatio defines the speed ratio to apply (1 by default)
  13689. * @param onAnimationEnd defines a callback which will be called when animation will end
  13690. * @returns a new animatable
  13691. */
  13692. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13693. /** @hidden */
  13694. _markAsDirty(): void;
  13695. /** @hidden */
  13696. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13697. /** @hidden */
  13698. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13699. private _computeTransformMatrices;
  13700. /**
  13701. * Build all resources required to render a skeleton
  13702. */
  13703. prepare(): void;
  13704. /**
  13705. * Gets the list of animatables currently running for this skeleton
  13706. * @returns an array of animatables
  13707. */
  13708. getAnimatables(): IAnimatable[];
  13709. /**
  13710. * Clone the current skeleton
  13711. * @param name defines the name of the new skeleton
  13712. * @param id defines the id of the new skeleton
  13713. * @returns the new skeleton
  13714. */
  13715. clone(name: string, id: string): Skeleton;
  13716. /**
  13717. * Enable animation blending for this skeleton
  13718. * @param blendingSpeed defines the blending speed to apply
  13719. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13720. */
  13721. enableBlending(blendingSpeed?: number): void;
  13722. /**
  13723. * Releases all resources associated with the current skeleton
  13724. */
  13725. dispose(): void;
  13726. /**
  13727. * Serialize the skeleton in a JSON object
  13728. * @returns a JSON object
  13729. */
  13730. serialize(): any;
  13731. /**
  13732. * Creates a new skeleton from serialized data
  13733. * @param parsedSkeleton defines the serialized data
  13734. * @param scene defines the hosting scene
  13735. * @returns a new skeleton
  13736. */
  13737. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13738. /**
  13739. * Compute all node absolute transforms
  13740. * @param forceUpdate defines if computation must be done even if cache is up to date
  13741. */
  13742. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13743. /**
  13744. * Gets the root pose matrix
  13745. * @returns a matrix
  13746. */
  13747. getPoseMatrix(): Nullable<Matrix>;
  13748. /**
  13749. * Sorts bones per internal index
  13750. */
  13751. sortBones(): void;
  13752. private _sortBones;
  13753. }
  13754. }
  13755. declare module "babylonjs/Bones/bone" {
  13756. import { Skeleton } from "babylonjs/Bones/skeleton";
  13757. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13758. import { Nullable } from "babylonjs/types";
  13759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13760. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13761. import { Node } from "babylonjs/node";
  13762. import { Space } from "babylonjs/Maths/math.axis";
  13763. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13764. /**
  13765. * Class used to store bone information
  13766. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13767. */
  13768. export class Bone extends Node {
  13769. /**
  13770. * defines the bone name
  13771. */
  13772. name: string;
  13773. private static _tmpVecs;
  13774. private static _tmpQuat;
  13775. private static _tmpMats;
  13776. /**
  13777. * Gets the list of child bones
  13778. */
  13779. children: Bone[];
  13780. /** Gets the animations associated with this bone */
  13781. animations: import("babylonjs/Animations/animation").Animation[];
  13782. /**
  13783. * Gets or sets bone length
  13784. */
  13785. length: number;
  13786. /**
  13787. * @hidden Internal only
  13788. * Set this value to map this bone to a different index in the transform matrices
  13789. * Set this value to -1 to exclude the bone from the transform matrices
  13790. */
  13791. _index: Nullable<number>;
  13792. private _skeleton;
  13793. private _localMatrix;
  13794. private _restPose;
  13795. private _baseMatrix;
  13796. private _absoluteTransform;
  13797. private _invertedAbsoluteTransform;
  13798. private _parent;
  13799. private _scalingDeterminant;
  13800. private _worldTransform;
  13801. private _localScaling;
  13802. private _localRotation;
  13803. private _localPosition;
  13804. private _needToDecompose;
  13805. private _needToCompose;
  13806. /** @hidden */
  13807. _linkedTransformNode: Nullable<TransformNode>;
  13808. /** @hidden */
  13809. _waitingTransformNodeId: Nullable<string>;
  13810. /** @hidden */
  13811. /** @hidden */
  13812. _matrix: Matrix;
  13813. /**
  13814. * Create a new bone
  13815. * @param name defines the bone name
  13816. * @param skeleton defines the parent skeleton
  13817. * @param parentBone defines the parent (can be null if the bone is the root)
  13818. * @param localMatrix defines the local matrix
  13819. * @param restPose defines the rest pose matrix
  13820. * @param baseMatrix defines the base matrix
  13821. * @param index defines index of the bone in the hiearchy
  13822. */
  13823. constructor(
  13824. /**
  13825. * defines the bone name
  13826. */
  13827. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13828. /**
  13829. * Gets the current object class name.
  13830. * @return the class name
  13831. */
  13832. getClassName(): string;
  13833. /**
  13834. * Gets the parent skeleton
  13835. * @returns a skeleton
  13836. */
  13837. getSkeleton(): Skeleton;
  13838. /**
  13839. * Gets parent bone
  13840. * @returns a bone or null if the bone is the root of the bone hierarchy
  13841. */
  13842. getParent(): Nullable<Bone>;
  13843. /**
  13844. * Returns an array containing the root bones
  13845. * @returns an array containing the root bones
  13846. */
  13847. getChildren(): Array<Bone>;
  13848. /**
  13849. * Sets the parent bone
  13850. * @param parent defines the parent (can be null if the bone is the root)
  13851. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13852. */
  13853. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13854. /**
  13855. * Gets the local matrix
  13856. * @returns a matrix
  13857. */
  13858. getLocalMatrix(): Matrix;
  13859. /**
  13860. * Gets the base matrix (initial matrix which remains unchanged)
  13861. * @returns a matrix
  13862. */
  13863. getBaseMatrix(): Matrix;
  13864. /**
  13865. * Gets the rest pose matrix
  13866. * @returns a matrix
  13867. */
  13868. getRestPose(): Matrix;
  13869. /**
  13870. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13871. */
  13872. getWorldMatrix(): Matrix;
  13873. /**
  13874. * Sets the local matrix to rest pose matrix
  13875. */
  13876. returnToRest(): void;
  13877. /**
  13878. * Gets the inverse of the absolute transform matrix.
  13879. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13880. * @returns a matrix
  13881. */
  13882. getInvertedAbsoluteTransform(): Matrix;
  13883. /**
  13884. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13885. * @returns a matrix
  13886. */
  13887. getAbsoluteTransform(): Matrix;
  13888. /**
  13889. * Links with the given transform node.
  13890. * The local matrix of this bone is copied from the transform node every frame.
  13891. * @param transformNode defines the transform node to link to
  13892. */
  13893. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13894. /**
  13895. * Gets the node used to drive the bone's transformation
  13896. * @returns a transform node or null
  13897. */
  13898. getTransformNode(): Nullable<TransformNode>;
  13899. /** Gets or sets current position (in local space) */
  13900. position: Vector3;
  13901. /** Gets or sets current rotation (in local space) */
  13902. rotation: Vector3;
  13903. /** Gets or sets current rotation quaternion (in local space) */
  13904. rotationQuaternion: Quaternion;
  13905. /** Gets or sets current scaling (in local space) */
  13906. scaling: Vector3;
  13907. /**
  13908. * Gets the animation properties override
  13909. */
  13910. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13911. private _decompose;
  13912. private _compose;
  13913. /**
  13914. * Update the base and local matrices
  13915. * @param matrix defines the new base or local matrix
  13916. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13917. * @param updateLocalMatrix defines if the local matrix should be updated
  13918. */
  13919. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13920. /** @hidden */
  13921. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13922. /**
  13923. * Flag the bone as dirty (Forcing it to update everything)
  13924. */
  13925. markAsDirty(): void;
  13926. /** @hidden */
  13927. _markAsDirtyAndCompose(): void;
  13928. private _markAsDirtyAndDecompose;
  13929. /**
  13930. * Translate the bone in local or world space
  13931. * @param vec The amount to translate the bone
  13932. * @param space The space that the translation is in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. */
  13935. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13936. /**
  13937. * Set the postion of the bone in local or world space
  13938. * @param position The position to set the bone
  13939. * @param space The space that the position is in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. */
  13942. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13943. /**
  13944. * Set the absolute position of the bone (world space)
  13945. * @param position The position to set the bone
  13946. * @param mesh The mesh that this bone is attached to
  13947. */
  13948. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13949. /**
  13950. * Scale the bone on the x, y and z axes (in local space)
  13951. * @param x The amount to scale the bone on the x axis
  13952. * @param y The amount to scale the bone on the y axis
  13953. * @param z The amount to scale the bone on the z axis
  13954. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13955. */
  13956. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13957. /**
  13958. * Set the bone scaling in local space
  13959. * @param scale defines the scaling vector
  13960. */
  13961. setScale(scale: Vector3): void;
  13962. /**
  13963. * Gets the current scaling in local space
  13964. * @returns the current scaling vector
  13965. */
  13966. getScale(): Vector3;
  13967. /**
  13968. * Gets the current scaling in local space and stores it in a target vector
  13969. * @param result defines the target vector
  13970. */
  13971. getScaleToRef(result: Vector3): void;
  13972. /**
  13973. * Set the yaw, pitch, and roll of the bone in local or world space
  13974. * @param yaw The rotation of the bone on the y axis
  13975. * @param pitch The rotation of the bone on the x axis
  13976. * @param roll The rotation of the bone on the z axis
  13977. * @param space The space that the axes of rotation are in
  13978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13979. */
  13980. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13981. /**
  13982. * Add a rotation to the bone on an axis in local or world space
  13983. * @param axis The axis to rotate the bone on
  13984. * @param amount The amount to rotate the bone
  13985. * @param space The space that the axis is in
  13986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13987. */
  13988. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13989. /**
  13990. * Set the rotation of the bone to a particular axis angle in local or world space
  13991. * @param axis The axis to rotate the bone on
  13992. * @param angle The angle that the bone should be rotated to
  13993. * @param space The space that the axis is in
  13994. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13995. */
  13996. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13997. /**
  13998. * Set the euler rotation of the bone in local of world space
  13999. * @param rotation The euler rotation that the bone should be set to
  14000. * @param space The space that the rotation is in
  14001. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14002. */
  14003. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14004. /**
  14005. * Set the quaternion rotation of the bone in local of world space
  14006. * @param quat The quaternion rotation that the bone should be set to
  14007. * @param space The space that the rotation is in
  14008. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14009. */
  14010. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14011. /**
  14012. * Set the rotation matrix of the bone in local of world space
  14013. * @param rotMat The rotation matrix that the bone should be set to
  14014. * @param space The space that the rotation is in
  14015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14016. */
  14017. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14018. private _rotateWithMatrix;
  14019. private _getNegativeRotationToRef;
  14020. /**
  14021. * Get the position of the bone in local or world space
  14022. * @param space The space that the returned position is in
  14023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14024. * @returns The position of the bone
  14025. */
  14026. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14027. /**
  14028. * Copy the position of the bone to a vector3 in local or world space
  14029. * @param space The space that the returned position is in
  14030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14031. * @param result The vector3 to copy the position to
  14032. */
  14033. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14034. /**
  14035. * Get the absolute position of the bone (world space)
  14036. * @param mesh The mesh that this bone is attached to
  14037. * @returns The absolute position of the bone
  14038. */
  14039. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14040. /**
  14041. * Copy the absolute position of the bone (world space) to the result param
  14042. * @param mesh The mesh that this bone is attached to
  14043. * @param result The vector3 to copy the absolute position to
  14044. */
  14045. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14046. /**
  14047. * Compute the absolute transforms of this bone and its children
  14048. */
  14049. computeAbsoluteTransforms(): void;
  14050. /**
  14051. * Get the world direction from an axis that is in the local space of the bone
  14052. * @param localAxis The local direction that is used to compute the world direction
  14053. * @param mesh The mesh that this bone is attached to
  14054. * @returns The world direction
  14055. */
  14056. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14057. /**
  14058. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14059. * @param localAxis The local direction that is used to compute the world direction
  14060. * @param mesh The mesh that this bone is attached to
  14061. * @param result The vector3 that the world direction will be copied to
  14062. */
  14063. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14064. /**
  14065. * Get the euler rotation of the bone in local or world space
  14066. * @param space The space that the rotation should be in
  14067. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14068. * @returns The euler rotation
  14069. */
  14070. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14071. /**
  14072. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14073. * @param space The space that the rotation should be in
  14074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14075. * @param result The vector3 that the rotation should be copied to
  14076. */
  14077. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14078. /**
  14079. * Get the quaternion rotation of the bone in either local or world space
  14080. * @param space The space that the rotation should be in
  14081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14082. * @returns The quaternion rotation
  14083. */
  14084. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14085. /**
  14086. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14087. * @param space The space that the rotation should be in
  14088. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14089. * @param result The quaternion that the rotation should be copied to
  14090. */
  14091. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14092. /**
  14093. * Get the rotation matrix of the bone in local or world space
  14094. * @param space The space that the rotation should be in
  14095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14096. * @returns The rotation matrix
  14097. */
  14098. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14099. /**
  14100. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14101. * @param space The space that the rotation should be in
  14102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14103. * @param result The quaternion that the rotation should be copied to
  14104. */
  14105. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14106. /**
  14107. * Get the world position of a point that is in the local space of the bone
  14108. * @param position The local position
  14109. * @param mesh The mesh that this bone is attached to
  14110. * @returns The world position
  14111. */
  14112. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14113. /**
  14114. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14115. * @param position The local position
  14116. * @param mesh The mesh that this bone is attached to
  14117. * @param result The vector3 that the world position should be copied to
  14118. */
  14119. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14120. /**
  14121. * Get the local position of a point that is in world space
  14122. * @param position The world position
  14123. * @param mesh The mesh that this bone is attached to
  14124. * @returns The local position
  14125. */
  14126. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14127. /**
  14128. * Get the local position of a point that is in world space and copy it to the result param
  14129. * @param position The world position
  14130. * @param mesh The mesh that this bone is attached to
  14131. * @param result The vector3 that the local position should be copied to
  14132. */
  14133. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14134. }
  14135. }
  14136. declare module "babylonjs/Meshes/transformNode" {
  14137. import { DeepImmutable } from "babylonjs/types";
  14138. import { Observable } from "babylonjs/Misc/observable";
  14139. import { Nullable } from "babylonjs/types";
  14140. import { Camera } from "babylonjs/Cameras/camera";
  14141. import { Scene } from "babylonjs/scene";
  14142. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14143. import { Node } from "babylonjs/node";
  14144. import { Bone } from "babylonjs/Bones/bone";
  14145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14146. import { Space } from "babylonjs/Maths/math.axis";
  14147. /**
  14148. * 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.
  14149. * @see https://doc.babylonjs.com/how_to/transformnode
  14150. */
  14151. export class TransformNode extends Node {
  14152. /**
  14153. * Object will not rotate to face the camera
  14154. */
  14155. static BILLBOARDMODE_NONE: number;
  14156. /**
  14157. * Object will rotate to face the camera but only on the x axis
  14158. */
  14159. static BILLBOARDMODE_X: number;
  14160. /**
  14161. * Object will rotate to face the camera but only on the y axis
  14162. */
  14163. static BILLBOARDMODE_Y: number;
  14164. /**
  14165. * Object will rotate to face the camera but only on the z axis
  14166. */
  14167. static BILLBOARDMODE_Z: number;
  14168. /**
  14169. * Object will rotate to face the camera
  14170. */
  14171. static BILLBOARDMODE_ALL: number;
  14172. /**
  14173. * Object will rotate to face the camera's position instead of orientation
  14174. */
  14175. static BILLBOARDMODE_USE_POSITION: number;
  14176. private _forward;
  14177. private _forwardInverted;
  14178. private _up;
  14179. private _right;
  14180. private _rightInverted;
  14181. private _position;
  14182. private _rotation;
  14183. private _rotationQuaternion;
  14184. protected _scaling: Vector3;
  14185. protected _isDirty: boolean;
  14186. private _transformToBoneReferal;
  14187. private _isAbsoluteSynced;
  14188. private _billboardMode;
  14189. /**
  14190. * Gets or sets the billboard mode. Default is 0.
  14191. *
  14192. * | Value | Type | Description |
  14193. * | --- | --- | --- |
  14194. * | 0 | BILLBOARDMODE_NONE | |
  14195. * | 1 | BILLBOARDMODE_X | |
  14196. * | 2 | BILLBOARDMODE_Y | |
  14197. * | 4 | BILLBOARDMODE_Z | |
  14198. * | 7 | BILLBOARDMODE_ALL | |
  14199. *
  14200. */
  14201. billboardMode: number;
  14202. private _preserveParentRotationForBillboard;
  14203. /**
  14204. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14205. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14206. */
  14207. preserveParentRotationForBillboard: boolean;
  14208. /**
  14209. * 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
  14210. */
  14211. scalingDeterminant: number;
  14212. private _infiniteDistance;
  14213. /**
  14214. * Gets or sets the distance of the object to max, often used by skybox
  14215. */
  14216. infiniteDistance: boolean;
  14217. /**
  14218. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14219. * By default the system will update normals to compensate
  14220. */
  14221. ignoreNonUniformScaling: boolean;
  14222. /**
  14223. * 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
  14224. */
  14225. reIntegrateRotationIntoRotationQuaternion: boolean;
  14226. /** @hidden */
  14227. _poseMatrix: Nullable<Matrix>;
  14228. /** @hidden */
  14229. _localMatrix: Matrix;
  14230. private _usePivotMatrix;
  14231. private _absolutePosition;
  14232. private _absoluteScaling;
  14233. private _absoluteRotationQuaternion;
  14234. private _pivotMatrix;
  14235. private _pivotMatrixInverse;
  14236. protected _postMultiplyPivotMatrix: boolean;
  14237. protected _isWorldMatrixFrozen: boolean;
  14238. /** @hidden */
  14239. _indexInSceneTransformNodesArray: number;
  14240. /**
  14241. * An event triggered after the world matrix is updated
  14242. */
  14243. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14244. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14245. /**
  14246. * Gets a string identifying the name of the class
  14247. * @returns "TransformNode" string
  14248. */
  14249. getClassName(): string;
  14250. /**
  14251. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14252. */
  14253. position: Vector3;
  14254. /**
  14255. * 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)).
  14256. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14257. */
  14258. rotation: Vector3;
  14259. /**
  14260. * 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)).
  14261. */
  14262. scaling: Vector3;
  14263. /**
  14264. * 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).
  14265. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14266. */
  14267. rotationQuaternion: Nullable<Quaternion>;
  14268. /**
  14269. * The forward direction of that transform in world space.
  14270. */
  14271. readonly forward: Vector3;
  14272. /**
  14273. * The up direction of that transform in world space.
  14274. */
  14275. readonly up: Vector3;
  14276. /**
  14277. * The right direction of that transform in world space.
  14278. */
  14279. readonly right: Vector3;
  14280. /**
  14281. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14282. * @param matrix the matrix to copy the pose from
  14283. * @returns this TransformNode.
  14284. */
  14285. updatePoseMatrix(matrix: Matrix): TransformNode;
  14286. /**
  14287. * Returns the mesh Pose matrix.
  14288. * @returns the pose matrix
  14289. */
  14290. getPoseMatrix(): Matrix;
  14291. /** @hidden */
  14292. _isSynchronized(): boolean;
  14293. /** @hidden */
  14294. _initCache(): void;
  14295. /**
  14296. * Flag the transform node as dirty (Forcing it to update everything)
  14297. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14298. * @returns this transform node
  14299. */
  14300. markAsDirty(property: string): TransformNode;
  14301. /**
  14302. * Returns the current mesh absolute position.
  14303. * Returns a Vector3.
  14304. */
  14305. readonly absolutePosition: Vector3;
  14306. /**
  14307. * Returns the current mesh absolute scaling.
  14308. * Returns a Vector3.
  14309. */
  14310. readonly absoluteScaling: Vector3;
  14311. /**
  14312. * Returns the current mesh absolute rotation.
  14313. * Returns a Quaternion.
  14314. */
  14315. readonly absoluteRotationQuaternion: Quaternion;
  14316. /**
  14317. * Sets a new matrix to apply before all other transformation
  14318. * @param matrix defines the transform matrix
  14319. * @returns the current TransformNode
  14320. */
  14321. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14322. /**
  14323. * Sets a new pivot matrix to the current node
  14324. * @param matrix defines the new pivot matrix to use
  14325. * @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
  14326. * @returns the current TransformNode
  14327. */
  14328. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14329. /**
  14330. * Returns the mesh pivot matrix.
  14331. * Default : Identity.
  14332. * @returns the matrix
  14333. */
  14334. getPivotMatrix(): Matrix;
  14335. /**
  14336. * Instantiate (when possible) or clone that node with its hierarchy
  14337. * @param newParent defines the new parent to use for the instance (or clone)
  14338. * @returns an instance (or a clone) of the current node with its hiearchy
  14339. */
  14340. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14341. /**
  14342. * Prevents the World matrix to be computed any longer
  14343. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14344. * @returns the TransformNode.
  14345. */
  14346. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14347. /**
  14348. * Allows back the World matrix computation.
  14349. * @returns the TransformNode.
  14350. */
  14351. unfreezeWorldMatrix(): this;
  14352. /**
  14353. * True if the World matrix has been frozen.
  14354. */
  14355. readonly isWorldMatrixFrozen: boolean;
  14356. /**
  14357. * Retuns the mesh absolute position in the World.
  14358. * @returns a Vector3.
  14359. */
  14360. getAbsolutePosition(): Vector3;
  14361. /**
  14362. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14363. * @param absolutePosition the absolute position to set
  14364. * @returns the TransformNode.
  14365. */
  14366. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14367. /**
  14368. * Sets the mesh position in its local space.
  14369. * @param vector3 the position to set in localspace
  14370. * @returns the TransformNode.
  14371. */
  14372. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14373. /**
  14374. * Returns the mesh position in the local space from the current World matrix values.
  14375. * @returns a new Vector3.
  14376. */
  14377. getPositionExpressedInLocalSpace(): Vector3;
  14378. /**
  14379. * Translates the mesh along the passed Vector3 in its local space.
  14380. * @param vector3 the distance to translate in localspace
  14381. * @returns the TransformNode.
  14382. */
  14383. locallyTranslate(vector3: Vector3): TransformNode;
  14384. private static _lookAtVectorCache;
  14385. /**
  14386. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14387. * @param targetPoint the position (must be in same space as current mesh) to look at
  14388. * @param yawCor optional yaw (y-axis) correction in radians
  14389. * @param pitchCor optional pitch (x-axis) correction in radians
  14390. * @param rollCor optional roll (z-axis) correction in radians
  14391. * @param space the choosen space of the target
  14392. * @returns the TransformNode.
  14393. */
  14394. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14395. /**
  14396. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14397. * This Vector3 is expressed in the World space.
  14398. * @param localAxis axis to rotate
  14399. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14400. */
  14401. getDirection(localAxis: Vector3): Vector3;
  14402. /**
  14403. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14404. * localAxis is expressed in the mesh local space.
  14405. * result is computed in the Wordl space from the mesh World matrix.
  14406. * @param localAxis axis to rotate
  14407. * @param result the resulting transformnode
  14408. * @returns this TransformNode.
  14409. */
  14410. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14411. /**
  14412. * Sets this transform node rotation to the given local axis.
  14413. * @param localAxis the axis in local space
  14414. * @param yawCor optional yaw (y-axis) correction in radians
  14415. * @param pitchCor optional pitch (x-axis) correction in radians
  14416. * @param rollCor optional roll (z-axis) correction in radians
  14417. * @returns this TransformNode
  14418. */
  14419. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14420. /**
  14421. * Sets a new pivot point to the current node
  14422. * @param point defines the new pivot point to use
  14423. * @param space defines if the point is in world or local space (local by default)
  14424. * @returns the current TransformNode
  14425. */
  14426. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14427. /**
  14428. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14429. * @returns the pivot point
  14430. */
  14431. getPivotPoint(): Vector3;
  14432. /**
  14433. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14434. * @param result the vector3 to store the result
  14435. * @returns this TransformNode.
  14436. */
  14437. getPivotPointToRef(result: Vector3): TransformNode;
  14438. /**
  14439. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14440. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14441. */
  14442. getAbsolutePivotPoint(): Vector3;
  14443. /**
  14444. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14445. * @param result vector3 to store the result
  14446. * @returns this TransformNode.
  14447. */
  14448. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14449. /**
  14450. * Defines the passed node as the parent of the current node.
  14451. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14452. * @see https://doc.babylonjs.com/how_to/parenting
  14453. * @param node the node ot set as the parent
  14454. * @returns this TransformNode.
  14455. */
  14456. setParent(node: Nullable<Node>): TransformNode;
  14457. private _nonUniformScaling;
  14458. /**
  14459. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14460. */
  14461. readonly nonUniformScaling: boolean;
  14462. /** @hidden */
  14463. _updateNonUniformScalingState(value: boolean): boolean;
  14464. /**
  14465. * Attach the current TransformNode to another TransformNode associated with a bone
  14466. * @param bone Bone affecting the TransformNode
  14467. * @param affectedTransformNode TransformNode associated with the bone
  14468. * @returns this object
  14469. */
  14470. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14471. /**
  14472. * Detach the transform node if its associated with a bone
  14473. * @returns this object
  14474. */
  14475. detachFromBone(): TransformNode;
  14476. private static _rotationAxisCache;
  14477. /**
  14478. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14479. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14480. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14481. * The passed axis is also normalized.
  14482. * @param axis the axis to rotate around
  14483. * @param amount the amount to rotate in radians
  14484. * @param space Space to rotate in (Default: local)
  14485. * @returns the TransformNode.
  14486. */
  14487. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14488. /**
  14489. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14490. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14491. * The passed axis is also normalized. .
  14492. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14493. * @param point the point to rotate around
  14494. * @param axis the axis to rotate around
  14495. * @param amount the amount to rotate in radians
  14496. * @returns the TransformNode
  14497. */
  14498. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14499. /**
  14500. * Translates the mesh along the axis vector for the passed distance in the given space.
  14501. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14502. * @param axis the axis to translate in
  14503. * @param distance the distance to translate
  14504. * @param space Space to rotate in (Default: local)
  14505. * @returns the TransformNode.
  14506. */
  14507. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14508. /**
  14509. * Adds a rotation step to the mesh current rotation.
  14510. * x, y, z are Euler angles expressed in radians.
  14511. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14512. * This means this rotation is made in the mesh local space only.
  14513. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14514. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14515. * ```javascript
  14516. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14517. * ```
  14518. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14519. * 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.
  14520. * @param x Rotation to add
  14521. * @param y Rotation to add
  14522. * @param z Rotation to add
  14523. * @returns the TransformNode.
  14524. */
  14525. addRotation(x: number, y: number, z: number): TransformNode;
  14526. /**
  14527. * @hidden
  14528. */
  14529. protected _getEffectiveParent(): Nullable<Node>;
  14530. /**
  14531. * Computes the world matrix of the node
  14532. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14533. * @returns the world matrix
  14534. */
  14535. computeWorldMatrix(force?: boolean): Matrix;
  14536. protected _afterComputeWorldMatrix(): void;
  14537. /**
  14538. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14539. * @param func callback function to add
  14540. *
  14541. * @returns the TransformNode.
  14542. */
  14543. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14544. /**
  14545. * Removes a registered callback function.
  14546. * @param func callback function to remove
  14547. * @returns the TransformNode.
  14548. */
  14549. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14550. /**
  14551. * Gets the position of the current mesh in camera space
  14552. * @param camera defines the camera to use
  14553. * @returns a position
  14554. */
  14555. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14556. /**
  14557. * Returns the distance from the mesh to the active camera
  14558. * @param camera defines the camera to use
  14559. * @returns the distance
  14560. */
  14561. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14562. /**
  14563. * Clone the current transform node
  14564. * @param name Name of the new clone
  14565. * @param newParent New parent for the clone
  14566. * @param doNotCloneChildren Do not clone children hierarchy
  14567. * @returns the new transform node
  14568. */
  14569. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14570. /**
  14571. * Serializes the objects information.
  14572. * @param currentSerializationObject defines the object to serialize in
  14573. * @returns the serialized object
  14574. */
  14575. serialize(currentSerializationObject?: any): any;
  14576. /**
  14577. * Returns a new TransformNode object parsed from the source provided.
  14578. * @param parsedTransformNode is the source.
  14579. * @param scene the scne the object belongs to
  14580. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14581. * @returns a new TransformNode object parsed from the source provided.
  14582. */
  14583. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14584. /**
  14585. * Get all child-transformNodes of this node
  14586. * @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
  14587. * @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
  14588. * @returns an array of TransformNode
  14589. */
  14590. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14591. /**
  14592. * Releases resources associated with this transform node.
  14593. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14594. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14595. */
  14596. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14597. /**
  14598. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14599. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14600. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14601. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14602. * @returns the current mesh
  14603. */
  14604. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14605. private _syncAbsoluteScalingAndRotation;
  14606. }
  14607. }
  14608. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14609. import { Observable } from "babylonjs/Misc/observable";
  14610. import { Nullable } from "babylonjs/types";
  14611. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14612. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14614. import { Ray } from "babylonjs/Culling/ray";
  14615. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14616. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14617. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14618. /**
  14619. * Defines the types of pose enabled controllers that are supported
  14620. */
  14621. export enum PoseEnabledControllerType {
  14622. /**
  14623. * HTC Vive
  14624. */
  14625. VIVE = 0,
  14626. /**
  14627. * Oculus Rift
  14628. */
  14629. OCULUS = 1,
  14630. /**
  14631. * Windows mixed reality
  14632. */
  14633. WINDOWS = 2,
  14634. /**
  14635. * Samsung gear VR
  14636. */
  14637. GEAR_VR = 3,
  14638. /**
  14639. * Google Daydream
  14640. */
  14641. DAYDREAM = 4,
  14642. /**
  14643. * Generic
  14644. */
  14645. GENERIC = 5
  14646. }
  14647. /**
  14648. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14649. */
  14650. export interface MutableGamepadButton {
  14651. /**
  14652. * Value of the button/trigger
  14653. */
  14654. value: number;
  14655. /**
  14656. * If the button/trigger is currently touched
  14657. */
  14658. touched: boolean;
  14659. /**
  14660. * If the button/trigger is currently pressed
  14661. */
  14662. pressed: boolean;
  14663. }
  14664. /**
  14665. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14666. * @hidden
  14667. */
  14668. export interface ExtendedGamepadButton extends GamepadButton {
  14669. /**
  14670. * If the button/trigger is currently pressed
  14671. */
  14672. readonly pressed: boolean;
  14673. /**
  14674. * If the button/trigger is currently touched
  14675. */
  14676. readonly touched: boolean;
  14677. /**
  14678. * Value of the button/trigger
  14679. */
  14680. readonly value: number;
  14681. }
  14682. /** @hidden */
  14683. export interface _GamePadFactory {
  14684. /**
  14685. * Returns wether or not the current gamepad can be created for this type of controller.
  14686. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14687. * @returns true if it can be created, otherwise false
  14688. */
  14689. canCreate(gamepadInfo: any): boolean;
  14690. /**
  14691. * Creates a new instance of the Gamepad.
  14692. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14693. * @returns the new gamepad instance
  14694. */
  14695. create(gamepadInfo: any): Gamepad;
  14696. }
  14697. /**
  14698. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14699. */
  14700. export class PoseEnabledControllerHelper {
  14701. /** @hidden */
  14702. static _ControllerFactories: _GamePadFactory[];
  14703. /** @hidden */
  14704. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14705. /**
  14706. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14707. * @param vrGamepad the gamepad to initialized
  14708. * @returns a vr controller of the type the gamepad identified as
  14709. */
  14710. static InitiateController(vrGamepad: any): Gamepad;
  14711. }
  14712. /**
  14713. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14714. */
  14715. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14716. /**
  14717. * If the controller is used in a webXR session
  14718. */
  14719. isXR: boolean;
  14720. private _deviceRoomPosition;
  14721. private _deviceRoomRotationQuaternion;
  14722. /**
  14723. * The device position in babylon space
  14724. */
  14725. devicePosition: Vector3;
  14726. /**
  14727. * The device rotation in babylon space
  14728. */
  14729. deviceRotationQuaternion: Quaternion;
  14730. /**
  14731. * The scale factor of the device in babylon space
  14732. */
  14733. deviceScaleFactor: number;
  14734. /**
  14735. * (Likely devicePosition should be used instead) The device position in its room space
  14736. */
  14737. position: Vector3;
  14738. /**
  14739. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14740. */
  14741. rotationQuaternion: Quaternion;
  14742. /**
  14743. * The type of controller (Eg. Windows mixed reality)
  14744. */
  14745. controllerType: PoseEnabledControllerType;
  14746. protected _calculatedPosition: Vector3;
  14747. private _calculatedRotation;
  14748. /**
  14749. * The raw pose from the device
  14750. */
  14751. rawPose: DevicePose;
  14752. private _trackPosition;
  14753. private _maxRotationDistFromHeadset;
  14754. private _draggedRoomRotation;
  14755. /**
  14756. * @hidden
  14757. */
  14758. _disableTrackPosition(fixedPosition: Vector3): void;
  14759. /**
  14760. * Internal, the mesh attached to the controller
  14761. * @hidden
  14762. */
  14763. _mesh: Nullable<AbstractMesh>;
  14764. private _poseControlledCamera;
  14765. private _leftHandSystemQuaternion;
  14766. /**
  14767. * Internal, matrix used to convert room space to babylon space
  14768. * @hidden
  14769. */
  14770. _deviceToWorld: Matrix;
  14771. /**
  14772. * Node to be used when casting a ray from the controller
  14773. * @hidden
  14774. */
  14775. _pointingPoseNode: Nullable<TransformNode>;
  14776. /**
  14777. * Name of the child mesh that can be used to cast a ray from the controller
  14778. */
  14779. static readonly POINTING_POSE: string;
  14780. /**
  14781. * Creates a new PoseEnabledController from a gamepad
  14782. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14783. */
  14784. constructor(browserGamepad: any);
  14785. private _workingMatrix;
  14786. /**
  14787. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14788. */
  14789. update(): void;
  14790. /**
  14791. * Updates only the pose device and mesh without doing any button event checking
  14792. */
  14793. protected _updatePoseAndMesh(): void;
  14794. /**
  14795. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14796. * @param poseData raw pose fromthe device
  14797. */
  14798. updateFromDevice(poseData: DevicePose): void;
  14799. /**
  14800. * @hidden
  14801. */
  14802. _meshAttachedObservable: Observable<AbstractMesh>;
  14803. /**
  14804. * Attaches a mesh to the controller
  14805. * @param mesh the mesh to be attached
  14806. */
  14807. attachToMesh(mesh: AbstractMesh): void;
  14808. /**
  14809. * Attaches the controllers mesh to a camera
  14810. * @param camera the camera the mesh should be attached to
  14811. */
  14812. attachToPoseControlledCamera(camera: TargetCamera): void;
  14813. /**
  14814. * Disposes of the controller
  14815. */
  14816. dispose(): void;
  14817. /**
  14818. * The mesh that is attached to the controller
  14819. */
  14820. readonly mesh: Nullable<AbstractMesh>;
  14821. /**
  14822. * Gets the ray of the controller in the direction the controller is pointing
  14823. * @param length the length the resulting ray should be
  14824. * @returns a ray in the direction the controller is pointing
  14825. */
  14826. getForwardRay(length?: number): Ray;
  14827. }
  14828. }
  14829. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14830. import { Observable } from "babylonjs/Misc/observable";
  14831. import { Scene } from "babylonjs/scene";
  14832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14833. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14834. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14835. import { Nullable } from "babylonjs/types";
  14836. /**
  14837. * Defines the WebVRController object that represents controllers tracked in 3D space
  14838. */
  14839. export abstract class WebVRController extends PoseEnabledController {
  14840. /**
  14841. * Internal, the default controller model for the controller
  14842. */
  14843. protected _defaultModel: Nullable<AbstractMesh>;
  14844. /**
  14845. * Fired when the trigger state has changed
  14846. */
  14847. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14848. /**
  14849. * Fired when the main button state has changed
  14850. */
  14851. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14852. /**
  14853. * Fired when the secondary button state has changed
  14854. */
  14855. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14856. /**
  14857. * Fired when the pad state has changed
  14858. */
  14859. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14860. /**
  14861. * Fired when controllers stick values have changed
  14862. */
  14863. onPadValuesChangedObservable: Observable<StickValues>;
  14864. /**
  14865. * Array of button availible on the controller
  14866. */
  14867. protected _buttons: Array<MutableGamepadButton>;
  14868. private _onButtonStateChange;
  14869. /**
  14870. * Fired when a controller button's state has changed
  14871. * @param callback the callback containing the button that was modified
  14872. */
  14873. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14874. /**
  14875. * X and Y axis corresponding to the controllers joystick
  14876. */
  14877. pad: StickValues;
  14878. /**
  14879. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14880. */
  14881. hand: string;
  14882. /**
  14883. * The default controller model for the controller
  14884. */
  14885. readonly defaultModel: Nullable<AbstractMesh>;
  14886. /**
  14887. * Creates a new WebVRController from a gamepad
  14888. * @param vrGamepad the gamepad that the WebVRController should be created from
  14889. */
  14890. constructor(vrGamepad: any);
  14891. /**
  14892. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14893. */
  14894. update(): void;
  14895. /**
  14896. * Function to be called when a button is modified
  14897. */
  14898. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14899. /**
  14900. * Loads a mesh and attaches it to the controller
  14901. * @param scene the scene the mesh should be added to
  14902. * @param meshLoaded callback for when the mesh has been loaded
  14903. */
  14904. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14905. private _setButtonValue;
  14906. private _changes;
  14907. private _checkChanges;
  14908. /**
  14909. * Disposes of th webVRCOntroller
  14910. */
  14911. dispose(): void;
  14912. }
  14913. }
  14914. declare module "babylonjs/Lights/hemisphericLight" {
  14915. import { Nullable } from "babylonjs/types";
  14916. import { Scene } from "babylonjs/scene";
  14917. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14918. import { Color3 } from "babylonjs/Maths/math.color";
  14919. import { Effect } from "babylonjs/Materials/effect";
  14920. import { Light } from "babylonjs/Lights/light";
  14921. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14922. /**
  14923. * The HemisphericLight simulates the ambient environment light,
  14924. * so the passed direction is the light reflection direction, not the incoming direction.
  14925. */
  14926. export class HemisphericLight extends Light {
  14927. /**
  14928. * The groundColor is the light in the opposite direction to the one specified during creation.
  14929. * 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.
  14930. */
  14931. groundColor: Color3;
  14932. /**
  14933. * The light reflection direction, not the incoming direction.
  14934. */
  14935. direction: Vector3;
  14936. /**
  14937. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14938. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14939. * The HemisphericLight can't cast shadows.
  14940. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14941. * @param name The friendly name of the light
  14942. * @param direction The direction of the light reflection
  14943. * @param scene The scene the light belongs to
  14944. */
  14945. constructor(name: string, direction: Vector3, scene: Scene);
  14946. protected _buildUniformLayout(): void;
  14947. /**
  14948. * Returns the string "HemisphericLight".
  14949. * @return The class name
  14950. */
  14951. getClassName(): string;
  14952. /**
  14953. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14954. * Returns the updated direction.
  14955. * @param target The target the direction should point to
  14956. * @return The computed direction
  14957. */
  14958. setDirectionToTarget(target: Vector3): Vector3;
  14959. /**
  14960. * Returns the shadow generator associated to the light.
  14961. * @returns Always null for hemispheric lights because it does not support shadows.
  14962. */
  14963. getShadowGenerator(): Nullable<IShadowGenerator>;
  14964. /**
  14965. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14966. * @param effect The effect to update
  14967. * @param lightIndex The index of the light in the effect to update
  14968. * @returns The hemispheric light
  14969. */
  14970. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14971. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14972. /**
  14973. * Computes the world matrix of the node
  14974. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14975. * @param useWasUpdatedFlag defines a reserved property
  14976. * @returns the world matrix
  14977. */
  14978. computeWorldMatrix(): Matrix;
  14979. /**
  14980. * Returns the integer 3.
  14981. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14982. */
  14983. getTypeID(): number;
  14984. /**
  14985. * Prepares the list of defines specific to the light type.
  14986. * @param defines the list of defines
  14987. * @param lightIndex defines the index of the light for the effect
  14988. */
  14989. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14990. }
  14991. }
  14992. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14993. /** @hidden */
  14994. export var vrMultiviewToSingleviewPixelShader: {
  14995. name: string;
  14996. shader: string;
  14997. };
  14998. }
  14999. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15000. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15001. import { Scene } from "babylonjs/scene";
  15002. /**
  15003. * Renders to multiple views with a single draw call
  15004. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15005. */
  15006. export class MultiviewRenderTarget extends RenderTargetTexture {
  15007. /**
  15008. * Creates a multiview render target
  15009. * @param scene scene used with the render target
  15010. * @param size the size of the render target (used for each view)
  15011. */
  15012. constructor(scene: Scene, size?: number | {
  15013. width: number;
  15014. height: number;
  15015. } | {
  15016. ratio: number;
  15017. });
  15018. /**
  15019. * @hidden
  15020. * @param faceIndex the face index, if its a cube texture
  15021. */
  15022. _bindFrameBuffer(faceIndex?: number): void;
  15023. /**
  15024. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15025. * @returns the view count
  15026. */
  15027. getViewCount(): number;
  15028. }
  15029. }
  15030. declare module "babylonjs/Maths/math.frustum" {
  15031. import { Matrix } from "babylonjs/Maths/math.vector";
  15032. import { DeepImmutable } from "babylonjs/types";
  15033. import { Plane } from "babylonjs/Maths/math.plane";
  15034. /**
  15035. * Represents a camera frustum
  15036. */
  15037. export class Frustum {
  15038. /**
  15039. * Gets the planes representing the frustum
  15040. * @param transform matrix to be applied to the returned planes
  15041. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15042. */
  15043. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15044. /**
  15045. * Gets the near frustum plane transformed by the transform matrix
  15046. * @param transform transformation matrix to be applied to the resulting frustum plane
  15047. * @param frustumPlane the resuling frustum plane
  15048. */
  15049. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15050. /**
  15051. * Gets the far frustum plane transformed by the transform matrix
  15052. * @param transform transformation matrix to be applied to the resulting frustum plane
  15053. * @param frustumPlane the resuling frustum plane
  15054. */
  15055. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15056. /**
  15057. * Gets the left frustum plane transformed by the transform matrix
  15058. * @param transform transformation matrix to be applied to the resulting frustum plane
  15059. * @param frustumPlane the resuling frustum plane
  15060. */
  15061. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15062. /**
  15063. * Gets the right frustum plane transformed by the transform matrix
  15064. * @param transform transformation matrix to be applied to the resulting frustum plane
  15065. * @param frustumPlane the resuling frustum plane
  15066. */
  15067. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15068. /**
  15069. * Gets the top frustum plane transformed by the transform matrix
  15070. * @param transform transformation matrix to be applied to the resulting frustum plane
  15071. * @param frustumPlane the resuling frustum plane
  15072. */
  15073. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15074. /**
  15075. * Gets the bottom frustum plane transformed by the transform matrix
  15076. * @param transform transformation matrix to be applied to the resulting frustum plane
  15077. * @param frustumPlane the resuling frustum plane
  15078. */
  15079. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15080. /**
  15081. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15082. * @param transform transformation matrix to be applied to the resulting frustum planes
  15083. * @param frustumPlanes the resuling frustum planes
  15084. */
  15085. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15086. }
  15087. }
  15088. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15089. import { Camera } from "babylonjs/Cameras/camera";
  15090. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15091. import { Nullable } from "babylonjs/types";
  15092. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15093. import { Matrix } from "babylonjs/Maths/math.vector";
  15094. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15095. module "babylonjs/Engines/engine" {
  15096. interface Engine {
  15097. /**
  15098. * Creates a new multiview render target
  15099. * @param width defines the width of the texture
  15100. * @param height defines the height of the texture
  15101. * @returns the created multiview texture
  15102. */
  15103. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15104. /**
  15105. * Binds a multiview framebuffer to be drawn to
  15106. * @param multiviewTexture texture to bind
  15107. */
  15108. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15109. }
  15110. }
  15111. module "babylonjs/Cameras/camera" {
  15112. interface Camera {
  15113. /**
  15114. * @hidden
  15115. * 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)
  15116. */
  15117. _useMultiviewToSingleView: boolean;
  15118. /**
  15119. * @hidden
  15120. * 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)
  15121. */
  15122. _multiviewTexture: Nullable<RenderTargetTexture>;
  15123. /**
  15124. * @hidden
  15125. * ensures the multiview texture of the camera exists and has the specified width/height
  15126. * @param width height to set on the multiview texture
  15127. * @param height width to set on the multiview texture
  15128. */
  15129. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15130. }
  15131. }
  15132. module "babylonjs/scene" {
  15133. interface Scene {
  15134. /** @hidden */
  15135. _transformMatrixR: Matrix;
  15136. /** @hidden */
  15137. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15138. /** @hidden */
  15139. _createMultiviewUbo(): void;
  15140. /** @hidden */
  15141. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15142. /** @hidden */
  15143. _renderMultiviewToSingleView(camera: Camera): void;
  15144. }
  15145. }
  15146. }
  15147. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15148. import { Camera } from "babylonjs/Cameras/camera";
  15149. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15150. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15151. import "babylonjs/Engines/Extensions/engine.multiview";
  15152. /**
  15153. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15154. * This will not be used for webXR as it supports displaying texture arrays directly
  15155. */
  15156. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15157. /**
  15158. * Initializes a VRMultiviewToSingleview
  15159. * @param name name of the post process
  15160. * @param camera camera to be applied to
  15161. * @param scaleFactor scaling factor to the size of the output texture
  15162. */
  15163. constructor(name: string, camera: Camera, scaleFactor: number);
  15164. }
  15165. }
  15166. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15167. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15168. import { Nullable } from "babylonjs/types";
  15169. import { Size } from "babylonjs/Maths/math.size";
  15170. import { Observable } from "babylonjs/Misc/observable";
  15171. module "babylonjs/Engines/engine" {
  15172. interface Engine {
  15173. /** @hidden */
  15174. _vrDisplay: any;
  15175. /** @hidden */
  15176. _vrSupported: boolean;
  15177. /** @hidden */
  15178. _oldSize: Size;
  15179. /** @hidden */
  15180. _oldHardwareScaleFactor: number;
  15181. /** @hidden */
  15182. _vrExclusivePointerMode: boolean;
  15183. /** @hidden */
  15184. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15185. /** @hidden */
  15186. _onVRDisplayPointerRestricted: () => void;
  15187. /** @hidden */
  15188. _onVRDisplayPointerUnrestricted: () => void;
  15189. /** @hidden */
  15190. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15191. /** @hidden */
  15192. _onVrDisplayDisconnect: Nullable<() => void>;
  15193. /** @hidden */
  15194. _onVrDisplayPresentChange: Nullable<() => void>;
  15195. /**
  15196. * Observable signaled when VR display mode changes
  15197. */
  15198. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15199. /**
  15200. * Observable signaled when VR request present is complete
  15201. */
  15202. onVRRequestPresentComplete: Observable<boolean>;
  15203. /**
  15204. * Observable signaled when VR request present starts
  15205. */
  15206. onVRRequestPresentStart: Observable<Engine>;
  15207. /**
  15208. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15209. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15210. */
  15211. isInVRExclusivePointerMode: boolean;
  15212. /**
  15213. * Gets a boolean indicating if a webVR device was detected
  15214. * @returns true if a webVR device was detected
  15215. */
  15216. isVRDevicePresent(): boolean;
  15217. /**
  15218. * Gets the current webVR device
  15219. * @returns the current webVR device (or null)
  15220. */
  15221. getVRDevice(): any;
  15222. /**
  15223. * Initializes a webVR display and starts listening to display change events
  15224. * The onVRDisplayChangedObservable will be notified upon these changes
  15225. * @returns A promise containing a VRDisplay and if vr is supported
  15226. */
  15227. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15228. /** @hidden */
  15229. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15230. /**
  15231. * Call this function to switch to webVR mode
  15232. * Will do nothing if webVR is not supported or if there is no webVR device
  15233. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15234. */
  15235. enableVR(): void;
  15236. /** @hidden */
  15237. _onVRFullScreenTriggered(): void;
  15238. }
  15239. }
  15240. }
  15241. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15242. import { Nullable } from "babylonjs/types";
  15243. import { Observable } from "babylonjs/Misc/observable";
  15244. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15245. import { Scene } from "babylonjs/scene";
  15246. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15247. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15248. import { Node } from "babylonjs/node";
  15249. import { Ray } from "babylonjs/Culling/ray";
  15250. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15251. import "babylonjs/Engines/Extensions/engine.webVR";
  15252. /**
  15253. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15254. * IMPORTANT!! The data is right-hand data.
  15255. * @export
  15256. * @interface DevicePose
  15257. */
  15258. export interface DevicePose {
  15259. /**
  15260. * The position of the device, values in array are [x,y,z].
  15261. */
  15262. readonly position: Nullable<Float32Array>;
  15263. /**
  15264. * The linearVelocity of the device, values in array are [x,y,z].
  15265. */
  15266. readonly linearVelocity: Nullable<Float32Array>;
  15267. /**
  15268. * The linearAcceleration of the device, values in array are [x,y,z].
  15269. */
  15270. readonly linearAcceleration: Nullable<Float32Array>;
  15271. /**
  15272. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15273. */
  15274. readonly orientation: Nullable<Float32Array>;
  15275. /**
  15276. * The angularVelocity of the device, values in array are [x,y,z].
  15277. */
  15278. readonly angularVelocity: Nullable<Float32Array>;
  15279. /**
  15280. * The angularAcceleration of the device, values in array are [x,y,z].
  15281. */
  15282. readonly angularAcceleration: Nullable<Float32Array>;
  15283. }
  15284. /**
  15285. * Interface representing a pose controlled object in Babylon.
  15286. * A pose controlled object has both regular pose values as well as pose values
  15287. * from an external device such as a VR head mounted display
  15288. */
  15289. export interface PoseControlled {
  15290. /**
  15291. * The position of the object in babylon space.
  15292. */
  15293. position: Vector3;
  15294. /**
  15295. * The rotation quaternion of the object in babylon space.
  15296. */
  15297. rotationQuaternion: Quaternion;
  15298. /**
  15299. * The position of the device in babylon space.
  15300. */
  15301. devicePosition?: Vector3;
  15302. /**
  15303. * The rotation quaternion of the device in babylon space.
  15304. */
  15305. deviceRotationQuaternion: Quaternion;
  15306. /**
  15307. * The raw pose coming from the device.
  15308. */
  15309. rawPose: Nullable<DevicePose>;
  15310. /**
  15311. * The scale of the device to be used when translating from device space to babylon space.
  15312. */
  15313. deviceScaleFactor: number;
  15314. /**
  15315. * Updates the poseControlled values based on the input device pose.
  15316. * @param poseData the pose data to update the object with
  15317. */
  15318. updateFromDevice(poseData: DevicePose): void;
  15319. }
  15320. /**
  15321. * Set of options to customize the webVRCamera
  15322. */
  15323. export interface WebVROptions {
  15324. /**
  15325. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15326. */
  15327. trackPosition?: boolean;
  15328. /**
  15329. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15330. */
  15331. positionScale?: number;
  15332. /**
  15333. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15334. */
  15335. displayName?: string;
  15336. /**
  15337. * Should the native controller meshes be initialized. (default: true)
  15338. */
  15339. controllerMeshes?: boolean;
  15340. /**
  15341. * Creating a default HemiLight only on controllers. (default: true)
  15342. */
  15343. defaultLightingOnControllers?: boolean;
  15344. /**
  15345. * If you don't want to use the default VR button of the helper. (default: false)
  15346. */
  15347. useCustomVRButton?: boolean;
  15348. /**
  15349. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15350. */
  15351. customVRButton?: HTMLButtonElement;
  15352. /**
  15353. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15354. */
  15355. rayLength?: number;
  15356. /**
  15357. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15358. */
  15359. defaultHeight?: number;
  15360. /**
  15361. * If multiview should be used if availible (default: false)
  15362. */
  15363. useMultiview?: boolean;
  15364. }
  15365. /**
  15366. * This represents a WebVR camera.
  15367. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15368. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15369. */
  15370. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15371. private webVROptions;
  15372. /**
  15373. * @hidden
  15374. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15375. */
  15376. _vrDevice: any;
  15377. /**
  15378. * The rawPose of the vrDevice.
  15379. */
  15380. rawPose: Nullable<DevicePose>;
  15381. private _onVREnabled;
  15382. private _specsVersion;
  15383. private _attached;
  15384. private _frameData;
  15385. protected _descendants: Array<Node>;
  15386. private _deviceRoomPosition;
  15387. /** @hidden */
  15388. _deviceRoomRotationQuaternion: Quaternion;
  15389. private _standingMatrix;
  15390. /**
  15391. * Represents device position in babylon space.
  15392. */
  15393. devicePosition: Vector3;
  15394. /**
  15395. * Represents device rotation in babylon space.
  15396. */
  15397. deviceRotationQuaternion: Quaternion;
  15398. /**
  15399. * The scale of the device to be used when translating from device space to babylon space.
  15400. */
  15401. deviceScaleFactor: number;
  15402. private _deviceToWorld;
  15403. private _worldToDevice;
  15404. /**
  15405. * References to the webVR controllers for the vrDevice.
  15406. */
  15407. controllers: Array<WebVRController>;
  15408. /**
  15409. * Emits an event when a controller is attached.
  15410. */
  15411. onControllersAttachedObservable: Observable<WebVRController[]>;
  15412. /**
  15413. * Emits an event when a controller's mesh has been loaded;
  15414. */
  15415. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15416. /**
  15417. * Emits an event when the HMD's pose has been updated.
  15418. */
  15419. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15420. private _poseSet;
  15421. /**
  15422. * If the rig cameras be used as parent instead of this camera.
  15423. */
  15424. rigParenting: boolean;
  15425. private _lightOnControllers;
  15426. private _defaultHeight?;
  15427. /**
  15428. * Instantiates a WebVRFreeCamera.
  15429. * @param name The name of the WebVRFreeCamera
  15430. * @param position The starting anchor position for the camera
  15431. * @param scene The scene the camera belongs to
  15432. * @param webVROptions a set of customizable options for the webVRCamera
  15433. */
  15434. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15435. /**
  15436. * Gets the device distance from the ground in meters.
  15437. * @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.
  15438. */
  15439. deviceDistanceToRoomGround(): number;
  15440. /**
  15441. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15442. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15443. */
  15444. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15445. /**
  15446. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15447. * @returns A promise with a boolean set to if the standing matrix is supported.
  15448. */
  15449. useStandingMatrixAsync(): Promise<boolean>;
  15450. /**
  15451. * Disposes the camera
  15452. */
  15453. dispose(): void;
  15454. /**
  15455. * Gets a vrController by name.
  15456. * @param name The name of the controller to retreive
  15457. * @returns the controller matching the name specified or null if not found
  15458. */
  15459. getControllerByName(name: string): Nullable<WebVRController>;
  15460. private _leftController;
  15461. /**
  15462. * The controller corresponding to the users left hand.
  15463. */
  15464. readonly leftController: Nullable<WebVRController>;
  15465. private _rightController;
  15466. /**
  15467. * The controller corresponding to the users right hand.
  15468. */
  15469. readonly rightController: Nullable<WebVRController>;
  15470. /**
  15471. * Casts a ray forward from the vrCamera's gaze.
  15472. * @param length Length of the ray (default: 100)
  15473. * @returns the ray corresponding to the gaze
  15474. */
  15475. getForwardRay(length?: number): Ray;
  15476. /**
  15477. * @hidden
  15478. * Updates the camera based on device's frame data
  15479. */
  15480. _checkInputs(): void;
  15481. /**
  15482. * Updates the poseControlled values based on the input device pose.
  15483. * @param poseData Pose coming from the device
  15484. */
  15485. updateFromDevice(poseData: DevicePose): void;
  15486. private _htmlElementAttached;
  15487. private _detachIfAttached;
  15488. /**
  15489. * WebVR's attach control will start broadcasting frames to the device.
  15490. * Note that in certain browsers (chrome for example) this function must be called
  15491. * within a user-interaction callback. Example:
  15492. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15493. *
  15494. * @param element html element to attach the vrDevice to
  15495. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15496. */
  15497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15498. /**
  15499. * Detaches the camera from the html element and disables VR
  15500. *
  15501. * @param element html element to detach from
  15502. */
  15503. detachControl(element: HTMLElement): void;
  15504. /**
  15505. * @returns the name of this class
  15506. */
  15507. getClassName(): string;
  15508. /**
  15509. * Calls resetPose on the vrDisplay
  15510. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15511. */
  15512. resetToCurrentRotation(): void;
  15513. /**
  15514. * @hidden
  15515. * Updates the rig cameras (left and right eye)
  15516. */
  15517. _updateRigCameras(): void;
  15518. private _workingVector;
  15519. private _oneVector;
  15520. private _workingMatrix;
  15521. private updateCacheCalled;
  15522. private _correctPositionIfNotTrackPosition;
  15523. /**
  15524. * @hidden
  15525. * Updates the cached values of the camera
  15526. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15527. */
  15528. _updateCache(ignoreParentClass?: boolean): void;
  15529. /**
  15530. * @hidden
  15531. * Get current device position in babylon world
  15532. */
  15533. _computeDevicePosition(): void;
  15534. /**
  15535. * Updates the current device position and rotation in the babylon world
  15536. */
  15537. update(): void;
  15538. /**
  15539. * @hidden
  15540. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15541. * @returns an identity matrix
  15542. */
  15543. _getViewMatrix(): Matrix;
  15544. private _tmpMatrix;
  15545. /**
  15546. * This function is called by the two RIG cameras.
  15547. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15548. * @hidden
  15549. */
  15550. _getWebVRViewMatrix(): Matrix;
  15551. /** @hidden */
  15552. _getWebVRProjectionMatrix(): Matrix;
  15553. private _onGamepadConnectedObserver;
  15554. private _onGamepadDisconnectedObserver;
  15555. private _updateCacheWhenTrackingDisabledObserver;
  15556. /**
  15557. * Initializes the controllers and their meshes
  15558. */
  15559. initControllers(): void;
  15560. }
  15561. }
  15562. declare module "babylonjs/PostProcesses/postProcess" {
  15563. import { Nullable } from "babylonjs/types";
  15564. import { SmartArray } from "babylonjs/Misc/smartArray";
  15565. import { Observable } from "babylonjs/Misc/observable";
  15566. import { Vector2 } from "babylonjs/Maths/math.vector";
  15567. import { Camera } from "babylonjs/Cameras/camera";
  15568. import { Effect } from "babylonjs/Materials/effect";
  15569. import "babylonjs/Shaders/postprocess.vertex";
  15570. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15571. import { Engine } from "babylonjs/Engines/engine";
  15572. import { Color4 } from "babylonjs/Maths/math.color";
  15573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15574. /**
  15575. * Size options for a post process
  15576. */
  15577. export type PostProcessOptions = {
  15578. width: number;
  15579. height: number;
  15580. };
  15581. /**
  15582. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15583. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15584. */
  15585. export class PostProcess {
  15586. /** Name of the PostProcess. */
  15587. name: string;
  15588. /**
  15589. * Gets or sets the unique id of the post process
  15590. */
  15591. uniqueId: number;
  15592. /**
  15593. * Width of the texture to apply the post process on
  15594. */
  15595. width: number;
  15596. /**
  15597. * Height of the texture to apply the post process on
  15598. */
  15599. height: number;
  15600. /**
  15601. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15602. * @hidden
  15603. */
  15604. _outputTexture: Nullable<InternalTexture>;
  15605. /**
  15606. * Sampling mode used by the shader
  15607. * See https://doc.babylonjs.com/classes/3.1/texture
  15608. */
  15609. renderTargetSamplingMode: number;
  15610. /**
  15611. * Clear color to use when screen clearing
  15612. */
  15613. clearColor: Color4;
  15614. /**
  15615. * If the buffer needs to be cleared before applying the post process. (default: true)
  15616. * Should be set to false if shader will overwrite all previous pixels.
  15617. */
  15618. autoClear: boolean;
  15619. /**
  15620. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15621. */
  15622. alphaMode: number;
  15623. /**
  15624. * Sets the setAlphaBlendConstants of the babylon engine
  15625. */
  15626. alphaConstants: Color4;
  15627. /**
  15628. * Animations to be used for the post processing
  15629. */
  15630. animations: import("babylonjs/Animations/animation").Animation[];
  15631. /**
  15632. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15633. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15634. */
  15635. enablePixelPerfectMode: boolean;
  15636. /**
  15637. * Force the postprocess to be applied without taking in account viewport
  15638. */
  15639. forceFullscreenViewport: boolean;
  15640. /**
  15641. * List of inspectable custom properties (used by the Inspector)
  15642. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15643. */
  15644. inspectableCustomProperties: IInspectable[];
  15645. /**
  15646. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15647. *
  15648. * | Value | Type | Description |
  15649. * | ----- | ----------------------------------- | ----------- |
  15650. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15651. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15652. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15653. *
  15654. */
  15655. scaleMode: number;
  15656. /**
  15657. * Force textures to be a power of two (default: false)
  15658. */
  15659. alwaysForcePOT: boolean;
  15660. private _samples;
  15661. /**
  15662. * Number of sample textures (default: 1)
  15663. */
  15664. samples: number;
  15665. /**
  15666. * Modify the scale of the post process to be the same as the viewport (default: false)
  15667. */
  15668. adaptScaleToCurrentViewport: boolean;
  15669. private _camera;
  15670. private _scene;
  15671. private _engine;
  15672. private _options;
  15673. private _reusable;
  15674. private _textureType;
  15675. /**
  15676. * Smart array of input and output textures for the post process.
  15677. * @hidden
  15678. */
  15679. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15680. /**
  15681. * The index in _textures that corresponds to the output texture.
  15682. * @hidden
  15683. */
  15684. _currentRenderTextureInd: number;
  15685. private _effect;
  15686. private _samplers;
  15687. private _fragmentUrl;
  15688. private _vertexUrl;
  15689. private _parameters;
  15690. private _scaleRatio;
  15691. protected _indexParameters: any;
  15692. private _shareOutputWithPostProcess;
  15693. private _texelSize;
  15694. private _forcedOutputTexture;
  15695. /**
  15696. * Returns the fragment url or shader name used in the post process.
  15697. * @returns the fragment url or name in the shader store.
  15698. */
  15699. getEffectName(): string;
  15700. /**
  15701. * An event triggered when the postprocess is activated.
  15702. */
  15703. onActivateObservable: Observable<Camera>;
  15704. private _onActivateObserver;
  15705. /**
  15706. * A function that is added to the onActivateObservable
  15707. */
  15708. onActivate: Nullable<(camera: Camera) => void>;
  15709. /**
  15710. * An event triggered when the postprocess changes its size.
  15711. */
  15712. onSizeChangedObservable: Observable<PostProcess>;
  15713. private _onSizeChangedObserver;
  15714. /**
  15715. * A function that is added to the onSizeChangedObservable
  15716. */
  15717. onSizeChanged: (postProcess: PostProcess) => void;
  15718. /**
  15719. * An event triggered when the postprocess applies its effect.
  15720. */
  15721. onApplyObservable: Observable<Effect>;
  15722. private _onApplyObserver;
  15723. /**
  15724. * A function that is added to the onApplyObservable
  15725. */
  15726. onApply: (effect: Effect) => void;
  15727. /**
  15728. * An event triggered before rendering the postprocess
  15729. */
  15730. onBeforeRenderObservable: Observable<Effect>;
  15731. private _onBeforeRenderObserver;
  15732. /**
  15733. * A function that is added to the onBeforeRenderObservable
  15734. */
  15735. onBeforeRender: (effect: Effect) => void;
  15736. /**
  15737. * An event triggered after rendering the postprocess
  15738. */
  15739. onAfterRenderObservable: Observable<Effect>;
  15740. private _onAfterRenderObserver;
  15741. /**
  15742. * A function that is added to the onAfterRenderObservable
  15743. */
  15744. onAfterRender: (efect: Effect) => void;
  15745. /**
  15746. * 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
  15747. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15748. */
  15749. inputTexture: InternalTexture;
  15750. /**
  15751. * Gets the camera which post process is applied to.
  15752. * @returns The camera the post process is applied to.
  15753. */
  15754. getCamera(): Camera;
  15755. /**
  15756. * Gets the texel size of the postprocess.
  15757. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15758. */
  15759. readonly texelSize: Vector2;
  15760. /**
  15761. * Creates a new instance PostProcess
  15762. * @param name The name of the PostProcess.
  15763. * @param fragmentUrl The url of the fragment shader to be used.
  15764. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15765. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15766. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15767. * @param camera The camera to apply the render pass to.
  15768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15769. * @param engine The engine which the post process will be applied. (default: current engine)
  15770. * @param reusable If the post process can be reused on the same frame. (default: false)
  15771. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15772. * @param textureType Type of textures used when performing the post process. (default: 0)
  15773. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15774. * @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
  15775. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15776. */
  15777. constructor(
  15778. /** Name of the PostProcess. */
  15779. 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);
  15780. /**
  15781. * Gets a string idenfifying the name of the class
  15782. * @returns "PostProcess" string
  15783. */
  15784. getClassName(): string;
  15785. /**
  15786. * Gets the engine which this post process belongs to.
  15787. * @returns The engine the post process was enabled with.
  15788. */
  15789. getEngine(): Engine;
  15790. /**
  15791. * The effect that is created when initializing the post process.
  15792. * @returns The created effect corresponding the the postprocess.
  15793. */
  15794. getEffect(): Effect;
  15795. /**
  15796. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15797. * @param postProcess The post process to share the output with.
  15798. * @returns This post process.
  15799. */
  15800. shareOutputWith(postProcess: PostProcess): PostProcess;
  15801. /**
  15802. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15803. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15804. */
  15805. useOwnOutput(): void;
  15806. /**
  15807. * Updates the effect with the current post process compile time values and recompiles the shader.
  15808. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15809. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15810. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15811. * @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
  15812. * @param onCompiled Called when the shader has been compiled.
  15813. * @param onError Called if there is an error when compiling a shader.
  15814. */
  15815. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15816. /**
  15817. * The post process is reusable if it can be used multiple times within one frame.
  15818. * @returns If the post process is reusable
  15819. */
  15820. isReusable(): boolean;
  15821. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15822. markTextureDirty(): void;
  15823. /**
  15824. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15825. * 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.
  15826. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15827. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15828. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15829. * @returns The target texture that was bound to be written to.
  15830. */
  15831. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15832. /**
  15833. * If the post process is supported.
  15834. */
  15835. readonly isSupported: boolean;
  15836. /**
  15837. * The aspect ratio of the output texture.
  15838. */
  15839. readonly aspectRatio: number;
  15840. /**
  15841. * Get a value indicating if the post-process is ready to be used
  15842. * @returns true if the post-process is ready (shader is compiled)
  15843. */
  15844. isReady(): boolean;
  15845. /**
  15846. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15847. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15848. */
  15849. apply(): Nullable<Effect>;
  15850. private _disposeTextures;
  15851. /**
  15852. * Disposes the post process.
  15853. * @param camera The camera to dispose the post process on.
  15854. */
  15855. dispose(camera?: Camera): void;
  15856. }
  15857. }
  15858. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15859. /** @hidden */
  15860. export var kernelBlurVaryingDeclaration: {
  15861. name: string;
  15862. shader: string;
  15863. };
  15864. }
  15865. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15866. /** @hidden */
  15867. export var kernelBlurFragment: {
  15868. name: string;
  15869. shader: string;
  15870. };
  15871. }
  15872. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15873. /** @hidden */
  15874. export var kernelBlurFragment2: {
  15875. name: string;
  15876. shader: string;
  15877. };
  15878. }
  15879. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15880. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15881. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15882. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15883. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15884. /** @hidden */
  15885. export var kernelBlurPixelShader: {
  15886. name: string;
  15887. shader: string;
  15888. };
  15889. }
  15890. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15891. /** @hidden */
  15892. export var kernelBlurVertex: {
  15893. name: string;
  15894. shader: string;
  15895. };
  15896. }
  15897. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15898. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15899. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15900. /** @hidden */
  15901. export var kernelBlurVertexShader: {
  15902. name: string;
  15903. shader: string;
  15904. };
  15905. }
  15906. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15907. import { Vector2 } from "babylonjs/Maths/math.vector";
  15908. import { Nullable } from "babylonjs/types";
  15909. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15910. import { Camera } from "babylonjs/Cameras/camera";
  15911. import { Effect } from "babylonjs/Materials/effect";
  15912. import { Engine } from "babylonjs/Engines/engine";
  15913. import "babylonjs/Shaders/kernelBlur.fragment";
  15914. import "babylonjs/Shaders/kernelBlur.vertex";
  15915. /**
  15916. * The Blur Post Process which blurs an image based on a kernel and direction.
  15917. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15918. */
  15919. export class BlurPostProcess extends PostProcess {
  15920. /** The direction in which to blur the image. */
  15921. direction: Vector2;
  15922. private blockCompilation;
  15923. protected _kernel: number;
  15924. protected _idealKernel: number;
  15925. protected _packedFloat: boolean;
  15926. private _staticDefines;
  15927. /**
  15928. * Sets the length in pixels of the blur sample region
  15929. */
  15930. /**
  15931. * Gets the length in pixels of the blur sample region
  15932. */
  15933. kernel: number;
  15934. /**
  15935. * Sets wether or not the blur needs to unpack/repack floats
  15936. */
  15937. /**
  15938. * Gets wether or not the blur is unpacking/repacking floats
  15939. */
  15940. packedFloat: boolean;
  15941. /**
  15942. * Creates a new instance BlurPostProcess
  15943. * @param name The name of the effect.
  15944. * @param direction The direction in which to blur the image.
  15945. * @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.
  15946. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15947. * @param camera The camera to apply the render pass to.
  15948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15949. * @param engine The engine which the post process will be applied. (default: current engine)
  15950. * @param reusable If the post process can be reused on the same frame. (default: false)
  15951. * @param textureType Type of textures used when performing the post process. (default: 0)
  15952. * @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)
  15953. */
  15954. constructor(name: string,
  15955. /** The direction in which to blur the image. */
  15956. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15957. /**
  15958. * Updates the effect with the current post process compile time values and recompiles the shader.
  15959. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15960. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15961. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15962. * @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
  15963. * @param onCompiled Called when the shader has been compiled.
  15964. * @param onError Called if there is an error when compiling a shader.
  15965. */
  15966. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15967. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15968. /**
  15969. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15970. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15971. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15972. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15973. * The gaps between physical kernels are compensated for in the weighting of the samples
  15974. * @param idealKernel Ideal blur kernel.
  15975. * @return Nearest best kernel.
  15976. */
  15977. protected _nearestBestKernel(idealKernel: number): number;
  15978. /**
  15979. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15980. * @param x The point on the Gaussian distribution to sample.
  15981. * @return the value of the Gaussian function at x.
  15982. */
  15983. protected _gaussianWeight(x: number): number;
  15984. /**
  15985. * Generates a string that can be used as a floating point number in GLSL.
  15986. * @param x Value to print.
  15987. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15988. * @return GLSL float string.
  15989. */
  15990. protected _glslFloat(x: number, decimalFigures?: number): string;
  15991. }
  15992. }
  15993. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15994. import { Scene } from "babylonjs/scene";
  15995. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15996. import { Plane } from "babylonjs/Maths/math.plane";
  15997. /**
  15998. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15999. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16000. * You can then easily use it as a reflectionTexture on a flat surface.
  16001. * In case the surface is not a plane, please consider relying on reflection probes.
  16002. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16003. */
  16004. export class MirrorTexture extends RenderTargetTexture {
  16005. private scene;
  16006. /**
  16007. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16008. * 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.
  16009. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16010. */
  16011. mirrorPlane: Plane;
  16012. /**
  16013. * Define the blur ratio used to blur the reflection if needed.
  16014. */
  16015. blurRatio: number;
  16016. /**
  16017. * Define the adaptive blur kernel used to blur the reflection if needed.
  16018. * This will autocompute the closest best match for the `blurKernel`
  16019. */
  16020. adaptiveBlurKernel: number;
  16021. /**
  16022. * Define the blur kernel used to blur the reflection if needed.
  16023. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16024. */
  16025. blurKernel: number;
  16026. /**
  16027. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16028. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16029. */
  16030. blurKernelX: number;
  16031. /**
  16032. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16033. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16034. */
  16035. blurKernelY: number;
  16036. private _autoComputeBlurKernel;
  16037. protected _onRatioRescale(): void;
  16038. private _updateGammaSpace;
  16039. private _imageProcessingConfigChangeObserver;
  16040. private _transformMatrix;
  16041. private _mirrorMatrix;
  16042. private _savedViewMatrix;
  16043. private _blurX;
  16044. private _blurY;
  16045. private _adaptiveBlurKernel;
  16046. private _blurKernelX;
  16047. private _blurKernelY;
  16048. private _blurRatio;
  16049. /**
  16050. * Instantiates a Mirror Texture.
  16051. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16052. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16053. * You can then easily use it as a reflectionTexture on a flat surface.
  16054. * In case the surface is not a plane, please consider relying on reflection probes.
  16055. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16056. * @param name
  16057. * @param size
  16058. * @param scene
  16059. * @param generateMipMaps
  16060. * @param type
  16061. * @param samplingMode
  16062. * @param generateDepthBuffer
  16063. */
  16064. constructor(name: string, size: number | {
  16065. width: number;
  16066. height: number;
  16067. } | {
  16068. ratio: number;
  16069. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16070. private _preparePostProcesses;
  16071. /**
  16072. * Clone the mirror texture.
  16073. * @returns the cloned texture
  16074. */
  16075. clone(): MirrorTexture;
  16076. /**
  16077. * Serialize the texture to a JSON representation you could use in Parse later on
  16078. * @returns the serialized JSON representation
  16079. */
  16080. serialize(): any;
  16081. /**
  16082. * Dispose the texture and release its associated resources.
  16083. */
  16084. dispose(): void;
  16085. }
  16086. }
  16087. declare module "babylonjs/Materials/Textures/texture" {
  16088. import { Observable } from "babylonjs/Misc/observable";
  16089. import { Nullable } from "babylonjs/types";
  16090. import { Scene } from "babylonjs/scene";
  16091. import { Matrix } from "babylonjs/Maths/math.vector";
  16092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16093. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16094. import { Engine } from "babylonjs/Engines/engine";
  16095. /**
  16096. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16097. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16098. */
  16099. export class Texture extends BaseTexture {
  16100. /**
  16101. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16102. */
  16103. static SerializeBuffers: boolean;
  16104. /** @hidden */
  16105. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16106. /** @hidden */
  16107. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16108. /** @hidden */
  16109. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16110. /** nearest is mag = nearest and min = nearest and mip = linear */
  16111. static readonly NEAREST_SAMPLINGMODE: number;
  16112. /** nearest is mag = nearest and min = nearest and mip = linear */
  16113. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16114. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16115. static readonly BILINEAR_SAMPLINGMODE: number;
  16116. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16117. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16118. /** Trilinear is mag = linear and min = linear and mip = linear */
  16119. static readonly TRILINEAR_SAMPLINGMODE: number;
  16120. /** Trilinear is mag = linear and min = linear and mip = linear */
  16121. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16122. /** mag = nearest and min = nearest and mip = nearest */
  16123. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16124. /** mag = nearest and min = linear and mip = nearest */
  16125. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16126. /** mag = nearest and min = linear and mip = linear */
  16127. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16128. /** mag = nearest and min = linear and mip = none */
  16129. static readonly NEAREST_LINEAR: number;
  16130. /** mag = nearest and min = nearest and mip = none */
  16131. static readonly NEAREST_NEAREST: number;
  16132. /** mag = linear and min = nearest and mip = nearest */
  16133. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16134. /** mag = linear and min = nearest and mip = linear */
  16135. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16136. /** mag = linear and min = linear and mip = none */
  16137. static readonly LINEAR_LINEAR: number;
  16138. /** mag = linear and min = nearest and mip = none */
  16139. static readonly LINEAR_NEAREST: number;
  16140. /** Explicit coordinates mode */
  16141. static readonly EXPLICIT_MODE: number;
  16142. /** Spherical coordinates mode */
  16143. static readonly SPHERICAL_MODE: number;
  16144. /** Planar coordinates mode */
  16145. static readonly PLANAR_MODE: number;
  16146. /** Cubic coordinates mode */
  16147. static readonly CUBIC_MODE: number;
  16148. /** Projection coordinates mode */
  16149. static readonly PROJECTION_MODE: number;
  16150. /** Inverse Cubic coordinates mode */
  16151. static readonly SKYBOX_MODE: number;
  16152. /** Inverse Cubic coordinates mode */
  16153. static readonly INVCUBIC_MODE: number;
  16154. /** Equirectangular coordinates mode */
  16155. static readonly EQUIRECTANGULAR_MODE: number;
  16156. /** Equirectangular Fixed coordinates mode */
  16157. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16158. /** Equirectangular Fixed Mirrored coordinates mode */
  16159. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16160. /** Texture is not repeating outside of 0..1 UVs */
  16161. static readonly CLAMP_ADDRESSMODE: number;
  16162. /** Texture is repeating outside of 0..1 UVs */
  16163. static readonly WRAP_ADDRESSMODE: number;
  16164. /** Texture is repeating and mirrored */
  16165. static readonly MIRROR_ADDRESSMODE: number;
  16166. /**
  16167. * 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
  16168. */
  16169. static UseSerializedUrlIfAny: boolean;
  16170. /**
  16171. * Define the url of the texture.
  16172. */
  16173. url: Nullable<string>;
  16174. /**
  16175. * Define an offset on the texture to offset the u coordinates of the UVs
  16176. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16177. */
  16178. uOffset: number;
  16179. /**
  16180. * Define an offset on the texture to offset the v coordinates of the UVs
  16181. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16182. */
  16183. vOffset: number;
  16184. /**
  16185. * Define an offset on the texture to scale the u coordinates of the UVs
  16186. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16187. */
  16188. uScale: number;
  16189. /**
  16190. * Define an offset on the texture to scale the v coordinates of the UVs
  16191. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16192. */
  16193. vScale: number;
  16194. /**
  16195. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16196. * @see http://doc.babylonjs.com/how_to/more_materials
  16197. */
  16198. uAng: number;
  16199. /**
  16200. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16201. * @see http://doc.babylonjs.com/how_to/more_materials
  16202. */
  16203. vAng: number;
  16204. /**
  16205. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16206. * @see http://doc.babylonjs.com/how_to/more_materials
  16207. */
  16208. wAng: number;
  16209. /**
  16210. * Defines the center of rotation (U)
  16211. */
  16212. uRotationCenter: number;
  16213. /**
  16214. * Defines the center of rotation (V)
  16215. */
  16216. vRotationCenter: number;
  16217. /**
  16218. * Defines the center of rotation (W)
  16219. */
  16220. wRotationCenter: number;
  16221. /**
  16222. * Are mip maps generated for this texture or not.
  16223. */
  16224. readonly noMipmap: boolean;
  16225. /**
  16226. * List of inspectable custom properties (used by the Inspector)
  16227. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16228. */
  16229. inspectableCustomProperties: Nullable<IInspectable[]>;
  16230. private _noMipmap;
  16231. /** @hidden */
  16232. _invertY: boolean;
  16233. private _rowGenerationMatrix;
  16234. private _cachedTextureMatrix;
  16235. private _projectionModeMatrix;
  16236. private _t0;
  16237. private _t1;
  16238. private _t2;
  16239. private _cachedUOffset;
  16240. private _cachedVOffset;
  16241. private _cachedUScale;
  16242. private _cachedVScale;
  16243. private _cachedUAng;
  16244. private _cachedVAng;
  16245. private _cachedWAng;
  16246. private _cachedProjectionMatrixId;
  16247. private _cachedCoordinatesMode;
  16248. /** @hidden */
  16249. protected _initialSamplingMode: number;
  16250. /** @hidden */
  16251. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16252. private _deleteBuffer;
  16253. protected _format: Nullable<number>;
  16254. private _delayedOnLoad;
  16255. private _delayedOnError;
  16256. /**
  16257. * Observable triggered once the texture has been loaded.
  16258. */
  16259. onLoadObservable: Observable<Texture>;
  16260. protected _isBlocking: boolean;
  16261. /**
  16262. * Is the texture preventing material to render while loading.
  16263. * If false, a default texture will be used instead of the loading one during the preparation step.
  16264. */
  16265. isBlocking: boolean;
  16266. /**
  16267. * Get the current sampling mode associated with the texture.
  16268. */
  16269. readonly samplingMode: number;
  16270. /**
  16271. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16272. */
  16273. readonly invertY: boolean;
  16274. /**
  16275. * Instantiates a new texture.
  16276. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16277. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16278. * @param url define the url of the picture to load as a texture
  16279. * @param scene define the scene or engine the texture will belong to
  16280. * @param noMipmap define if the texture will require mip maps or not
  16281. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16282. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16283. * @param onLoad define a callback triggered when the texture has been loaded
  16284. * @param onError define a callback triggered when an error occurred during the loading session
  16285. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16286. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16287. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16288. */
  16289. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16290. /**
  16291. * Update the url (and optional buffer) of this texture if url was null during construction.
  16292. * @param url the url of the texture
  16293. * @param buffer the buffer of the texture (defaults to null)
  16294. * @param onLoad callback called when the texture is loaded (defaults to null)
  16295. */
  16296. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16297. /**
  16298. * Finish the loading sequence of a texture flagged as delayed load.
  16299. * @hidden
  16300. */
  16301. delayLoad(): void;
  16302. private _prepareRowForTextureGeneration;
  16303. /**
  16304. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16305. * @returns the transform matrix of the texture.
  16306. */
  16307. getTextureMatrix(): Matrix;
  16308. /**
  16309. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16310. * @returns The reflection texture transform
  16311. */
  16312. getReflectionTextureMatrix(): Matrix;
  16313. /**
  16314. * Clones the texture.
  16315. * @returns the cloned texture
  16316. */
  16317. clone(): Texture;
  16318. /**
  16319. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16320. * @returns The JSON representation of the texture
  16321. */
  16322. serialize(): any;
  16323. /**
  16324. * Get the current class name of the texture useful for serialization or dynamic coding.
  16325. * @returns "Texture"
  16326. */
  16327. getClassName(): string;
  16328. /**
  16329. * Dispose the texture and release its associated resources.
  16330. */
  16331. dispose(): void;
  16332. /**
  16333. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16334. * @param parsedTexture Define the JSON representation of the texture
  16335. * @param scene Define the scene the parsed texture should be instantiated in
  16336. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16337. * @returns The parsed texture if successful
  16338. */
  16339. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16340. /**
  16341. * Creates a texture from its base 64 representation.
  16342. * @param data Define the base64 payload without the data: prefix
  16343. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16344. * @param scene Define the scene the texture should belong to
  16345. * @param noMipmap Forces the texture to not create mip map information if true
  16346. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16347. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16348. * @param onLoad define a callback triggered when the texture has been loaded
  16349. * @param onError define a callback triggered when an error occurred during the loading session
  16350. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16351. * @returns the created texture
  16352. */
  16353. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16354. /**
  16355. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16356. * @param data Define the base64 payload without the data: prefix
  16357. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16358. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16359. * @param scene Define the scene the texture should belong to
  16360. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16361. * @param noMipmap Forces the texture to not create mip map information if true
  16362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16364. * @param onLoad define a callback triggered when the texture has been loaded
  16365. * @param onError define a callback triggered when an error occurred during the loading session
  16366. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16367. * @returns the created texture
  16368. */
  16369. 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;
  16370. }
  16371. }
  16372. declare module "babylonjs/PostProcesses/postProcessManager" {
  16373. import { Nullable } from "babylonjs/types";
  16374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16375. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16376. import { Scene } from "babylonjs/scene";
  16377. /**
  16378. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16379. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16380. */
  16381. export class PostProcessManager {
  16382. private _scene;
  16383. private _indexBuffer;
  16384. private _vertexBuffers;
  16385. /**
  16386. * Creates a new instance PostProcess
  16387. * @param scene The scene that the post process is associated with.
  16388. */
  16389. constructor(scene: Scene);
  16390. private _prepareBuffers;
  16391. private _buildIndexBuffer;
  16392. /**
  16393. * Rebuilds the vertex buffers of the manager.
  16394. * @hidden
  16395. */
  16396. _rebuild(): void;
  16397. /**
  16398. * Prepares a frame to be run through a post process.
  16399. * @param sourceTexture The input texture to the post procesess. (default: null)
  16400. * @param postProcesses An array of post processes to be run. (default: null)
  16401. * @returns True if the post processes were able to be run.
  16402. * @hidden
  16403. */
  16404. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16405. /**
  16406. * Manually render a set of post processes to a texture.
  16407. * @param postProcesses An array of post processes to be run.
  16408. * @param targetTexture The target texture to render to.
  16409. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16410. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16411. * @param lodLevel defines which lod of the texture to render to
  16412. */
  16413. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16414. /**
  16415. * Finalize the result of the output of the postprocesses.
  16416. * @param doNotPresent If true the result will not be displayed to the screen.
  16417. * @param targetTexture The target texture to render to.
  16418. * @param faceIndex The index of the face to bind the target texture to.
  16419. * @param postProcesses The array of post processes to render.
  16420. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16421. * @hidden
  16422. */
  16423. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16424. /**
  16425. * Disposes of the post process manager.
  16426. */
  16427. dispose(): void;
  16428. }
  16429. }
  16430. declare module "babylonjs/Misc/gradients" {
  16431. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16432. /** Interface used by value gradients (color, factor, ...) */
  16433. export interface IValueGradient {
  16434. /**
  16435. * Gets or sets the gradient value (between 0 and 1)
  16436. */
  16437. gradient: number;
  16438. }
  16439. /** Class used to store color4 gradient */
  16440. export class ColorGradient implements IValueGradient {
  16441. /**
  16442. * Gets or sets the gradient value (between 0 and 1)
  16443. */
  16444. gradient: number;
  16445. /**
  16446. * Gets or sets first associated color
  16447. */
  16448. color1: Color4;
  16449. /**
  16450. * Gets or sets second associated color
  16451. */
  16452. color2?: Color4;
  16453. /**
  16454. * Will get a color picked randomly between color1 and color2.
  16455. * If color2 is undefined then color1 will be used
  16456. * @param result defines the target Color4 to store the result in
  16457. */
  16458. getColorToRef(result: Color4): void;
  16459. }
  16460. /** Class used to store color 3 gradient */
  16461. export class Color3Gradient implements IValueGradient {
  16462. /**
  16463. * Gets or sets the gradient value (between 0 and 1)
  16464. */
  16465. gradient: number;
  16466. /**
  16467. * Gets or sets the associated color
  16468. */
  16469. color: Color3;
  16470. }
  16471. /** Class used to store factor gradient */
  16472. export class FactorGradient implements IValueGradient {
  16473. /**
  16474. * Gets or sets the gradient value (between 0 and 1)
  16475. */
  16476. gradient: number;
  16477. /**
  16478. * Gets or sets first associated factor
  16479. */
  16480. factor1: number;
  16481. /**
  16482. * Gets or sets second associated factor
  16483. */
  16484. factor2?: number;
  16485. /**
  16486. * Will get a number picked randomly between factor1 and factor2.
  16487. * If factor2 is undefined then factor1 will be used
  16488. * @returns the picked number
  16489. */
  16490. getFactor(): number;
  16491. }
  16492. /**
  16493. * Helper used to simplify some generic gradient tasks
  16494. */
  16495. export class GradientHelper {
  16496. /**
  16497. * Gets the current gradient from an array of IValueGradient
  16498. * @param ratio defines the current ratio to get
  16499. * @param gradients defines the array of IValueGradient
  16500. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16501. */
  16502. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16503. }
  16504. }
  16505. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16506. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16507. import { Nullable } from "babylonjs/types";
  16508. module "babylonjs/Engines/thinEngine" {
  16509. interface ThinEngine {
  16510. /**
  16511. * Creates a dynamic texture
  16512. * @param width defines the width of the texture
  16513. * @param height defines the height of the texture
  16514. * @param generateMipMaps defines if the engine should generate the mip levels
  16515. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16516. * @returns the dynamic texture inside an InternalTexture
  16517. */
  16518. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16519. /**
  16520. * Update the content of a dynamic texture
  16521. * @param texture defines the texture to update
  16522. * @param canvas defines the canvas containing the source
  16523. * @param invertY defines if data must be stored with Y axis inverted
  16524. * @param premulAlpha defines if alpha is stored as premultiplied
  16525. * @param format defines the format of the data
  16526. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16527. */
  16528. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16529. }
  16530. }
  16531. }
  16532. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16533. import { Scene } from "babylonjs/scene";
  16534. import { Texture } from "babylonjs/Materials/Textures/texture";
  16535. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16536. /**
  16537. * A class extending Texture allowing drawing on a texture
  16538. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16539. */
  16540. export class DynamicTexture extends Texture {
  16541. private _generateMipMaps;
  16542. private _canvas;
  16543. private _context;
  16544. private _engine;
  16545. /**
  16546. * Creates a DynamicTexture
  16547. * @param name defines the name of the texture
  16548. * @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
  16549. * @param scene defines the scene where you want the texture
  16550. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16551. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16552. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16553. */
  16554. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16555. /**
  16556. * Get the current class name of the texture useful for serialization or dynamic coding.
  16557. * @returns "DynamicTexture"
  16558. */
  16559. getClassName(): string;
  16560. /**
  16561. * Gets the current state of canRescale
  16562. */
  16563. readonly canRescale: boolean;
  16564. private _recreate;
  16565. /**
  16566. * Scales the texture
  16567. * @param ratio the scale factor to apply to both width and height
  16568. */
  16569. scale(ratio: number): void;
  16570. /**
  16571. * Resizes the texture
  16572. * @param width the new width
  16573. * @param height the new height
  16574. */
  16575. scaleTo(width: number, height: number): void;
  16576. /**
  16577. * Gets the context of the canvas used by the texture
  16578. * @returns the canvas context of the dynamic texture
  16579. */
  16580. getContext(): CanvasRenderingContext2D;
  16581. /**
  16582. * Clears the texture
  16583. */
  16584. clear(): void;
  16585. /**
  16586. * Updates the texture
  16587. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16588. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16589. */
  16590. update(invertY?: boolean, premulAlpha?: boolean): void;
  16591. /**
  16592. * Draws text onto the texture
  16593. * @param text defines the text to be drawn
  16594. * @param x defines the placement of the text from the left
  16595. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16596. * @param font defines the font to be used with font-style, font-size, font-name
  16597. * @param color defines the color used for the text
  16598. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16599. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16600. * @param update defines whether texture is immediately update (default is true)
  16601. */
  16602. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16603. /**
  16604. * Clones the texture
  16605. * @returns the clone of the texture.
  16606. */
  16607. clone(): DynamicTexture;
  16608. /**
  16609. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16610. * @returns a serialized dynamic texture object
  16611. */
  16612. serialize(): any;
  16613. /** @hidden */
  16614. _rebuild(): void;
  16615. }
  16616. }
  16617. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16618. import { Scene } from "babylonjs/scene";
  16619. import { ISceneComponent } from "babylonjs/sceneComponent";
  16620. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16621. module "babylonjs/abstractScene" {
  16622. interface AbstractScene {
  16623. /**
  16624. * The list of procedural textures added to the scene
  16625. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16626. */
  16627. proceduralTextures: Array<ProceduralTexture>;
  16628. }
  16629. }
  16630. /**
  16631. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16632. * in a given scene.
  16633. */
  16634. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16635. /**
  16636. * The component name helpfull to identify the component in the list of scene components.
  16637. */
  16638. readonly name: string;
  16639. /**
  16640. * The scene the component belongs to.
  16641. */
  16642. scene: Scene;
  16643. /**
  16644. * Creates a new instance of the component for the given scene
  16645. * @param scene Defines the scene to register the component in
  16646. */
  16647. constructor(scene: Scene);
  16648. /**
  16649. * Registers the component in a given scene
  16650. */
  16651. register(): void;
  16652. /**
  16653. * Rebuilds the elements related to this component in case of
  16654. * context lost for instance.
  16655. */
  16656. rebuild(): void;
  16657. /**
  16658. * Disposes the component and the associated ressources.
  16659. */
  16660. dispose(): void;
  16661. private _beforeClear;
  16662. }
  16663. }
  16664. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16665. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16666. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16667. module "babylonjs/Engines/thinEngine" {
  16668. interface ThinEngine {
  16669. /**
  16670. * Creates a new render target cube texture
  16671. * @param size defines the size of the texture
  16672. * @param options defines the options used to create the texture
  16673. * @returns a new render target cube texture stored in an InternalTexture
  16674. */
  16675. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16676. }
  16677. }
  16678. }
  16679. declare module "babylonjs/Shaders/procedural.vertex" {
  16680. /** @hidden */
  16681. export var proceduralVertexShader: {
  16682. name: string;
  16683. shader: string;
  16684. };
  16685. }
  16686. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16687. import { Observable } from "babylonjs/Misc/observable";
  16688. import { Nullable } from "babylonjs/types";
  16689. import { Scene } from "babylonjs/scene";
  16690. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16691. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16692. import { Effect } from "babylonjs/Materials/effect";
  16693. import { Texture } from "babylonjs/Materials/Textures/texture";
  16694. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16695. import "babylonjs/Shaders/procedural.vertex";
  16696. /**
  16697. * 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.
  16698. * This is the base class of any Procedural texture and contains most of the shareable code.
  16699. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16700. */
  16701. export class ProceduralTexture extends Texture {
  16702. isCube: boolean;
  16703. /**
  16704. * Define if the texture is enabled or not (disabled texture will not render)
  16705. */
  16706. isEnabled: boolean;
  16707. /**
  16708. * Define if the texture must be cleared before rendering (default is true)
  16709. */
  16710. autoClear: boolean;
  16711. /**
  16712. * Callback called when the texture is generated
  16713. */
  16714. onGenerated: () => void;
  16715. /**
  16716. * Event raised when the texture is generated
  16717. */
  16718. onGeneratedObservable: Observable<ProceduralTexture>;
  16719. /** @hidden */
  16720. _generateMipMaps: boolean;
  16721. /** @hidden **/
  16722. _effect: Effect;
  16723. /** @hidden */
  16724. _textures: {
  16725. [key: string]: Texture;
  16726. };
  16727. private _size;
  16728. private _currentRefreshId;
  16729. private _refreshRate;
  16730. private _vertexBuffers;
  16731. private _indexBuffer;
  16732. private _uniforms;
  16733. private _samplers;
  16734. private _fragment;
  16735. private _floats;
  16736. private _ints;
  16737. private _floatsArrays;
  16738. private _colors3;
  16739. private _colors4;
  16740. private _vectors2;
  16741. private _vectors3;
  16742. private _matrices;
  16743. private _fallbackTexture;
  16744. private _fallbackTextureUsed;
  16745. private _engine;
  16746. private _cachedDefines;
  16747. private _contentUpdateId;
  16748. private _contentData;
  16749. /**
  16750. * Instantiates a new procedural texture.
  16751. * 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.
  16752. * This is the base class of any Procedural texture and contains most of the shareable code.
  16753. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16754. * @param name Define the name of the texture
  16755. * @param size Define the size of the texture to create
  16756. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16757. * @param scene Define the scene the texture belongs to
  16758. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16759. * @param generateMipMaps Define if the texture should creates mip maps or not
  16760. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16761. */
  16762. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16763. /**
  16764. * The effect that is created when initializing the post process.
  16765. * @returns The created effect corresponding the the postprocess.
  16766. */
  16767. getEffect(): Effect;
  16768. /**
  16769. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16770. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16771. */
  16772. getContent(): Nullable<ArrayBufferView>;
  16773. private _createIndexBuffer;
  16774. /** @hidden */
  16775. _rebuild(): void;
  16776. /**
  16777. * Resets the texture in order to recreate its associated resources.
  16778. * This can be called in case of context loss
  16779. */
  16780. reset(): void;
  16781. protected _getDefines(): string;
  16782. /**
  16783. * Is the texture ready to be used ? (rendered at least once)
  16784. * @returns true if ready, otherwise, false.
  16785. */
  16786. isReady(): boolean;
  16787. /**
  16788. * Resets the refresh counter of the texture and start bak from scratch.
  16789. * Could be useful to regenerate the texture if it is setup to render only once.
  16790. */
  16791. resetRefreshCounter(): void;
  16792. /**
  16793. * Set the fragment shader to use in order to render the texture.
  16794. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16795. */
  16796. setFragment(fragment: any): void;
  16797. /**
  16798. * Define the refresh rate of the texture or the rendering frequency.
  16799. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16800. */
  16801. refreshRate: number;
  16802. /** @hidden */
  16803. _shouldRender(): boolean;
  16804. /**
  16805. * Get the size the texture is rendering at.
  16806. * @returns the size (texture is always squared)
  16807. */
  16808. getRenderSize(): number;
  16809. /**
  16810. * Resize the texture to new value.
  16811. * @param size Define the new size the texture should have
  16812. * @param generateMipMaps Define whether the new texture should create mip maps
  16813. */
  16814. resize(size: number, generateMipMaps: boolean): void;
  16815. private _checkUniform;
  16816. /**
  16817. * Set a texture in the shader program used to render.
  16818. * @param name Define the name of the uniform samplers as defined in the shader
  16819. * @param texture Define the texture to bind to this sampler
  16820. * @return the texture itself allowing "fluent" like uniform updates
  16821. */
  16822. setTexture(name: string, texture: Texture): ProceduralTexture;
  16823. /**
  16824. * Set a float in the shader.
  16825. * @param name Define the name of the uniform as defined in the shader
  16826. * @param value Define the value to give to the uniform
  16827. * @return the texture itself allowing "fluent" like uniform updates
  16828. */
  16829. setFloat(name: string, value: number): ProceduralTexture;
  16830. /**
  16831. * Set a int in the shader.
  16832. * @param name Define the name of the uniform as defined in the shader
  16833. * @param value Define the value to give to the uniform
  16834. * @return the texture itself allowing "fluent" like uniform updates
  16835. */
  16836. setInt(name: string, value: number): ProceduralTexture;
  16837. /**
  16838. * Set an array of floats in the shader.
  16839. * @param name Define the name of the uniform as defined in the shader
  16840. * @param value Define the value to give to the uniform
  16841. * @return the texture itself allowing "fluent" like uniform updates
  16842. */
  16843. setFloats(name: string, value: number[]): ProceduralTexture;
  16844. /**
  16845. * Set a vec3 in the shader from a Color3.
  16846. * @param name Define the name of the uniform as defined in the shader
  16847. * @param value Define the value to give to the uniform
  16848. * @return the texture itself allowing "fluent" like uniform updates
  16849. */
  16850. setColor3(name: string, value: Color3): ProceduralTexture;
  16851. /**
  16852. * Set a vec4 in the shader from a Color4.
  16853. * @param name Define the name of the uniform as defined in the shader
  16854. * @param value Define the value to give to the uniform
  16855. * @return the texture itself allowing "fluent" like uniform updates
  16856. */
  16857. setColor4(name: string, value: Color4): ProceduralTexture;
  16858. /**
  16859. * Set a vec2 in the shader from a Vector2.
  16860. * @param name Define the name of the uniform as defined in the shader
  16861. * @param value Define the value to give to the uniform
  16862. * @return the texture itself allowing "fluent" like uniform updates
  16863. */
  16864. setVector2(name: string, value: Vector2): ProceduralTexture;
  16865. /**
  16866. * Set a vec3 in the shader from a Vector3.
  16867. * @param name Define the name of the uniform as defined in the shader
  16868. * @param value Define the value to give to the uniform
  16869. * @return the texture itself allowing "fluent" like uniform updates
  16870. */
  16871. setVector3(name: string, value: Vector3): ProceduralTexture;
  16872. /**
  16873. * Set a mat4 in the shader from a MAtrix.
  16874. * @param name Define the name of the uniform as defined in the shader
  16875. * @param value Define the value to give to the uniform
  16876. * @return the texture itself allowing "fluent" like uniform updates
  16877. */
  16878. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16879. /**
  16880. * Render the texture to its associated render target.
  16881. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16882. */
  16883. render(useCameraPostProcess?: boolean): void;
  16884. /**
  16885. * Clone the texture.
  16886. * @returns the cloned texture
  16887. */
  16888. clone(): ProceduralTexture;
  16889. /**
  16890. * Dispose the texture and release its asoociated resources.
  16891. */
  16892. dispose(): void;
  16893. }
  16894. }
  16895. declare module "babylonjs/Particles/baseParticleSystem" {
  16896. import { Nullable } from "babylonjs/types";
  16897. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16899. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16900. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16901. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16902. import { Scene } from "babylonjs/scene";
  16903. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16904. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16905. import { Texture } from "babylonjs/Materials/Textures/texture";
  16906. import { Color4 } from "babylonjs/Maths/math.color";
  16907. import { Animation } from "babylonjs/Animations/animation";
  16908. /**
  16909. * This represents the base class for particle system in Babylon.
  16910. * 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.
  16911. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16912. * @example https://doc.babylonjs.com/babylon101/particles
  16913. */
  16914. export class BaseParticleSystem {
  16915. /**
  16916. * Source color is added to the destination color without alpha affecting the result
  16917. */
  16918. static BLENDMODE_ONEONE: number;
  16919. /**
  16920. * Blend current color and particle color using particle’s alpha
  16921. */
  16922. static BLENDMODE_STANDARD: number;
  16923. /**
  16924. * Add current color and particle color multiplied by particle’s alpha
  16925. */
  16926. static BLENDMODE_ADD: number;
  16927. /**
  16928. * Multiply current color with particle color
  16929. */
  16930. static BLENDMODE_MULTIPLY: number;
  16931. /**
  16932. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16933. */
  16934. static BLENDMODE_MULTIPLYADD: number;
  16935. /**
  16936. * List of animations used by the particle system.
  16937. */
  16938. animations: Animation[];
  16939. /**
  16940. * The id of the Particle system.
  16941. */
  16942. id: string;
  16943. /**
  16944. * The friendly name of the Particle system.
  16945. */
  16946. name: string;
  16947. /**
  16948. * The rendering group used by the Particle system to chose when to render.
  16949. */
  16950. renderingGroupId: number;
  16951. /**
  16952. * The emitter represents the Mesh or position we are attaching the particle system to.
  16953. */
  16954. emitter: Nullable<AbstractMesh | Vector3>;
  16955. /**
  16956. * The maximum number of particles to emit per frame
  16957. */
  16958. emitRate: number;
  16959. /**
  16960. * If you want to launch only a few particles at once, that can be done, as well.
  16961. */
  16962. manualEmitCount: number;
  16963. /**
  16964. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16965. */
  16966. updateSpeed: number;
  16967. /**
  16968. * The amount of time the particle system is running (depends of the overall update speed).
  16969. */
  16970. targetStopDuration: number;
  16971. /**
  16972. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16973. */
  16974. disposeOnStop: boolean;
  16975. /**
  16976. * Minimum power of emitting particles.
  16977. */
  16978. minEmitPower: number;
  16979. /**
  16980. * Maximum power of emitting particles.
  16981. */
  16982. maxEmitPower: number;
  16983. /**
  16984. * Minimum life time of emitting particles.
  16985. */
  16986. minLifeTime: number;
  16987. /**
  16988. * Maximum life time of emitting particles.
  16989. */
  16990. maxLifeTime: number;
  16991. /**
  16992. * Minimum Size of emitting particles.
  16993. */
  16994. minSize: number;
  16995. /**
  16996. * Maximum Size of emitting particles.
  16997. */
  16998. maxSize: number;
  16999. /**
  17000. * Minimum scale of emitting particles on X axis.
  17001. */
  17002. minScaleX: number;
  17003. /**
  17004. * Maximum scale of emitting particles on X axis.
  17005. */
  17006. maxScaleX: number;
  17007. /**
  17008. * Minimum scale of emitting particles on Y axis.
  17009. */
  17010. minScaleY: number;
  17011. /**
  17012. * Maximum scale of emitting particles on Y axis.
  17013. */
  17014. maxScaleY: number;
  17015. /**
  17016. * Gets or sets the minimal initial rotation in radians.
  17017. */
  17018. minInitialRotation: number;
  17019. /**
  17020. * Gets or sets the maximal initial rotation in radians.
  17021. */
  17022. maxInitialRotation: number;
  17023. /**
  17024. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17025. */
  17026. minAngularSpeed: number;
  17027. /**
  17028. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17029. */
  17030. maxAngularSpeed: number;
  17031. /**
  17032. * The texture used to render each particle. (this can be a spritesheet)
  17033. */
  17034. particleTexture: Nullable<Texture>;
  17035. /**
  17036. * The layer mask we are rendering the particles through.
  17037. */
  17038. layerMask: number;
  17039. /**
  17040. * This can help using your own shader to render the particle system.
  17041. * The according effect will be created
  17042. */
  17043. customShader: any;
  17044. /**
  17045. * By default particle system starts as soon as they are created. This prevents the
  17046. * automatic start to happen and let you decide when to start emitting particles.
  17047. */
  17048. preventAutoStart: boolean;
  17049. private _noiseTexture;
  17050. /**
  17051. * Gets or sets a texture used to add random noise to particle positions
  17052. */
  17053. noiseTexture: Nullable<ProceduralTexture>;
  17054. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17055. noiseStrength: Vector3;
  17056. /**
  17057. * Callback triggered when the particle animation is ending.
  17058. */
  17059. onAnimationEnd: Nullable<() => void>;
  17060. /**
  17061. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17062. */
  17063. blendMode: number;
  17064. /**
  17065. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17066. * to override the particles.
  17067. */
  17068. forceDepthWrite: boolean;
  17069. /** 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 */
  17070. preWarmCycles: number;
  17071. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17072. preWarmStepOffset: number;
  17073. /**
  17074. * 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)
  17075. */
  17076. spriteCellChangeSpeed: number;
  17077. /**
  17078. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17079. */
  17080. startSpriteCellID: number;
  17081. /**
  17082. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17083. */
  17084. endSpriteCellID: number;
  17085. /**
  17086. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17087. */
  17088. spriteCellWidth: number;
  17089. /**
  17090. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17091. */
  17092. spriteCellHeight: number;
  17093. /**
  17094. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17095. */
  17096. spriteRandomStartCell: boolean;
  17097. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17098. translationPivot: Vector2;
  17099. /** @hidden */
  17100. protected _isAnimationSheetEnabled: boolean;
  17101. /**
  17102. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17103. */
  17104. beginAnimationOnStart: boolean;
  17105. /**
  17106. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17107. */
  17108. beginAnimationFrom: number;
  17109. /**
  17110. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17111. */
  17112. beginAnimationTo: number;
  17113. /**
  17114. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17115. */
  17116. beginAnimationLoop: boolean;
  17117. /**
  17118. * Gets or sets a world offset applied to all particles
  17119. */
  17120. worldOffset: Vector3;
  17121. /**
  17122. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17123. */
  17124. isAnimationSheetEnabled: boolean;
  17125. /**
  17126. * Get hosting scene
  17127. * @returns the scene
  17128. */
  17129. getScene(): Scene;
  17130. /**
  17131. * You can use gravity if you want to give an orientation to your particles.
  17132. */
  17133. gravity: Vector3;
  17134. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17135. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17136. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17137. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17138. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17139. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17140. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17141. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17142. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17143. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17144. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17145. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17146. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17147. /**
  17148. * Defines the delay in milliseconds before starting the system (0 by default)
  17149. */
  17150. startDelay: number;
  17151. /**
  17152. * Gets the current list of drag gradients.
  17153. * You must use addDragGradient and removeDragGradient to udpate this list
  17154. * @returns the list of drag gradients
  17155. */
  17156. getDragGradients(): Nullable<Array<FactorGradient>>;
  17157. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17158. limitVelocityDamping: number;
  17159. /**
  17160. * Gets the current list of limit velocity gradients.
  17161. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17162. * @returns the list of limit velocity gradients
  17163. */
  17164. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17165. /**
  17166. * Gets the current list of color gradients.
  17167. * You must use addColorGradient and removeColorGradient to udpate this list
  17168. * @returns the list of color gradients
  17169. */
  17170. getColorGradients(): Nullable<Array<ColorGradient>>;
  17171. /**
  17172. * Gets the current list of size gradients.
  17173. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17174. * @returns the list of size gradients
  17175. */
  17176. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17177. /**
  17178. * Gets the current list of color remap gradients.
  17179. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17180. * @returns the list of color remap gradients
  17181. */
  17182. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17183. /**
  17184. * Gets the current list of alpha remap gradients.
  17185. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17186. * @returns the list of alpha remap gradients
  17187. */
  17188. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17189. /**
  17190. * Gets the current list of life time gradients.
  17191. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17192. * @returns the list of life time gradients
  17193. */
  17194. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17195. /**
  17196. * Gets the current list of angular speed gradients.
  17197. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17198. * @returns the list of angular speed gradients
  17199. */
  17200. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17201. /**
  17202. * Gets the current list of velocity gradients.
  17203. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17204. * @returns the list of velocity gradients
  17205. */
  17206. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17207. /**
  17208. * Gets the current list of start size gradients.
  17209. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17210. * @returns the list of start size gradients
  17211. */
  17212. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17213. /**
  17214. * Gets the current list of emit rate gradients.
  17215. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17216. * @returns the list of emit rate gradients
  17217. */
  17218. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17219. /**
  17220. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17221. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17222. */
  17223. direction1: Vector3;
  17224. /**
  17225. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17226. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17227. */
  17228. direction2: Vector3;
  17229. /**
  17230. * 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.
  17231. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17232. */
  17233. minEmitBox: Vector3;
  17234. /**
  17235. * 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.
  17236. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17237. */
  17238. maxEmitBox: Vector3;
  17239. /**
  17240. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17241. */
  17242. color1: Color4;
  17243. /**
  17244. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17245. */
  17246. color2: Color4;
  17247. /**
  17248. * Color the particle will have at the end of its lifetime
  17249. */
  17250. colorDead: Color4;
  17251. /**
  17252. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17253. */
  17254. textureMask: Color4;
  17255. /**
  17256. * The particle emitter type defines the emitter used by the particle system.
  17257. * It can be for example box, sphere, or cone...
  17258. */
  17259. particleEmitterType: IParticleEmitterType;
  17260. /** @hidden */
  17261. _isSubEmitter: boolean;
  17262. /**
  17263. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17264. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17265. */
  17266. billboardMode: number;
  17267. protected _isBillboardBased: boolean;
  17268. /**
  17269. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17270. */
  17271. isBillboardBased: boolean;
  17272. /**
  17273. * The scene the particle system belongs to.
  17274. */
  17275. protected _scene: Scene;
  17276. /**
  17277. * Local cache of defines for image processing.
  17278. */
  17279. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17280. /**
  17281. * Default configuration related to image processing available in the standard Material.
  17282. */
  17283. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17284. /**
  17285. * Gets the image processing configuration used either in this material.
  17286. */
  17287. /**
  17288. * Sets the Default image processing configuration used either in the this material.
  17289. *
  17290. * If sets to null, the scene one is in use.
  17291. */
  17292. imageProcessingConfiguration: ImageProcessingConfiguration;
  17293. /**
  17294. * Attaches a new image processing configuration to the Standard Material.
  17295. * @param configuration
  17296. */
  17297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17298. /** @hidden */
  17299. protected _reset(): void;
  17300. /** @hidden */
  17301. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17302. /**
  17303. * Instantiates a particle system.
  17304. * 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.
  17305. * @param name The name of the particle system
  17306. */
  17307. constructor(name: string);
  17308. /**
  17309. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17310. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17311. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17312. * @returns the emitter
  17313. */
  17314. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17315. /**
  17316. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17317. * @param radius The radius of the hemisphere to emit from
  17318. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17319. * @returns the emitter
  17320. */
  17321. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17322. /**
  17323. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17324. * @param radius The radius of the sphere to emit from
  17325. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17326. * @returns the emitter
  17327. */
  17328. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17329. /**
  17330. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17331. * @param radius The radius of the sphere to emit from
  17332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17334. * @returns the emitter
  17335. */
  17336. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17337. /**
  17338. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17339. * @param radius The radius of the emission cylinder
  17340. * @param height The height of the emission cylinder
  17341. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17342. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17343. * @returns the emitter
  17344. */
  17345. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17346. /**
  17347. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17348. * @param radius The radius of the cylinder to emit from
  17349. * @param height The height of the emission cylinder
  17350. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17351. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17352. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17353. * @returns the emitter
  17354. */
  17355. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17356. /**
  17357. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17358. * @param radius The radius of the cone to emit from
  17359. * @param angle The base angle of the cone
  17360. * @returns the emitter
  17361. */
  17362. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17363. /**
  17364. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17365. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17366. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17367. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17368. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17369. * @returns the emitter
  17370. */
  17371. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17372. }
  17373. }
  17374. declare module "babylonjs/Particles/subEmitter" {
  17375. import { Scene } from "babylonjs/scene";
  17376. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17377. /**
  17378. * Type of sub emitter
  17379. */
  17380. export enum SubEmitterType {
  17381. /**
  17382. * Attached to the particle over it's lifetime
  17383. */
  17384. ATTACHED = 0,
  17385. /**
  17386. * Created when the particle dies
  17387. */
  17388. END = 1
  17389. }
  17390. /**
  17391. * Sub emitter class used to emit particles from an existing particle
  17392. */
  17393. export class SubEmitter {
  17394. /**
  17395. * the particle system to be used by the sub emitter
  17396. */
  17397. particleSystem: ParticleSystem;
  17398. /**
  17399. * Type of the submitter (Default: END)
  17400. */
  17401. type: SubEmitterType;
  17402. /**
  17403. * 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)
  17404. * Note: This only is supported when using an emitter of type Mesh
  17405. */
  17406. inheritDirection: boolean;
  17407. /**
  17408. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17409. */
  17410. inheritedVelocityAmount: number;
  17411. /**
  17412. * Creates a sub emitter
  17413. * @param particleSystem the particle system to be used by the sub emitter
  17414. */
  17415. constructor(
  17416. /**
  17417. * the particle system to be used by the sub emitter
  17418. */
  17419. particleSystem: ParticleSystem);
  17420. /**
  17421. * Clones the sub emitter
  17422. * @returns the cloned sub emitter
  17423. */
  17424. clone(): SubEmitter;
  17425. /**
  17426. * Serialize current object to a JSON object
  17427. * @returns the serialized object
  17428. */
  17429. serialize(): any;
  17430. /** @hidden */
  17431. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17432. /**
  17433. * Creates a new SubEmitter from a serialized JSON version
  17434. * @param serializationObject defines the JSON object to read from
  17435. * @param scene defines the hosting scene
  17436. * @param rootUrl defines the rootUrl for data loading
  17437. * @returns a new SubEmitter
  17438. */
  17439. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17440. /** Release associated resources */
  17441. dispose(): void;
  17442. }
  17443. }
  17444. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17445. /** @hidden */
  17446. export var clipPlaneFragmentDeclaration: {
  17447. name: string;
  17448. shader: string;
  17449. };
  17450. }
  17451. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17452. /** @hidden */
  17453. export var imageProcessingDeclaration: {
  17454. name: string;
  17455. shader: string;
  17456. };
  17457. }
  17458. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17459. /** @hidden */
  17460. export var imageProcessingFunctions: {
  17461. name: string;
  17462. shader: string;
  17463. };
  17464. }
  17465. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17466. /** @hidden */
  17467. export var clipPlaneFragment: {
  17468. name: string;
  17469. shader: string;
  17470. };
  17471. }
  17472. declare module "babylonjs/Shaders/particles.fragment" {
  17473. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17474. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17475. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17476. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17477. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17478. /** @hidden */
  17479. export var particlesPixelShader: {
  17480. name: string;
  17481. shader: string;
  17482. };
  17483. }
  17484. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17485. /** @hidden */
  17486. export var clipPlaneVertexDeclaration: {
  17487. name: string;
  17488. shader: string;
  17489. };
  17490. }
  17491. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17492. /** @hidden */
  17493. export var clipPlaneVertex: {
  17494. name: string;
  17495. shader: string;
  17496. };
  17497. }
  17498. declare module "babylonjs/Shaders/particles.vertex" {
  17499. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17500. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17501. /** @hidden */
  17502. export var particlesVertexShader: {
  17503. name: string;
  17504. shader: string;
  17505. };
  17506. }
  17507. declare module "babylonjs/Particles/particleSystem" {
  17508. import { Nullable } from "babylonjs/types";
  17509. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17510. import { Observable } from "babylonjs/Misc/observable";
  17511. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17512. import { Effect } from "babylonjs/Materials/effect";
  17513. import { Scene, IDisposable } from "babylonjs/scene";
  17514. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17515. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17516. import { Particle } from "babylonjs/Particles/particle";
  17517. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17518. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17519. import "babylonjs/Shaders/particles.fragment";
  17520. import "babylonjs/Shaders/particles.vertex";
  17521. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17522. /**
  17523. * This represents a particle system in Babylon.
  17524. * 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.
  17525. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17526. * @example https://doc.babylonjs.com/babylon101/particles
  17527. */
  17528. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17529. /**
  17530. * Billboard mode will only apply to Y axis
  17531. */
  17532. static readonly BILLBOARDMODE_Y: number;
  17533. /**
  17534. * Billboard mode will apply to all axes
  17535. */
  17536. static readonly BILLBOARDMODE_ALL: number;
  17537. /**
  17538. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17539. */
  17540. static readonly BILLBOARDMODE_STRETCHED: number;
  17541. /**
  17542. * This function can be defined to provide custom update for active particles.
  17543. * This function will be called instead of regular update (age, position, color, etc.).
  17544. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17545. */
  17546. updateFunction: (particles: Particle[]) => void;
  17547. private _emitterWorldMatrix;
  17548. /**
  17549. * This function can be defined to specify initial direction for every new particle.
  17550. * It by default use the emitterType defined function
  17551. */
  17552. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17553. /**
  17554. * This function can be defined to specify initial position for every new particle.
  17555. * It by default use the emitterType defined function
  17556. */
  17557. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17558. /**
  17559. * @hidden
  17560. */
  17561. _inheritedVelocityOffset: Vector3;
  17562. /**
  17563. * An event triggered when the system is disposed
  17564. */
  17565. onDisposeObservable: Observable<ParticleSystem>;
  17566. private _onDisposeObserver;
  17567. /**
  17568. * Sets a callback that will be triggered when the system is disposed
  17569. */
  17570. onDispose: () => void;
  17571. private _particles;
  17572. private _epsilon;
  17573. private _capacity;
  17574. private _stockParticles;
  17575. private _newPartsExcess;
  17576. private _vertexData;
  17577. private _vertexBuffer;
  17578. private _vertexBuffers;
  17579. private _spriteBuffer;
  17580. private _indexBuffer;
  17581. private _effect;
  17582. private _customEffect;
  17583. private _cachedDefines;
  17584. private _scaledColorStep;
  17585. private _colorDiff;
  17586. private _scaledDirection;
  17587. private _scaledGravity;
  17588. private _currentRenderId;
  17589. private _alive;
  17590. private _useInstancing;
  17591. private _started;
  17592. private _stopped;
  17593. private _actualFrame;
  17594. private _scaledUpdateSpeed;
  17595. private _vertexBufferSize;
  17596. /** @hidden */
  17597. _currentEmitRateGradient: Nullable<FactorGradient>;
  17598. /** @hidden */
  17599. _currentEmitRate1: number;
  17600. /** @hidden */
  17601. _currentEmitRate2: number;
  17602. /** @hidden */
  17603. _currentStartSizeGradient: Nullable<FactorGradient>;
  17604. /** @hidden */
  17605. _currentStartSize1: number;
  17606. /** @hidden */
  17607. _currentStartSize2: number;
  17608. private readonly _rawTextureWidth;
  17609. private _rampGradientsTexture;
  17610. private _useRampGradients;
  17611. /** Gets or sets a boolean indicating that ramp gradients must be used
  17612. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17613. */
  17614. useRampGradients: boolean;
  17615. /**
  17616. * 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.
  17617. * 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: [])
  17618. */
  17619. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17620. private _subEmitters;
  17621. /**
  17622. * @hidden
  17623. * If the particle systems emitter should be disposed when the particle system is disposed
  17624. */
  17625. _disposeEmitterOnDispose: boolean;
  17626. /**
  17627. * The current active Sub-systems, this property is used by the root particle system only.
  17628. */
  17629. activeSubSystems: Array<ParticleSystem>;
  17630. private _rootParticleSystem;
  17631. /**
  17632. * Gets the current list of active particles
  17633. */
  17634. readonly particles: Particle[];
  17635. /**
  17636. * Returns the string "ParticleSystem"
  17637. * @returns a string containing the class name
  17638. */
  17639. getClassName(): string;
  17640. /**
  17641. * Instantiates a particle system.
  17642. * 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.
  17643. * @param name The name of the particle system
  17644. * @param capacity The max number of particles alive at the same time
  17645. * @param scene The scene the particle system belongs to
  17646. * @param customEffect a custom effect used to change the way particles are rendered by default
  17647. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17648. * @param epsilon Offset used to render the particles
  17649. */
  17650. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17651. private _addFactorGradient;
  17652. private _removeFactorGradient;
  17653. /**
  17654. * Adds a new life time gradient
  17655. * @param gradient defines the gradient to use (between 0 and 1)
  17656. * @param factor defines the life time factor to affect to the specified gradient
  17657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17658. * @returns the current particle system
  17659. */
  17660. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17661. /**
  17662. * Remove a specific life time gradient
  17663. * @param gradient defines the gradient to remove
  17664. * @returns the current particle system
  17665. */
  17666. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17667. /**
  17668. * Adds a new size gradient
  17669. * @param gradient defines the gradient to use (between 0 and 1)
  17670. * @param factor defines the size factor to affect to the specified gradient
  17671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17672. * @returns the current particle system
  17673. */
  17674. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17675. /**
  17676. * Remove a specific size gradient
  17677. * @param gradient defines the gradient to remove
  17678. * @returns the current particle system
  17679. */
  17680. removeSizeGradient(gradient: number): IParticleSystem;
  17681. /**
  17682. * Adds a new color remap gradient
  17683. * @param gradient defines the gradient to use (between 0 and 1)
  17684. * @param min defines the color remap minimal range
  17685. * @param max defines the color remap maximal range
  17686. * @returns the current particle system
  17687. */
  17688. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17689. /**
  17690. * Remove a specific color remap gradient
  17691. * @param gradient defines the gradient to remove
  17692. * @returns the current particle system
  17693. */
  17694. removeColorRemapGradient(gradient: number): IParticleSystem;
  17695. /**
  17696. * Adds a new alpha remap gradient
  17697. * @param gradient defines the gradient to use (between 0 and 1)
  17698. * @param min defines the alpha remap minimal range
  17699. * @param max defines the alpha remap maximal range
  17700. * @returns the current particle system
  17701. */
  17702. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17703. /**
  17704. * Remove a specific alpha remap gradient
  17705. * @param gradient defines the gradient to remove
  17706. * @returns the current particle system
  17707. */
  17708. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17709. /**
  17710. * Adds a new angular speed gradient
  17711. * @param gradient defines the gradient to use (between 0 and 1)
  17712. * @param factor defines the angular speed to affect to the specified gradient
  17713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17714. * @returns the current particle system
  17715. */
  17716. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17717. /**
  17718. * Remove a specific angular speed gradient
  17719. * @param gradient defines the gradient to remove
  17720. * @returns the current particle system
  17721. */
  17722. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17723. /**
  17724. * Adds a new velocity gradient
  17725. * @param gradient defines the gradient to use (between 0 and 1)
  17726. * @param factor defines the velocity to affect to the specified gradient
  17727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17728. * @returns the current particle system
  17729. */
  17730. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17731. /**
  17732. * Remove a specific velocity gradient
  17733. * @param gradient defines the gradient to remove
  17734. * @returns the current particle system
  17735. */
  17736. removeVelocityGradient(gradient: number): IParticleSystem;
  17737. /**
  17738. * Adds a new limit velocity gradient
  17739. * @param gradient defines the gradient to use (between 0 and 1)
  17740. * @param factor defines the limit velocity value to affect to the specified gradient
  17741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17742. * @returns the current particle system
  17743. */
  17744. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17745. /**
  17746. * Remove a specific limit velocity gradient
  17747. * @param gradient defines the gradient to remove
  17748. * @returns the current particle system
  17749. */
  17750. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17751. /**
  17752. * Adds a new drag gradient
  17753. * @param gradient defines the gradient to use (between 0 and 1)
  17754. * @param factor defines the drag value to affect to the specified gradient
  17755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17756. * @returns the current particle system
  17757. */
  17758. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17759. /**
  17760. * Remove a specific drag gradient
  17761. * @param gradient defines the gradient to remove
  17762. * @returns the current particle system
  17763. */
  17764. removeDragGradient(gradient: number): IParticleSystem;
  17765. /**
  17766. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17767. * @param gradient defines the gradient to use (between 0 and 1)
  17768. * @param factor defines the emit rate value to affect to the specified gradient
  17769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17770. * @returns the current particle system
  17771. */
  17772. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17773. /**
  17774. * Remove a specific emit rate gradient
  17775. * @param gradient defines the gradient to remove
  17776. * @returns the current particle system
  17777. */
  17778. removeEmitRateGradient(gradient: number): IParticleSystem;
  17779. /**
  17780. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17781. * @param gradient defines the gradient to use (between 0 and 1)
  17782. * @param factor defines the start size value to affect to the specified gradient
  17783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17784. * @returns the current particle system
  17785. */
  17786. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17787. /**
  17788. * Remove a specific start size gradient
  17789. * @param gradient defines the gradient to remove
  17790. * @returns the current particle system
  17791. */
  17792. removeStartSizeGradient(gradient: number): IParticleSystem;
  17793. private _createRampGradientTexture;
  17794. /**
  17795. * Gets the current list of ramp gradients.
  17796. * You must use addRampGradient and removeRampGradient to udpate this list
  17797. * @returns the list of ramp gradients
  17798. */
  17799. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17800. /**
  17801. * Adds a new ramp gradient used to remap particle colors
  17802. * @param gradient defines the gradient to use (between 0 and 1)
  17803. * @param color defines the color to affect to the specified gradient
  17804. * @returns the current particle system
  17805. */
  17806. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17807. /**
  17808. * Remove a specific ramp gradient
  17809. * @param gradient defines the gradient to remove
  17810. * @returns the current particle system
  17811. */
  17812. removeRampGradient(gradient: number): ParticleSystem;
  17813. /**
  17814. * Adds a new color gradient
  17815. * @param gradient defines the gradient to use (between 0 and 1)
  17816. * @param color1 defines the color to affect to the specified gradient
  17817. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17818. * @returns this particle system
  17819. */
  17820. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17821. /**
  17822. * Remove a specific color gradient
  17823. * @param gradient defines the gradient to remove
  17824. * @returns this particle system
  17825. */
  17826. removeColorGradient(gradient: number): IParticleSystem;
  17827. private _fetchR;
  17828. protected _reset(): void;
  17829. private _resetEffect;
  17830. private _createVertexBuffers;
  17831. private _createIndexBuffer;
  17832. /**
  17833. * Gets the maximum number of particles active at the same time.
  17834. * @returns The max number of active particles.
  17835. */
  17836. getCapacity(): number;
  17837. /**
  17838. * Gets whether there are still active particles in the system.
  17839. * @returns True if it is alive, otherwise false.
  17840. */
  17841. isAlive(): boolean;
  17842. /**
  17843. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17844. * @returns True if it has been started, otherwise false.
  17845. */
  17846. isStarted(): boolean;
  17847. private _prepareSubEmitterInternalArray;
  17848. /**
  17849. * Starts the particle system and begins to emit
  17850. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17851. */
  17852. start(delay?: number): void;
  17853. /**
  17854. * Stops the particle system.
  17855. * @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.
  17856. */
  17857. stop(stopSubEmitters?: boolean): void;
  17858. /**
  17859. * Remove all active particles
  17860. */
  17861. reset(): void;
  17862. /**
  17863. * @hidden (for internal use only)
  17864. */
  17865. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17866. /**
  17867. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17868. * Its lifetime will start back at 0.
  17869. */
  17870. recycleParticle: (particle: Particle) => void;
  17871. private _stopSubEmitters;
  17872. private _createParticle;
  17873. private _removeFromRoot;
  17874. private _emitFromParticle;
  17875. private _update;
  17876. /** @hidden */
  17877. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17878. /** @hidden */
  17879. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17880. /** @hidden */
  17881. private _getEffect;
  17882. /**
  17883. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17884. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17885. */
  17886. animate(preWarmOnly?: boolean): void;
  17887. private _appendParticleVertices;
  17888. /**
  17889. * Rebuilds the particle system.
  17890. */
  17891. rebuild(): void;
  17892. /**
  17893. * Is this system ready to be used/rendered
  17894. * @return true if the system is ready
  17895. */
  17896. isReady(): boolean;
  17897. private _render;
  17898. /**
  17899. * Renders the particle system in its current state.
  17900. * @returns the current number of particles
  17901. */
  17902. render(): number;
  17903. /**
  17904. * Disposes the particle system and free the associated resources
  17905. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17906. */
  17907. dispose(disposeTexture?: boolean): void;
  17908. /**
  17909. * Clones the particle system.
  17910. * @param name The name of the cloned object
  17911. * @param newEmitter The new emitter to use
  17912. * @returns the cloned particle system
  17913. */
  17914. clone(name: string, newEmitter: any): ParticleSystem;
  17915. /**
  17916. * Serializes the particle system to a JSON object.
  17917. * @returns the JSON object
  17918. */
  17919. serialize(): any;
  17920. /** @hidden */
  17921. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17922. /** @hidden */
  17923. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17924. /**
  17925. * Parses a JSON object to create a particle system.
  17926. * @param parsedParticleSystem The JSON object to parse
  17927. * @param scene The scene to create the particle system in
  17928. * @param rootUrl The root url to use to load external dependencies like texture
  17929. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17930. * @returns the Parsed particle system
  17931. */
  17932. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17933. }
  17934. }
  17935. declare module "babylonjs/Particles/particle" {
  17936. import { Nullable } from "babylonjs/types";
  17937. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17938. import { Color4 } from "babylonjs/Maths/math.color";
  17939. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17940. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17941. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17942. /**
  17943. * A particle represents one of the element emitted by a particle system.
  17944. * This is mainly define by its coordinates, direction, velocity and age.
  17945. */
  17946. export class Particle {
  17947. /**
  17948. * The particle system the particle belongs to.
  17949. */
  17950. particleSystem: ParticleSystem;
  17951. private static _Count;
  17952. /**
  17953. * Unique ID of the particle
  17954. */
  17955. id: number;
  17956. /**
  17957. * The world position of the particle in the scene.
  17958. */
  17959. position: Vector3;
  17960. /**
  17961. * The world direction of the particle in the scene.
  17962. */
  17963. direction: Vector3;
  17964. /**
  17965. * The color of the particle.
  17966. */
  17967. color: Color4;
  17968. /**
  17969. * The color change of the particle per step.
  17970. */
  17971. colorStep: Color4;
  17972. /**
  17973. * Defines how long will the life of the particle be.
  17974. */
  17975. lifeTime: number;
  17976. /**
  17977. * The current age of the particle.
  17978. */
  17979. age: number;
  17980. /**
  17981. * The current size of the particle.
  17982. */
  17983. size: number;
  17984. /**
  17985. * The current scale of the particle.
  17986. */
  17987. scale: Vector2;
  17988. /**
  17989. * The current angle of the particle.
  17990. */
  17991. angle: number;
  17992. /**
  17993. * Defines how fast is the angle changing.
  17994. */
  17995. angularSpeed: number;
  17996. /**
  17997. * Defines the cell index used by the particle to be rendered from a sprite.
  17998. */
  17999. cellIndex: number;
  18000. /**
  18001. * The information required to support color remapping
  18002. */
  18003. remapData: Vector4;
  18004. /** @hidden */
  18005. _randomCellOffset?: number;
  18006. /** @hidden */
  18007. _initialDirection: Nullable<Vector3>;
  18008. /** @hidden */
  18009. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18010. /** @hidden */
  18011. _initialStartSpriteCellID: number;
  18012. /** @hidden */
  18013. _initialEndSpriteCellID: number;
  18014. /** @hidden */
  18015. _currentColorGradient: Nullable<ColorGradient>;
  18016. /** @hidden */
  18017. _currentColor1: Color4;
  18018. /** @hidden */
  18019. _currentColor2: Color4;
  18020. /** @hidden */
  18021. _currentSizeGradient: Nullable<FactorGradient>;
  18022. /** @hidden */
  18023. _currentSize1: number;
  18024. /** @hidden */
  18025. _currentSize2: number;
  18026. /** @hidden */
  18027. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18028. /** @hidden */
  18029. _currentAngularSpeed1: number;
  18030. /** @hidden */
  18031. _currentAngularSpeed2: number;
  18032. /** @hidden */
  18033. _currentVelocityGradient: Nullable<FactorGradient>;
  18034. /** @hidden */
  18035. _currentVelocity1: number;
  18036. /** @hidden */
  18037. _currentVelocity2: number;
  18038. /** @hidden */
  18039. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18040. /** @hidden */
  18041. _currentLimitVelocity1: number;
  18042. /** @hidden */
  18043. _currentLimitVelocity2: number;
  18044. /** @hidden */
  18045. _currentDragGradient: Nullable<FactorGradient>;
  18046. /** @hidden */
  18047. _currentDrag1: number;
  18048. /** @hidden */
  18049. _currentDrag2: number;
  18050. /** @hidden */
  18051. _randomNoiseCoordinates1: Vector3;
  18052. /** @hidden */
  18053. _randomNoiseCoordinates2: Vector3;
  18054. /**
  18055. * Creates a new instance Particle
  18056. * @param particleSystem the particle system the particle belongs to
  18057. */
  18058. constructor(
  18059. /**
  18060. * The particle system the particle belongs to.
  18061. */
  18062. particleSystem: ParticleSystem);
  18063. private updateCellInfoFromSystem;
  18064. /**
  18065. * Defines how the sprite cell index is updated for the particle
  18066. */
  18067. updateCellIndex(): void;
  18068. /** @hidden */
  18069. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18070. /** @hidden */
  18071. _inheritParticleInfoToSubEmitters(): void;
  18072. /** @hidden */
  18073. _reset(): void;
  18074. /**
  18075. * Copy the properties of particle to another one.
  18076. * @param other the particle to copy the information to.
  18077. */
  18078. copyTo(other: Particle): void;
  18079. }
  18080. }
  18081. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18082. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18083. import { Effect } from "babylonjs/Materials/effect";
  18084. import { Particle } from "babylonjs/Particles/particle";
  18085. /**
  18086. * Particle emitter represents a volume emitting particles.
  18087. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18088. */
  18089. export interface IParticleEmitterType {
  18090. /**
  18091. * Called by the particle System when the direction is computed for the created particle.
  18092. * @param worldMatrix is the world matrix of the particle system
  18093. * @param directionToUpdate is the direction vector to update with the result
  18094. * @param particle is the particle we are computed the direction for
  18095. */
  18096. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18097. /**
  18098. * Called by the particle System when the position is computed for the created particle.
  18099. * @param worldMatrix is the world matrix of the particle system
  18100. * @param positionToUpdate is the position vector to update with the result
  18101. * @param particle is the particle we are computed the position for
  18102. */
  18103. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18104. /**
  18105. * Clones the current emitter and returns a copy of it
  18106. * @returns the new emitter
  18107. */
  18108. clone(): IParticleEmitterType;
  18109. /**
  18110. * Called by the GPUParticleSystem to setup the update shader
  18111. * @param effect defines the update shader
  18112. */
  18113. applyToShader(effect: Effect): void;
  18114. /**
  18115. * Returns a string to use to update the GPU particles update shader
  18116. * @returns the effect defines string
  18117. */
  18118. getEffectDefines(): string;
  18119. /**
  18120. * Returns a string representing the class name
  18121. * @returns a string containing the class name
  18122. */
  18123. getClassName(): string;
  18124. /**
  18125. * Serializes the particle system to a JSON object.
  18126. * @returns the JSON object
  18127. */
  18128. serialize(): any;
  18129. /**
  18130. * Parse properties from a JSON object
  18131. * @param serializationObject defines the JSON object
  18132. */
  18133. parse(serializationObject: any): void;
  18134. }
  18135. }
  18136. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18137. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18138. import { Effect } from "babylonjs/Materials/effect";
  18139. import { Particle } from "babylonjs/Particles/particle";
  18140. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18141. /**
  18142. * Particle emitter emitting particles from the inside of a box.
  18143. * It emits the particles randomly between 2 given directions.
  18144. */
  18145. export class BoxParticleEmitter implements IParticleEmitterType {
  18146. /**
  18147. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18148. */
  18149. direction1: Vector3;
  18150. /**
  18151. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18152. */
  18153. direction2: Vector3;
  18154. /**
  18155. * 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.
  18156. */
  18157. minEmitBox: Vector3;
  18158. /**
  18159. * 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.
  18160. */
  18161. maxEmitBox: Vector3;
  18162. /**
  18163. * Creates a new instance BoxParticleEmitter
  18164. */
  18165. constructor();
  18166. /**
  18167. * Called by the particle System when the direction is computed for the created particle.
  18168. * @param worldMatrix is the world matrix of the particle system
  18169. * @param directionToUpdate is the direction vector to update with the result
  18170. * @param particle is the particle we are computed the direction for
  18171. */
  18172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18173. /**
  18174. * Called by the particle System when the position is computed for the created particle.
  18175. * @param worldMatrix is the world matrix of the particle system
  18176. * @param positionToUpdate is the position vector to update with the result
  18177. * @param particle is the particle we are computed the position for
  18178. */
  18179. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18180. /**
  18181. * Clones the current emitter and returns a copy of it
  18182. * @returns the new emitter
  18183. */
  18184. clone(): BoxParticleEmitter;
  18185. /**
  18186. * Called by the GPUParticleSystem to setup the update shader
  18187. * @param effect defines the update shader
  18188. */
  18189. applyToShader(effect: Effect): void;
  18190. /**
  18191. * Returns a string to use to update the GPU particles update shader
  18192. * @returns a string containng the defines string
  18193. */
  18194. getEffectDefines(): string;
  18195. /**
  18196. * Returns the string "BoxParticleEmitter"
  18197. * @returns a string containing the class name
  18198. */
  18199. getClassName(): string;
  18200. /**
  18201. * Serializes the particle system to a JSON object.
  18202. * @returns the JSON object
  18203. */
  18204. serialize(): any;
  18205. /**
  18206. * Parse properties from a JSON object
  18207. * @param serializationObject defines the JSON object
  18208. */
  18209. parse(serializationObject: any): void;
  18210. }
  18211. }
  18212. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18213. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18214. import { Effect } from "babylonjs/Materials/effect";
  18215. import { Particle } from "babylonjs/Particles/particle";
  18216. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18217. /**
  18218. * Particle emitter emitting particles from the inside of a cone.
  18219. * It emits the particles alongside the cone volume from the base to the particle.
  18220. * The emission direction might be randomized.
  18221. */
  18222. export class ConeParticleEmitter implements IParticleEmitterType {
  18223. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18224. directionRandomizer: number;
  18225. private _radius;
  18226. private _angle;
  18227. private _height;
  18228. /**
  18229. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18230. */
  18231. radiusRange: number;
  18232. /**
  18233. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18234. */
  18235. heightRange: number;
  18236. /**
  18237. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18238. */
  18239. emitFromSpawnPointOnly: boolean;
  18240. /**
  18241. * Gets or sets the radius of the emission cone
  18242. */
  18243. radius: number;
  18244. /**
  18245. * Gets or sets the angle of the emission cone
  18246. */
  18247. angle: number;
  18248. private _buildHeight;
  18249. /**
  18250. * Creates a new instance ConeParticleEmitter
  18251. * @param radius the radius of the emission cone (1 by default)
  18252. * @param angle the cone base angle (PI by default)
  18253. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18254. */
  18255. constructor(radius?: number, angle?: number,
  18256. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18257. directionRandomizer?: number);
  18258. /**
  18259. * Called by the particle System when the direction is computed for the created particle.
  18260. * @param worldMatrix is the world matrix of the particle system
  18261. * @param directionToUpdate is the direction vector to update with the result
  18262. * @param particle is the particle we are computed the direction for
  18263. */
  18264. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18265. /**
  18266. * Called by the particle System when the position is computed for the created particle.
  18267. * @param worldMatrix is the world matrix of the particle system
  18268. * @param positionToUpdate is the position vector to update with the result
  18269. * @param particle is the particle we are computed the position for
  18270. */
  18271. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18272. /**
  18273. * Clones the current emitter and returns a copy of it
  18274. * @returns the new emitter
  18275. */
  18276. clone(): ConeParticleEmitter;
  18277. /**
  18278. * Called by the GPUParticleSystem to setup the update shader
  18279. * @param effect defines the update shader
  18280. */
  18281. applyToShader(effect: Effect): void;
  18282. /**
  18283. * Returns a string to use to update the GPU particles update shader
  18284. * @returns a string containng the defines string
  18285. */
  18286. getEffectDefines(): string;
  18287. /**
  18288. * Returns the string "ConeParticleEmitter"
  18289. * @returns a string containing the class name
  18290. */
  18291. getClassName(): string;
  18292. /**
  18293. * Serializes the particle system to a JSON object.
  18294. * @returns the JSON object
  18295. */
  18296. serialize(): any;
  18297. /**
  18298. * Parse properties from a JSON object
  18299. * @param serializationObject defines the JSON object
  18300. */
  18301. parse(serializationObject: any): void;
  18302. }
  18303. }
  18304. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18305. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18306. import { Effect } from "babylonjs/Materials/effect";
  18307. import { Particle } from "babylonjs/Particles/particle";
  18308. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18309. /**
  18310. * Particle emitter emitting particles from the inside of a cylinder.
  18311. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18312. */
  18313. export class CylinderParticleEmitter implements IParticleEmitterType {
  18314. /**
  18315. * The radius of the emission cylinder.
  18316. */
  18317. radius: number;
  18318. /**
  18319. * The height of the emission cylinder.
  18320. */
  18321. height: number;
  18322. /**
  18323. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18324. */
  18325. radiusRange: number;
  18326. /**
  18327. * How much to randomize the particle direction [0-1].
  18328. */
  18329. directionRandomizer: number;
  18330. /**
  18331. * Creates a new instance CylinderParticleEmitter
  18332. * @param radius the radius of the emission cylinder (1 by default)
  18333. * @param height the height of the emission cylinder (1 by default)
  18334. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18335. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18336. */
  18337. constructor(
  18338. /**
  18339. * The radius of the emission cylinder.
  18340. */
  18341. radius?: number,
  18342. /**
  18343. * The height of the emission cylinder.
  18344. */
  18345. height?: number,
  18346. /**
  18347. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18348. */
  18349. radiusRange?: number,
  18350. /**
  18351. * How much to randomize the particle direction [0-1].
  18352. */
  18353. directionRandomizer?: number);
  18354. /**
  18355. * Called by the particle System when the direction is computed for the created particle.
  18356. * @param worldMatrix is the world matrix of the particle system
  18357. * @param directionToUpdate is the direction vector to update with the result
  18358. * @param particle is the particle we are computed the direction for
  18359. */
  18360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18361. /**
  18362. * Called by the particle System when the position is computed for the created particle.
  18363. * @param worldMatrix is the world matrix of the particle system
  18364. * @param positionToUpdate is the position vector to update with the result
  18365. * @param particle is the particle we are computed the position for
  18366. */
  18367. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18368. /**
  18369. * Clones the current emitter and returns a copy of it
  18370. * @returns the new emitter
  18371. */
  18372. clone(): CylinderParticleEmitter;
  18373. /**
  18374. * Called by the GPUParticleSystem to setup the update shader
  18375. * @param effect defines the update shader
  18376. */
  18377. applyToShader(effect: Effect): void;
  18378. /**
  18379. * Returns a string to use to update the GPU particles update shader
  18380. * @returns a string containng the defines string
  18381. */
  18382. getEffectDefines(): string;
  18383. /**
  18384. * Returns the string "CylinderParticleEmitter"
  18385. * @returns a string containing the class name
  18386. */
  18387. getClassName(): string;
  18388. /**
  18389. * Serializes the particle system to a JSON object.
  18390. * @returns the JSON object
  18391. */
  18392. serialize(): any;
  18393. /**
  18394. * Parse properties from a JSON object
  18395. * @param serializationObject defines the JSON object
  18396. */
  18397. parse(serializationObject: any): void;
  18398. }
  18399. /**
  18400. * Particle emitter emitting particles from the inside of a cylinder.
  18401. * It emits the particles randomly between two vectors.
  18402. */
  18403. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18404. /**
  18405. * The min limit of the emission direction.
  18406. */
  18407. direction1: Vector3;
  18408. /**
  18409. * The max limit of the emission direction.
  18410. */
  18411. direction2: Vector3;
  18412. /**
  18413. * Creates a new instance CylinderDirectedParticleEmitter
  18414. * @param radius the radius of the emission cylinder (1 by default)
  18415. * @param height the height of the emission cylinder (1 by default)
  18416. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18417. * @param direction1 the min limit of the emission direction (up vector by default)
  18418. * @param direction2 the max limit of the emission direction (up vector by default)
  18419. */
  18420. constructor(radius?: number, height?: number, radiusRange?: number,
  18421. /**
  18422. * The min limit of the emission direction.
  18423. */
  18424. direction1?: Vector3,
  18425. /**
  18426. * The max limit of the emission direction.
  18427. */
  18428. direction2?: Vector3);
  18429. /**
  18430. * Called by the particle System when the direction is computed for the created particle.
  18431. * @param worldMatrix is the world matrix of the particle system
  18432. * @param directionToUpdate is the direction vector to update with the result
  18433. * @param particle is the particle we are computed the direction for
  18434. */
  18435. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18436. /**
  18437. * Clones the current emitter and returns a copy of it
  18438. * @returns the new emitter
  18439. */
  18440. clone(): CylinderDirectedParticleEmitter;
  18441. /**
  18442. * Called by the GPUParticleSystem to setup the update shader
  18443. * @param effect defines the update shader
  18444. */
  18445. applyToShader(effect: Effect): void;
  18446. /**
  18447. * Returns a string to use to update the GPU particles update shader
  18448. * @returns a string containng the defines string
  18449. */
  18450. getEffectDefines(): string;
  18451. /**
  18452. * Returns the string "CylinderDirectedParticleEmitter"
  18453. * @returns a string containing the class name
  18454. */
  18455. getClassName(): string;
  18456. /**
  18457. * Serializes the particle system to a JSON object.
  18458. * @returns the JSON object
  18459. */
  18460. serialize(): any;
  18461. /**
  18462. * Parse properties from a JSON object
  18463. * @param serializationObject defines the JSON object
  18464. */
  18465. parse(serializationObject: any): void;
  18466. }
  18467. }
  18468. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18469. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18470. import { Effect } from "babylonjs/Materials/effect";
  18471. import { Particle } from "babylonjs/Particles/particle";
  18472. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18473. /**
  18474. * Particle emitter emitting particles from the inside of a hemisphere.
  18475. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18476. */
  18477. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18478. /**
  18479. * The radius of the emission hemisphere.
  18480. */
  18481. radius: number;
  18482. /**
  18483. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18484. */
  18485. radiusRange: number;
  18486. /**
  18487. * How much to randomize the particle direction [0-1].
  18488. */
  18489. directionRandomizer: number;
  18490. /**
  18491. * Creates a new instance HemisphericParticleEmitter
  18492. * @param radius the radius of the emission hemisphere (1 by default)
  18493. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18494. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18495. */
  18496. constructor(
  18497. /**
  18498. * The radius of the emission hemisphere.
  18499. */
  18500. radius?: number,
  18501. /**
  18502. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18503. */
  18504. radiusRange?: number,
  18505. /**
  18506. * How much to randomize the particle direction [0-1].
  18507. */
  18508. directionRandomizer?: number);
  18509. /**
  18510. * Called by the particle System when the direction is computed for the created particle.
  18511. * @param worldMatrix is the world matrix of the particle system
  18512. * @param directionToUpdate is the direction vector to update with the result
  18513. * @param particle is the particle we are computed the direction for
  18514. */
  18515. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18516. /**
  18517. * Called by the particle System when the position is computed for the created particle.
  18518. * @param worldMatrix is the world matrix of the particle system
  18519. * @param positionToUpdate is the position vector to update with the result
  18520. * @param particle is the particle we are computed the position for
  18521. */
  18522. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18523. /**
  18524. * Clones the current emitter and returns a copy of it
  18525. * @returns the new emitter
  18526. */
  18527. clone(): HemisphericParticleEmitter;
  18528. /**
  18529. * Called by the GPUParticleSystem to setup the update shader
  18530. * @param effect defines the update shader
  18531. */
  18532. applyToShader(effect: Effect): void;
  18533. /**
  18534. * Returns a string to use to update the GPU particles update shader
  18535. * @returns a string containng the defines string
  18536. */
  18537. getEffectDefines(): string;
  18538. /**
  18539. * Returns the string "HemisphericParticleEmitter"
  18540. * @returns a string containing the class name
  18541. */
  18542. getClassName(): string;
  18543. /**
  18544. * Serializes the particle system to a JSON object.
  18545. * @returns the JSON object
  18546. */
  18547. serialize(): any;
  18548. /**
  18549. * Parse properties from a JSON object
  18550. * @param serializationObject defines the JSON object
  18551. */
  18552. parse(serializationObject: any): void;
  18553. }
  18554. }
  18555. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18556. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18557. import { Effect } from "babylonjs/Materials/effect";
  18558. import { Particle } from "babylonjs/Particles/particle";
  18559. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18560. /**
  18561. * Particle emitter emitting particles from a point.
  18562. * It emits the particles randomly between 2 given directions.
  18563. */
  18564. export class PointParticleEmitter implements IParticleEmitterType {
  18565. /**
  18566. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18567. */
  18568. direction1: Vector3;
  18569. /**
  18570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18571. */
  18572. direction2: Vector3;
  18573. /**
  18574. * Creates a new instance PointParticleEmitter
  18575. */
  18576. constructor();
  18577. /**
  18578. * Called by the particle System when the direction is computed for the created particle.
  18579. * @param worldMatrix is the world matrix of the particle system
  18580. * @param directionToUpdate is the direction vector to update with the result
  18581. * @param particle is the particle we are computed the direction for
  18582. */
  18583. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18584. /**
  18585. * Called by the particle System when the position is computed for the created particle.
  18586. * @param worldMatrix is the world matrix of the particle system
  18587. * @param positionToUpdate is the position vector to update with the result
  18588. * @param particle is the particle we are computed the position for
  18589. */
  18590. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18591. /**
  18592. * Clones the current emitter and returns a copy of it
  18593. * @returns the new emitter
  18594. */
  18595. clone(): PointParticleEmitter;
  18596. /**
  18597. * Called by the GPUParticleSystem to setup the update shader
  18598. * @param effect defines the update shader
  18599. */
  18600. applyToShader(effect: Effect): void;
  18601. /**
  18602. * Returns a string to use to update the GPU particles update shader
  18603. * @returns a string containng the defines string
  18604. */
  18605. getEffectDefines(): string;
  18606. /**
  18607. * Returns the string "PointParticleEmitter"
  18608. * @returns a string containing the class name
  18609. */
  18610. getClassName(): string;
  18611. /**
  18612. * Serializes the particle system to a JSON object.
  18613. * @returns the JSON object
  18614. */
  18615. serialize(): any;
  18616. /**
  18617. * Parse properties from a JSON object
  18618. * @param serializationObject defines the JSON object
  18619. */
  18620. parse(serializationObject: any): void;
  18621. }
  18622. }
  18623. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18624. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18625. import { Effect } from "babylonjs/Materials/effect";
  18626. import { Particle } from "babylonjs/Particles/particle";
  18627. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18628. /**
  18629. * Particle emitter emitting particles from the inside of a sphere.
  18630. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18631. */
  18632. export class SphereParticleEmitter implements IParticleEmitterType {
  18633. /**
  18634. * The radius of the emission sphere.
  18635. */
  18636. radius: number;
  18637. /**
  18638. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18639. */
  18640. radiusRange: number;
  18641. /**
  18642. * How much to randomize the particle direction [0-1].
  18643. */
  18644. directionRandomizer: number;
  18645. /**
  18646. * Creates a new instance SphereParticleEmitter
  18647. * @param radius the radius of the emission sphere (1 by default)
  18648. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18649. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18650. */
  18651. constructor(
  18652. /**
  18653. * The radius of the emission sphere.
  18654. */
  18655. radius?: number,
  18656. /**
  18657. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18658. */
  18659. radiusRange?: number,
  18660. /**
  18661. * How much to randomize the particle direction [0-1].
  18662. */
  18663. directionRandomizer?: number);
  18664. /**
  18665. * Called by the particle System when the direction is computed for the created particle.
  18666. * @param worldMatrix is the world matrix of the particle system
  18667. * @param directionToUpdate is the direction vector to update with the result
  18668. * @param particle is the particle we are computed the direction for
  18669. */
  18670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18671. /**
  18672. * Called by the particle System when the position is computed for the created particle.
  18673. * @param worldMatrix is the world matrix of the particle system
  18674. * @param positionToUpdate is the position vector to update with the result
  18675. * @param particle is the particle we are computed the position for
  18676. */
  18677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18678. /**
  18679. * Clones the current emitter and returns a copy of it
  18680. * @returns the new emitter
  18681. */
  18682. clone(): SphereParticleEmitter;
  18683. /**
  18684. * Called by the GPUParticleSystem to setup the update shader
  18685. * @param effect defines the update shader
  18686. */
  18687. applyToShader(effect: Effect): void;
  18688. /**
  18689. * Returns a string to use to update the GPU particles update shader
  18690. * @returns a string containng the defines string
  18691. */
  18692. getEffectDefines(): string;
  18693. /**
  18694. * Returns the string "SphereParticleEmitter"
  18695. * @returns a string containing the class name
  18696. */
  18697. getClassName(): string;
  18698. /**
  18699. * Serializes the particle system to a JSON object.
  18700. * @returns the JSON object
  18701. */
  18702. serialize(): any;
  18703. /**
  18704. * Parse properties from a JSON object
  18705. * @param serializationObject defines the JSON object
  18706. */
  18707. parse(serializationObject: any): void;
  18708. }
  18709. /**
  18710. * Particle emitter emitting particles from the inside of a sphere.
  18711. * It emits the particles randomly between two vectors.
  18712. */
  18713. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18714. /**
  18715. * The min limit of the emission direction.
  18716. */
  18717. direction1: Vector3;
  18718. /**
  18719. * The max limit of the emission direction.
  18720. */
  18721. direction2: Vector3;
  18722. /**
  18723. * Creates a new instance SphereDirectedParticleEmitter
  18724. * @param radius the radius of the emission sphere (1 by default)
  18725. * @param direction1 the min limit of the emission direction (up vector by default)
  18726. * @param direction2 the max limit of the emission direction (up vector by default)
  18727. */
  18728. constructor(radius?: number,
  18729. /**
  18730. * The min limit of the emission direction.
  18731. */
  18732. direction1?: Vector3,
  18733. /**
  18734. * The max limit of the emission direction.
  18735. */
  18736. direction2?: Vector3);
  18737. /**
  18738. * Called by the particle System when the direction is computed for the created particle.
  18739. * @param worldMatrix is the world matrix of the particle system
  18740. * @param directionToUpdate is the direction vector to update with the result
  18741. * @param particle is the particle we are computed the direction for
  18742. */
  18743. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18744. /**
  18745. * Clones the current emitter and returns a copy of it
  18746. * @returns the new emitter
  18747. */
  18748. clone(): SphereDirectedParticleEmitter;
  18749. /**
  18750. * Called by the GPUParticleSystem to setup the update shader
  18751. * @param effect defines the update shader
  18752. */
  18753. applyToShader(effect: Effect): void;
  18754. /**
  18755. * Returns a string to use to update the GPU particles update shader
  18756. * @returns a string containng the defines string
  18757. */
  18758. getEffectDefines(): string;
  18759. /**
  18760. * Returns the string "SphereDirectedParticleEmitter"
  18761. * @returns a string containing the class name
  18762. */
  18763. getClassName(): string;
  18764. /**
  18765. * Serializes the particle system to a JSON object.
  18766. * @returns the JSON object
  18767. */
  18768. serialize(): any;
  18769. /**
  18770. * Parse properties from a JSON object
  18771. * @param serializationObject defines the JSON object
  18772. */
  18773. parse(serializationObject: any): void;
  18774. }
  18775. }
  18776. declare module "babylonjs/Particles/EmitterTypes/index" {
  18777. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18778. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18779. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18780. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18781. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18782. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18783. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18784. }
  18785. declare module "babylonjs/Particles/IParticleSystem" {
  18786. import { Nullable } from "babylonjs/types";
  18787. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18788. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18791. import { Texture } from "babylonjs/Materials/Textures/texture";
  18792. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18793. import { Scene } from "babylonjs/scene";
  18794. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18795. import { Animation } from "babylonjs/Animations/animation";
  18796. /**
  18797. * Interface representing a particle system in Babylon.js.
  18798. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18799. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18800. */
  18801. export interface IParticleSystem {
  18802. /**
  18803. * List of animations used by the particle system.
  18804. */
  18805. animations: Animation[];
  18806. /**
  18807. * The id of the Particle system.
  18808. */
  18809. id: string;
  18810. /**
  18811. * The name of the Particle system.
  18812. */
  18813. name: string;
  18814. /**
  18815. * The emitter represents the Mesh or position we are attaching the particle system to.
  18816. */
  18817. emitter: Nullable<AbstractMesh | Vector3>;
  18818. /**
  18819. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18820. */
  18821. isBillboardBased: boolean;
  18822. /**
  18823. * The rendering group used by the Particle system to chose when to render.
  18824. */
  18825. renderingGroupId: number;
  18826. /**
  18827. * The layer mask we are rendering the particles through.
  18828. */
  18829. layerMask: number;
  18830. /**
  18831. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18832. */
  18833. updateSpeed: number;
  18834. /**
  18835. * The amount of time the particle system is running (depends of the overall update speed).
  18836. */
  18837. targetStopDuration: number;
  18838. /**
  18839. * The texture used to render each particle. (this can be a spritesheet)
  18840. */
  18841. particleTexture: Nullable<Texture>;
  18842. /**
  18843. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18844. */
  18845. blendMode: number;
  18846. /**
  18847. * Minimum life time of emitting particles.
  18848. */
  18849. minLifeTime: number;
  18850. /**
  18851. * Maximum life time of emitting particles.
  18852. */
  18853. maxLifeTime: number;
  18854. /**
  18855. * Minimum Size of emitting particles.
  18856. */
  18857. minSize: number;
  18858. /**
  18859. * Maximum Size of emitting particles.
  18860. */
  18861. maxSize: number;
  18862. /**
  18863. * Minimum scale of emitting particles on X axis.
  18864. */
  18865. minScaleX: number;
  18866. /**
  18867. * Maximum scale of emitting particles on X axis.
  18868. */
  18869. maxScaleX: number;
  18870. /**
  18871. * Minimum scale of emitting particles on Y axis.
  18872. */
  18873. minScaleY: number;
  18874. /**
  18875. * Maximum scale of emitting particles on Y axis.
  18876. */
  18877. maxScaleY: number;
  18878. /**
  18879. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18880. */
  18881. color1: Color4;
  18882. /**
  18883. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18884. */
  18885. color2: Color4;
  18886. /**
  18887. * Color the particle will have at the end of its lifetime.
  18888. */
  18889. colorDead: Color4;
  18890. /**
  18891. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18892. */
  18893. emitRate: number;
  18894. /**
  18895. * You can use gravity if you want to give an orientation to your particles.
  18896. */
  18897. gravity: Vector3;
  18898. /**
  18899. * Minimum power of emitting particles.
  18900. */
  18901. minEmitPower: number;
  18902. /**
  18903. * Maximum power of emitting particles.
  18904. */
  18905. maxEmitPower: number;
  18906. /**
  18907. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18908. */
  18909. minAngularSpeed: number;
  18910. /**
  18911. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18912. */
  18913. maxAngularSpeed: number;
  18914. /**
  18915. * Gets or sets the minimal initial rotation in radians.
  18916. */
  18917. minInitialRotation: number;
  18918. /**
  18919. * Gets or sets the maximal initial rotation in radians.
  18920. */
  18921. maxInitialRotation: number;
  18922. /**
  18923. * The particle emitter type defines the emitter used by the particle system.
  18924. * It can be for example box, sphere, or cone...
  18925. */
  18926. particleEmitterType: Nullable<IParticleEmitterType>;
  18927. /**
  18928. * Defines the delay in milliseconds before starting the system (0 by default)
  18929. */
  18930. startDelay: number;
  18931. /**
  18932. * 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
  18933. */
  18934. preWarmCycles: number;
  18935. /**
  18936. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18937. */
  18938. preWarmStepOffset: number;
  18939. /**
  18940. * 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)
  18941. */
  18942. spriteCellChangeSpeed: number;
  18943. /**
  18944. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18945. */
  18946. startSpriteCellID: number;
  18947. /**
  18948. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18949. */
  18950. endSpriteCellID: number;
  18951. /**
  18952. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18953. */
  18954. spriteCellWidth: number;
  18955. /**
  18956. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18957. */
  18958. spriteCellHeight: number;
  18959. /**
  18960. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18961. */
  18962. spriteRandomStartCell: boolean;
  18963. /**
  18964. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18965. */
  18966. isAnimationSheetEnabled: boolean;
  18967. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18968. translationPivot: Vector2;
  18969. /**
  18970. * Gets or sets a texture used to add random noise to particle positions
  18971. */
  18972. noiseTexture: Nullable<BaseTexture>;
  18973. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18974. noiseStrength: Vector3;
  18975. /**
  18976. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18977. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18978. */
  18979. billboardMode: number;
  18980. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18981. limitVelocityDamping: number;
  18982. /**
  18983. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18984. */
  18985. beginAnimationOnStart: boolean;
  18986. /**
  18987. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18988. */
  18989. beginAnimationFrom: number;
  18990. /**
  18991. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18992. */
  18993. beginAnimationTo: number;
  18994. /**
  18995. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18996. */
  18997. beginAnimationLoop: boolean;
  18998. /**
  18999. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19000. */
  19001. disposeOnStop: boolean;
  19002. /**
  19003. * Gets the maximum number of particles active at the same time.
  19004. * @returns The max number of active particles.
  19005. */
  19006. getCapacity(): number;
  19007. /**
  19008. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19009. * @returns True if it has been started, otherwise false.
  19010. */
  19011. isStarted(): boolean;
  19012. /**
  19013. * Animates the particle system for this frame.
  19014. */
  19015. animate(): void;
  19016. /**
  19017. * Renders the particle system in its current state.
  19018. * @returns the current number of particles
  19019. */
  19020. render(): number;
  19021. /**
  19022. * Dispose the particle system and frees its associated resources.
  19023. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19024. */
  19025. dispose(disposeTexture?: boolean): void;
  19026. /**
  19027. * Clones the particle system.
  19028. * @param name The name of the cloned object
  19029. * @param newEmitter The new emitter to use
  19030. * @returns the cloned particle system
  19031. */
  19032. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19033. /**
  19034. * Serializes the particle system to a JSON object.
  19035. * @returns the JSON object
  19036. */
  19037. serialize(): any;
  19038. /**
  19039. * Rebuild the particle system
  19040. */
  19041. rebuild(): void;
  19042. /**
  19043. * Starts the particle system and begins to emit
  19044. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19045. */
  19046. start(delay?: number): void;
  19047. /**
  19048. * Stops the particle system.
  19049. */
  19050. stop(): void;
  19051. /**
  19052. * Remove all active particles
  19053. */
  19054. reset(): void;
  19055. /**
  19056. * Is this system ready to be used/rendered
  19057. * @return true if the system is ready
  19058. */
  19059. isReady(): boolean;
  19060. /**
  19061. * Adds a new color gradient
  19062. * @param gradient defines the gradient to use (between 0 and 1)
  19063. * @param color1 defines the color to affect to the specified gradient
  19064. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19065. * @returns the current particle system
  19066. */
  19067. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19068. /**
  19069. * Remove a specific color gradient
  19070. * @param gradient defines the gradient to remove
  19071. * @returns the current particle system
  19072. */
  19073. removeColorGradient(gradient: number): IParticleSystem;
  19074. /**
  19075. * Adds a new size gradient
  19076. * @param gradient defines the gradient to use (between 0 and 1)
  19077. * @param factor defines the size factor to affect to the specified gradient
  19078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19079. * @returns the current particle system
  19080. */
  19081. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19082. /**
  19083. * Remove a specific size gradient
  19084. * @param gradient defines the gradient to remove
  19085. * @returns the current particle system
  19086. */
  19087. removeSizeGradient(gradient: number): IParticleSystem;
  19088. /**
  19089. * Gets the current list of color gradients.
  19090. * You must use addColorGradient and removeColorGradient to udpate this list
  19091. * @returns the list of color gradients
  19092. */
  19093. getColorGradients(): Nullable<Array<ColorGradient>>;
  19094. /**
  19095. * Gets the current list of size gradients.
  19096. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19097. * @returns the list of size gradients
  19098. */
  19099. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19100. /**
  19101. * Gets the current list of angular speed gradients.
  19102. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19103. * @returns the list of angular speed gradients
  19104. */
  19105. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19106. /**
  19107. * Adds a new angular speed gradient
  19108. * @param gradient defines the gradient to use (between 0 and 1)
  19109. * @param factor defines the angular speed to affect to the specified gradient
  19110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19111. * @returns the current particle system
  19112. */
  19113. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19114. /**
  19115. * Remove a specific angular speed gradient
  19116. * @param gradient defines the gradient to remove
  19117. * @returns the current particle system
  19118. */
  19119. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19120. /**
  19121. * Gets the current list of velocity gradients.
  19122. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19123. * @returns the list of velocity gradients
  19124. */
  19125. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19126. /**
  19127. * Adds a new velocity gradient
  19128. * @param gradient defines the gradient to use (between 0 and 1)
  19129. * @param factor defines the velocity to affect to the specified gradient
  19130. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19131. * @returns the current particle system
  19132. */
  19133. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19134. /**
  19135. * Remove a specific velocity gradient
  19136. * @param gradient defines the gradient to remove
  19137. * @returns the current particle system
  19138. */
  19139. removeVelocityGradient(gradient: number): IParticleSystem;
  19140. /**
  19141. * Gets the current list of limit velocity gradients.
  19142. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19143. * @returns the list of limit velocity gradients
  19144. */
  19145. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19146. /**
  19147. * Adds a new limit velocity gradient
  19148. * @param gradient defines the gradient to use (between 0 and 1)
  19149. * @param factor defines the limit velocity to affect to the specified gradient
  19150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19151. * @returns the current particle system
  19152. */
  19153. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19154. /**
  19155. * Remove a specific limit velocity gradient
  19156. * @param gradient defines the gradient to remove
  19157. * @returns the current particle system
  19158. */
  19159. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19160. /**
  19161. * Adds a new drag gradient
  19162. * @param gradient defines the gradient to use (between 0 and 1)
  19163. * @param factor defines the drag to affect to the specified gradient
  19164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19165. * @returns the current particle system
  19166. */
  19167. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19168. /**
  19169. * Remove a specific drag gradient
  19170. * @param gradient defines the gradient to remove
  19171. * @returns the current particle system
  19172. */
  19173. removeDragGradient(gradient: number): IParticleSystem;
  19174. /**
  19175. * Gets the current list of drag gradients.
  19176. * You must use addDragGradient and removeDragGradient to udpate this list
  19177. * @returns the list of drag gradients
  19178. */
  19179. getDragGradients(): Nullable<Array<FactorGradient>>;
  19180. /**
  19181. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19182. * @param gradient defines the gradient to use (between 0 and 1)
  19183. * @param factor defines the emit rate to affect to the specified gradient
  19184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19185. * @returns the current particle system
  19186. */
  19187. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19188. /**
  19189. * Remove a specific emit rate gradient
  19190. * @param gradient defines the gradient to remove
  19191. * @returns the current particle system
  19192. */
  19193. removeEmitRateGradient(gradient: number): IParticleSystem;
  19194. /**
  19195. * Gets the current list of emit rate gradients.
  19196. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19197. * @returns the list of emit rate gradients
  19198. */
  19199. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19200. /**
  19201. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19202. * @param gradient defines the gradient to use (between 0 and 1)
  19203. * @param factor defines the start size to affect to the specified gradient
  19204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19205. * @returns the current particle system
  19206. */
  19207. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19208. /**
  19209. * Remove a specific start size gradient
  19210. * @param gradient defines the gradient to remove
  19211. * @returns the current particle system
  19212. */
  19213. removeStartSizeGradient(gradient: number): IParticleSystem;
  19214. /**
  19215. * Gets the current list of start size gradients.
  19216. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19217. * @returns the list of start size gradients
  19218. */
  19219. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19220. /**
  19221. * Adds a new life time gradient
  19222. * @param gradient defines the gradient to use (between 0 and 1)
  19223. * @param factor defines the life time factor to affect to the specified gradient
  19224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19225. * @returns the current particle system
  19226. */
  19227. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19228. /**
  19229. * Remove a specific life time gradient
  19230. * @param gradient defines the gradient to remove
  19231. * @returns the current particle system
  19232. */
  19233. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19234. /**
  19235. * Gets the current list of life time gradients.
  19236. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19237. * @returns the list of life time gradients
  19238. */
  19239. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19240. /**
  19241. * Gets the current list of color gradients.
  19242. * You must use addColorGradient and removeColorGradient to udpate this list
  19243. * @returns the list of color gradients
  19244. */
  19245. getColorGradients(): Nullable<Array<ColorGradient>>;
  19246. /**
  19247. * Adds a new ramp gradient used to remap particle colors
  19248. * @param gradient defines the gradient to use (between 0 and 1)
  19249. * @param color defines the color to affect to the specified gradient
  19250. * @returns the current particle system
  19251. */
  19252. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19253. /**
  19254. * Gets the current list of ramp gradients.
  19255. * You must use addRampGradient and removeRampGradient to udpate this list
  19256. * @returns the list of ramp gradients
  19257. */
  19258. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19259. /** Gets or sets a boolean indicating that ramp gradients must be used
  19260. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19261. */
  19262. useRampGradients: boolean;
  19263. /**
  19264. * Adds a new color remap gradient
  19265. * @param gradient defines the gradient to use (between 0 and 1)
  19266. * @param min defines the color remap minimal range
  19267. * @param max defines the color remap maximal range
  19268. * @returns the current particle system
  19269. */
  19270. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19271. /**
  19272. * Gets the current list of color remap gradients.
  19273. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19274. * @returns the list of color remap gradients
  19275. */
  19276. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19277. /**
  19278. * Adds a new alpha remap gradient
  19279. * @param gradient defines the gradient to use (between 0 and 1)
  19280. * @param min defines the alpha remap minimal range
  19281. * @param max defines the alpha remap maximal range
  19282. * @returns the current particle system
  19283. */
  19284. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19285. /**
  19286. * Gets the current list of alpha remap gradients.
  19287. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19288. * @returns the list of alpha remap gradients
  19289. */
  19290. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19291. /**
  19292. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19293. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19294. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19295. * @returns the emitter
  19296. */
  19297. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19298. /**
  19299. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19300. * @param radius The radius of the hemisphere to emit from
  19301. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19302. * @returns the emitter
  19303. */
  19304. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19305. /**
  19306. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19307. * @param radius The radius of the sphere to emit from
  19308. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19309. * @returns the emitter
  19310. */
  19311. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19312. /**
  19313. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19314. * @param radius The radius of the sphere to emit from
  19315. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19316. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19317. * @returns the emitter
  19318. */
  19319. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19320. /**
  19321. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19322. * @param radius The radius of the emission cylinder
  19323. * @param height The height of the emission cylinder
  19324. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19325. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19326. * @returns the emitter
  19327. */
  19328. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19329. /**
  19330. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19331. * @param radius The radius of the cylinder to emit from
  19332. * @param height The height of the emission cylinder
  19333. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19334. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19335. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19336. * @returns the emitter
  19337. */
  19338. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19339. /**
  19340. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19341. * @param radius The radius of the cone to emit from
  19342. * @param angle The base angle of the cone
  19343. * @returns the emitter
  19344. */
  19345. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19346. /**
  19347. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19348. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19349. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19350. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19351. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19352. * @returns the emitter
  19353. */
  19354. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19355. /**
  19356. * Get hosting scene
  19357. * @returns the scene
  19358. */
  19359. getScene(): Scene;
  19360. }
  19361. }
  19362. declare module "babylonjs/Meshes/instancedMesh" {
  19363. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19364. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19365. import { Camera } from "babylonjs/Cameras/camera";
  19366. import { Node } from "babylonjs/node";
  19367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19368. import { Mesh } from "babylonjs/Meshes/mesh";
  19369. import { Material } from "babylonjs/Materials/material";
  19370. import { Skeleton } from "babylonjs/Bones/skeleton";
  19371. import { Light } from "babylonjs/Lights/light";
  19372. /**
  19373. * Creates an instance based on a source mesh.
  19374. */
  19375. export class InstancedMesh extends AbstractMesh {
  19376. private _sourceMesh;
  19377. private _currentLOD;
  19378. /** @hidden */
  19379. _indexInSourceMeshInstanceArray: number;
  19380. constructor(name: string, source: Mesh);
  19381. /**
  19382. * Returns the string "InstancedMesh".
  19383. */
  19384. getClassName(): string;
  19385. /** Gets the list of lights affecting that mesh */
  19386. readonly lightSources: Light[];
  19387. _resyncLightSources(): void;
  19388. _resyncLighSource(light: Light): void;
  19389. _removeLightSource(light: Light, dispose: boolean): void;
  19390. /**
  19391. * If the source mesh receives shadows
  19392. */
  19393. readonly receiveShadows: boolean;
  19394. /**
  19395. * The material of the source mesh
  19396. */
  19397. readonly material: Nullable<Material>;
  19398. /**
  19399. * Visibility of the source mesh
  19400. */
  19401. readonly visibility: number;
  19402. /**
  19403. * Skeleton of the source mesh
  19404. */
  19405. readonly skeleton: Nullable<Skeleton>;
  19406. /**
  19407. * Rendering ground id of the source mesh
  19408. */
  19409. renderingGroupId: number;
  19410. /**
  19411. * Returns the total number of vertices (integer).
  19412. */
  19413. getTotalVertices(): number;
  19414. /**
  19415. * Returns a positive integer : the total number of indices in this mesh geometry.
  19416. * @returns the numner of indices or zero if the mesh has no geometry.
  19417. */
  19418. getTotalIndices(): number;
  19419. /**
  19420. * The source mesh of the instance
  19421. */
  19422. readonly sourceMesh: Mesh;
  19423. /**
  19424. * Is this node ready to be used/rendered
  19425. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19426. * @return {boolean} is it ready
  19427. */
  19428. isReady(completeCheck?: boolean): boolean;
  19429. /**
  19430. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19431. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19432. * @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.
  19433. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19434. */
  19435. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19436. /**
  19437. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19438. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19439. * The `data` are either a numeric array either a Float32Array.
  19440. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19441. * 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).
  19442. * Note that a new underlying VertexBuffer object is created each call.
  19443. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19444. *
  19445. * Possible `kind` values :
  19446. * - VertexBuffer.PositionKind
  19447. * - VertexBuffer.UVKind
  19448. * - VertexBuffer.UV2Kind
  19449. * - VertexBuffer.UV3Kind
  19450. * - VertexBuffer.UV4Kind
  19451. * - VertexBuffer.UV5Kind
  19452. * - VertexBuffer.UV6Kind
  19453. * - VertexBuffer.ColorKind
  19454. * - VertexBuffer.MatricesIndicesKind
  19455. * - VertexBuffer.MatricesIndicesExtraKind
  19456. * - VertexBuffer.MatricesWeightsKind
  19457. * - VertexBuffer.MatricesWeightsExtraKind
  19458. *
  19459. * Returns the Mesh.
  19460. */
  19461. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19462. /**
  19463. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19464. * If the mesh has no geometry, it is simply returned as it is.
  19465. * The `data` are either a numeric array either a Float32Array.
  19466. * No new underlying VertexBuffer object is created.
  19467. * 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.
  19468. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19469. *
  19470. * Possible `kind` values :
  19471. * - VertexBuffer.PositionKind
  19472. * - VertexBuffer.UVKind
  19473. * - VertexBuffer.UV2Kind
  19474. * - VertexBuffer.UV3Kind
  19475. * - VertexBuffer.UV4Kind
  19476. * - VertexBuffer.UV5Kind
  19477. * - VertexBuffer.UV6Kind
  19478. * - VertexBuffer.ColorKind
  19479. * - VertexBuffer.MatricesIndicesKind
  19480. * - VertexBuffer.MatricesIndicesExtraKind
  19481. * - VertexBuffer.MatricesWeightsKind
  19482. * - VertexBuffer.MatricesWeightsExtraKind
  19483. *
  19484. * Returns the Mesh.
  19485. */
  19486. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19487. /**
  19488. * Sets the mesh indices.
  19489. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19490. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19491. * This method creates a new index buffer each call.
  19492. * Returns the Mesh.
  19493. */
  19494. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19495. /**
  19496. * Boolean : True if the mesh owns the requested kind of data.
  19497. */
  19498. isVerticesDataPresent(kind: string): boolean;
  19499. /**
  19500. * Returns an array of indices (IndicesArray).
  19501. */
  19502. getIndices(): Nullable<IndicesArray>;
  19503. readonly _positions: Nullable<Vector3[]>;
  19504. /**
  19505. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19506. * This means the mesh underlying bounding box and sphere are recomputed.
  19507. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19508. * @returns the current mesh
  19509. */
  19510. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19511. /** @hidden */
  19512. _preActivate(): InstancedMesh;
  19513. /** @hidden */
  19514. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19515. /** @hidden */
  19516. _postActivate(): void;
  19517. getWorldMatrix(): Matrix;
  19518. readonly isAnInstance: boolean;
  19519. /**
  19520. * Returns the current associated LOD AbstractMesh.
  19521. */
  19522. getLOD(camera: Camera): AbstractMesh;
  19523. /** @hidden */
  19524. _syncSubMeshes(): InstancedMesh;
  19525. /** @hidden */
  19526. _generatePointsArray(): boolean;
  19527. /**
  19528. * Creates a new InstancedMesh from the current mesh.
  19529. * - name (string) : the cloned mesh name
  19530. * - newParent (optional Node) : the optional Node to parent the clone to.
  19531. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19532. *
  19533. * Returns the clone.
  19534. */
  19535. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19536. /**
  19537. * Disposes the InstancedMesh.
  19538. * Returns nothing.
  19539. */
  19540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19541. }
  19542. }
  19543. declare module "babylonjs/Materials/shaderMaterial" {
  19544. import { Scene } from "babylonjs/scene";
  19545. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19547. import { Mesh } from "babylonjs/Meshes/mesh";
  19548. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19549. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19550. import { Texture } from "babylonjs/Materials/Textures/texture";
  19551. import { Material } from "babylonjs/Materials/material";
  19552. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19553. /**
  19554. * Defines the options associated with the creation of a shader material.
  19555. */
  19556. export interface IShaderMaterialOptions {
  19557. /**
  19558. * Does the material work in alpha blend mode
  19559. */
  19560. needAlphaBlending: boolean;
  19561. /**
  19562. * Does the material work in alpha test mode
  19563. */
  19564. needAlphaTesting: boolean;
  19565. /**
  19566. * The list of attribute names used in the shader
  19567. */
  19568. attributes: string[];
  19569. /**
  19570. * The list of unifrom names used in the shader
  19571. */
  19572. uniforms: string[];
  19573. /**
  19574. * The list of UBO names used in the shader
  19575. */
  19576. uniformBuffers: string[];
  19577. /**
  19578. * The list of sampler names used in the shader
  19579. */
  19580. samplers: string[];
  19581. /**
  19582. * The list of defines used in the shader
  19583. */
  19584. defines: string[];
  19585. }
  19586. /**
  19587. * 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.
  19588. *
  19589. * This returned material effects how the mesh will look based on the code in the shaders.
  19590. *
  19591. * @see http://doc.babylonjs.com/how_to/shader_material
  19592. */
  19593. export class ShaderMaterial extends Material {
  19594. private _shaderPath;
  19595. private _options;
  19596. private _textures;
  19597. private _textureArrays;
  19598. private _floats;
  19599. private _ints;
  19600. private _floatsArrays;
  19601. private _colors3;
  19602. private _colors3Arrays;
  19603. private _colors4;
  19604. private _colors4Arrays;
  19605. private _vectors2;
  19606. private _vectors3;
  19607. private _vectors4;
  19608. private _matrices;
  19609. private _matrices3x3;
  19610. private _matrices2x2;
  19611. private _vectors2Arrays;
  19612. private _vectors3Arrays;
  19613. private _vectors4Arrays;
  19614. private _cachedWorldViewMatrix;
  19615. private _cachedWorldViewProjectionMatrix;
  19616. private _renderId;
  19617. /**
  19618. * Instantiate a new shader material.
  19619. * 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.
  19620. * This returned material effects how the mesh will look based on the code in the shaders.
  19621. * @see http://doc.babylonjs.com/how_to/shader_material
  19622. * @param name Define the name of the material in the scene
  19623. * @param scene Define the scene the material belongs to
  19624. * @param shaderPath Defines the route to the shader code in one of three ways:
  19625. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19626. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19627. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19628. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19629. * @param options Define the options used to create the shader
  19630. */
  19631. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19632. /**
  19633. * Gets the options used to compile the shader.
  19634. * They can be modified to trigger a new compilation
  19635. */
  19636. readonly options: IShaderMaterialOptions;
  19637. /**
  19638. * Gets the current class name of the material e.g. "ShaderMaterial"
  19639. * Mainly use in serialization.
  19640. * @returns the class name
  19641. */
  19642. getClassName(): string;
  19643. /**
  19644. * Specifies if the material will require alpha blending
  19645. * @returns a boolean specifying if alpha blending is needed
  19646. */
  19647. needAlphaBlending(): boolean;
  19648. /**
  19649. * Specifies if this material should be rendered in alpha test mode
  19650. * @returns a boolean specifying if an alpha test is needed.
  19651. */
  19652. needAlphaTesting(): boolean;
  19653. private _checkUniform;
  19654. /**
  19655. * Set a texture in the shader.
  19656. * @param name Define the name of the uniform samplers as defined in the shader
  19657. * @param texture Define the texture to bind to this sampler
  19658. * @return the material itself allowing "fluent" like uniform updates
  19659. */
  19660. setTexture(name: string, texture: Texture): ShaderMaterial;
  19661. /**
  19662. * Set a texture array in the shader.
  19663. * @param name Define the name of the uniform sampler array as defined in the shader
  19664. * @param textures Define the list of textures to bind to this sampler
  19665. * @return the material itself allowing "fluent" like uniform updates
  19666. */
  19667. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19668. /**
  19669. * Set a float in the shader.
  19670. * @param name Define the name of the uniform as defined in the shader
  19671. * @param value Define the value to give to the uniform
  19672. * @return the material itself allowing "fluent" like uniform updates
  19673. */
  19674. setFloat(name: string, value: number): ShaderMaterial;
  19675. /**
  19676. * Set a int in the shader.
  19677. * @param name Define the name of the uniform as defined in the shader
  19678. * @param value Define the value to give to the uniform
  19679. * @return the material itself allowing "fluent" like uniform updates
  19680. */
  19681. setInt(name: string, value: number): ShaderMaterial;
  19682. /**
  19683. * Set an array of floats in the shader.
  19684. * @param name Define the name of the uniform as defined in the shader
  19685. * @param value Define the value to give to the uniform
  19686. * @return the material itself allowing "fluent" like uniform updates
  19687. */
  19688. setFloats(name: string, value: number[]): ShaderMaterial;
  19689. /**
  19690. * Set a vec3 in the shader from a Color3.
  19691. * @param name Define the name of the uniform as defined in the shader
  19692. * @param value Define the value to give to the uniform
  19693. * @return the material itself allowing "fluent" like uniform updates
  19694. */
  19695. setColor3(name: string, value: Color3): ShaderMaterial;
  19696. /**
  19697. * Set a vec3 array in the shader from a Color3 array.
  19698. * @param name Define the name of the uniform as defined in the shader
  19699. * @param value Define the value to give to the uniform
  19700. * @return the material itself allowing "fluent" like uniform updates
  19701. */
  19702. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19703. /**
  19704. * Set a vec4 in the shader from a Color4.
  19705. * @param name Define the name of the uniform as defined in the shader
  19706. * @param value Define the value to give to the uniform
  19707. * @return the material itself allowing "fluent" like uniform updates
  19708. */
  19709. setColor4(name: string, value: Color4): ShaderMaterial;
  19710. /**
  19711. * Set a vec4 array in the shader from a Color4 array.
  19712. * @param name Define the name of the uniform as defined in the shader
  19713. * @param value Define the value to give to the uniform
  19714. * @return the material itself allowing "fluent" like uniform updates
  19715. */
  19716. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19717. /**
  19718. * Set a vec2 in the shader from a Vector2.
  19719. * @param name Define the name of the uniform as defined in the shader
  19720. * @param value Define the value to give to the uniform
  19721. * @return the material itself allowing "fluent" like uniform updates
  19722. */
  19723. setVector2(name: string, value: Vector2): ShaderMaterial;
  19724. /**
  19725. * Set a vec3 in the shader from a Vector3.
  19726. * @param name Define the name of the uniform as defined in the shader
  19727. * @param value Define the value to give to the uniform
  19728. * @return the material itself allowing "fluent" like uniform updates
  19729. */
  19730. setVector3(name: string, value: Vector3): ShaderMaterial;
  19731. /**
  19732. * Set a vec4 in the shader from a Vector4.
  19733. * @param name Define the name of the uniform as defined in the shader
  19734. * @param value Define the value to give to the uniform
  19735. * @return the material itself allowing "fluent" like uniform updates
  19736. */
  19737. setVector4(name: string, value: Vector4): ShaderMaterial;
  19738. /**
  19739. * Set a mat4 in the shader from a Matrix.
  19740. * @param name Define the name of the uniform as defined in the shader
  19741. * @param value Define the value to give to the uniform
  19742. * @return the material itself allowing "fluent" like uniform updates
  19743. */
  19744. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19745. /**
  19746. * Set a mat3 in the shader from a Float32Array.
  19747. * @param name Define the name of the uniform as defined in the shader
  19748. * @param value Define the value to give to the uniform
  19749. * @return the material itself allowing "fluent" like uniform updates
  19750. */
  19751. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19752. /**
  19753. * Set a mat2 in the shader from a Float32Array.
  19754. * @param name Define the name of the uniform as defined in the shader
  19755. * @param value Define the value to give to the uniform
  19756. * @return the material itself allowing "fluent" like uniform updates
  19757. */
  19758. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19759. /**
  19760. * Set a vec2 array in the shader from a number array.
  19761. * @param name Define the name of the uniform as defined in the shader
  19762. * @param value Define the value to give to the uniform
  19763. * @return the material itself allowing "fluent" like uniform updates
  19764. */
  19765. setArray2(name: string, value: number[]): ShaderMaterial;
  19766. /**
  19767. * Set a vec3 array in the shader from a number array.
  19768. * @param name Define the name of the uniform as defined in the shader
  19769. * @param value Define the value to give to the uniform
  19770. * @return the material itself allowing "fluent" like uniform updates
  19771. */
  19772. setArray3(name: string, value: number[]): ShaderMaterial;
  19773. /**
  19774. * Set a vec4 array in the shader from a number array.
  19775. * @param name Define the name of the uniform as defined in the shader
  19776. * @param value Define the value to give to the uniform
  19777. * @return the material itself allowing "fluent" like uniform updates
  19778. */
  19779. setArray4(name: string, value: number[]): ShaderMaterial;
  19780. private _checkCache;
  19781. /**
  19782. * Specifies that the submesh is ready to be used
  19783. * @param mesh defines the mesh to check
  19784. * @param subMesh defines which submesh to check
  19785. * @param useInstances specifies that instances should be used
  19786. * @returns a boolean indicating that the submesh is ready or not
  19787. */
  19788. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19789. /**
  19790. * Checks if the material is ready to render the requested mesh
  19791. * @param mesh Define the mesh to render
  19792. * @param useInstances Define whether or not the material is used with instances
  19793. * @returns true if ready, otherwise false
  19794. */
  19795. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19796. /**
  19797. * Binds the world matrix to the material
  19798. * @param world defines the world transformation matrix
  19799. */
  19800. bindOnlyWorldMatrix(world: Matrix): void;
  19801. /**
  19802. * Binds the material to the mesh
  19803. * @param world defines the world transformation matrix
  19804. * @param mesh defines the mesh to bind the material to
  19805. */
  19806. bind(world: Matrix, mesh?: Mesh): void;
  19807. /**
  19808. * Gets the active textures from the material
  19809. * @returns an array of textures
  19810. */
  19811. getActiveTextures(): BaseTexture[];
  19812. /**
  19813. * Specifies if the material uses a texture
  19814. * @param texture defines the texture to check against the material
  19815. * @returns a boolean specifying if the material uses the texture
  19816. */
  19817. hasTexture(texture: BaseTexture): boolean;
  19818. /**
  19819. * Makes a duplicate of the material, and gives it a new name
  19820. * @param name defines the new name for the duplicated material
  19821. * @returns the cloned material
  19822. */
  19823. clone(name: string): ShaderMaterial;
  19824. /**
  19825. * Disposes the material
  19826. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19827. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19828. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19829. */
  19830. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19831. /**
  19832. * Serializes this material in a JSON representation
  19833. * @returns the serialized material object
  19834. */
  19835. serialize(): any;
  19836. /**
  19837. * Creates a shader material from parsed shader material data
  19838. * @param source defines the JSON represnetation of the material
  19839. * @param scene defines the hosting scene
  19840. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19841. * @returns a new material
  19842. */
  19843. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19844. }
  19845. }
  19846. declare module "babylonjs/Shaders/color.fragment" {
  19847. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19848. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19849. /** @hidden */
  19850. export var colorPixelShader: {
  19851. name: string;
  19852. shader: string;
  19853. };
  19854. }
  19855. declare module "babylonjs/Shaders/color.vertex" {
  19856. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19857. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19858. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19859. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19860. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19861. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19862. /** @hidden */
  19863. export var colorVertexShader: {
  19864. name: string;
  19865. shader: string;
  19866. };
  19867. }
  19868. declare module "babylonjs/Meshes/linesMesh" {
  19869. import { Nullable } from "babylonjs/types";
  19870. import { Scene } from "babylonjs/scene";
  19871. import { Color3 } from "babylonjs/Maths/math.color";
  19872. import { Node } from "babylonjs/node";
  19873. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19874. import { Mesh } from "babylonjs/Meshes/mesh";
  19875. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19876. import { Effect } from "babylonjs/Materials/effect";
  19877. import { Material } from "babylonjs/Materials/material";
  19878. import "babylonjs/Shaders/color.fragment";
  19879. import "babylonjs/Shaders/color.vertex";
  19880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19881. /**
  19882. * Line mesh
  19883. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19884. */
  19885. export class LinesMesh extends Mesh {
  19886. /**
  19887. * If vertex color should be applied to the mesh
  19888. */
  19889. readonly useVertexColor?: boolean | undefined;
  19890. /**
  19891. * If vertex alpha should be applied to the mesh
  19892. */
  19893. readonly useVertexAlpha?: boolean | undefined;
  19894. /**
  19895. * Color of the line (Default: White)
  19896. */
  19897. color: Color3;
  19898. /**
  19899. * Alpha of the line (Default: 1)
  19900. */
  19901. alpha: number;
  19902. /**
  19903. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19904. * This margin is expressed in world space coordinates, so its value may vary.
  19905. * Default value is 0.1
  19906. */
  19907. intersectionThreshold: number;
  19908. private _colorShader;
  19909. private color4;
  19910. /**
  19911. * Creates a new LinesMesh
  19912. * @param name defines the name
  19913. * @param scene defines the hosting scene
  19914. * @param parent defines the parent mesh if any
  19915. * @param source defines the optional source LinesMesh used to clone data from
  19916. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19917. * When false, achieved by calling a clone(), also passing False.
  19918. * This will make creation of children, recursive.
  19919. * @param useVertexColor defines if this LinesMesh supports vertex color
  19920. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19921. */
  19922. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19923. /**
  19924. * If vertex color should be applied to the mesh
  19925. */
  19926. useVertexColor?: boolean | undefined,
  19927. /**
  19928. * If vertex alpha should be applied to the mesh
  19929. */
  19930. useVertexAlpha?: boolean | undefined);
  19931. private _addClipPlaneDefine;
  19932. private _removeClipPlaneDefine;
  19933. isReady(): boolean;
  19934. /**
  19935. * Returns the string "LineMesh"
  19936. */
  19937. getClassName(): string;
  19938. /**
  19939. * @hidden
  19940. */
  19941. /**
  19942. * @hidden
  19943. */
  19944. material: Material;
  19945. /**
  19946. * @hidden
  19947. */
  19948. readonly checkCollisions: boolean;
  19949. /** @hidden */
  19950. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19951. /** @hidden */
  19952. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19953. /**
  19954. * Disposes of the line mesh
  19955. * @param doNotRecurse If children should be disposed
  19956. */
  19957. dispose(doNotRecurse?: boolean): void;
  19958. /**
  19959. * Returns a new LineMesh object cloned from the current one.
  19960. */
  19961. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19962. /**
  19963. * Creates a new InstancedLinesMesh object from the mesh model.
  19964. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19965. * @param name defines the name of the new instance
  19966. * @returns a new InstancedLinesMesh
  19967. */
  19968. createInstance(name: string): InstancedLinesMesh;
  19969. }
  19970. /**
  19971. * Creates an instance based on a source LinesMesh
  19972. */
  19973. export class InstancedLinesMesh extends InstancedMesh {
  19974. /**
  19975. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19976. * This margin is expressed in world space coordinates, so its value may vary.
  19977. * Initilized with the intersectionThreshold value of the source LinesMesh
  19978. */
  19979. intersectionThreshold: number;
  19980. constructor(name: string, source: LinesMesh);
  19981. /**
  19982. * Returns the string "InstancedLinesMesh".
  19983. */
  19984. getClassName(): string;
  19985. }
  19986. }
  19987. declare module "babylonjs/Shaders/line.fragment" {
  19988. /** @hidden */
  19989. export var linePixelShader: {
  19990. name: string;
  19991. shader: string;
  19992. };
  19993. }
  19994. declare module "babylonjs/Shaders/line.vertex" {
  19995. /** @hidden */
  19996. export var lineVertexShader: {
  19997. name: string;
  19998. shader: string;
  19999. };
  20000. }
  20001. declare module "babylonjs/Rendering/edgesRenderer" {
  20002. import { Nullable } from "babylonjs/types";
  20003. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20005. import { Vector3 } from "babylonjs/Maths/math.vector";
  20006. import { IDisposable } from "babylonjs/scene";
  20007. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20008. import "babylonjs/Shaders/line.fragment";
  20009. import "babylonjs/Shaders/line.vertex";
  20010. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20011. module "babylonjs/Meshes/abstractMesh" {
  20012. interface AbstractMesh {
  20013. /**
  20014. * Gets the edgesRenderer associated with the mesh
  20015. */
  20016. edgesRenderer: Nullable<EdgesRenderer>;
  20017. }
  20018. }
  20019. module "babylonjs/Meshes/linesMesh" {
  20020. interface LinesMesh {
  20021. /**
  20022. * Enables the edge rendering mode on the mesh.
  20023. * This mode makes the mesh edges visible
  20024. * @param epsilon defines the maximal distance between two angles to detect a face
  20025. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20026. * @returns the currentAbstractMesh
  20027. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20028. */
  20029. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20030. }
  20031. }
  20032. module "babylonjs/Meshes/linesMesh" {
  20033. interface InstancedLinesMesh {
  20034. /**
  20035. * Enables the edge rendering mode on the mesh.
  20036. * This mode makes the mesh edges visible
  20037. * @param epsilon defines the maximal distance between two angles to detect a face
  20038. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20039. * @returns the current InstancedLinesMesh
  20040. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20041. */
  20042. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20043. }
  20044. }
  20045. /**
  20046. * Defines the minimum contract an Edges renderer should follow.
  20047. */
  20048. export interface IEdgesRenderer extends IDisposable {
  20049. /**
  20050. * Gets or sets a boolean indicating if the edgesRenderer is active
  20051. */
  20052. isEnabled: boolean;
  20053. /**
  20054. * Renders the edges of the attached mesh,
  20055. */
  20056. render(): void;
  20057. /**
  20058. * Checks wether or not the edges renderer is ready to render.
  20059. * @return true if ready, otherwise false.
  20060. */
  20061. isReady(): boolean;
  20062. }
  20063. /**
  20064. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20065. */
  20066. export class EdgesRenderer implements IEdgesRenderer {
  20067. /**
  20068. * Define the size of the edges with an orthographic camera
  20069. */
  20070. edgesWidthScalerForOrthographic: number;
  20071. /**
  20072. * Define the size of the edges with a perspective camera
  20073. */
  20074. edgesWidthScalerForPerspective: number;
  20075. protected _source: AbstractMesh;
  20076. protected _linesPositions: number[];
  20077. protected _linesNormals: number[];
  20078. protected _linesIndices: number[];
  20079. protected _epsilon: number;
  20080. protected _indicesCount: number;
  20081. protected _lineShader: ShaderMaterial;
  20082. protected _ib: DataBuffer;
  20083. protected _buffers: {
  20084. [key: string]: Nullable<VertexBuffer>;
  20085. };
  20086. protected _checkVerticesInsteadOfIndices: boolean;
  20087. private _meshRebuildObserver;
  20088. private _meshDisposeObserver;
  20089. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20090. isEnabled: boolean;
  20091. /**
  20092. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20093. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20094. * @param source Mesh used to create edges
  20095. * @param epsilon sum of angles in adjacency to check for edge
  20096. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20097. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20098. */
  20099. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20100. protected _prepareRessources(): void;
  20101. /** @hidden */
  20102. _rebuild(): void;
  20103. /**
  20104. * Releases the required resources for the edges renderer
  20105. */
  20106. dispose(): void;
  20107. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20108. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20109. /**
  20110. * Checks if the pair of p0 and p1 is en edge
  20111. * @param faceIndex
  20112. * @param edge
  20113. * @param faceNormals
  20114. * @param p0
  20115. * @param p1
  20116. * @private
  20117. */
  20118. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20119. /**
  20120. * push line into the position, normal and index buffer
  20121. * @protected
  20122. */
  20123. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20124. /**
  20125. * Generates lines edges from adjacencjes
  20126. * @private
  20127. */
  20128. _generateEdgesLines(): void;
  20129. /**
  20130. * Checks wether or not the edges renderer is ready to render.
  20131. * @return true if ready, otherwise false.
  20132. */
  20133. isReady(): boolean;
  20134. /**
  20135. * Renders the edges of the attached mesh,
  20136. */
  20137. render(): void;
  20138. }
  20139. /**
  20140. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20141. */
  20142. export class LineEdgesRenderer extends EdgesRenderer {
  20143. /**
  20144. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20145. * @param source LineMesh used to generate edges
  20146. * @param epsilon not important (specified angle for edge detection)
  20147. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20148. */
  20149. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20150. /**
  20151. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20152. */
  20153. _generateEdgesLines(): void;
  20154. }
  20155. }
  20156. declare module "babylonjs/Rendering/renderingGroup" {
  20157. import { SmartArray } from "babylonjs/Misc/smartArray";
  20158. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20160. import { Nullable } from "babylonjs/types";
  20161. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20162. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20163. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20164. import { Material } from "babylonjs/Materials/material";
  20165. import { Scene } from "babylonjs/scene";
  20166. /**
  20167. * This represents the object necessary to create a rendering group.
  20168. * This is exclusively used and created by the rendering manager.
  20169. * To modify the behavior, you use the available helpers in your scene or meshes.
  20170. * @hidden
  20171. */
  20172. export class RenderingGroup {
  20173. index: number;
  20174. private static _zeroVector;
  20175. private _scene;
  20176. private _opaqueSubMeshes;
  20177. private _transparentSubMeshes;
  20178. private _alphaTestSubMeshes;
  20179. private _depthOnlySubMeshes;
  20180. private _particleSystems;
  20181. private _spriteManagers;
  20182. private _opaqueSortCompareFn;
  20183. private _alphaTestSortCompareFn;
  20184. private _transparentSortCompareFn;
  20185. private _renderOpaque;
  20186. private _renderAlphaTest;
  20187. private _renderTransparent;
  20188. /** @hidden */
  20189. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20190. onBeforeTransparentRendering: () => void;
  20191. /**
  20192. * Set the opaque sort comparison function.
  20193. * If null the sub meshes will be render in the order they were created
  20194. */
  20195. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20196. /**
  20197. * Set the alpha test sort comparison function.
  20198. * If null the sub meshes will be render in the order they were created
  20199. */
  20200. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20201. /**
  20202. * Set the transparent sort comparison function.
  20203. * If null the sub meshes will be render in the order they were created
  20204. */
  20205. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20206. /**
  20207. * Creates a new rendering group.
  20208. * @param index The rendering group index
  20209. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20210. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20211. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20212. */
  20213. 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>);
  20214. /**
  20215. * Render all the sub meshes contained in the group.
  20216. * @param customRenderFunction Used to override the default render behaviour of the group.
  20217. * @returns true if rendered some submeshes.
  20218. */
  20219. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20220. /**
  20221. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20222. * @param subMeshes The submeshes to render
  20223. */
  20224. private renderOpaqueSorted;
  20225. /**
  20226. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20227. * @param subMeshes The submeshes to render
  20228. */
  20229. private renderAlphaTestSorted;
  20230. /**
  20231. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20232. * @param subMeshes The submeshes to render
  20233. */
  20234. private renderTransparentSorted;
  20235. /**
  20236. * Renders the submeshes in a specified order.
  20237. * @param subMeshes The submeshes to sort before render
  20238. * @param sortCompareFn The comparison function use to sort
  20239. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20240. * @param transparent Specifies to activate blending if true
  20241. */
  20242. private static renderSorted;
  20243. /**
  20244. * Renders the submeshes in the order they were dispatched (no sort applied).
  20245. * @param subMeshes The submeshes to render
  20246. */
  20247. private static renderUnsorted;
  20248. /**
  20249. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20250. * are rendered back to front if in the same alpha index.
  20251. *
  20252. * @param a The first submesh
  20253. * @param b The second submesh
  20254. * @returns The result of the comparison
  20255. */
  20256. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20257. /**
  20258. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20259. * are rendered back to front.
  20260. *
  20261. * @param a The first submesh
  20262. * @param b The second submesh
  20263. * @returns The result of the comparison
  20264. */
  20265. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20266. /**
  20267. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20268. * are rendered front to back (prevent overdraw).
  20269. *
  20270. * @param a The first submesh
  20271. * @param b The second submesh
  20272. * @returns The result of the comparison
  20273. */
  20274. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20275. /**
  20276. * Resets the different lists of submeshes to prepare a new frame.
  20277. */
  20278. prepare(): void;
  20279. dispose(): void;
  20280. /**
  20281. * Inserts the submesh in its correct queue depending on its material.
  20282. * @param subMesh The submesh to dispatch
  20283. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20284. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20285. */
  20286. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20287. dispatchSprites(spriteManager: ISpriteManager): void;
  20288. dispatchParticles(particleSystem: IParticleSystem): void;
  20289. private _renderParticles;
  20290. private _renderSprites;
  20291. }
  20292. }
  20293. declare module "babylonjs/Rendering/renderingManager" {
  20294. import { Nullable } from "babylonjs/types";
  20295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20297. import { SmartArray } from "babylonjs/Misc/smartArray";
  20298. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20299. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20300. import { Material } from "babylonjs/Materials/material";
  20301. import { Scene } from "babylonjs/scene";
  20302. import { Camera } from "babylonjs/Cameras/camera";
  20303. /**
  20304. * Interface describing the different options available in the rendering manager
  20305. * regarding Auto Clear between groups.
  20306. */
  20307. export interface IRenderingManagerAutoClearSetup {
  20308. /**
  20309. * Defines whether or not autoclear is enable.
  20310. */
  20311. autoClear: boolean;
  20312. /**
  20313. * Defines whether or not to autoclear the depth buffer.
  20314. */
  20315. depth: boolean;
  20316. /**
  20317. * Defines whether or not to autoclear the stencil buffer.
  20318. */
  20319. stencil: boolean;
  20320. }
  20321. /**
  20322. * This class is used by the onRenderingGroupObservable
  20323. */
  20324. export class RenderingGroupInfo {
  20325. /**
  20326. * The Scene that being rendered
  20327. */
  20328. scene: Scene;
  20329. /**
  20330. * The camera currently used for the rendering pass
  20331. */
  20332. camera: Nullable<Camera>;
  20333. /**
  20334. * The ID of the renderingGroup being processed
  20335. */
  20336. renderingGroupId: number;
  20337. }
  20338. /**
  20339. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20340. * It is enable to manage the different groups as well as the different necessary sort functions.
  20341. * This should not be used directly aside of the few static configurations
  20342. */
  20343. export class RenderingManager {
  20344. /**
  20345. * The max id used for rendering groups (not included)
  20346. */
  20347. static MAX_RENDERINGGROUPS: number;
  20348. /**
  20349. * The min id used for rendering groups (included)
  20350. */
  20351. static MIN_RENDERINGGROUPS: number;
  20352. /**
  20353. * Used to globally prevent autoclearing scenes.
  20354. */
  20355. static AUTOCLEAR: boolean;
  20356. /**
  20357. * @hidden
  20358. */
  20359. _useSceneAutoClearSetup: boolean;
  20360. private _scene;
  20361. private _renderingGroups;
  20362. private _depthStencilBufferAlreadyCleaned;
  20363. private _autoClearDepthStencil;
  20364. private _customOpaqueSortCompareFn;
  20365. private _customAlphaTestSortCompareFn;
  20366. private _customTransparentSortCompareFn;
  20367. private _renderingGroupInfo;
  20368. /**
  20369. * Instantiates a new rendering group for a particular scene
  20370. * @param scene Defines the scene the groups belongs to
  20371. */
  20372. constructor(scene: Scene);
  20373. private _clearDepthStencilBuffer;
  20374. /**
  20375. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20376. * @hidden
  20377. */
  20378. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20379. /**
  20380. * Resets the different information of the group to prepare a new frame
  20381. * @hidden
  20382. */
  20383. reset(): void;
  20384. /**
  20385. * Dispose and release the group and its associated resources.
  20386. * @hidden
  20387. */
  20388. dispose(): void;
  20389. /**
  20390. * Clear the info related to rendering groups preventing retention points during dispose.
  20391. */
  20392. freeRenderingGroups(): void;
  20393. private _prepareRenderingGroup;
  20394. /**
  20395. * Add a sprite manager to the rendering manager in order to render it this frame.
  20396. * @param spriteManager Define the sprite manager to render
  20397. */
  20398. dispatchSprites(spriteManager: ISpriteManager): void;
  20399. /**
  20400. * Add a particle system to the rendering manager in order to render it this frame.
  20401. * @param particleSystem Define the particle system to render
  20402. */
  20403. dispatchParticles(particleSystem: IParticleSystem): void;
  20404. /**
  20405. * Add a submesh to the manager in order to render it this frame
  20406. * @param subMesh The submesh to dispatch
  20407. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20408. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20409. */
  20410. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20411. /**
  20412. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20413. * This allowed control for front to back rendering or reversly depending of the special needs.
  20414. *
  20415. * @param renderingGroupId The rendering group id corresponding to its index
  20416. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20417. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20418. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20419. */
  20420. 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;
  20421. /**
  20422. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20423. *
  20424. * @param renderingGroupId The rendering group id corresponding to its index
  20425. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20426. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20427. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20428. */
  20429. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20430. /**
  20431. * Gets the current auto clear configuration for one rendering group of the rendering
  20432. * manager.
  20433. * @param index the rendering group index to get the information for
  20434. * @returns The auto clear setup for the requested rendering group
  20435. */
  20436. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20437. }
  20438. }
  20439. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20440. import { Observable } from "babylonjs/Misc/observable";
  20441. import { SmartArray } from "babylonjs/Misc/smartArray";
  20442. import { Nullable } from "babylonjs/types";
  20443. import { Camera } from "babylonjs/Cameras/camera";
  20444. import { Scene } from "babylonjs/scene";
  20445. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20446. import { Color4 } from "babylonjs/Maths/math.color";
  20447. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20449. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20451. import { Texture } from "babylonjs/Materials/Textures/texture";
  20452. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20453. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20454. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20455. import { Engine } from "babylonjs/Engines/engine";
  20456. /**
  20457. * This Helps creating a texture that will be created from a camera in your scene.
  20458. * It is basically a dynamic texture that could be used to create special effects for instance.
  20459. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20460. */
  20461. export class RenderTargetTexture extends Texture {
  20462. isCube: boolean;
  20463. /**
  20464. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20465. */
  20466. static readonly REFRESHRATE_RENDER_ONCE: number;
  20467. /**
  20468. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20469. */
  20470. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20471. /**
  20472. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20473. * the central point of your effect and can save a lot of performances.
  20474. */
  20475. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20476. /**
  20477. * Use this predicate to dynamically define the list of mesh you want to render.
  20478. * If set, the renderList property will be overwritten.
  20479. */
  20480. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20481. private _renderList;
  20482. /**
  20483. * Use this list to define the list of mesh you want to render.
  20484. */
  20485. renderList: Nullable<Array<AbstractMesh>>;
  20486. private _hookArray;
  20487. /**
  20488. * Define if particles should be rendered in your texture.
  20489. */
  20490. renderParticles: boolean;
  20491. /**
  20492. * Define if sprites should be rendered in your texture.
  20493. */
  20494. renderSprites: boolean;
  20495. /**
  20496. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20497. */
  20498. coordinatesMode: number;
  20499. /**
  20500. * Define the camera used to render the texture.
  20501. */
  20502. activeCamera: Nullable<Camera>;
  20503. /**
  20504. * Override the render function of the texture with your own one.
  20505. */
  20506. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20507. /**
  20508. * Define if camera post processes should be use while rendering the texture.
  20509. */
  20510. useCameraPostProcesses: boolean;
  20511. /**
  20512. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20513. */
  20514. ignoreCameraViewport: boolean;
  20515. private _postProcessManager;
  20516. private _postProcesses;
  20517. private _resizeObserver;
  20518. /**
  20519. * An event triggered when the texture is unbind.
  20520. */
  20521. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20522. /**
  20523. * An event triggered when the texture is unbind.
  20524. */
  20525. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20526. private _onAfterUnbindObserver;
  20527. /**
  20528. * Set a after unbind callback in the texture.
  20529. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20530. */
  20531. onAfterUnbind: () => void;
  20532. /**
  20533. * An event triggered before rendering the texture
  20534. */
  20535. onBeforeRenderObservable: Observable<number>;
  20536. private _onBeforeRenderObserver;
  20537. /**
  20538. * Set a before render callback in the texture.
  20539. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20540. */
  20541. onBeforeRender: (faceIndex: number) => void;
  20542. /**
  20543. * An event triggered after rendering the texture
  20544. */
  20545. onAfterRenderObservable: Observable<number>;
  20546. private _onAfterRenderObserver;
  20547. /**
  20548. * Set a after render callback in the texture.
  20549. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20550. */
  20551. onAfterRender: (faceIndex: number) => void;
  20552. /**
  20553. * An event triggered after the texture clear
  20554. */
  20555. onClearObservable: Observable<Engine>;
  20556. private _onClearObserver;
  20557. /**
  20558. * Set a clear callback in the texture.
  20559. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20560. */
  20561. onClear: (Engine: Engine) => void;
  20562. /**
  20563. * An event triggered when the texture is resized.
  20564. */
  20565. onResizeObservable: Observable<RenderTargetTexture>;
  20566. /**
  20567. * Define the clear color of the Render Target if it should be different from the scene.
  20568. */
  20569. clearColor: Color4;
  20570. protected _size: number | {
  20571. width: number;
  20572. height: number;
  20573. };
  20574. protected _initialSizeParameter: number | {
  20575. width: number;
  20576. height: number;
  20577. } | {
  20578. ratio: number;
  20579. };
  20580. protected _sizeRatio: Nullable<number>;
  20581. /** @hidden */
  20582. _generateMipMaps: boolean;
  20583. protected _renderingManager: RenderingManager;
  20584. /** @hidden */
  20585. _waitingRenderList: string[];
  20586. protected _doNotChangeAspectRatio: boolean;
  20587. protected _currentRefreshId: number;
  20588. protected _refreshRate: number;
  20589. protected _textureMatrix: Matrix;
  20590. protected _samples: number;
  20591. protected _renderTargetOptions: RenderTargetCreationOptions;
  20592. /**
  20593. * Gets render target creation options that were used.
  20594. */
  20595. readonly renderTargetOptions: RenderTargetCreationOptions;
  20596. protected _engine: Engine;
  20597. protected _onRatioRescale(): void;
  20598. /**
  20599. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20600. * It must define where the camera used to render the texture is set
  20601. */
  20602. boundingBoxPosition: Vector3;
  20603. private _boundingBoxSize;
  20604. /**
  20605. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20606. * When defined, the cubemap will switch to local mode
  20607. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20608. * @example https://www.babylonjs-playground.com/#RNASML
  20609. */
  20610. boundingBoxSize: Vector3;
  20611. /**
  20612. * In case the RTT has been created with a depth texture, get the associated
  20613. * depth texture.
  20614. * Otherwise, return null.
  20615. */
  20616. depthStencilTexture: Nullable<InternalTexture>;
  20617. /**
  20618. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20619. * or used a shadow, depth texture...
  20620. * @param name The friendly name of the texture
  20621. * @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)
  20622. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20623. * @param generateMipMaps True if mip maps need to be generated after render.
  20624. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20625. * @param type The type of the buffer in the RTT (int, half float, float...)
  20626. * @param isCube True if a cube texture needs to be created
  20627. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20628. * @param generateDepthBuffer True to generate a depth buffer
  20629. * @param generateStencilBuffer True to generate a stencil buffer
  20630. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20631. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20632. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20633. */
  20634. constructor(name: string, size: number | {
  20635. width: number;
  20636. height: number;
  20637. } | {
  20638. ratio: number;
  20639. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20640. /**
  20641. * Creates a depth stencil texture.
  20642. * This is only available in WebGL 2 or with the depth texture extension available.
  20643. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20644. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20645. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20646. */
  20647. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20648. private _processSizeParameter;
  20649. /**
  20650. * Define the number of samples to use in case of MSAA.
  20651. * It defaults to one meaning no MSAA has been enabled.
  20652. */
  20653. samples: number;
  20654. /**
  20655. * Resets the refresh counter of the texture and start bak from scratch.
  20656. * Could be useful to regenerate the texture if it is setup to render only once.
  20657. */
  20658. resetRefreshCounter(): void;
  20659. /**
  20660. * Define the refresh rate of the texture or the rendering frequency.
  20661. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20662. */
  20663. refreshRate: number;
  20664. /**
  20665. * Adds a post process to the render target rendering passes.
  20666. * @param postProcess define the post process to add
  20667. */
  20668. addPostProcess(postProcess: PostProcess): void;
  20669. /**
  20670. * Clear all the post processes attached to the render target
  20671. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20672. */
  20673. clearPostProcesses(dispose?: boolean): void;
  20674. /**
  20675. * Remove one of the post process from the list of attached post processes to the texture
  20676. * @param postProcess define the post process to remove from the list
  20677. */
  20678. removePostProcess(postProcess: PostProcess): void;
  20679. /** @hidden */
  20680. _shouldRender(): boolean;
  20681. /**
  20682. * Gets the actual render size of the texture.
  20683. * @returns the width of the render size
  20684. */
  20685. getRenderSize(): number;
  20686. /**
  20687. * Gets the actual render width of the texture.
  20688. * @returns the width of the render size
  20689. */
  20690. getRenderWidth(): number;
  20691. /**
  20692. * Gets the actual render height of the texture.
  20693. * @returns the height of the render size
  20694. */
  20695. getRenderHeight(): number;
  20696. /**
  20697. * Get if the texture can be rescaled or not.
  20698. */
  20699. readonly canRescale: boolean;
  20700. /**
  20701. * Resize the texture using a ratio.
  20702. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20703. */
  20704. scale(ratio: number): void;
  20705. /**
  20706. * Get the texture reflection matrix used to rotate/transform the reflection.
  20707. * @returns the reflection matrix
  20708. */
  20709. getReflectionTextureMatrix(): Matrix;
  20710. /**
  20711. * Resize the texture to a new desired size.
  20712. * Be carrefull as it will recreate all the data in the new texture.
  20713. * @param size Define the new size. It can be:
  20714. * - a number for squared texture,
  20715. * - an object containing { width: number, height: number }
  20716. * - or an object containing a ratio { ratio: number }
  20717. */
  20718. resize(size: number | {
  20719. width: number;
  20720. height: number;
  20721. } | {
  20722. ratio: number;
  20723. }): void;
  20724. /**
  20725. * Renders all the objects from the render list into the texture.
  20726. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20727. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20728. */
  20729. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20730. private _bestReflectionRenderTargetDimension;
  20731. /**
  20732. * @hidden
  20733. * @param faceIndex face index to bind to if this is a cubetexture
  20734. */
  20735. _bindFrameBuffer(faceIndex?: number): void;
  20736. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20737. private renderToTarget;
  20738. /**
  20739. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20740. * This allowed control for front to back rendering or reversly depending of the special needs.
  20741. *
  20742. * @param renderingGroupId The rendering group id corresponding to its index
  20743. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20744. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20745. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20746. */
  20747. 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;
  20748. /**
  20749. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20750. *
  20751. * @param renderingGroupId The rendering group id corresponding to its index
  20752. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20753. */
  20754. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20755. /**
  20756. * Clones the texture.
  20757. * @returns the cloned texture
  20758. */
  20759. clone(): RenderTargetTexture;
  20760. /**
  20761. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20762. * @returns The JSON representation of the texture
  20763. */
  20764. serialize(): any;
  20765. /**
  20766. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20767. */
  20768. disposeFramebufferObjects(): void;
  20769. /**
  20770. * Dispose the texture and release its associated resources.
  20771. */
  20772. dispose(): void;
  20773. /** @hidden */
  20774. _rebuild(): void;
  20775. /**
  20776. * Clear the info related to rendering groups preventing retention point in material dispose.
  20777. */
  20778. freeRenderingGroups(): void;
  20779. /**
  20780. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20781. * @returns the view count
  20782. */
  20783. getViewCount(): number;
  20784. }
  20785. }
  20786. declare module "babylonjs/Materials/material" {
  20787. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20788. import { SmartArray } from "babylonjs/Misc/smartArray";
  20789. import { Observable } from "babylonjs/Misc/observable";
  20790. import { Nullable } from "babylonjs/types";
  20791. import { Scene } from "babylonjs/scene";
  20792. import { Matrix } from "babylonjs/Maths/math.vector";
  20793. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20795. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20796. import { Effect } from "babylonjs/Materials/effect";
  20797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20799. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20800. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20801. import { Mesh } from "babylonjs/Meshes/mesh";
  20802. import { Animation } from "babylonjs/Animations/animation";
  20803. /**
  20804. * Base class for the main features of a material in Babylon.js
  20805. */
  20806. export class Material implements IAnimatable {
  20807. /**
  20808. * Returns the triangle fill mode
  20809. */
  20810. static readonly TriangleFillMode: number;
  20811. /**
  20812. * Returns the wireframe mode
  20813. */
  20814. static readonly WireFrameFillMode: number;
  20815. /**
  20816. * Returns the point fill mode
  20817. */
  20818. static readonly PointFillMode: number;
  20819. /**
  20820. * Returns the point list draw mode
  20821. */
  20822. static readonly PointListDrawMode: number;
  20823. /**
  20824. * Returns the line list draw mode
  20825. */
  20826. static readonly LineListDrawMode: number;
  20827. /**
  20828. * Returns the line loop draw mode
  20829. */
  20830. static readonly LineLoopDrawMode: number;
  20831. /**
  20832. * Returns the line strip draw mode
  20833. */
  20834. static readonly LineStripDrawMode: number;
  20835. /**
  20836. * Returns the triangle strip draw mode
  20837. */
  20838. static readonly TriangleStripDrawMode: number;
  20839. /**
  20840. * Returns the triangle fan draw mode
  20841. */
  20842. static readonly TriangleFanDrawMode: number;
  20843. /**
  20844. * Stores the clock-wise side orientation
  20845. */
  20846. static readonly ClockWiseSideOrientation: number;
  20847. /**
  20848. * Stores the counter clock-wise side orientation
  20849. */
  20850. static readonly CounterClockWiseSideOrientation: number;
  20851. /**
  20852. * The dirty texture flag value
  20853. */
  20854. static readonly TextureDirtyFlag: number;
  20855. /**
  20856. * The dirty light flag value
  20857. */
  20858. static readonly LightDirtyFlag: number;
  20859. /**
  20860. * The dirty fresnel flag value
  20861. */
  20862. static readonly FresnelDirtyFlag: number;
  20863. /**
  20864. * The dirty attribute flag value
  20865. */
  20866. static readonly AttributesDirtyFlag: number;
  20867. /**
  20868. * The dirty misc flag value
  20869. */
  20870. static readonly MiscDirtyFlag: number;
  20871. /**
  20872. * The all dirty flag value
  20873. */
  20874. static readonly AllDirtyFlag: number;
  20875. /**
  20876. * The ID of the material
  20877. */
  20878. id: string;
  20879. /**
  20880. * Gets or sets the unique id of the material
  20881. */
  20882. uniqueId: number;
  20883. /**
  20884. * The name of the material
  20885. */
  20886. name: string;
  20887. /**
  20888. * Gets or sets user defined metadata
  20889. */
  20890. metadata: any;
  20891. /**
  20892. * For internal use only. Please do not use.
  20893. */
  20894. reservedDataStore: any;
  20895. /**
  20896. * Specifies if the ready state should be checked on each call
  20897. */
  20898. checkReadyOnEveryCall: boolean;
  20899. /**
  20900. * Specifies if the ready state should be checked once
  20901. */
  20902. checkReadyOnlyOnce: boolean;
  20903. /**
  20904. * The state of the material
  20905. */
  20906. state: string;
  20907. /**
  20908. * The alpha value of the material
  20909. */
  20910. protected _alpha: number;
  20911. /**
  20912. * List of inspectable custom properties (used by the Inspector)
  20913. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20914. */
  20915. inspectableCustomProperties: IInspectable[];
  20916. /**
  20917. * Sets the alpha value of the material
  20918. */
  20919. /**
  20920. * Gets the alpha value of the material
  20921. */
  20922. alpha: number;
  20923. /**
  20924. * Specifies if back face culling is enabled
  20925. */
  20926. protected _backFaceCulling: boolean;
  20927. /**
  20928. * Sets the back-face culling state
  20929. */
  20930. /**
  20931. * Gets the back-face culling state
  20932. */
  20933. backFaceCulling: boolean;
  20934. /**
  20935. * Stores the value for side orientation
  20936. */
  20937. sideOrientation: number;
  20938. /**
  20939. * Callback triggered when the material is compiled
  20940. */
  20941. onCompiled: Nullable<(effect: Effect) => void>;
  20942. /**
  20943. * Callback triggered when an error occurs
  20944. */
  20945. onError: Nullable<(effect: Effect, errors: string) => void>;
  20946. /**
  20947. * Callback triggered to get the render target textures
  20948. */
  20949. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20950. /**
  20951. * Gets a boolean indicating that current material needs to register RTT
  20952. */
  20953. readonly hasRenderTargetTextures: boolean;
  20954. /**
  20955. * Specifies if the material should be serialized
  20956. */
  20957. doNotSerialize: boolean;
  20958. /**
  20959. * @hidden
  20960. */
  20961. _storeEffectOnSubMeshes: boolean;
  20962. /**
  20963. * Stores the animations for the material
  20964. */
  20965. animations: Nullable<Array<Animation>>;
  20966. /**
  20967. * An event triggered when the material is disposed
  20968. */
  20969. onDisposeObservable: Observable<Material>;
  20970. /**
  20971. * An observer which watches for dispose events
  20972. */
  20973. private _onDisposeObserver;
  20974. private _onUnBindObservable;
  20975. /**
  20976. * Called during a dispose event
  20977. */
  20978. onDispose: () => void;
  20979. private _onBindObservable;
  20980. /**
  20981. * An event triggered when the material is bound
  20982. */
  20983. readonly onBindObservable: Observable<AbstractMesh>;
  20984. /**
  20985. * An observer which watches for bind events
  20986. */
  20987. private _onBindObserver;
  20988. /**
  20989. * Called during a bind event
  20990. */
  20991. onBind: (Mesh: AbstractMesh) => void;
  20992. /**
  20993. * An event triggered when the material is unbound
  20994. */
  20995. readonly onUnBindObservable: Observable<Material>;
  20996. /**
  20997. * Stores the value of the alpha mode
  20998. */
  20999. private _alphaMode;
  21000. /**
  21001. * Sets the value of the alpha mode.
  21002. *
  21003. * | Value | Type | Description |
  21004. * | --- | --- | --- |
  21005. * | 0 | ALPHA_DISABLE | |
  21006. * | 1 | ALPHA_ADD | |
  21007. * | 2 | ALPHA_COMBINE | |
  21008. * | 3 | ALPHA_SUBTRACT | |
  21009. * | 4 | ALPHA_MULTIPLY | |
  21010. * | 5 | ALPHA_MAXIMIZED | |
  21011. * | 6 | ALPHA_ONEONE | |
  21012. * | 7 | ALPHA_PREMULTIPLIED | |
  21013. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21014. * | 9 | ALPHA_INTERPOLATE | |
  21015. * | 10 | ALPHA_SCREENMODE | |
  21016. *
  21017. */
  21018. /**
  21019. * Gets the value of the alpha mode
  21020. */
  21021. alphaMode: number;
  21022. /**
  21023. * Stores the state of the need depth pre-pass value
  21024. */
  21025. private _needDepthPrePass;
  21026. /**
  21027. * Sets the need depth pre-pass value
  21028. */
  21029. /**
  21030. * Gets the depth pre-pass value
  21031. */
  21032. needDepthPrePass: boolean;
  21033. /**
  21034. * Specifies if depth writing should be disabled
  21035. */
  21036. disableDepthWrite: boolean;
  21037. /**
  21038. * Specifies if depth writing should be forced
  21039. */
  21040. forceDepthWrite: boolean;
  21041. /**
  21042. * Specifies if there should be a separate pass for culling
  21043. */
  21044. separateCullingPass: boolean;
  21045. /**
  21046. * Stores the state specifing if fog should be enabled
  21047. */
  21048. private _fogEnabled;
  21049. /**
  21050. * Sets the state for enabling fog
  21051. */
  21052. /**
  21053. * Gets the value of the fog enabled state
  21054. */
  21055. fogEnabled: boolean;
  21056. /**
  21057. * Stores the size of points
  21058. */
  21059. pointSize: number;
  21060. /**
  21061. * Stores the z offset value
  21062. */
  21063. zOffset: number;
  21064. /**
  21065. * Gets a value specifying if wireframe mode is enabled
  21066. */
  21067. /**
  21068. * Sets the state of wireframe mode
  21069. */
  21070. wireframe: boolean;
  21071. /**
  21072. * Gets the value specifying if point clouds are enabled
  21073. */
  21074. /**
  21075. * Sets the state of point cloud mode
  21076. */
  21077. pointsCloud: boolean;
  21078. /**
  21079. * Gets the material fill mode
  21080. */
  21081. /**
  21082. * Sets the material fill mode
  21083. */
  21084. fillMode: number;
  21085. /**
  21086. * @hidden
  21087. * Stores the effects for the material
  21088. */
  21089. _effect: Nullable<Effect>;
  21090. /**
  21091. * @hidden
  21092. * Specifies if the material was previously ready
  21093. */
  21094. _wasPreviouslyReady: boolean;
  21095. /**
  21096. * Specifies if uniform buffers should be used
  21097. */
  21098. private _useUBO;
  21099. /**
  21100. * Stores a reference to the scene
  21101. */
  21102. private _scene;
  21103. /**
  21104. * Stores the fill mode state
  21105. */
  21106. private _fillMode;
  21107. /**
  21108. * Specifies if the depth write state should be cached
  21109. */
  21110. private _cachedDepthWriteState;
  21111. /**
  21112. * Stores the uniform buffer
  21113. */
  21114. protected _uniformBuffer: UniformBuffer;
  21115. /** @hidden */
  21116. _indexInSceneMaterialArray: number;
  21117. /** @hidden */
  21118. meshMap: Nullable<{
  21119. [id: string]: AbstractMesh | undefined;
  21120. }>;
  21121. /**
  21122. * Creates a material instance
  21123. * @param name defines the name of the material
  21124. * @param scene defines the scene to reference
  21125. * @param doNotAdd specifies if the material should be added to the scene
  21126. */
  21127. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21128. /**
  21129. * Returns a string representation of the current material
  21130. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21131. * @returns a string with material information
  21132. */
  21133. toString(fullDetails?: boolean): string;
  21134. /**
  21135. * Gets the class name of the material
  21136. * @returns a string with the class name of the material
  21137. */
  21138. getClassName(): string;
  21139. /**
  21140. * Specifies if updates for the material been locked
  21141. */
  21142. readonly isFrozen: boolean;
  21143. /**
  21144. * Locks updates for the material
  21145. */
  21146. freeze(): void;
  21147. /**
  21148. * Unlocks updates for the material
  21149. */
  21150. unfreeze(): void;
  21151. /**
  21152. * Specifies if the material is ready to be used
  21153. * @param mesh defines the mesh to check
  21154. * @param useInstances specifies if instances should be used
  21155. * @returns a boolean indicating if the material is ready to be used
  21156. */
  21157. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21158. /**
  21159. * Specifies that the submesh is ready to be used
  21160. * @param mesh defines the mesh to check
  21161. * @param subMesh defines which submesh to check
  21162. * @param useInstances specifies that instances should be used
  21163. * @returns a boolean indicating that the submesh is ready or not
  21164. */
  21165. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21166. /**
  21167. * Returns the material effect
  21168. * @returns the effect associated with the material
  21169. */
  21170. getEffect(): Nullable<Effect>;
  21171. /**
  21172. * Returns the current scene
  21173. * @returns a Scene
  21174. */
  21175. getScene(): Scene;
  21176. /**
  21177. * Specifies if the material will require alpha blending
  21178. * @returns a boolean specifying if alpha blending is needed
  21179. */
  21180. needAlphaBlending(): boolean;
  21181. /**
  21182. * Specifies if the mesh will require alpha blending
  21183. * @param mesh defines the mesh to check
  21184. * @returns a boolean specifying if alpha blending is needed for the mesh
  21185. */
  21186. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21187. /**
  21188. * Specifies if this material should be rendered in alpha test mode
  21189. * @returns a boolean specifying if an alpha test is needed.
  21190. */
  21191. needAlphaTesting(): boolean;
  21192. /**
  21193. * Gets the texture used for the alpha test
  21194. * @returns the texture to use for alpha testing
  21195. */
  21196. getAlphaTestTexture(): Nullable<BaseTexture>;
  21197. /**
  21198. * Marks the material to indicate that it needs to be re-calculated
  21199. */
  21200. markDirty(): void;
  21201. /** @hidden */
  21202. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21203. /**
  21204. * Binds the material to the mesh
  21205. * @param world defines the world transformation matrix
  21206. * @param mesh defines the mesh to bind the material to
  21207. */
  21208. bind(world: Matrix, mesh?: Mesh): void;
  21209. /**
  21210. * Binds the submesh to the material
  21211. * @param world defines the world transformation matrix
  21212. * @param mesh defines the mesh containing the submesh
  21213. * @param subMesh defines the submesh to bind the material to
  21214. */
  21215. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21216. /**
  21217. * Binds the world matrix to the material
  21218. * @param world defines the world transformation matrix
  21219. */
  21220. bindOnlyWorldMatrix(world: Matrix): void;
  21221. /**
  21222. * Binds the scene's uniform buffer to the effect.
  21223. * @param effect defines the effect to bind to the scene uniform buffer
  21224. * @param sceneUbo defines the uniform buffer storing scene data
  21225. */
  21226. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21227. /**
  21228. * Binds the view matrix to the effect
  21229. * @param effect defines the effect to bind the view matrix to
  21230. */
  21231. bindView(effect: Effect): void;
  21232. /**
  21233. * Binds the view projection matrix to the effect
  21234. * @param effect defines the effect to bind the view projection matrix to
  21235. */
  21236. bindViewProjection(effect: Effect): void;
  21237. /**
  21238. * Specifies if material alpha testing should be turned on for the mesh
  21239. * @param mesh defines the mesh to check
  21240. */
  21241. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21242. /**
  21243. * Processes to execute after binding the material to a mesh
  21244. * @param mesh defines the rendered mesh
  21245. */
  21246. protected _afterBind(mesh?: Mesh): void;
  21247. /**
  21248. * Unbinds the material from the mesh
  21249. */
  21250. unbind(): void;
  21251. /**
  21252. * Gets the active textures from the material
  21253. * @returns an array of textures
  21254. */
  21255. getActiveTextures(): BaseTexture[];
  21256. /**
  21257. * Specifies if the material uses a texture
  21258. * @param texture defines the texture to check against the material
  21259. * @returns a boolean specifying if the material uses the texture
  21260. */
  21261. hasTexture(texture: BaseTexture): boolean;
  21262. /**
  21263. * Makes a duplicate of the material, and gives it a new name
  21264. * @param name defines the new name for the duplicated material
  21265. * @returns the cloned material
  21266. */
  21267. clone(name: string): Nullable<Material>;
  21268. /**
  21269. * Gets the meshes bound to the material
  21270. * @returns an array of meshes bound to the material
  21271. */
  21272. getBindedMeshes(): AbstractMesh[];
  21273. /**
  21274. * Force shader compilation
  21275. * @param mesh defines the mesh associated with this material
  21276. * @param onCompiled defines a function to execute once the material is compiled
  21277. * @param options defines the options to configure the compilation
  21278. */
  21279. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21280. clipPlane: boolean;
  21281. }>): void;
  21282. /**
  21283. * Force shader compilation
  21284. * @param mesh defines the mesh that will use this material
  21285. * @param options defines additional options for compiling the shaders
  21286. * @returns a promise that resolves when the compilation completes
  21287. */
  21288. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21289. clipPlane: boolean;
  21290. }>): Promise<void>;
  21291. private static readonly _AllDirtyCallBack;
  21292. private static readonly _ImageProcessingDirtyCallBack;
  21293. private static readonly _TextureDirtyCallBack;
  21294. private static readonly _FresnelDirtyCallBack;
  21295. private static readonly _MiscDirtyCallBack;
  21296. private static readonly _LightsDirtyCallBack;
  21297. private static readonly _AttributeDirtyCallBack;
  21298. private static _FresnelAndMiscDirtyCallBack;
  21299. private static _TextureAndMiscDirtyCallBack;
  21300. private static readonly _DirtyCallbackArray;
  21301. private static readonly _RunDirtyCallBacks;
  21302. /**
  21303. * Marks a define in the material to indicate that it needs to be re-computed
  21304. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21305. */
  21306. markAsDirty(flag: number): void;
  21307. /**
  21308. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21309. * @param func defines a function which checks material defines against the submeshes
  21310. */
  21311. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21312. /**
  21313. * Indicates that we need to re-calculated for all submeshes
  21314. */
  21315. protected _markAllSubMeshesAsAllDirty(): void;
  21316. /**
  21317. * Indicates that image processing needs to be re-calculated for all submeshes
  21318. */
  21319. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21320. /**
  21321. * Indicates that textures need to be re-calculated for all submeshes
  21322. */
  21323. protected _markAllSubMeshesAsTexturesDirty(): void;
  21324. /**
  21325. * Indicates that fresnel needs to be re-calculated for all submeshes
  21326. */
  21327. protected _markAllSubMeshesAsFresnelDirty(): void;
  21328. /**
  21329. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21330. */
  21331. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21332. /**
  21333. * Indicates that lights need to be re-calculated for all submeshes
  21334. */
  21335. protected _markAllSubMeshesAsLightsDirty(): void;
  21336. /**
  21337. * Indicates that attributes need to be re-calculated for all submeshes
  21338. */
  21339. protected _markAllSubMeshesAsAttributesDirty(): void;
  21340. /**
  21341. * Indicates that misc needs to be re-calculated for all submeshes
  21342. */
  21343. protected _markAllSubMeshesAsMiscDirty(): void;
  21344. /**
  21345. * Indicates that textures and misc need to be re-calculated for all submeshes
  21346. */
  21347. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21348. /**
  21349. * Disposes the material
  21350. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21351. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21352. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21353. */
  21354. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21355. /** @hidden */
  21356. private releaseVertexArrayObject;
  21357. /**
  21358. * Serializes this material
  21359. * @returns the serialized material object
  21360. */
  21361. serialize(): any;
  21362. /**
  21363. * Creates a material from parsed material data
  21364. * @param parsedMaterial defines parsed material data
  21365. * @param scene defines the hosting scene
  21366. * @param rootUrl defines the root URL to use to load textures
  21367. * @returns a new material
  21368. */
  21369. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21370. }
  21371. }
  21372. declare module "babylonjs/Materials/multiMaterial" {
  21373. import { Nullable } from "babylonjs/types";
  21374. import { Scene } from "babylonjs/scene";
  21375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21376. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21378. import { Material } from "babylonjs/Materials/material";
  21379. /**
  21380. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21381. * separate meshes. This can be use to improve performances.
  21382. * @see http://doc.babylonjs.com/how_to/multi_materials
  21383. */
  21384. export class MultiMaterial extends Material {
  21385. private _subMaterials;
  21386. /**
  21387. * Gets or Sets the list of Materials used within the multi material.
  21388. * They need to be ordered according to the submeshes order in the associated mesh
  21389. */
  21390. subMaterials: Nullable<Material>[];
  21391. /**
  21392. * Function used to align with Node.getChildren()
  21393. * @returns the list of Materials used within the multi material
  21394. */
  21395. getChildren(): Nullable<Material>[];
  21396. /**
  21397. * Instantiates a new Multi Material
  21398. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21399. * separate meshes. This can be use to improve performances.
  21400. * @see http://doc.babylonjs.com/how_to/multi_materials
  21401. * @param name Define the name in the scene
  21402. * @param scene Define the scene the material belongs to
  21403. */
  21404. constructor(name: string, scene: Scene);
  21405. private _hookArray;
  21406. /**
  21407. * Get one of the submaterial by its index in the submaterials array
  21408. * @param index The index to look the sub material at
  21409. * @returns The Material if the index has been defined
  21410. */
  21411. getSubMaterial(index: number): Nullable<Material>;
  21412. /**
  21413. * Get the list of active textures for the whole sub materials list.
  21414. * @returns All the textures that will be used during the rendering
  21415. */
  21416. getActiveTextures(): BaseTexture[];
  21417. /**
  21418. * Gets the current class name of the material e.g. "MultiMaterial"
  21419. * Mainly use in serialization.
  21420. * @returns the class name
  21421. */
  21422. getClassName(): string;
  21423. /**
  21424. * Checks if the material is ready to render the requested sub mesh
  21425. * @param mesh Define the mesh the submesh belongs to
  21426. * @param subMesh Define the sub mesh to look readyness for
  21427. * @param useInstances Define whether or not the material is used with instances
  21428. * @returns true if ready, otherwise false
  21429. */
  21430. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21431. /**
  21432. * Clones the current material and its related sub materials
  21433. * @param name Define the name of the newly cloned material
  21434. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21435. * @returns the cloned material
  21436. */
  21437. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21438. /**
  21439. * Serializes the materials into a JSON representation.
  21440. * @returns the JSON representation
  21441. */
  21442. serialize(): any;
  21443. /**
  21444. * Dispose the material and release its associated resources
  21445. * @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)
  21446. * @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)
  21447. * @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)
  21448. */
  21449. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21450. /**
  21451. * Creates a MultiMaterial from parsed MultiMaterial data.
  21452. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21453. * @param scene defines the hosting scene
  21454. * @returns a new MultiMaterial
  21455. */
  21456. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21457. }
  21458. }
  21459. declare module "babylonjs/Meshes/subMesh" {
  21460. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21461. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21462. import { Engine } from "babylonjs/Engines/engine";
  21463. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21464. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21465. import { Effect } from "babylonjs/Materials/effect";
  21466. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21467. import { Plane } from "babylonjs/Maths/math.plane";
  21468. import { Collider } from "babylonjs/Collisions/collider";
  21469. import { Material } from "babylonjs/Materials/material";
  21470. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21472. import { Mesh } from "babylonjs/Meshes/mesh";
  21473. import { Ray } from "babylonjs/Culling/ray";
  21474. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21475. /**
  21476. * Base class for submeshes
  21477. */
  21478. export class BaseSubMesh {
  21479. /** @hidden */
  21480. _materialDefines: Nullable<MaterialDefines>;
  21481. /** @hidden */
  21482. _materialEffect: Nullable<Effect>;
  21483. /**
  21484. * Gets associated effect
  21485. */
  21486. readonly effect: Nullable<Effect>;
  21487. /**
  21488. * Sets associated effect (effect used to render this submesh)
  21489. * @param effect defines the effect to associate with
  21490. * @param defines defines the set of defines used to compile this effect
  21491. */
  21492. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21493. }
  21494. /**
  21495. * Defines a subdivision inside a mesh
  21496. */
  21497. export class SubMesh extends BaseSubMesh implements ICullable {
  21498. /** the material index to use */
  21499. materialIndex: number;
  21500. /** vertex index start */
  21501. verticesStart: number;
  21502. /** vertices count */
  21503. verticesCount: number;
  21504. /** index start */
  21505. indexStart: number;
  21506. /** indices count */
  21507. indexCount: number;
  21508. /** @hidden */
  21509. _linesIndexCount: number;
  21510. private _mesh;
  21511. private _renderingMesh;
  21512. private _boundingInfo;
  21513. private _linesIndexBuffer;
  21514. /** @hidden */
  21515. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21516. /** @hidden */
  21517. _trianglePlanes: Plane[];
  21518. /** @hidden */
  21519. _lastColliderTransformMatrix: Nullable<Matrix>;
  21520. /** @hidden */
  21521. _renderId: number;
  21522. /** @hidden */
  21523. _alphaIndex: number;
  21524. /** @hidden */
  21525. _distanceToCamera: number;
  21526. /** @hidden */
  21527. _id: number;
  21528. private _currentMaterial;
  21529. /**
  21530. * Add a new submesh to a mesh
  21531. * @param materialIndex defines the material index to use
  21532. * @param verticesStart defines vertex index start
  21533. * @param verticesCount defines vertices count
  21534. * @param indexStart defines index start
  21535. * @param indexCount defines indices count
  21536. * @param mesh defines the parent mesh
  21537. * @param renderingMesh defines an optional rendering mesh
  21538. * @param createBoundingBox defines if bounding box should be created for this submesh
  21539. * @returns the new submesh
  21540. */
  21541. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21542. /**
  21543. * Creates a new submesh
  21544. * @param materialIndex defines the material index to use
  21545. * @param verticesStart defines vertex index start
  21546. * @param verticesCount defines vertices count
  21547. * @param indexStart defines index start
  21548. * @param indexCount defines indices count
  21549. * @param mesh defines the parent mesh
  21550. * @param renderingMesh defines an optional rendering mesh
  21551. * @param createBoundingBox defines if bounding box should be created for this submesh
  21552. */
  21553. constructor(
  21554. /** the material index to use */
  21555. materialIndex: number,
  21556. /** vertex index start */
  21557. verticesStart: number,
  21558. /** vertices count */
  21559. verticesCount: number,
  21560. /** index start */
  21561. indexStart: number,
  21562. /** indices count */
  21563. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21564. /**
  21565. * Returns true if this submesh covers the entire parent mesh
  21566. * @ignorenaming
  21567. */
  21568. readonly IsGlobal: boolean;
  21569. /**
  21570. * Returns the submesh BoudingInfo object
  21571. * @returns current bounding info (or mesh's one if the submesh is global)
  21572. */
  21573. getBoundingInfo(): BoundingInfo;
  21574. /**
  21575. * Sets the submesh BoundingInfo
  21576. * @param boundingInfo defines the new bounding info to use
  21577. * @returns the SubMesh
  21578. */
  21579. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21580. /**
  21581. * Returns the mesh of the current submesh
  21582. * @return the parent mesh
  21583. */
  21584. getMesh(): AbstractMesh;
  21585. /**
  21586. * Returns the rendering mesh of the submesh
  21587. * @returns the rendering mesh (could be different from parent mesh)
  21588. */
  21589. getRenderingMesh(): Mesh;
  21590. /**
  21591. * Returns the submesh material
  21592. * @returns null or the current material
  21593. */
  21594. getMaterial(): Nullable<Material>;
  21595. /**
  21596. * Sets a new updated BoundingInfo object to the submesh
  21597. * @param data defines an optional position array to use to determine the bounding info
  21598. * @returns the SubMesh
  21599. */
  21600. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21601. /** @hidden */
  21602. _checkCollision(collider: Collider): boolean;
  21603. /**
  21604. * Updates the submesh BoundingInfo
  21605. * @param world defines the world matrix to use to update the bounding info
  21606. * @returns the submesh
  21607. */
  21608. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21609. /**
  21610. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21611. * @param frustumPlanes defines the frustum planes
  21612. * @returns true if the submesh is intersecting with the frustum
  21613. */
  21614. isInFrustum(frustumPlanes: Plane[]): boolean;
  21615. /**
  21616. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21617. * @param frustumPlanes defines the frustum planes
  21618. * @returns true if the submesh is inside the frustum
  21619. */
  21620. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21621. /**
  21622. * Renders the submesh
  21623. * @param enableAlphaMode defines if alpha needs to be used
  21624. * @returns the submesh
  21625. */
  21626. render(enableAlphaMode: boolean): SubMesh;
  21627. /**
  21628. * @hidden
  21629. */
  21630. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21631. /**
  21632. * Checks if the submesh intersects with a ray
  21633. * @param ray defines the ray to test
  21634. * @returns true is the passed ray intersects the submesh bounding box
  21635. */
  21636. canIntersects(ray: Ray): boolean;
  21637. /**
  21638. * Intersects current submesh with a ray
  21639. * @param ray defines the ray to test
  21640. * @param positions defines mesh's positions array
  21641. * @param indices defines mesh's indices array
  21642. * @param fastCheck defines if only bounding info should be used
  21643. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21644. * @returns intersection info or null if no intersection
  21645. */
  21646. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21647. /** @hidden */
  21648. private _intersectLines;
  21649. /** @hidden */
  21650. private _intersectUnIndexedLines;
  21651. /** @hidden */
  21652. private _intersectTriangles;
  21653. /** @hidden */
  21654. private _intersectUnIndexedTriangles;
  21655. /** @hidden */
  21656. _rebuild(): void;
  21657. /**
  21658. * Creates a new submesh from the passed mesh
  21659. * @param newMesh defines the new hosting mesh
  21660. * @param newRenderingMesh defines an optional rendering mesh
  21661. * @returns the new submesh
  21662. */
  21663. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21664. /**
  21665. * Release associated resources
  21666. */
  21667. dispose(): void;
  21668. /**
  21669. * Gets the class name
  21670. * @returns the string "SubMesh".
  21671. */
  21672. getClassName(): string;
  21673. /**
  21674. * Creates a new submesh from indices data
  21675. * @param materialIndex the index of the main mesh material
  21676. * @param startIndex the index where to start the copy in the mesh indices array
  21677. * @param indexCount the number of indices to copy then from the startIndex
  21678. * @param mesh the main mesh to create the submesh from
  21679. * @param renderingMesh the optional rendering mesh
  21680. * @returns a new submesh
  21681. */
  21682. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21683. }
  21684. }
  21685. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21686. /**
  21687. * Class used to represent data loading progression
  21688. */
  21689. export class SceneLoaderFlags {
  21690. private static _ForceFullSceneLoadingForIncremental;
  21691. private static _ShowLoadingScreen;
  21692. private static _CleanBoneMatrixWeights;
  21693. private static _loggingLevel;
  21694. /**
  21695. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21696. */
  21697. static ForceFullSceneLoadingForIncremental: boolean;
  21698. /**
  21699. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21700. */
  21701. static ShowLoadingScreen: boolean;
  21702. /**
  21703. * Defines the current logging level (while loading the scene)
  21704. * @ignorenaming
  21705. */
  21706. static loggingLevel: number;
  21707. /**
  21708. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21709. */
  21710. static CleanBoneMatrixWeights: boolean;
  21711. }
  21712. }
  21713. declare module "babylonjs/Meshes/geometry" {
  21714. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21715. import { Scene } from "babylonjs/scene";
  21716. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21717. import { Engine } from "babylonjs/Engines/engine";
  21718. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21719. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21720. import { Effect } from "babylonjs/Materials/effect";
  21721. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21722. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21723. import { Mesh } from "babylonjs/Meshes/mesh";
  21724. /**
  21725. * Class used to store geometry data (vertex buffers + index buffer)
  21726. */
  21727. export class Geometry implements IGetSetVerticesData {
  21728. /**
  21729. * Gets or sets the ID of the geometry
  21730. */
  21731. id: string;
  21732. /**
  21733. * Gets or sets the unique ID of the geometry
  21734. */
  21735. uniqueId: number;
  21736. /**
  21737. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21738. */
  21739. delayLoadState: number;
  21740. /**
  21741. * Gets the file containing the data to load when running in delay load state
  21742. */
  21743. delayLoadingFile: Nullable<string>;
  21744. /**
  21745. * Callback called when the geometry is updated
  21746. */
  21747. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21748. private _scene;
  21749. private _engine;
  21750. private _meshes;
  21751. private _totalVertices;
  21752. /** @hidden */
  21753. _indices: IndicesArray;
  21754. /** @hidden */
  21755. _vertexBuffers: {
  21756. [key: string]: VertexBuffer;
  21757. };
  21758. private _isDisposed;
  21759. private _extend;
  21760. private _boundingBias;
  21761. /** @hidden */
  21762. _delayInfo: Array<string>;
  21763. private _indexBuffer;
  21764. private _indexBufferIsUpdatable;
  21765. /** @hidden */
  21766. _boundingInfo: Nullable<BoundingInfo>;
  21767. /** @hidden */
  21768. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21769. /** @hidden */
  21770. _softwareSkinningFrameId: number;
  21771. private _vertexArrayObjects;
  21772. private _updatable;
  21773. /** @hidden */
  21774. _positions: Nullable<Vector3[]>;
  21775. /**
  21776. * 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
  21777. */
  21778. /**
  21779. * 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
  21780. */
  21781. boundingBias: Vector2;
  21782. /**
  21783. * Static function used to attach a new empty geometry to a mesh
  21784. * @param mesh defines the mesh to attach the geometry to
  21785. * @returns the new Geometry
  21786. */
  21787. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21788. /**
  21789. * Creates a new geometry
  21790. * @param id defines the unique ID
  21791. * @param scene defines the hosting scene
  21792. * @param vertexData defines the VertexData used to get geometry data
  21793. * @param updatable defines if geometry must be updatable (false by default)
  21794. * @param mesh defines the mesh that will be associated with the geometry
  21795. */
  21796. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21797. /**
  21798. * Gets the current extend of the geometry
  21799. */
  21800. readonly extend: {
  21801. minimum: Vector3;
  21802. maximum: Vector3;
  21803. };
  21804. /**
  21805. * Gets the hosting scene
  21806. * @returns the hosting Scene
  21807. */
  21808. getScene(): Scene;
  21809. /**
  21810. * Gets the hosting engine
  21811. * @returns the hosting Engine
  21812. */
  21813. getEngine(): Engine;
  21814. /**
  21815. * Defines if the geometry is ready to use
  21816. * @returns true if the geometry is ready to be used
  21817. */
  21818. isReady(): boolean;
  21819. /**
  21820. * Gets a value indicating that the geometry should not be serialized
  21821. */
  21822. readonly doNotSerialize: boolean;
  21823. /** @hidden */
  21824. _rebuild(): void;
  21825. /**
  21826. * Affects all geometry data in one call
  21827. * @param vertexData defines the geometry data
  21828. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21829. */
  21830. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21831. /**
  21832. * Set specific vertex data
  21833. * @param kind defines the data kind (Position, normal, etc...)
  21834. * @param data defines the vertex data to use
  21835. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21836. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21837. */
  21838. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21839. /**
  21840. * Removes a specific vertex data
  21841. * @param kind defines the data kind (Position, normal, etc...)
  21842. */
  21843. removeVerticesData(kind: string): void;
  21844. /**
  21845. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21846. * @param buffer defines the vertex buffer to use
  21847. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21848. */
  21849. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21850. /**
  21851. * Update a specific vertex buffer
  21852. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21853. * It will do nothing if the buffer is not updatable
  21854. * @param kind defines the data kind (Position, normal, etc...)
  21855. * @param data defines the data to use
  21856. * @param offset defines the offset in the target buffer where to store the data
  21857. * @param useBytes set to true if the offset is in bytes
  21858. */
  21859. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21860. /**
  21861. * Update a specific vertex buffer
  21862. * This function will create a new buffer if the current one is not updatable
  21863. * @param kind defines the data kind (Position, normal, etc...)
  21864. * @param data defines the data to use
  21865. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21866. */
  21867. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21868. private _updateBoundingInfo;
  21869. /** @hidden */
  21870. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21871. /**
  21872. * Gets total number of vertices
  21873. * @returns the total number of vertices
  21874. */
  21875. getTotalVertices(): number;
  21876. /**
  21877. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21878. * @param kind defines the data kind (Position, normal, etc...)
  21879. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21881. * @returns a float array containing vertex data
  21882. */
  21883. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21884. /**
  21885. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21886. * @param kind defines the data kind (Position, normal, etc...)
  21887. * @returns true if the vertex buffer with the specified kind is updatable
  21888. */
  21889. isVertexBufferUpdatable(kind: string): boolean;
  21890. /**
  21891. * Gets a specific vertex buffer
  21892. * @param kind defines the data kind (Position, normal, etc...)
  21893. * @returns a VertexBuffer
  21894. */
  21895. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21896. /**
  21897. * Returns all vertex buffers
  21898. * @return an object holding all vertex buffers indexed by kind
  21899. */
  21900. getVertexBuffers(): Nullable<{
  21901. [key: string]: VertexBuffer;
  21902. }>;
  21903. /**
  21904. * Gets a boolean indicating if specific vertex buffer is present
  21905. * @param kind defines the data kind (Position, normal, etc...)
  21906. * @returns true if data is present
  21907. */
  21908. isVerticesDataPresent(kind: string): boolean;
  21909. /**
  21910. * Gets a list of all attached data kinds (Position, normal, etc...)
  21911. * @returns a list of string containing all kinds
  21912. */
  21913. getVerticesDataKinds(): string[];
  21914. /**
  21915. * Update index buffer
  21916. * @param indices defines the indices to store in the index buffer
  21917. * @param offset defines the offset in the target buffer where to store the data
  21918. * @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)
  21919. */
  21920. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21921. /**
  21922. * Creates a new index buffer
  21923. * @param indices defines the indices to store in the index buffer
  21924. * @param totalVertices defines the total number of vertices (could be null)
  21925. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21926. */
  21927. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21928. /**
  21929. * Return the total number of indices
  21930. * @returns the total number of indices
  21931. */
  21932. getTotalIndices(): number;
  21933. /**
  21934. * Gets the index buffer array
  21935. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21936. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21937. * @returns the index buffer array
  21938. */
  21939. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21940. /**
  21941. * Gets the index buffer
  21942. * @return the index buffer
  21943. */
  21944. getIndexBuffer(): Nullable<DataBuffer>;
  21945. /** @hidden */
  21946. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21947. /**
  21948. * Release the associated resources for a specific mesh
  21949. * @param mesh defines the source mesh
  21950. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21951. */
  21952. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21953. /**
  21954. * Apply current geometry to a given mesh
  21955. * @param mesh defines the mesh to apply geometry to
  21956. */
  21957. applyToMesh(mesh: Mesh): void;
  21958. private _updateExtend;
  21959. private _applyToMesh;
  21960. private notifyUpdate;
  21961. /**
  21962. * Load the geometry if it was flagged as delay loaded
  21963. * @param scene defines the hosting scene
  21964. * @param onLoaded defines a callback called when the geometry is loaded
  21965. */
  21966. load(scene: Scene, onLoaded?: () => void): void;
  21967. private _queueLoad;
  21968. /**
  21969. * Invert the geometry to move from a right handed system to a left handed one.
  21970. */
  21971. toLeftHanded(): void;
  21972. /** @hidden */
  21973. _resetPointsArrayCache(): void;
  21974. /** @hidden */
  21975. _generatePointsArray(): boolean;
  21976. /**
  21977. * Gets a value indicating if the geometry is disposed
  21978. * @returns true if the geometry was disposed
  21979. */
  21980. isDisposed(): boolean;
  21981. private _disposeVertexArrayObjects;
  21982. /**
  21983. * Free all associated resources
  21984. */
  21985. dispose(): void;
  21986. /**
  21987. * Clone the current geometry into a new geometry
  21988. * @param id defines the unique ID of the new geometry
  21989. * @returns a new geometry object
  21990. */
  21991. copy(id: string): Geometry;
  21992. /**
  21993. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21994. * @return a JSON representation of the current geometry data (without the vertices data)
  21995. */
  21996. serialize(): any;
  21997. private toNumberArray;
  21998. /**
  21999. * Serialize all vertices data into a JSON oject
  22000. * @returns a JSON representation of the current geometry data
  22001. */
  22002. serializeVerticeData(): any;
  22003. /**
  22004. * Extracts a clone of a mesh geometry
  22005. * @param mesh defines the source mesh
  22006. * @param id defines the unique ID of the new geometry object
  22007. * @returns the new geometry object
  22008. */
  22009. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22010. /**
  22011. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22012. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22013. * Be aware Math.random() could cause collisions, but:
  22014. * "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"
  22015. * @returns a string containing a new GUID
  22016. */
  22017. static RandomId(): string;
  22018. /** @hidden */
  22019. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22020. private static _CleanMatricesWeights;
  22021. /**
  22022. * Create a new geometry from persisted data (Using .babylon file format)
  22023. * @param parsedVertexData defines the persisted data
  22024. * @param scene defines the hosting scene
  22025. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22026. * @returns the new geometry object
  22027. */
  22028. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22029. }
  22030. }
  22031. declare module "babylonjs/Meshes/mesh.vertexData" {
  22032. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22033. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22034. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22035. import { Geometry } from "babylonjs/Meshes/geometry";
  22036. import { Mesh } from "babylonjs/Meshes/mesh";
  22037. /**
  22038. * Define an interface for all classes that will get and set the data on vertices
  22039. */
  22040. export interface IGetSetVerticesData {
  22041. /**
  22042. * Gets a boolean indicating if specific vertex data is present
  22043. * @param kind defines the vertex data kind to use
  22044. * @returns true is data kind is present
  22045. */
  22046. isVerticesDataPresent(kind: string): boolean;
  22047. /**
  22048. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22049. * @param kind defines the data kind (Position, normal, etc...)
  22050. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22051. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22052. * @returns a float array containing vertex data
  22053. */
  22054. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22055. /**
  22056. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22057. * @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.
  22058. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22059. * @returns the indices array or an empty array if the mesh has no geometry
  22060. */
  22061. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22062. /**
  22063. * Set specific vertex data
  22064. * @param kind defines the data kind (Position, normal, etc...)
  22065. * @param data defines the vertex data to use
  22066. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22067. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22068. */
  22069. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22070. /**
  22071. * Update a specific associated vertex buffer
  22072. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22073. * - VertexBuffer.PositionKind
  22074. * - VertexBuffer.UVKind
  22075. * - VertexBuffer.UV2Kind
  22076. * - VertexBuffer.UV3Kind
  22077. * - VertexBuffer.UV4Kind
  22078. * - VertexBuffer.UV5Kind
  22079. * - VertexBuffer.UV6Kind
  22080. * - VertexBuffer.ColorKind
  22081. * - VertexBuffer.MatricesIndicesKind
  22082. * - VertexBuffer.MatricesIndicesExtraKind
  22083. * - VertexBuffer.MatricesWeightsKind
  22084. * - VertexBuffer.MatricesWeightsExtraKind
  22085. * @param data defines the data source
  22086. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22087. * @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)
  22088. */
  22089. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22090. /**
  22091. * Creates a new index buffer
  22092. * @param indices defines the indices to store in the index buffer
  22093. * @param totalVertices defines the total number of vertices (could be null)
  22094. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22095. */
  22096. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22097. }
  22098. /**
  22099. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22100. */
  22101. export class VertexData {
  22102. /**
  22103. * Mesh side orientation : usually the external or front surface
  22104. */
  22105. static readonly FRONTSIDE: number;
  22106. /**
  22107. * Mesh side orientation : usually the internal or back surface
  22108. */
  22109. static readonly BACKSIDE: number;
  22110. /**
  22111. * Mesh side orientation : both internal and external or front and back surfaces
  22112. */
  22113. static readonly DOUBLESIDE: number;
  22114. /**
  22115. * Mesh side orientation : by default, `FRONTSIDE`
  22116. */
  22117. static readonly DEFAULTSIDE: number;
  22118. /**
  22119. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22120. */
  22121. positions: Nullable<FloatArray>;
  22122. /**
  22123. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22124. */
  22125. normals: Nullable<FloatArray>;
  22126. /**
  22127. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22128. */
  22129. tangents: Nullable<FloatArray>;
  22130. /**
  22131. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22132. */
  22133. uvs: Nullable<FloatArray>;
  22134. /**
  22135. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22136. */
  22137. uvs2: Nullable<FloatArray>;
  22138. /**
  22139. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22140. */
  22141. uvs3: Nullable<FloatArray>;
  22142. /**
  22143. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22144. */
  22145. uvs4: Nullable<FloatArray>;
  22146. /**
  22147. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22148. */
  22149. uvs5: Nullable<FloatArray>;
  22150. /**
  22151. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22152. */
  22153. uvs6: Nullable<FloatArray>;
  22154. /**
  22155. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22156. */
  22157. colors: Nullable<FloatArray>;
  22158. /**
  22159. * 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).
  22160. */
  22161. matricesIndices: Nullable<FloatArray>;
  22162. /**
  22163. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22164. */
  22165. matricesWeights: Nullable<FloatArray>;
  22166. /**
  22167. * An array extending the number of possible indices
  22168. */
  22169. matricesIndicesExtra: Nullable<FloatArray>;
  22170. /**
  22171. * An array extending the number of possible weights when the number of indices is extended
  22172. */
  22173. matricesWeightsExtra: Nullable<FloatArray>;
  22174. /**
  22175. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22176. */
  22177. indices: Nullable<IndicesArray>;
  22178. /**
  22179. * Uses the passed data array to set the set the values for the specified kind of data
  22180. * @param data a linear array of floating numbers
  22181. * @param kind the type of data that is being set, eg positions, colors etc
  22182. */
  22183. set(data: FloatArray, kind: string): void;
  22184. /**
  22185. * Associates the vertexData to the passed Mesh.
  22186. * Sets it as updatable or not (default `false`)
  22187. * @param mesh the mesh the vertexData is applied to
  22188. * @param updatable when used and having the value true allows new data to update the vertexData
  22189. * @returns the VertexData
  22190. */
  22191. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22192. /**
  22193. * Associates the vertexData to the passed Geometry.
  22194. * Sets it as updatable or not (default `false`)
  22195. * @param geometry the geometry the vertexData is applied to
  22196. * @param updatable when used and having the value true allows new data to update the vertexData
  22197. * @returns VertexData
  22198. */
  22199. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22200. /**
  22201. * Updates the associated mesh
  22202. * @param mesh the mesh to be updated
  22203. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22204. * @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
  22205. * @returns VertexData
  22206. */
  22207. updateMesh(mesh: Mesh): VertexData;
  22208. /**
  22209. * Updates the associated geometry
  22210. * @param geometry the geometry to be updated
  22211. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22212. * @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
  22213. * @returns VertexData.
  22214. */
  22215. updateGeometry(geometry: Geometry): VertexData;
  22216. private _applyTo;
  22217. private _update;
  22218. /**
  22219. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22220. * @param matrix the transforming matrix
  22221. * @returns the VertexData
  22222. */
  22223. transform(matrix: Matrix): VertexData;
  22224. /**
  22225. * Merges the passed VertexData into the current one
  22226. * @param other the VertexData to be merged into the current one
  22227. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22228. * @returns the modified VertexData
  22229. */
  22230. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22231. private _mergeElement;
  22232. private _validate;
  22233. /**
  22234. * Serializes the VertexData
  22235. * @returns a serialized object
  22236. */
  22237. serialize(): any;
  22238. /**
  22239. * Extracts the vertexData from a mesh
  22240. * @param mesh the mesh from which to extract the VertexData
  22241. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22242. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22243. * @returns the object VertexData associated to the passed mesh
  22244. */
  22245. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22246. /**
  22247. * Extracts the vertexData from the geometry
  22248. * @param geometry the geometry from which to extract the VertexData
  22249. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22250. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22251. * @returns the object VertexData associated to the passed mesh
  22252. */
  22253. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22254. private static _ExtractFrom;
  22255. /**
  22256. * Creates the VertexData for a Ribbon
  22257. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22258. * * pathArray array of paths, each of which an array of successive Vector3
  22259. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22260. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22261. * * 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
  22262. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22263. * * 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)
  22264. * * 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)
  22265. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22266. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22267. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22268. * @returns the VertexData of the ribbon
  22269. */
  22270. static CreateRibbon(options: {
  22271. pathArray: Vector3[][];
  22272. closeArray?: boolean;
  22273. closePath?: boolean;
  22274. offset?: number;
  22275. sideOrientation?: number;
  22276. frontUVs?: Vector4;
  22277. backUVs?: Vector4;
  22278. invertUV?: boolean;
  22279. uvs?: Vector2[];
  22280. colors?: Color4[];
  22281. }): VertexData;
  22282. /**
  22283. * Creates the VertexData for a box
  22284. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22285. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22286. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22287. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22288. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22289. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22290. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22292. * * 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)
  22293. * * 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)
  22294. * @returns the VertexData of the box
  22295. */
  22296. static CreateBox(options: {
  22297. size?: number;
  22298. width?: number;
  22299. height?: number;
  22300. depth?: number;
  22301. faceUV?: Vector4[];
  22302. faceColors?: Color4[];
  22303. sideOrientation?: number;
  22304. frontUVs?: Vector4;
  22305. backUVs?: Vector4;
  22306. }): VertexData;
  22307. /**
  22308. * Creates the VertexData for a tiled box
  22309. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22310. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22311. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22312. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22313. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22314. * @returns the VertexData of the box
  22315. */
  22316. static CreateTiledBox(options: {
  22317. pattern?: number;
  22318. width?: number;
  22319. height?: number;
  22320. depth?: number;
  22321. tileSize?: number;
  22322. tileWidth?: number;
  22323. tileHeight?: number;
  22324. alignHorizontal?: number;
  22325. alignVertical?: number;
  22326. faceUV?: Vector4[];
  22327. faceColors?: Color4[];
  22328. sideOrientation?: number;
  22329. }): VertexData;
  22330. /**
  22331. * Creates the VertexData for a tiled plane
  22332. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22333. * * pattern a limited pattern arrangement depending on the number
  22334. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22335. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22336. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22337. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22338. * * 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)
  22339. * * 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)
  22340. * @returns the VertexData of the tiled plane
  22341. */
  22342. static CreateTiledPlane(options: {
  22343. pattern?: number;
  22344. tileSize?: number;
  22345. tileWidth?: number;
  22346. tileHeight?: number;
  22347. size?: number;
  22348. width?: number;
  22349. height?: number;
  22350. alignHorizontal?: number;
  22351. alignVertical?: number;
  22352. sideOrientation?: number;
  22353. frontUVs?: Vector4;
  22354. backUVs?: Vector4;
  22355. }): VertexData;
  22356. /**
  22357. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22358. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22359. * * segments sets the number of horizontal strips optional, default 32
  22360. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22361. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22362. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22363. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22364. * * 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
  22365. * * 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
  22366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22367. * * 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)
  22368. * * 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)
  22369. * @returns the VertexData of the ellipsoid
  22370. */
  22371. static CreateSphere(options: {
  22372. segments?: number;
  22373. diameter?: number;
  22374. diameterX?: number;
  22375. diameterY?: number;
  22376. diameterZ?: number;
  22377. arc?: number;
  22378. slice?: number;
  22379. sideOrientation?: number;
  22380. frontUVs?: Vector4;
  22381. backUVs?: Vector4;
  22382. }): VertexData;
  22383. /**
  22384. * Creates the VertexData for a cylinder, cone or prism
  22385. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22386. * * height sets the height (y direction) of the cylinder, optional, default 2
  22387. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22388. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22389. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22390. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22391. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22392. * * 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
  22393. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22394. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22395. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22396. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22398. * * 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)
  22399. * * 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)
  22400. * @returns the VertexData of the cylinder, cone or prism
  22401. */
  22402. static CreateCylinder(options: {
  22403. height?: number;
  22404. diameterTop?: number;
  22405. diameterBottom?: number;
  22406. diameter?: number;
  22407. tessellation?: number;
  22408. subdivisions?: number;
  22409. arc?: number;
  22410. faceColors?: Color4[];
  22411. faceUV?: Vector4[];
  22412. hasRings?: boolean;
  22413. enclose?: boolean;
  22414. sideOrientation?: number;
  22415. frontUVs?: Vector4;
  22416. backUVs?: Vector4;
  22417. }): VertexData;
  22418. /**
  22419. * Creates the VertexData for a torus
  22420. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22421. * * diameter the diameter of the torus, optional default 1
  22422. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22423. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22425. * * 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)
  22426. * * 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)
  22427. * @returns the VertexData of the torus
  22428. */
  22429. static CreateTorus(options: {
  22430. diameter?: number;
  22431. thickness?: number;
  22432. tessellation?: number;
  22433. sideOrientation?: number;
  22434. frontUVs?: Vector4;
  22435. backUVs?: Vector4;
  22436. }): VertexData;
  22437. /**
  22438. * Creates the VertexData of the LineSystem
  22439. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22440. * - lines an array of lines, each line being an array of successive Vector3
  22441. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22442. * @returns the VertexData of the LineSystem
  22443. */
  22444. static CreateLineSystem(options: {
  22445. lines: Vector3[][];
  22446. colors?: Nullable<Color4[][]>;
  22447. }): VertexData;
  22448. /**
  22449. * Create the VertexData for a DashedLines
  22450. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22451. * - points an array successive Vector3
  22452. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22453. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22454. * - dashNb the intended total number of dashes, optional, default 200
  22455. * @returns the VertexData for the DashedLines
  22456. */
  22457. static CreateDashedLines(options: {
  22458. points: Vector3[];
  22459. dashSize?: number;
  22460. gapSize?: number;
  22461. dashNb?: number;
  22462. }): VertexData;
  22463. /**
  22464. * Creates the VertexData for a Ground
  22465. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22466. * - width the width (x direction) of the ground, optional, default 1
  22467. * - height the height (z direction) of the ground, optional, default 1
  22468. * - subdivisions the number of subdivisions per side, optional, default 1
  22469. * @returns the VertexData of the Ground
  22470. */
  22471. static CreateGround(options: {
  22472. width?: number;
  22473. height?: number;
  22474. subdivisions?: number;
  22475. subdivisionsX?: number;
  22476. subdivisionsY?: number;
  22477. }): VertexData;
  22478. /**
  22479. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22480. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22481. * * xmin the ground minimum X coordinate, optional, default -1
  22482. * * zmin the ground minimum Z coordinate, optional, default -1
  22483. * * xmax the ground maximum X coordinate, optional, default 1
  22484. * * zmax the ground maximum Z coordinate, optional, default 1
  22485. * * 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}
  22486. * * 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}
  22487. * @returns the VertexData of the TiledGround
  22488. */
  22489. static CreateTiledGround(options: {
  22490. xmin: number;
  22491. zmin: number;
  22492. xmax: number;
  22493. zmax: number;
  22494. subdivisions?: {
  22495. w: number;
  22496. h: number;
  22497. };
  22498. precision?: {
  22499. w: number;
  22500. h: number;
  22501. };
  22502. }): VertexData;
  22503. /**
  22504. * Creates the VertexData of the Ground designed from a heightmap
  22505. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22506. * * width the width (x direction) of the ground
  22507. * * height the height (z direction) of the ground
  22508. * * subdivisions the number of subdivisions per side
  22509. * * minHeight the minimum altitude on the ground, optional, default 0
  22510. * * maxHeight the maximum altitude on the ground, optional default 1
  22511. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22512. * * buffer the array holding the image color data
  22513. * * bufferWidth the width of image
  22514. * * bufferHeight the height of image
  22515. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22516. * @returns the VertexData of the Ground designed from a heightmap
  22517. */
  22518. static CreateGroundFromHeightMap(options: {
  22519. width: number;
  22520. height: number;
  22521. subdivisions: number;
  22522. minHeight: number;
  22523. maxHeight: number;
  22524. colorFilter: Color3;
  22525. buffer: Uint8Array;
  22526. bufferWidth: number;
  22527. bufferHeight: number;
  22528. alphaFilter: number;
  22529. }): VertexData;
  22530. /**
  22531. * Creates the VertexData for a Plane
  22532. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22533. * * size sets the width and height of the plane to the value of size, optional default 1
  22534. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22535. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22536. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22537. * * 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)
  22538. * * 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)
  22539. * @returns the VertexData of the box
  22540. */
  22541. static CreatePlane(options: {
  22542. size?: number;
  22543. width?: number;
  22544. height?: number;
  22545. sideOrientation?: number;
  22546. frontUVs?: Vector4;
  22547. backUVs?: Vector4;
  22548. }): VertexData;
  22549. /**
  22550. * Creates the VertexData of the Disc or regular Polygon
  22551. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22552. * * radius the radius of the disc, optional default 0.5
  22553. * * tessellation the number of polygon sides, optional, default 64
  22554. * * 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
  22555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22556. * * 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)
  22557. * * 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)
  22558. * @returns the VertexData of the box
  22559. */
  22560. static CreateDisc(options: {
  22561. radius?: number;
  22562. tessellation?: number;
  22563. arc?: number;
  22564. sideOrientation?: number;
  22565. frontUVs?: Vector4;
  22566. backUVs?: Vector4;
  22567. }): VertexData;
  22568. /**
  22569. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22570. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22571. * @param polygon a mesh built from polygonTriangulation.build()
  22572. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22573. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22574. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22575. * @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)
  22576. * @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)
  22577. * @returns the VertexData of the Polygon
  22578. */
  22579. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22580. /**
  22581. * Creates the VertexData of the IcoSphere
  22582. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22583. * * radius the radius of the IcoSphere, optional default 1
  22584. * * radiusX allows stretching in the x direction, optional, default radius
  22585. * * radiusY allows stretching in the y direction, optional, default radius
  22586. * * radiusZ allows stretching in the z direction, optional, default radius
  22587. * * flat when true creates a flat shaded mesh, optional, default true
  22588. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22590. * * 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)
  22591. * * 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)
  22592. * @returns the VertexData of the IcoSphere
  22593. */
  22594. static CreateIcoSphere(options: {
  22595. radius?: number;
  22596. radiusX?: number;
  22597. radiusY?: number;
  22598. radiusZ?: number;
  22599. flat?: boolean;
  22600. subdivisions?: number;
  22601. sideOrientation?: number;
  22602. frontUVs?: Vector4;
  22603. backUVs?: Vector4;
  22604. }): VertexData;
  22605. /**
  22606. * Creates the VertexData for a Polyhedron
  22607. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22608. * * type provided types are:
  22609. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22610. * * 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)
  22611. * * size the size of the IcoSphere, optional default 1
  22612. * * sizeX allows stretching in the x direction, optional, default size
  22613. * * sizeY allows stretching in the y direction, optional, default size
  22614. * * sizeZ allows stretching in the z direction, optional, default size
  22615. * * 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
  22616. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22617. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22618. * * flat when true creates a flat shaded mesh, optional, default true
  22619. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22621. * * 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)
  22622. * * 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)
  22623. * @returns the VertexData of the Polyhedron
  22624. */
  22625. static CreatePolyhedron(options: {
  22626. type?: number;
  22627. size?: number;
  22628. sizeX?: number;
  22629. sizeY?: number;
  22630. sizeZ?: number;
  22631. custom?: any;
  22632. faceUV?: Vector4[];
  22633. faceColors?: Color4[];
  22634. flat?: boolean;
  22635. sideOrientation?: number;
  22636. frontUVs?: Vector4;
  22637. backUVs?: Vector4;
  22638. }): VertexData;
  22639. /**
  22640. * Creates the VertexData for a TorusKnot
  22641. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22642. * * radius the radius of the torus knot, optional, default 2
  22643. * * tube the thickness of the tube, optional, default 0.5
  22644. * * radialSegments the number of sides on each tube segments, optional, default 32
  22645. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22646. * * p the number of windings around the z axis, optional, default 2
  22647. * * q the number of windings around the x axis, optional, default 3
  22648. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22649. * * 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)
  22650. * * 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)
  22651. * @returns the VertexData of the Torus Knot
  22652. */
  22653. static CreateTorusKnot(options: {
  22654. radius?: number;
  22655. tube?: number;
  22656. radialSegments?: number;
  22657. tubularSegments?: number;
  22658. p?: number;
  22659. q?: number;
  22660. sideOrientation?: number;
  22661. frontUVs?: Vector4;
  22662. backUVs?: Vector4;
  22663. }): VertexData;
  22664. /**
  22665. * Compute normals for given positions and indices
  22666. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22667. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22668. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22669. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22670. * * facetNormals : optional array of facet normals (vector3)
  22671. * * facetPositions : optional array of facet positions (vector3)
  22672. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22673. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22674. * * bInfo : optional bounding info, required for facetPartitioning computation
  22675. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22676. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22677. * * useRightHandedSystem: optional boolean to for right handed system computation
  22678. * * depthSort : optional boolean to enable the facet depth sort computation
  22679. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22680. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22681. */
  22682. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22683. facetNormals?: any;
  22684. facetPositions?: any;
  22685. facetPartitioning?: any;
  22686. ratio?: number;
  22687. bInfo?: any;
  22688. bbSize?: Vector3;
  22689. subDiv?: any;
  22690. useRightHandedSystem?: boolean;
  22691. depthSort?: boolean;
  22692. distanceTo?: Vector3;
  22693. depthSortedFacets?: any;
  22694. }): void;
  22695. /** @hidden */
  22696. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22697. /**
  22698. * Applies VertexData created from the imported parameters to the geometry
  22699. * @param parsedVertexData the parsed data from an imported file
  22700. * @param geometry the geometry to apply the VertexData to
  22701. */
  22702. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22703. }
  22704. }
  22705. declare module "babylonjs/Morph/morphTarget" {
  22706. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22707. import { Observable } from "babylonjs/Misc/observable";
  22708. import { Nullable, FloatArray } from "babylonjs/types";
  22709. import { Scene } from "babylonjs/scene";
  22710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22711. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22712. /**
  22713. * Defines a target to use with MorphTargetManager
  22714. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22715. */
  22716. export class MorphTarget implements IAnimatable {
  22717. /** defines the name of the target */
  22718. name: string;
  22719. /**
  22720. * Gets or sets the list of animations
  22721. */
  22722. animations: import("babylonjs/Animations/animation").Animation[];
  22723. private _scene;
  22724. private _positions;
  22725. private _normals;
  22726. private _tangents;
  22727. private _uvs;
  22728. private _influence;
  22729. /**
  22730. * Observable raised when the influence changes
  22731. */
  22732. onInfluenceChanged: Observable<boolean>;
  22733. /** @hidden */
  22734. _onDataLayoutChanged: Observable<void>;
  22735. /**
  22736. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22737. */
  22738. influence: number;
  22739. /**
  22740. * Gets or sets the id of the morph Target
  22741. */
  22742. id: string;
  22743. private _animationPropertiesOverride;
  22744. /**
  22745. * Gets or sets the animation properties override
  22746. */
  22747. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22748. /**
  22749. * Creates a new MorphTarget
  22750. * @param name defines the name of the target
  22751. * @param influence defines the influence to use
  22752. * @param scene defines the scene the morphtarget belongs to
  22753. */
  22754. constructor(
  22755. /** defines the name of the target */
  22756. name: string, influence?: number, scene?: Nullable<Scene>);
  22757. /**
  22758. * Gets a boolean defining if the target contains position data
  22759. */
  22760. readonly hasPositions: boolean;
  22761. /**
  22762. * Gets a boolean defining if the target contains normal data
  22763. */
  22764. readonly hasNormals: boolean;
  22765. /**
  22766. * Gets a boolean defining if the target contains tangent data
  22767. */
  22768. readonly hasTangents: boolean;
  22769. /**
  22770. * Gets a boolean defining if the target contains texture coordinates data
  22771. */
  22772. readonly hasUVs: boolean;
  22773. /**
  22774. * Affects position data to this target
  22775. * @param data defines the position data to use
  22776. */
  22777. setPositions(data: Nullable<FloatArray>): void;
  22778. /**
  22779. * Gets the position data stored in this target
  22780. * @returns a FloatArray containing the position data (or null if not present)
  22781. */
  22782. getPositions(): Nullable<FloatArray>;
  22783. /**
  22784. * Affects normal data to this target
  22785. * @param data defines the normal data to use
  22786. */
  22787. setNormals(data: Nullable<FloatArray>): void;
  22788. /**
  22789. * Gets the normal data stored in this target
  22790. * @returns a FloatArray containing the normal data (or null if not present)
  22791. */
  22792. getNormals(): Nullable<FloatArray>;
  22793. /**
  22794. * Affects tangent data to this target
  22795. * @param data defines the tangent data to use
  22796. */
  22797. setTangents(data: Nullable<FloatArray>): void;
  22798. /**
  22799. * Gets the tangent data stored in this target
  22800. * @returns a FloatArray containing the tangent data (or null if not present)
  22801. */
  22802. getTangents(): Nullable<FloatArray>;
  22803. /**
  22804. * Affects texture coordinates data to this target
  22805. * @param data defines the texture coordinates data to use
  22806. */
  22807. setUVs(data: Nullable<FloatArray>): void;
  22808. /**
  22809. * Gets the texture coordinates data stored in this target
  22810. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22811. */
  22812. getUVs(): Nullable<FloatArray>;
  22813. /**
  22814. * Serializes the current target into a Serialization object
  22815. * @returns the serialized object
  22816. */
  22817. serialize(): any;
  22818. /**
  22819. * Returns the string "MorphTarget"
  22820. * @returns "MorphTarget"
  22821. */
  22822. getClassName(): string;
  22823. /**
  22824. * Creates a new target from serialized data
  22825. * @param serializationObject defines the serialized data to use
  22826. * @returns a new MorphTarget
  22827. */
  22828. static Parse(serializationObject: any): MorphTarget;
  22829. /**
  22830. * Creates a MorphTarget from mesh data
  22831. * @param mesh defines the source mesh
  22832. * @param name defines the name to use for the new target
  22833. * @param influence defines the influence to attach to the target
  22834. * @returns a new MorphTarget
  22835. */
  22836. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22837. }
  22838. }
  22839. declare module "babylonjs/Morph/morphTargetManager" {
  22840. import { Nullable } from "babylonjs/types";
  22841. import { Scene } from "babylonjs/scene";
  22842. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22843. /**
  22844. * This class is used to deform meshes using morphing between different targets
  22845. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22846. */
  22847. export class MorphTargetManager {
  22848. private _targets;
  22849. private _targetInfluenceChangedObservers;
  22850. private _targetDataLayoutChangedObservers;
  22851. private _activeTargets;
  22852. private _scene;
  22853. private _influences;
  22854. private _supportsNormals;
  22855. private _supportsTangents;
  22856. private _supportsUVs;
  22857. private _vertexCount;
  22858. private _uniqueId;
  22859. private _tempInfluences;
  22860. /**
  22861. * Gets or sets a boolean indicating if normals must be morphed
  22862. */
  22863. enableNormalMorphing: boolean;
  22864. /**
  22865. * Gets or sets a boolean indicating if tangents must be morphed
  22866. */
  22867. enableTangentMorphing: boolean;
  22868. /**
  22869. * Gets or sets a boolean indicating if UV must be morphed
  22870. */
  22871. enableUVMorphing: boolean;
  22872. /**
  22873. * Creates a new MorphTargetManager
  22874. * @param scene defines the current scene
  22875. */
  22876. constructor(scene?: Nullable<Scene>);
  22877. /**
  22878. * Gets the unique ID of this manager
  22879. */
  22880. readonly uniqueId: number;
  22881. /**
  22882. * Gets the number of vertices handled by this manager
  22883. */
  22884. readonly vertexCount: number;
  22885. /**
  22886. * Gets a boolean indicating if this manager supports morphing of normals
  22887. */
  22888. readonly supportsNormals: boolean;
  22889. /**
  22890. * Gets a boolean indicating if this manager supports morphing of tangents
  22891. */
  22892. readonly supportsTangents: boolean;
  22893. /**
  22894. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22895. */
  22896. readonly supportsUVs: boolean;
  22897. /**
  22898. * Gets the number of targets stored in this manager
  22899. */
  22900. readonly numTargets: number;
  22901. /**
  22902. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22903. */
  22904. readonly numInfluencers: number;
  22905. /**
  22906. * Gets the list of influences (one per target)
  22907. */
  22908. readonly influences: Float32Array;
  22909. /**
  22910. * Gets the active target at specified index. An active target is a target with an influence > 0
  22911. * @param index defines the index to check
  22912. * @returns the requested target
  22913. */
  22914. getActiveTarget(index: number): MorphTarget;
  22915. /**
  22916. * Gets the target at specified index
  22917. * @param index defines the index to check
  22918. * @returns the requested target
  22919. */
  22920. getTarget(index: number): MorphTarget;
  22921. /**
  22922. * Add a new target to this manager
  22923. * @param target defines the target to add
  22924. */
  22925. addTarget(target: MorphTarget): void;
  22926. /**
  22927. * Removes a target from the manager
  22928. * @param target defines the target to remove
  22929. */
  22930. removeTarget(target: MorphTarget): void;
  22931. /**
  22932. * Serializes the current manager into a Serialization object
  22933. * @returns the serialized object
  22934. */
  22935. serialize(): any;
  22936. private _syncActiveTargets;
  22937. /**
  22938. * Syncrhonize the targets with all the meshes using this morph target manager
  22939. */
  22940. synchronize(): void;
  22941. /**
  22942. * Creates a new MorphTargetManager from serialized data
  22943. * @param serializationObject defines the serialized data
  22944. * @param scene defines the hosting scene
  22945. * @returns the new MorphTargetManager
  22946. */
  22947. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22948. }
  22949. }
  22950. declare module "babylonjs/Meshes/meshLODLevel" {
  22951. import { Mesh } from "babylonjs/Meshes/mesh";
  22952. import { Nullable } from "babylonjs/types";
  22953. /**
  22954. * Class used to represent a specific level of detail of a mesh
  22955. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22956. */
  22957. export class MeshLODLevel {
  22958. /** Defines the distance where this level should start being displayed */
  22959. distance: number;
  22960. /** Defines the mesh to use to render this level */
  22961. mesh: Nullable<Mesh>;
  22962. /**
  22963. * Creates a new LOD level
  22964. * @param distance defines the distance where this level should star being displayed
  22965. * @param mesh defines the mesh to use to render this level
  22966. */
  22967. constructor(
  22968. /** Defines the distance where this level should start being displayed */
  22969. distance: number,
  22970. /** Defines the mesh to use to render this level */
  22971. mesh: Nullable<Mesh>);
  22972. }
  22973. }
  22974. declare module "babylonjs/Meshes/groundMesh" {
  22975. import { Scene } from "babylonjs/scene";
  22976. import { Vector3 } from "babylonjs/Maths/math.vector";
  22977. import { Mesh } from "babylonjs/Meshes/mesh";
  22978. /**
  22979. * Mesh representing the gorund
  22980. */
  22981. export class GroundMesh extends Mesh {
  22982. /** If octree should be generated */
  22983. generateOctree: boolean;
  22984. private _heightQuads;
  22985. /** @hidden */
  22986. _subdivisionsX: number;
  22987. /** @hidden */
  22988. _subdivisionsY: number;
  22989. /** @hidden */
  22990. _width: number;
  22991. /** @hidden */
  22992. _height: number;
  22993. /** @hidden */
  22994. _minX: number;
  22995. /** @hidden */
  22996. _maxX: number;
  22997. /** @hidden */
  22998. _minZ: number;
  22999. /** @hidden */
  23000. _maxZ: number;
  23001. constructor(name: string, scene: Scene);
  23002. /**
  23003. * "GroundMesh"
  23004. * @returns "GroundMesh"
  23005. */
  23006. getClassName(): string;
  23007. /**
  23008. * The minimum of x and y subdivisions
  23009. */
  23010. readonly subdivisions: number;
  23011. /**
  23012. * X subdivisions
  23013. */
  23014. readonly subdivisionsX: number;
  23015. /**
  23016. * Y subdivisions
  23017. */
  23018. readonly subdivisionsY: number;
  23019. /**
  23020. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23021. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23022. * @param chunksCount the number of subdivisions for x and y
  23023. * @param octreeBlocksSize (Default: 32)
  23024. */
  23025. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23026. /**
  23027. * Returns a height (y) value in the Worl system :
  23028. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23029. * @param x x coordinate
  23030. * @param z z coordinate
  23031. * @returns the ground y position if (x, z) are outside the ground surface.
  23032. */
  23033. getHeightAtCoordinates(x: number, z: number): number;
  23034. /**
  23035. * Returns a normalized vector (Vector3) orthogonal to the ground
  23036. * at the ground coordinates (x, z) expressed in the World system.
  23037. * @param x x coordinate
  23038. * @param z z coordinate
  23039. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23040. */
  23041. getNormalAtCoordinates(x: number, z: number): Vector3;
  23042. /**
  23043. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23044. * at the ground coordinates (x, z) expressed in the World system.
  23045. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23046. * @param x x coordinate
  23047. * @param z z coordinate
  23048. * @param ref vector to store the result
  23049. * @returns the GroundMesh.
  23050. */
  23051. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23052. /**
  23053. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23054. * if the ground has been updated.
  23055. * This can be used in the render loop.
  23056. * @returns the GroundMesh.
  23057. */
  23058. updateCoordinateHeights(): GroundMesh;
  23059. private _getFacetAt;
  23060. private _initHeightQuads;
  23061. private _computeHeightQuads;
  23062. /**
  23063. * Serializes this ground mesh
  23064. * @param serializationObject object to write serialization to
  23065. */
  23066. serialize(serializationObject: any): void;
  23067. /**
  23068. * Parses a serialized ground mesh
  23069. * @param parsedMesh the serialized mesh
  23070. * @param scene the scene to create the ground mesh in
  23071. * @returns the created ground mesh
  23072. */
  23073. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23074. }
  23075. }
  23076. declare module "babylonjs/Physics/physicsJoint" {
  23077. import { Vector3 } from "babylonjs/Maths/math.vector";
  23078. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23079. /**
  23080. * Interface for Physics-Joint data
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export interface PhysicsJointData {
  23084. /**
  23085. * The main pivot of the joint
  23086. */
  23087. mainPivot?: Vector3;
  23088. /**
  23089. * The connected pivot of the joint
  23090. */
  23091. connectedPivot?: Vector3;
  23092. /**
  23093. * The main axis of the joint
  23094. */
  23095. mainAxis?: Vector3;
  23096. /**
  23097. * The connected axis of the joint
  23098. */
  23099. connectedAxis?: Vector3;
  23100. /**
  23101. * The collision of the joint
  23102. */
  23103. collision?: boolean;
  23104. /**
  23105. * Native Oimo/Cannon/Energy data
  23106. */
  23107. nativeParams?: any;
  23108. }
  23109. /**
  23110. * This is a holder class for the physics joint created by the physics plugin
  23111. * It holds a set of functions to control the underlying joint
  23112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23113. */
  23114. export class PhysicsJoint {
  23115. /**
  23116. * The type of the physics joint
  23117. */
  23118. type: number;
  23119. /**
  23120. * The data for the physics joint
  23121. */
  23122. jointData: PhysicsJointData;
  23123. private _physicsJoint;
  23124. protected _physicsPlugin: IPhysicsEnginePlugin;
  23125. /**
  23126. * Initializes the physics joint
  23127. * @param type The type of the physics joint
  23128. * @param jointData The data for the physics joint
  23129. */
  23130. constructor(
  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. /**
  23140. * Gets the physics joint
  23141. */
  23142. /**
  23143. * Sets the physics joint
  23144. */
  23145. physicsJoint: any;
  23146. /**
  23147. * Sets the physics plugin
  23148. */
  23149. physicsPlugin: IPhysicsEnginePlugin;
  23150. /**
  23151. * Execute a function that is physics-plugin specific.
  23152. * @param {Function} func the function that will be executed.
  23153. * It accepts two parameters: the physics world and the physics joint
  23154. */
  23155. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23156. /**
  23157. * Distance-Joint type
  23158. */
  23159. static DistanceJoint: number;
  23160. /**
  23161. * Hinge-Joint type
  23162. */
  23163. static HingeJoint: number;
  23164. /**
  23165. * Ball-and-Socket joint type
  23166. */
  23167. static BallAndSocketJoint: number;
  23168. /**
  23169. * Wheel-Joint type
  23170. */
  23171. static WheelJoint: number;
  23172. /**
  23173. * Slider-Joint type
  23174. */
  23175. static SliderJoint: number;
  23176. /**
  23177. * Prismatic-Joint type
  23178. */
  23179. static PrismaticJoint: number;
  23180. /**
  23181. * Universal-Joint type
  23182. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23183. */
  23184. static UniversalJoint: number;
  23185. /**
  23186. * Hinge-Joint 2 type
  23187. */
  23188. static Hinge2Joint: number;
  23189. /**
  23190. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23191. */
  23192. static PointToPointJoint: number;
  23193. /**
  23194. * Spring-Joint type
  23195. */
  23196. static SpringJoint: number;
  23197. /**
  23198. * Lock-Joint type
  23199. */
  23200. static LockJoint: number;
  23201. }
  23202. /**
  23203. * A class representing a physics distance joint
  23204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23205. */
  23206. export class DistanceJoint extends PhysicsJoint {
  23207. /**
  23208. *
  23209. * @param jointData The data for the Distance-Joint
  23210. */
  23211. constructor(jointData: DistanceJointData);
  23212. /**
  23213. * Update the predefined distance.
  23214. * @param maxDistance The maximum preferred distance
  23215. * @param minDistance The minimum preferred distance
  23216. */
  23217. updateDistance(maxDistance: number, minDistance?: number): void;
  23218. }
  23219. /**
  23220. * Represents a Motor-Enabled Joint
  23221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23222. */
  23223. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23224. /**
  23225. * Initializes the Motor-Enabled Joint
  23226. * @param type The type of the joint
  23227. * @param jointData The physica joint data for the joint
  23228. */
  23229. constructor(type: number, jointData: PhysicsJointData);
  23230. /**
  23231. * Set the motor values.
  23232. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23233. * @param force the force to apply
  23234. * @param maxForce max force for this motor.
  23235. */
  23236. setMotor(force?: number, maxForce?: number): void;
  23237. /**
  23238. * Set the motor's limits.
  23239. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23240. * @param upperLimit The upper limit of the motor
  23241. * @param lowerLimit The lower limit of the motor
  23242. */
  23243. setLimit(upperLimit: number, lowerLimit?: number): void;
  23244. }
  23245. /**
  23246. * This class represents a single physics Hinge-Joint
  23247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23248. */
  23249. export class HingeJoint extends MotorEnabledJoint {
  23250. /**
  23251. * Initializes the Hinge-Joint
  23252. * @param jointData The joint data for the Hinge-Joint
  23253. */
  23254. constructor(jointData: PhysicsJointData);
  23255. /**
  23256. * Set the motor values.
  23257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23258. * @param {number} force the force to apply
  23259. * @param {number} maxForce max force for this motor.
  23260. */
  23261. setMotor(force?: number, maxForce?: number): void;
  23262. /**
  23263. * Set the motor's limits.
  23264. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23265. * @param upperLimit The upper limit of the motor
  23266. * @param lowerLimit The lower limit of the motor
  23267. */
  23268. setLimit(upperLimit: number, lowerLimit?: number): void;
  23269. }
  23270. /**
  23271. * This class represents a dual hinge physics joint (same as wheel joint)
  23272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23273. */
  23274. export class Hinge2Joint extends MotorEnabledJoint {
  23275. /**
  23276. * Initializes the Hinge2-Joint
  23277. * @param jointData The joint data for the Hinge2-Joint
  23278. */
  23279. constructor(jointData: PhysicsJointData);
  23280. /**
  23281. * Set the motor values.
  23282. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23283. * @param {number} targetSpeed the speed the motor is to reach
  23284. * @param {number} maxForce max force for this motor.
  23285. * @param {motorIndex} the motor's index, 0 or 1.
  23286. */
  23287. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23288. /**
  23289. * Set the motor limits.
  23290. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23291. * @param {number} upperLimit the upper limit
  23292. * @param {number} lowerLimit lower limit
  23293. * @param {motorIndex} the motor's index, 0 or 1.
  23294. */
  23295. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23296. }
  23297. /**
  23298. * Interface for a motor enabled joint
  23299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23300. */
  23301. export interface IMotorEnabledJoint {
  23302. /**
  23303. * Physics joint
  23304. */
  23305. physicsJoint: any;
  23306. /**
  23307. * Sets the motor of the motor-enabled joint
  23308. * @param force The force of the motor
  23309. * @param maxForce The maximum force of the motor
  23310. * @param motorIndex The index of the motor
  23311. */
  23312. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23313. /**
  23314. * Sets the limit of the motor
  23315. * @param upperLimit The upper limit of the motor
  23316. * @param lowerLimit The lower limit of the motor
  23317. * @param motorIndex The index of the motor
  23318. */
  23319. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23320. }
  23321. /**
  23322. * Joint data for a Distance-Joint
  23323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23324. */
  23325. export interface DistanceJointData extends PhysicsJointData {
  23326. /**
  23327. * Max distance the 2 joint objects can be apart
  23328. */
  23329. maxDistance: number;
  23330. }
  23331. /**
  23332. * Joint data from a spring joint
  23333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23334. */
  23335. export interface SpringJointData extends PhysicsJointData {
  23336. /**
  23337. * Length of the spring
  23338. */
  23339. length: number;
  23340. /**
  23341. * Stiffness of the spring
  23342. */
  23343. stiffness: number;
  23344. /**
  23345. * Damping of the spring
  23346. */
  23347. damping: number;
  23348. /** this callback will be called when applying the force to the impostors. */
  23349. forceApplicationCallback: () => void;
  23350. }
  23351. }
  23352. declare module "babylonjs/Physics/physicsRaycastResult" {
  23353. import { Vector3 } from "babylonjs/Maths/math.vector";
  23354. /**
  23355. * Holds the data for the raycast result
  23356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23357. */
  23358. export class PhysicsRaycastResult {
  23359. private _hasHit;
  23360. private _hitDistance;
  23361. private _hitNormalWorld;
  23362. private _hitPointWorld;
  23363. private _rayFromWorld;
  23364. private _rayToWorld;
  23365. /**
  23366. * Gets if there was a hit
  23367. */
  23368. readonly hasHit: boolean;
  23369. /**
  23370. * Gets the distance from the hit
  23371. */
  23372. readonly hitDistance: number;
  23373. /**
  23374. * Gets the hit normal/direction in the world
  23375. */
  23376. readonly hitNormalWorld: Vector3;
  23377. /**
  23378. * Gets the hit point in the world
  23379. */
  23380. readonly hitPointWorld: Vector3;
  23381. /**
  23382. * Gets the ray "start point" of the ray in the world
  23383. */
  23384. readonly rayFromWorld: Vector3;
  23385. /**
  23386. * Gets the ray "end point" of the ray in the world
  23387. */
  23388. readonly rayToWorld: Vector3;
  23389. /**
  23390. * Sets the hit data (normal & point in world space)
  23391. * @param hitNormalWorld defines the normal in world space
  23392. * @param hitPointWorld defines the point in world space
  23393. */
  23394. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23395. /**
  23396. * Sets the distance from the start point to the hit point
  23397. * @param distance
  23398. */
  23399. setHitDistance(distance: number): void;
  23400. /**
  23401. * Calculates the distance manually
  23402. */
  23403. calculateHitDistance(): void;
  23404. /**
  23405. * Resets all the values to default
  23406. * @param from The from point on world space
  23407. * @param to The to point on world space
  23408. */
  23409. reset(from?: Vector3, to?: Vector3): void;
  23410. }
  23411. /**
  23412. * Interface for the size containing width and height
  23413. */
  23414. interface IXYZ {
  23415. /**
  23416. * X
  23417. */
  23418. x: number;
  23419. /**
  23420. * Y
  23421. */
  23422. y: number;
  23423. /**
  23424. * Z
  23425. */
  23426. z: number;
  23427. }
  23428. }
  23429. declare module "babylonjs/Physics/IPhysicsEngine" {
  23430. import { Nullable } from "babylonjs/types";
  23431. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23433. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23434. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23435. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23436. /**
  23437. * Interface used to describe a physics joint
  23438. */
  23439. export interface PhysicsImpostorJoint {
  23440. /** Defines the main impostor to which the joint is linked */
  23441. mainImpostor: PhysicsImpostor;
  23442. /** Defines the impostor that is connected to the main impostor using this joint */
  23443. connectedImpostor: PhysicsImpostor;
  23444. /** Defines the joint itself */
  23445. joint: PhysicsJoint;
  23446. }
  23447. /** @hidden */
  23448. export interface IPhysicsEnginePlugin {
  23449. world: any;
  23450. name: string;
  23451. setGravity(gravity: Vector3): void;
  23452. setTimeStep(timeStep: number): void;
  23453. getTimeStep(): number;
  23454. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23455. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23456. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23457. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23458. removePhysicsBody(impostor: PhysicsImpostor): void;
  23459. generateJoint(joint: PhysicsImpostorJoint): void;
  23460. removeJoint(joint: PhysicsImpostorJoint): void;
  23461. isSupported(): boolean;
  23462. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23463. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23464. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23465. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23466. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23467. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23468. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23469. getBodyMass(impostor: PhysicsImpostor): number;
  23470. getBodyFriction(impostor: PhysicsImpostor): number;
  23471. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23472. getBodyRestitution(impostor: PhysicsImpostor): number;
  23473. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23474. getBodyPressure?(impostor: PhysicsImpostor): number;
  23475. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23476. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23477. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23478. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23479. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23480. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23481. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23482. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23483. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23484. sleepBody(impostor: PhysicsImpostor): void;
  23485. wakeUpBody(impostor: PhysicsImpostor): void;
  23486. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23487. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23488. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23489. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23490. getRadius(impostor: PhysicsImpostor): number;
  23491. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23492. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23493. dispose(): void;
  23494. }
  23495. /**
  23496. * Interface used to define a physics engine
  23497. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23498. */
  23499. export interface IPhysicsEngine {
  23500. /**
  23501. * Gets the gravity vector used by the simulation
  23502. */
  23503. gravity: Vector3;
  23504. /**
  23505. * Sets the gravity vector used by the simulation
  23506. * @param gravity defines the gravity vector to use
  23507. */
  23508. setGravity(gravity: Vector3): void;
  23509. /**
  23510. * Set the time step of the physics engine.
  23511. * Default is 1/60.
  23512. * To slow it down, enter 1/600 for example.
  23513. * To speed it up, 1/30
  23514. * @param newTimeStep the new timestep to apply to this world.
  23515. */
  23516. setTimeStep(newTimeStep: number): void;
  23517. /**
  23518. * Get the time step of the physics engine.
  23519. * @returns the current time step
  23520. */
  23521. getTimeStep(): number;
  23522. /**
  23523. * Release all resources
  23524. */
  23525. dispose(): void;
  23526. /**
  23527. * Gets the name of the current physics plugin
  23528. * @returns the name of the plugin
  23529. */
  23530. getPhysicsPluginName(): string;
  23531. /**
  23532. * Adding a new impostor for the impostor tracking.
  23533. * This will be done by the impostor itself.
  23534. * @param impostor the impostor to add
  23535. */
  23536. addImpostor(impostor: PhysicsImpostor): void;
  23537. /**
  23538. * Remove an impostor from the engine.
  23539. * This impostor and its mesh will not longer be updated by the physics engine.
  23540. * @param impostor the impostor to remove
  23541. */
  23542. removeImpostor(impostor: PhysicsImpostor): void;
  23543. /**
  23544. * Add a joint to the physics engine
  23545. * @param mainImpostor defines the main impostor to which the joint is added.
  23546. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23547. * @param joint defines the joint that will connect both impostors.
  23548. */
  23549. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23550. /**
  23551. * Removes a joint from the simulation
  23552. * @param mainImpostor defines the impostor used with the joint
  23553. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23554. * @param joint defines the joint to remove
  23555. */
  23556. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23557. /**
  23558. * Gets the current plugin used to run the simulation
  23559. * @returns current plugin
  23560. */
  23561. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23562. /**
  23563. * Gets the list of physic impostors
  23564. * @returns an array of PhysicsImpostor
  23565. */
  23566. getImpostors(): Array<PhysicsImpostor>;
  23567. /**
  23568. * Gets the impostor for a physics enabled object
  23569. * @param object defines the object impersonated by the impostor
  23570. * @returns the PhysicsImpostor or null if not found
  23571. */
  23572. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23573. /**
  23574. * Gets the impostor for a physics body object
  23575. * @param body defines physics body used by the impostor
  23576. * @returns the PhysicsImpostor or null if not found
  23577. */
  23578. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23579. /**
  23580. * Does a raycast in the physics world
  23581. * @param from when should the ray start?
  23582. * @param to when should the ray end?
  23583. * @returns PhysicsRaycastResult
  23584. */
  23585. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23586. /**
  23587. * Called by the scene. No need to call it.
  23588. * @param delta defines the timespam between frames
  23589. */
  23590. _step(delta: number): void;
  23591. }
  23592. }
  23593. declare module "babylonjs/Physics/physicsImpostor" {
  23594. import { Nullable, IndicesArray } from "babylonjs/types";
  23595. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23596. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23598. import { Scene } from "babylonjs/scene";
  23599. import { Bone } from "babylonjs/Bones/bone";
  23600. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23601. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23602. import { Space } from "babylonjs/Maths/math.axis";
  23603. /**
  23604. * The interface for the physics imposter parameters
  23605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23606. */
  23607. export interface PhysicsImpostorParameters {
  23608. /**
  23609. * The mass of the physics imposter
  23610. */
  23611. mass: number;
  23612. /**
  23613. * The friction of the physics imposter
  23614. */
  23615. friction?: number;
  23616. /**
  23617. * The coefficient of restitution of the physics imposter
  23618. */
  23619. restitution?: number;
  23620. /**
  23621. * The native options of the physics imposter
  23622. */
  23623. nativeOptions?: any;
  23624. /**
  23625. * Specifies if the parent should be ignored
  23626. */
  23627. ignoreParent?: boolean;
  23628. /**
  23629. * Specifies if bi-directional transformations should be disabled
  23630. */
  23631. disableBidirectionalTransformation?: boolean;
  23632. /**
  23633. * The pressure inside the physics imposter, soft object only
  23634. */
  23635. pressure?: number;
  23636. /**
  23637. * The stiffness the physics imposter, soft object only
  23638. */
  23639. stiffness?: number;
  23640. /**
  23641. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23642. */
  23643. velocityIterations?: number;
  23644. /**
  23645. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23646. */
  23647. positionIterations?: number;
  23648. /**
  23649. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23650. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23651. * Add to fix multiple points
  23652. */
  23653. fixedPoints?: number;
  23654. /**
  23655. * The collision margin around a soft object
  23656. */
  23657. margin?: number;
  23658. /**
  23659. * The collision margin around a soft object
  23660. */
  23661. damping?: number;
  23662. /**
  23663. * The path for a rope based on an extrusion
  23664. */
  23665. path?: any;
  23666. /**
  23667. * The shape of an extrusion used for a rope based on an extrusion
  23668. */
  23669. shape?: any;
  23670. }
  23671. /**
  23672. * Interface for a physics-enabled object
  23673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23674. */
  23675. export interface IPhysicsEnabledObject {
  23676. /**
  23677. * The position of the physics-enabled object
  23678. */
  23679. position: Vector3;
  23680. /**
  23681. * The rotation of the physics-enabled object
  23682. */
  23683. rotationQuaternion: Nullable<Quaternion>;
  23684. /**
  23685. * The scale of the physics-enabled object
  23686. */
  23687. scaling: Vector3;
  23688. /**
  23689. * The rotation of the physics-enabled object
  23690. */
  23691. rotation?: Vector3;
  23692. /**
  23693. * The parent of the physics-enabled object
  23694. */
  23695. parent?: any;
  23696. /**
  23697. * The bounding info of the physics-enabled object
  23698. * @returns The bounding info of the physics-enabled object
  23699. */
  23700. getBoundingInfo(): BoundingInfo;
  23701. /**
  23702. * Computes the world matrix
  23703. * @param force Specifies if the world matrix should be computed by force
  23704. * @returns A world matrix
  23705. */
  23706. computeWorldMatrix(force: boolean): Matrix;
  23707. /**
  23708. * Gets the world matrix
  23709. * @returns A world matrix
  23710. */
  23711. getWorldMatrix?(): Matrix;
  23712. /**
  23713. * Gets the child meshes
  23714. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23715. * @returns An array of abstract meshes
  23716. */
  23717. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23718. /**
  23719. * Gets the vertex data
  23720. * @param kind The type of vertex data
  23721. * @returns A nullable array of numbers, or a float32 array
  23722. */
  23723. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23724. /**
  23725. * Gets the indices from the mesh
  23726. * @returns A nullable array of index arrays
  23727. */
  23728. getIndices?(): Nullable<IndicesArray>;
  23729. /**
  23730. * Gets the scene from the mesh
  23731. * @returns the indices array or null
  23732. */
  23733. getScene?(): Scene;
  23734. /**
  23735. * Gets the absolute position from the mesh
  23736. * @returns the absolute position
  23737. */
  23738. getAbsolutePosition(): Vector3;
  23739. /**
  23740. * Gets the absolute pivot point from the mesh
  23741. * @returns the absolute pivot point
  23742. */
  23743. getAbsolutePivotPoint(): Vector3;
  23744. /**
  23745. * Rotates the mesh
  23746. * @param axis The axis of rotation
  23747. * @param amount The amount of rotation
  23748. * @param space The space of the rotation
  23749. * @returns The rotation transform node
  23750. */
  23751. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23752. /**
  23753. * Translates the mesh
  23754. * @param axis The axis of translation
  23755. * @param distance The distance of translation
  23756. * @param space The space of the translation
  23757. * @returns The transform node
  23758. */
  23759. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23760. /**
  23761. * Sets the absolute position of the mesh
  23762. * @param absolutePosition The absolute position of the mesh
  23763. * @returns The transform node
  23764. */
  23765. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23766. /**
  23767. * Gets the class name of the mesh
  23768. * @returns The class name
  23769. */
  23770. getClassName(): string;
  23771. }
  23772. /**
  23773. * Represents a physics imposter
  23774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23775. */
  23776. export class PhysicsImpostor {
  23777. /**
  23778. * The physics-enabled object used as the physics imposter
  23779. */
  23780. object: IPhysicsEnabledObject;
  23781. /**
  23782. * The type of the physics imposter
  23783. */
  23784. type: number;
  23785. private _options;
  23786. private _scene?;
  23787. /**
  23788. * The default object size of the imposter
  23789. */
  23790. static DEFAULT_OBJECT_SIZE: Vector3;
  23791. /**
  23792. * The identity quaternion of the imposter
  23793. */
  23794. static IDENTITY_QUATERNION: Quaternion;
  23795. /** @hidden */
  23796. _pluginData: any;
  23797. private _physicsEngine;
  23798. private _physicsBody;
  23799. private _bodyUpdateRequired;
  23800. private _onBeforePhysicsStepCallbacks;
  23801. private _onAfterPhysicsStepCallbacks;
  23802. /** @hidden */
  23803. _onPhysicsCollideCallbacks: Array<{
  23804. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23805. otherImpostors: Array<PhysicsImpostor>;
  23806. }>;
  23807. private _deltaPosition;
  23808. private _deltaRotation;
  23809. private _deltaRotationConjugated;
  23810. /** @hidden */
  23811. _isFromLine: boolean;
  23812. private _parent;
  23813. private _isDisposed;
  23814. private static _tmpVecs;
  23815. private static _tmpQuat;
  23816. /**
  23817. * Specifies if the physics imposter is disposed
  23818. */
  23819. readonly isDisposed: boolean;
  23820. /**
  23821. * Gets the mass of the physics imposter
  23822. */
  23823. mass: number;
  23824. /**
  23825. * Gets the coefficient of friction
  23826. */
  23827. /**
  23828. * Sets the coefficient of friction
  23829. */
  23830. friction: number;
  23831. /**
  23832. * Gets the coefficient of restitution
  23833. */
  23834. /**
  23835. * Sets the coefficient of restitution
  23836. */
  23837. restitution: number;
  23838. /**
  23839. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23840. */
  23841. /**
  23842. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23843. */
  23844. pressure: number;
  23845. /**
  23846. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23847. */
  23848. /**
  23849. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23850. */
  23851. stiffness: number;
  23852. /**
  23853. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23854. */
  23855. /**
  23856. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23857. */
  23858. velocityIterations: number;
  23859. /**
  23860. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23861. */
  23862. /**
  23863. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23864. */
  23865. positionIterations: number;
  23866. /**
  23867. * The unique id of the physics imposter
  23868. * set by the physics engine when adding this impostor to the array
  23869. */
  23870. uniqueId: number;
  23871. /**
  23872. * @hidden
  23873. */
  23874. soft: boolean;
  23875. /**
  23876. * @hidden
  23877. */
  23878. segments: number;
  23879. private _joints;
  23880. /**
  23881. * Initializes the physics imposter
  23882. * @param object The physics-enabled object used as the physics imposter
  23883. * @param type The type of the physics imposter
  23884. * @param _options The options for the physics imposter
  23885. * @param _scene The Babylon scene
  23886. */
  23887. constructor(
  23888. /**
  23889. * The physics-enabled object used as the physics imposter
  23890. */
  23891. object: IPhysicsEnabledObject,
  23892. /**
  23893. * The type of the physics imposter
  23894. */
  23895. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23896. /**
  23897. * This function will completly initialize this impostor.
  23898. * It will create a new body - but only if this mesh has no parent.
  23899. * If it has, this impostor will not be used other than to define the impostor
  23900. * of the child mesh.
  23901. * @hidden
  23902. */
  23903. _init(): void;
  23904. private _getPhysicsParent;
  23905. /**
  23906. * Should a new body be generated.
  23907. * @returns boolean specifying if body initialization is required
  23908. */
  23909. isBodyInitRequired(): boolean;
  23910. /**
  23911. * Sets the updated scaling
  23912. * @param updated Specifies if the scaling is updated
  23913. */
  23914. setScalingUpdated(): void;
  23915. /**
  23916. * Force a regeneration of this or the parent's impostor's body.
  23917. * Use under cautious - This will remove all joints already implemented.
  23918. */
  23919. forceUpdate(): void;
  23920. /**
  23921. * Gets the body that holds this impostor. Either its own, or its parent.
  23922. */
  23923. /**
  23924. * Set the physics body. Used mainly by the physics engine/plugin
  23925. */
  23926. physicsBody: any;
  23927. /**
  23928. * Get the parent of the physics imposter
  23929. * @returns Physics imposter or null
  23930. */
  23931. /**
  23932. * Sets the parent of the physics imposter
  23933. */
  23934. parent: Nullable<PhysicsImpostor>;
  23935. /**
  23936. * Resets the update flags
  23937. */
  23938. resetUpdateFlags(): void;
  23939. /**
  23940. * Gets the object extend size
  23941. * @returns the object extend size
  23942. */
  23943. getObjectExtendSize(): Vector3;
  23944. /**
  23945. * Gets the object center
  23946. * @returns The object center
  23947. */
  23948. getObjectCenter(): Vector3;
  23949. /**
  23950. * Get a specific parametes from the options parameter
  23951. * @param paramName The object parameter name
  23952. * @returns The object parameter
  23953. */
  23954. getParam(paramName: string): any;
  23955. /**
  23956. * Sets a specific parameter in the options given to the physics plugin
  23957. * @param paramName The parameter name
  23958. * @param value The value of the parameter
  23959. */
  23960. setParam(paramName: string, value: number): void;
  23961. /**
  23962. * Specifically change the body's mass option. Won't recreate the physics body object
  23963. * @param mass The mass of the physics imposter
  23964. */
  23965. setMass(mass: number): void;
  23966. /**
  23967. * Gets the linear velocity
  23968. * @returns linear velocity or null
  23969. */
  23970. getLinearVelocity(): Nullable<Vector3>;
  23971. /**
  23972. * Sets the linear velocity
  23973. * @param velocity linear velocity or null
  23974. */
  23975. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23976. /**
  23977. * Gets the angular velocity
  23978. * @returns angular velocity or null
  23979. */
  23980. getAngularVelocity(): Nullable<Vector3>;
  23981. /**
  23982. * Sets the angular velocity
  23983. * @param velocity The velocity or null
  23984. */
  23985. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23986. /**
  23987. * Execute a function with the physics plugin native code
  23988. * Provide a function the will have two variables - the world object and the physics body object
  23989. * @param func The function to execute with the physics plugin native code
  23990. */
  23991. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23992. /**
  23993. * Register a function that will be executed before the physics world is stepping forward
  23994. * @param func The function to execute before the physics world is stepped forward
  23995. */
  23996. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23997. /**
  23998. * Unregister a function that will be executed before the physics world is stepping forward
  23999. * @param func The function to execute before the physics world is stepped forward
  24000. */
  24001. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24002. /**
  24003. * Register a function that will be executed after the physics step
  24004. * @param func The function to execute after physics step
  24005. */
  24006. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24007. /**
  24008. * Unregisters a function that will be executed after the physics step
  24009. * @param func The function to execute after physics step
  24010. */
  24011. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24012. /**
  24013. * register a function that will be executed when this impostor collides against a different body
  24014. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24015. * @param func Callback that is executed on collision
  24016. */
  24017. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24018. /**
  24019. * Unregisters the physics imposter on contact
  24020. * @param collideAgainst The physics object to collide against
  24021. * @param func Callback to execute on collision
  24022. */
  24023. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24024. private _tmpQuat;
  24025. private _tmpQuat2;
  24026. /**
  24027. * Get the parent rotation
  24028. * @returns The parent rotation
  24029. */
  24030. getParentsRotation(): Quaternion;
  24031. /**
  24032. * this function is executed by the physics engine.
  24033. */
  24034. beforeStep: () => void;
  24035. /**
  24036. * this function is executed by the physics engine
  24037. */
  24038. afterStep: () => void;
  24039. /**
  24040. * Legacy collision detection event support
  24041. */
  24042. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24043. /**
  24044. * event and body object due to cannon's event-based architecture.
  24045. */
  24046. onCollide: (e: {
  24047. body: any;
  24048. }) => void;
  24049. /**
  24050. * Apply a force
  24051. * @param force The force to apply
  24052. * @param contactPoint The contact point for the force
  24053. * @returns The physics imposter
  24054. */
  24055. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24056. /**
  24057. * Apply an impulse
  24058. * @param force The impulse force
  24059. * @param contactPoint The contact point for the impulse force
  24060. * @returns The physics imposter
  24061. */
  24062. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24063. /**
  24064. * A help function to create a joint
  24065. * @param otherImpostor A physics imposter used to create a joint
  24066. * @param jointType The type of joint
  24067. * @param jointData The data for the joint
  24068. * @returns The physics imposter
  24069. */
  24070. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24071. /**
  24072. * Add a joint to this impostor with a different impostor
  24073. * @param otherImpostor A physics imposter used to add a joint
  24074. * @param joint The joint to add
  24075. * @returns The physics imposter
  24076. */
  24077. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24078. /**
  24079. * Add an anchor to a cloth impostor
  24080. * @param otherImpostor rigid impostor to anchor to
  24081. * @param width ratio across width from 0 to 1
  24082. * @param height ratio up height from 0 to 1
  24083. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24084. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24085. * @returns impostor the soft imposter
  24086. */
  24087. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24088. /**
  24089. * Add a hook to a rope impostor
  24090. * @param otherImpostor rigid impostor to anchor to
  24091. * @param length ratio across rope from 0 to 1
  24092. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24093. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24094. * @returns impostor the rope imposter
  24095. */
  24096. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24097. /**
  24098. * Will keep this body still, in a sleep mode.
  24099. * @returns the physics imposter
  24100. */
  24101. sleep(): PhysicsImpostor;
  24102. /**
  24103. * Wake the body up.
  24104. * @returns The physics imposter
  24105. */
  24106. wakeUp(): PhysicsImpostor;
  24107. /**
  24108. * Clones the physics imposter
  24109. * @param newObject The physics imposter clones to this physics-enabled object
  24110. * @returns A nullable physics imposter
  24111. */
  24112. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24113. /**
  24114. * Disposes the physics imposter
  24115. */
  24116. dispose(): void;
  24117. /**
  24118. * Sets the delta position
  24119. * @param position The delta position amount
  24120. */
  24121. setDeltaPosition(position: Vector3): void;
  24122. /**
  24123. * Sets the delta rotation
  24124. * @param rotation The delta rotation amount
  24125. */
  24126. setDeltaRotation(rotation: Quaternion): void;
  24127. /**
  24128. * Gets the box size of the physics imposter and stores the result in the input parameter
  24129. * @param result Stores the box size
  24130. * @returns The physics imposter
  24131. */
  24132. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24133. /**
  24134. * Gets the radius of the physics imposter
  24135. * @returns Radius of the physics imposter
  24136. */
  24137. getRadius(): number;
  24138. /**
  24139. * Sync a bone with this impostor
  24140. * @param bone The bone to sync to the impostor.
  24141. * @param boneMesh The mesh that the bone is influencing.
  24142. * @param jointPivot The pivot of the joint / bone in local space.
  24143. * @param distToJoint Optional distance from the impostor to the joint.
  24144. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24145. */
  24146. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24147. /**
  24148. * Sync impostor to a bone
  24149. * @param bone The bone that the impostor will be synced to.
  24150. * @param boneMesh The mesh that the bone is influencing.
  24151. * @param jointPivot The pivot of the joint / bone in local space.
  24152. * @param distToJoint Optional distance from the impostor to the joint.
  24153. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24154. * @param boneAxis Optional vector3 axis the bone is aligned with
  24155. */
  24156. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24157. /**
  24158. * No-Imposter type
  24159. */
  24160. static NoImpostor: number;
  24161. /**
  24162. * Sphere-Imposter type
  24163. */
  24164. static SphereImpostor: number;
  24165. /**
  24166. * Box-Imposter type
  24167. */
  24168. static BoxImpostor: number;
  24169. /**
  24170. * Plane-Imposter type
  24171. */
  24172. static PlaneImpostor: number;
  24173. /**
  24174. * Mesh-imposter type
  24175. */
  24176. static MeshImpostor: number;
  24177. /**
  24178. * Capsule-Impostor type (Ammo.js plugin only)
  24179. */
  24180. static CapsuleImpostor: number;
  24181. /**
  24182. * Cylinder-Imposter type
  24183. */
  24184. static CylinderImpostor: number;
  24185. /**
  24186. * Particle-Imposter type
  24187. */
  24188. static ParticleImpostor: number;
  24189. /**
  24190. * Heightmap-Imposter type
  24191. */
  24192. static HeightmapImpostor: number;
  24193. /**
  24194. * ConvexHull-Impostor type (Ammo.js plugin only)
  24195. */
  24196. static ConvexHullImpostor: number;
  24197. /**
  24198. * Rope-Imposter type
  24199. */
  24200. static RopeImpostor: number;
  24201. /**
  24202. * Cloth-Imposter type
  24203. */
  24204. static ClothImpostor: number;
  24205. /**
  24206. * Softbody-Imposter type
  24207. */
  24208. static SoftbodyImpostor: number;
  24209. }
  24210. }
  24211. declare module "babylonjs/Meshes/mesh" {
  24212. import { Observable } from "babylonjs/Misc/observable";
  24213. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24214. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24215. import { Camera } from "babylonjs/Cameras/camera";
  24216. import { Scene } from "babylonjs/scene";
  24217. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24218. import { Color4 } from "babylonjs/Maths/math.color";
  24219. import { Engine } from "babylonjs/Engines/engine";
  24220. import { Node } from "babylonjs/node";
  24221. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24222. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24223. import { Buffer } from "babylonjs/Meshes/buffer";
  24224. import { Geometry } from "babylonjs/Meshes/geometry";
  24225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24226. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24227. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24228. import { Effect } from "babylonjs/Materials/effect";
  24229. import { Material } from "babylonjs/Materials/material";
  24230. import { Skeleton } from "babylonjs/Bones/skeleton";
  24231. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24232. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24233. import { Path3D } from "babylonjs/Maths/math.path";
  24234. import { Plane } from "babylonjs/Maths/math.plane";
  24235. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24236. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24237. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24238. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24239. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24240. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24241. /**
  24242. * @hidden
  24243. **/
  24244. export class _CreationDataStorage {
  24245. closePath?: boolean;
  24246. closeArray?: boolean;
  24247. idx: number[];
  24248. dashSize: number;
  24249. gapSize: number;
  24250. path3D: Path3D;
  24251. pathArray: Vector3[][];
  24252. arc: number;
  24253. radius: number;
  24254. cap: number;
  24255. tessellation: number;
  24256. }
  24257. /**
  24258. * @hidden
  24259. **/
  24260. class _InstanceDataStorage {
  24261. visibleInstances: any;
  24262. batchCache: _InstancesBatch;
  24263. instancesBufferSize: number;
  24264. instancesBuffer: Nullable<Buffer>;
  24265. instancesData: Float32Array;
  24266. overridenInstanceCount: number;
  24267. isFrozen: boolean;
  24268. previousBatch: Nullable<_InstancesBatch>;
  24269. hardwareInstancedRendering: boolean;
  24270. sideOrientation: number;
  24271. }
  24272. /**
  24273. * @hidden
  24274. **/
  24275. export class _InstancesBatch {
  24276. mustReturn: boolean;
  24277. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24278. renderSelf: boolean[];
  24279. hardwareInstancedRendering: boolean[];
  24280. }
  24281. /**
  24282. * Class used to represent renderable models
  24283. */
  24284. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24285. /**
  24286. * Mesh side orientation : usually the external or front surface
  24287. */
  24288. static readonly FRONTSIDE: number;
  24289. /**
  24290. * Mesh side orientation : usually the internal or back surface
  24291. */
  24292. static readonly BACKSIDE: number;
  24293. /**
  24294. * Mesh side orientation : both internal and external or front and back surfaces
  24295. */
  24296. static readonly DOUBLESIDE: number;
  24297. /**
  24298. * Mesh side orientation : by default, `FRONTSIDE`
  24299. */
  24300. static readonly DEFAULTSIDE: number;
  24301. /**
  24302. * Mesh cap setting : no cap
  24303. */
  24304. static readonly NO_CAP: number;
  24305. /**
  24306. * Mesh cap setting : one cap at the beginning of the mesh
  24307. */
  24308. static readonly CAP_START: number;
  24309. /**
  24310. * Mesh cap setting : one cap at the end of the mesh
  24311. */
  24312. static readonly CAP_END: number;
  24313. /**
  24314. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24315. */
  24316. static readonly CAP_ALL: number;
  24317. /**
  24318. * Mesh pattern setting : no flip or rotate
  24319. */
  24320. static readonly NO_FLIP: number;
  24321. /**
  24322. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24323. */
  24324. static readonly FLIP_TILE: number;
  24325. /**
  24326. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24327. */
  24328. static readonly ROTATE_TILE: number;
  24329. /**
  24330. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24331. */
  24332. static readonly FLIP_ROW: number;
  24333. /**
  24334. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24335. */
  24336. static readonly ROTATE_ROW: number;
  24337. /**
  24338. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24339. */
  24340. static readonly FLIP_N_ROTATE_TILE: number;
  24341. /**
  24342. * Mesh pattern setting : rotate pattern and rotate
  24343. */
  24344. static readonly FLIP_N_ROTATE_ROW: number;
  24345. /**
  24346. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24347. */
  24348. static readonly CENTER: number;
  24349. /**
  24350. * Mesh tile positioning : part tiles on left
  24351. */
  24352. static readonly LEFT: number;
  24353. /**
  24354. * Mesh tile positioning : part tiles on right
  24355. */
  24356. static readonly RIGHT: number;
  24357. /**
  24358. * Mesh tile positioning : part tiles on top
  24359. */
  24360. static readonly TOP: number;
  24361. /**
  24362. * Mesh tile positioning : part tiles on bottom
  24363. */
  24364. static readonly BOTTOM: number;
  24365. /**
  24366. * Gets the default side orientation.
  24367. * @param orientation the orientation to value to attempt to get
  24368. * @returns the default orientation
  24369. * @hidden
  24370. */
  24371. static _GetDefaultSideOrientation(orientation?: number): number;
  24372. private _internalMeshDataInfo;
  24373. /**
  24374. * An event triggered before rendering the mesh
  24375. */
  24376. readonly onBeforeRenderObservable: Observable<Mesh>;
  24377. /**
  24378. * An event triggered before binding the mesh
  24379. */
  24380. readonly onBeforeBindObservable: Observable<Mesh>;
  24381. /**
  24382. * An event triggered after rendering the mesh
  24383. */
  24384. readonly onAfterRenderObservable: Observable<Mesh>;
  24385. /**
  24386. * An event triggered before drawing the mesh
  24387. */
  24388. readonly onBeforeDrawObservable: Observable<Mesh>;
  24389. private _onBeforeDrawObserver;
  24390. /**
  24391. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24392. */
  24393. onBeforeDraw: () => void;
  24394. readonly hasInstances: boolean;
  24395. /**
  24396. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24397. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24398. */
  24399. delayLoadState: number;
  24400. /**
  24401. * Gets the list of instances created from this mesh
  24402. * it is not supposed to be modified manually.
  24403. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24404. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24405. */
  24406. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24407. /**
  24408. * Gets the file containing delay loading data for this mesh
  24409. */
  24410. delayLoadingFile: string;
  24411. /** @hidden */
  24412. _binaryInfo: any;
  24413. /**
  24414. * User defined function used to change how LOD level selection is done
  24415. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24416. */
  24417. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24418. /**
  24419. * Gets or sets the morph target manager
  24420. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24421. */
  24422. morphTargetManager: Nullable<MorphTargetManager>;
  24423. /** @hidden */
  24424. _creationDataStorage: Nullable<_CreationDataStorage>;
  24425. /** @hidden */
  24426. _geometry: Nullable<Geometry>;
  24427. /** @hidden */
  24428. _delayInfo: Array<string>;
  24429. /** @hidden */
  24430. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24431. /** @hidden */
  24432. _instanceDataStorage: _InstanceDataStorage;
  24433. private _effectiveMaterial;
  24434. /** @hidden */
  24435. _shouldGenerateFlatShading: boolean;
  24436. /** @hidden */
  24437. _originalBuilderSideOrientation: number;
  24438. /**
  24439. * Use this property to change the original side orientation defined at construction time
  24440. */
  24441. overrideMaterialSideOrientation: Nullable<number>;
  24442. /**
  24443. * Gets the source mesh (the one used to clone this one from)
  24444. */
  24445. readonly source: Nullable<Mesh>;
  24446. /**
  24447. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24448. */
  24449. isUnIndexed: boolean;
  24450. /**
  24451. * @constructor
  24452. * @param name The value used by scene.getMeshByName() to do a lookup.
  24453. * @param scene The scene to add this mesh to.
  24454. * @param parent The parent of this mesh, if it has one
  24455. * @param source An optional Mesh from which geometry is shared, cloned.
  24456. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24457. * When false, achieved by calling a clone(), also passing False.
  24458. * This will make creation of children, recursive.
  24459. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24460. */
  24461. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24462. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24463. /**
  24464. * Gets the class name
  24465. * @returns the string "Mesh".
  24466. */
  24467. getClassName(): string;
  24468. /** @hidden */
  24469. readonly _isMesh: boolean;
  24470. /**
  24471. * Returns a description of this mesh
  24472. * @param fullDetails define if full details about this mesh must be used
  24473. * @returns a descriptive string representing this mesh
  24474. */
  24475. toString(fullDetails?: boolean): string;
  24476. /** @hidden */
  24477. _unBindEffect(): void;
  24478. /**
  24479. * Gets a boolean indicating if this mesh has LOD
  24480. */
  24481. readonly hasLODLevels: boolean;
  24482. /**
  24483. * Gets the list of MeshLODLevel associated with the current mesh
  24484. * @returns an array of MeshLODLevel
  24485. */
  24486. getLODLevels(): MeshLODLevel[];
  24487. private _sortLODLevels;
  24488. /**
  24489. * Add a mesh as LOD level triggered at the given distance.
  24490. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24491. * @param distance The distance from the center of the object to show this level
  24492. * @param mesh The mesh to be added as LOD level (can be null)
  24493. * @return This mesh (for chaining)
  24494. */
  24495. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24496. /**
  24497. * Returns the LOD level mesh at the passed distance or null if not found.
  24498. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24499. * @param distance The distance from the center of the object to show this level
  24500. * @returns a Mesh or `null`
  24501. */
  24502. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24503. /**
  24504. * Remove a mesh from the LOD array
  24505. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24506. * @param mesh defines the mesh to be removed
  24507. * @return This mesh (for chaining)
  24508. */
  24509. removeLODLevel(mesh: Mesh): Mesh;
  24510. /**
  24511. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24512. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24513. * @param camera defines the camera to use to compute distance
  24514. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24515. * @return This mesh (for chaining)
  24516. */
  24517. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24518. /**
  24519. * Gets the mesh internal Geometry object
  24520. */
  24521. readonly geometry: Nullable<Geometry>;
  24522. /**
  24523. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24524. * @returns the total number of vertices
  24525. */
  24526. getTotalVertices(): number;
  24527. /**
  24528. * Returns the content of an associated vertex buffer
  24529. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24530. * - VertexBuffer.PositionKind
  24531. * - VertexBuffer.UVKind
  24532. * - VertexBuffer.UV2Kind
  24533. * - VertexBuffer.UV3Kind
  24534. * - VertexBuffer.UV4Kind
  24535. * - VertexBuffer.UV5Kind
  24536. * - VertexBuffer.UV6Kind
  24537. * - VertexBuffer.ColorKind
  24538. * - VertexBuffer.MatricesIndicesKind
  24539. * - VertexBuffer.MatricesIndicesExtraKind
  24540. * - VertexBuffer.MatricesWeightsKind
  24541. * - VertexBuffer.MatricesWeightsExtraKind
  24542. * @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
  24543. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24544. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24545. */
  24546. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24547. /**
  24548. * Returns the mesh VertexBuffer object from the requested `kind`
  24549. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24550. * - VertexBuffer.PositionKind
  24551. * - VertexBuffer.NormalKind
  24552. * - VertexBuffer.UVKind
  24553. * - VertexBuffer.UV2Kind
  24554. * - VertexBuffer.UV3Kind
  24555. * - VertexBuffer.UV4Kind
  24556. * - VertexBuffer.UV5Kind
  24557. * - VertexBuffer.UV6Kind
  24558. * - VertexBuffer.ColorKind
  24559. * - VertexBuffer.MatricesIndicesKind
  24560. * - VertexBuffer.MatricesIndicesExtraKind
  24561. * - VertexBuffer.MatricesWeightsKind
  24562. * - VertexBuffer.MatricesWeightsExtraKind
  24563. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24564. */
  24565. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24566. /**
  24567. * Tests if a specific vertex buffer is associated with this mesh
  24568. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24569. * - VertexBuffer.PositionKind
  24570. * - VertexBuffer.NormalKind
  24571. * - VertexBuffer.UVKind
  24572. * - VertexBuffer.UV2Kind
  24573. * - VertexBuffer.UV3Kind
  24574. * - VertexBuffer.UV4Kind
  24575. * - VertexBuffer.UV5Kind
  24576. * - VertexBuffer.UV6Kind
  24577. * - VertexBuffer.ColorKind
  24578. * - VertexBuffer.MatricesIndicesKind
  24579. * - VertexBuffer.MatricesIndicesExtraKind
  24580. * - VertexBuffer.MatricesWeightsKind
  24581. * - VertexBuffer.MatricesWeightsExtraKind
  24582. * @returns a boolean
  24583. */
  24584. isVerticesDataPresent(kind: string): boolean;
  24585. /**
  24586. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24587. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24588. * - VertexBuffer.PositionKind
  24589. * - VertexBuffer.UVKind
  24590. * - VertexBuffer.UV2Kind
  24591. * - VertexBuffer.UV3Kind
  24592. * - VertexBuffer.UV4Kind
  24593. * - VertexBuffer.UV5Kind
  24594. * - VertexBuffer.UV6Kind
  24595. * - VertexBuffer.ColorKind
  24596. * - VertexBuffer.MatricesIndicesKind
  24597. * - VertexBuffer.MatricesIndicesExtraKind
  24598. * - VertexBuffer.MatricesWeightsKind
  24599. * - VertexBuffer.MatricesWeightsExtraKind
  24600. * @returns a boolean
  24601. */
  24602. isVertexBufferUpdatable(kind: string): boolean;
  24603. /**
  24604. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24605. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24606. * - VertexBuffer.PositionKind
  24607. * - VertexBuffer.NormalKind
  24608. * - VertexBuffer.UVKind
  24609. * - VertexBuffer.UV2Kind
  24610. * - VertexBuffer.UV3Kind
  24611. * - VertexBuffer.UV4Kind
  24612. * - VertexBuffer.UV5Kind
  24613. * - VertexBuffer.UV6Kind
  24614. * - VertexBuffer.ColorKind
  24615. * - VertexBuffer.MatricesIndicesKind
  24616. * - VertexBuffer.MatricesIndicesExtraKind
  24617. * - VertexBuffer.MatricesWeightsKind
  24618. * - VertexBuffer.MatricesWeightsExtraKind
  24619. * @returns an array of strings
  24620. */
  24621. getVerticesDataKinds(): string[];
  24622. /**
  24623. * Returns a positive integer : the total number of indices in this mesh geometry.
  24624. * @returns the numner of indices or zero if the mesh has no geometry.
  24625. */
  24626. getTotalIndices(): number;
  24627. /**
  24628. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24629. * @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.
  24630. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24631. * @returns the indices array or an empty array if the mesh has no geometry
  24632. */
  24633. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24634. readonly isBlocked: boolean;
  24635. /**
  24636. * Determine if the current mesh is ready to be rendered
  24637. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24638. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24639. * @returns true if all associated assets are ready (material, textures, shaders)
  24640. */
  24641. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24642. /**
  24643. * 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.
  24644. */
  24645. readonly areNormalsFrozen: boolean;
  24646. /**
  24647. * 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.
  24648. * @returns the current mesh
  24649. */
  24650. freezeNormals(): Mesh;
  24651. /**
  24652. * 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
  24653. * @returns the current mesh
  24654. */
  24655. unfreezeNormals(): Mesh;
  24656. /**
  24657. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24658. */
  24659. overridenInstanceCount: number;
  24660. /** @hidden */
  24661. _preActivate(): Mesh;
  24662. /** @hidden */
  24663. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24664. /** @hidden */
  24665. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24666. /**
  24667. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24668. * This means the mesh underlying bounding box and sphere are recomputed.
  24669. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24670. * @returns the current mesh
  24671. */
  24672. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24673. /** @hidden */
  24674. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24675. /**
  24676. * This function will subdivide the mesh into multiple submeshes
  24677. * @param count defines the expected number of submeshes
  24678. */
  24679. subdivide(count: number): void;
  24680. /**
  24681. * Copy a FloatArray into a specific associated vertex buffer
  24682. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24683. * - VertexBuffer.PositionKind
  24684. * - VertexBuffer.UVKind
  24685. * - VertexBuffer.UV2Kind
  24686. * - VertexBuffer.UV3Kind
  24687. * - VertexBuffer.UV4Kind
  24688. * - VertexBuffer.UV5Kind
  24689. * - VertexBuffer.UV6Kind
  24690. * - VertexBuffer.ColorKind
  24691. * - VertexBuffer.MatricesIndicesKind
  24692. * - VertexBuffer.MatricesIndicesExtraKind
  24693. * - VertexBuffer.MatricesWeightsKind
  24694. * - VertexBuffer.MatricesWeightsExtraKind
  24695. * @param data defines the data source
  24696. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24697. * @param stride defines the data stride size (can be null)
  24698. * @returns the current mesh
  24699. */
  24700. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24701. /**
  24702. * Flags an associated vertex buffer as updatable
  24703. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24704. * - VertexBuffer.PositionKind
  24705. * - VertexBuffer.UVKind
  24706. * - VertexBuffer.UV2Kind
  24707. * - VertexBuffer.UV3Kind
  24708. * - VertexBuffer.UV4Kind
  24709. * - VertexBuffer.UV5Kind
  24710. * - VertexBuffer.UV6Kind
  24711. * - VertexBuffer.ColorKind
  24712. * - VertexBuffer.MatricesIndicesKind
  24713. * - VertexBuffer.MatricesIndicesExtraKind
  24714. * - VertexBuffer.MatricesWeightsKind
  24715. * - VertexBuffer.MatricesWeightsExtraKind
  24716. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24717. */
  24718. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24719. /**
  24720. * Sets the mesh global Vertex Buffer
  24721. * @param buffer defines the buffer to use
  24722. * @returns the current mesh
  24723. */
  24724. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24725. /**
  24726. * Update a specific associated vertex buffer
  24727. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24728. * - VertexBuffer.PositionKind
  24729. * - VertexBuffer.UVKind
  24730. * - VertexBuffer.UV2Kind
  24731. * - VertexBuffer.UV3Kind
  24732. * - VertexBuffer.UV4Kind
  24733. * - VertexBuffer.UV5Kind
  24734. * - VertexBuffer.UV6Kind
  24735. * - VertexBuffer.ColorKind
  24736. * - VertexBuffer.MatricesIndicesKind
  24737. * - VertexBuffer.MatricesIndicesExtraKind
  24738. * - VertexBuffer.MatricesWeightsKind
  24739. * - VertexBuffer.MatricesWeightsExtraKind
  24740. * @param data defines the data source
  24741. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24742. * @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)
  24743. * @returns the current mesh
  24744. */
  24745. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24746. /**
  24747. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24748. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24749. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24750. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24751. * @returns the current mesh
  24752. */
  24753. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24754. /**
  24755. * Creates a un-shared specific occurence of the geometry for the mesh.
  24756. * @returns the current mesh
  24757. */
  24758. makeGeometryUnique(): Mesh;
  24759. /**
  24760. * Set the index buffer of this mesh
  24761. * @param indices defines the source data
  24762. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24763. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24764. * @returns the current mesh
  24765. */
  24766. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24767. /**
  24768. * Update the current index buffer
  24769. * @param indices defines the source data
  24770. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24771. * @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)
  24772. * @returns the current mesh
  24773. */
  24774. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24775. /**
  24776. * Invert the geometry to move from a right handed system to a left handed one.
  24777. * @returns the current mesh
  24778. */
  24779. toLeftHanded(): Mesh;
  24780. /** @hidden */
  24781. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24782. /** @hidden */
  24783. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24784. /**
  24785. * Registers for this mesh a javascript function called just before the rendering process
  24786. * @param func defines the function to call before rendering this mesh
  24787. * @returns the current mesh
  24788. */
  24789. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24790. /**
  24791. * Disposes a previously registered javascript function called before the rendering
  24792. * @param func defines the function to remove
  24793. * @returns the current mesh
  24794. */
  24795. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24796. /**
  24797. * Registers for this mesh a javascript function called just after the rendering is complete
  24798. * @param func defines the function to call after rendering this mesh
  24799. * @returns the current mesh
  24800. */
  24801. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24802. /**
  24803. * Disposes a previously registered javascript function called after the rendering.
  24804. * @param func defines the function to remove
  24805. * @returns the current mesh
  24806. */
  24807. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24808. /** @hidden */
  24809. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24810. /** @hidden */
  24811. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24812. /** @hidden */
  24813. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24814. /** @hidden */
  24815. _rebuild(): void;
  24816. /** @hidden */
  24817. _freeze(): void;
  24818. /** @hidden */
  24819. _unFreeze(): void;
  24820. /**
  24821. * 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
  24822. * @param subMesh defines the subMesh to render
  24823. * @param enableAlphaMode defines if alpha mode can be changed
  24824. * @returns the current mesh
  24825. */
  24826. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24827. private _onBeforeDraw;
  24828. /**
  24829. * Renormalize the mesh and patch it up if there are no weights
  24830. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24831. * However in the case of zero weights then we set just a single influence to 1.
  24832. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24833. */
  24834. cleanMatrixWeights(): void;
  24835. private normalizeSkinFourWeights;
  24836. private normalizeSkinWeightsAndExtra;
  24837. /**
  24838. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24839. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24840. * the user know there was an issue with importing the mesh
  24841. * @returns a validation object with skinned, valid and report string
  24842. */
  24843. validateSkinning(): {
  24844. skinned: boolean;
  24845. valid: boolean;
  24846. report: string;
  24847. };
  24848. /** @hidden */
  24849. _checkDelayState(): Mesh;
  24850. private _queueLoad;
  24851. /**
  24852. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24853. * A mesh is in the frustum if its bounding box intersects the frustum
  24854. * @param frustumPlanes defines the frustum to test
  24855. * @returns true if the mesh is in the frustum planes
  24856. */
  24857. isInFrustum(frustumPlanes: Plane[]): boolean;
  24858. /**
  24859. * Sets the mesh material by the material or multiMaterial `id` property
  24860. * @param id is a string identifying the material or the multiMaterial
  24861. * @returns the current mesh
  24862. */
  24863. setMaterialByID(id: string): Mesh;
  24864. /**
  24865. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24866. * @returns an array of IAnimatable
  24867. */
  24868. getAnimatables(): IAnimatable[];
  24869. /**
  24870. * Modifies the mesh geometry according to the passed transformation matrix.
  24871. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24872. * The mesh normals are modified using the same transformation.
  24873. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24874. * @param transform defines the transform matrix to use
  24875. * @see http://doc.babylonjs.com/resources/baking_transformations
  24876. * @returns the current mesh
  24877. */
  24878. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24879. /**
  24880. * Modifies the mesh geometry according to its own current World Matrix.
  24881. * The mesh World Matrix is then reset.
  24882. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24883. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24884. * @see http://doc.babylonjs.com/resources/baking_transformations
  24885. * @returns the current mesh
  24886. */
  24887. bakeCurrentTransformIntoVertices(): Mesh;
  24888. /** @hidden */
  24889. readonly _positions: Nullable<Vector3[]>;
  24890. /** @hidden */
  24891. _resetPointsArrayCache(): Mesh;
  24892. /** @hidden */
  24893. _generatePointsArray(): boolean;
  24894. /**
  24895. * Returns a new Mesh object generated from the current mesh properties.
  24896. * This method must not get confused with createInstance()
  24897. * @param name is a string, the name given to the new mesh
  24898. * @param newParent can be any Node object (default `null`)
  24899. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24900. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24901. * @returns a new mesh
  24902. */
  24903. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24904. /**
  24905. * Releases resources associated with this mesh.
  24906. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24907. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24908. */
  24909. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24910. /**
  24911. * Modifies the mesh geometry according to a displacement map.
  24912. * 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.
  24913. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24914. * @param url is a string, the URL from the image file is to be downloaded.
  24915. * @param minHeight is the lower limit of the displacement.
  24916. * @param maxHeight is the upper limit of the displacement.
  24917. * @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.
  24918. * @param uvOffset is an optional vector2 used to offset UV.
  24919. * @param uvScale is an optional vector2 used to scale UV.
  24920. * @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.
  24921. * @returns the Mesh.
  24922. */
  24923. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24924. /**
  24925. * Modifies the mesh geometry according to a displacementMap buffer.
  24926. * 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.
  24927. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24928. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24929. * @param heightMapWidth is the width of the buffer image.
  24930. * @param heightMapHeight is the height of the buffer image.
  24931. * @param minHeight is the lower limit of the displacement.
  24932. * @param maxHeight is the upper limit of the displacement.
  24933. * @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.
  24934. * @param uvOffset is an optional vector2 used to offset UV.
  24935. * @param uvScale is an optional vector2 used to scale UV.
  24936. * @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.
  24937. * @returns the Mesh.
  24938. */
  24939. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24940. /**
  24941. * Modify the mesh to get a flat shading rendering.
  24942. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24943. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24944. * @returns current mesh
  24945. */
  24946. convertToFlatShadedMesh(): Mesh;
  24947. /**
  24948. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24949. * In other words, more vertices, no more indices and a single bigger VBO.
  24950. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24951. * @returns current mesh
  24952. */
  24953. convertToUnIndexedMesh(): Mesh;
  24954. /**
  24955. * Inverses facet orientations.
  24956. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24957. * @param flipNormals will also inverts the normals
  24958. * @returns current mesh
  24959. */
  24960. flipFaces(flipNormals?: boolean): Mesh;
  24961. /**
  24962. * Increase the number of facets and hence vertices in a mesh
  24963. * Vertex normals are interpolated from existing vertex normals
  24964. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24965. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24966. */
  24967. increaseVertices(numberPerEdge: number): void;
  24968. /**
  24969. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24970. * This will undo any application of covertToFlatShadedMesh
  24971. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24972. */
  24973. forceSharedVertices(): void;
  24974. /** @hidden */
  24975. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24976. /** @hidden */
  24977. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24978. /**
  24979. * Creates a new InstancedMesh object from the mesh model.
  24980. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24981. * @param name defines the name of the new instance
  24982. * @returns a new InstancedMesh
  24983. */
  24984. createInstance(name: string): InstancedMesh;
  24985. /**
  24986. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24987. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24988. * @returns the current mesh
  24989. */
  24990. synchronizeInstances(): Mesh;
  24991. /**
  24992. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24993. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24994. * This should be used together with the simplification to avoid disappearing triangles.
  24995. * @param successCallback an optional success callback to be called after the optimization finished.
  24996. * @returns the current mesh
  24997. */
  24998. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24999. /**
  25000. * Serialize current mesh
  25001. * @param serializationObject defines the object which will receive the serialization data
  25002. */
  25003. serialize(serializationObject: any): void;
  25004. /** @hidden */
  25005. _syncGeometryWithMorphTargetManager(): void;
  25006. /** @hidden */
  25007. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25008. /**
  25009. * Returns a new Mesh object parsed from the source provided.
  25010. * @param parsedMesh is the source
  25011. * @param scene defines the hosting scene
  25012. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25013. * @returns a new Mesh
  25014. */
  25015. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25016. /**
  25017. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25018. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25019. * @param name defines the name of the mesh to create
  25020. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25021. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25022. * @param closePath creates a seam between the first and the last points of each path of the path array
  25023. * @param offset is taken in account only if the `pathArray` is containing a single path
  25024. * @param scene defines the hosting scene
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25027. * @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)
  25028. * @returns a new Mesh
  25029. */
  25030. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25031. /**
  25032. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25033. * @param name defines the name of the mesh to create
  25034. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25035. * @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
  25036. * @param scene defines the hosting scene
  25037. * @param updatable defines if the mesh must be flagged as updatable
  25038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25039. * @returns a new Mesh
  25040. */
  25041. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25042. /**
  25043. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25044. * @param name defines the name of the mesh to create
  25045. * @param size sets the size (float) of each box side (default 1)
  25046. * @param scene defines the hosting scene
  25047. * @param updatable defines if the mesh must be flagged as updatable
  25048. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25049. * @returns a new Mesh
  25050. */
  25051. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25052. /**
  25053. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25054. * @param name defines the name of the mesh to create
  25055. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25056. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25057. * @param scene defines the hosting scene
  25058. * @param updatable defines if the mesh must be flagged as updatable
  25059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25060. * @returns a new Mesh
  25061. */
  25062. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25063. /**
  25064. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25065. * @param name defines the name of the mesh to create
  25066. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25067. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25068. * @param scene defines the hosting scene
  25069. * @returns a new Mesh
  25070. */
  25071. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25072. /**
  25073. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25074. * @param name defines the name of the mesh to create
  25075. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25076. * @param diameterTop set the top cap diameter (floats, default 1)
  25077. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25078. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25079. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25080. * @param scene defines the hosting scene
  25081. * @param updatable defines if the mesh must be flagged as updatable
  25082. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25083. * @returns a new Mesh
  25084. */
  25085. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25086. /**
  25087. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25088. * @param name defines the name of the mesh to create
  25089. * @param diameter sets the diameter size (float) of the torus (default 1)
  25090. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25091. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25092. * @param scene defines the hosting scene
  25093. * @param updatable defines if the mesh must be flagged as updatable
  25094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25095. * @returns a new Mesh
  25096. */
  25097. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25098. /**
  25099. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25100. * @param name defines the name of the mesh to create
  25101. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25102. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25103. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25104. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25105. * @param p the number of windings on X axis (positive integers, default 2)
  25106. * @param q the number of windings on Y axis (positive integers, default 3)
  25107. * @param scene defines the hosting scene
  25108. * @param updatable defines if the mesh must be flagged as updatable
  25109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25110. * @returns a new Mesh
  25111. */
  25112. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25113. /**
  25114. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25115. * @param name defines the name of the mesh to create
  25116. * @param points is an array successive Vector3
  25117. * @param scene defines the hosting scene
  25118. * @param updatable defines if the mesh must be flagged as updatable
  25119. * @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).
  25120. * @returns a new Mesh
  25121. */
  25122. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25123. /**
  25124. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25125. * @param name defines the name of the mesh to create
  25126. * @param points is an array successive Vector3
  25127. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25128. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25129. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25130. * @param scene defines the hosting scene
  25131. * @param updatable defines if the mesh must be flagged as updatable
  25132. * @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)
  25133. * @returns a new Mesh
  25134. */
  25135. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25136. /**
  25137. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25138. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25139. * 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.
  25140. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25141. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25142. * Remember you can only change the shape positions, not their number when updating a polygon.
  25143. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25144. * @param name defines the name of the mesh to create
  25145. * @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
  25146. * @param scene defines the hosting scene
  25147. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25148. * @param updatable defines if the mesh must be flagged as updatable
  25149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25150. * @param earcutInjection can be used to inject your own earcut reference
  25151. * @returns a new Mesh
  25152. */
  25153. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25154. /**
  25155. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25156. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25157. * @param name defines the name of the mesh to create
  25158. * @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
  25159. * @param depth defines the height of extrusion
  25160. * @param scene defines the hosting scene
  25161. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25162. * @param updatable defines if the mesh must be flagged as updatable
  25163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25164. * @param earcutInjection can be used to inject your own earcut reference
  25165. * @returns a new Mesh
  25166. */
  25167. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25168. /**
  25169. * Creates an extruded shape mesh.
  25170. * 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
  25171. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25172. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25173. * @param name defines the name of the mesh to create
  25174. * @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
  25175. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25176. * @param scale is the value to scale the shape
  25177. * @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
  25178. * @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
  25179. * @param scene defines the hosting scene
  25180. * @param updatable defines if the mesh must be flagged as updatable
  25181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25182. * @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)
  25183. * @returns a new Mesh
  25184. */
  25185. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25186. /**
  25187. * Creates an custom extruded shape mesh.
  25188. * The custom extrusion is a parametric shape.
  25189. * It has no predefined shape. Its final shape will depend on the input parameters.
  25190. * Please consider using the same method from the MeshBuilder class instead
  25191. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25192. * @param name defines the name of the mesh to create
  25193. * @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
  25194. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25195. * @param scaleFunction is a custom Javascript function called on each path point
  25196. * @param rotationFunction is a custom Javascript function called on each path point
  25197. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25198. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25199. * @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
  25200. * @param scene defines the hosting scene
  25201. * @param updatable defines if the mesh must be flagged as updatable
  25202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25203. * @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)
  25204. * @returns a new Mesh
  25205. */
  25206. 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;
  25207. /**
  25208. * Creates lathe mesh.
  25209. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25210. * Please consider using the same method from the MeshBuilder class instead
  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 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
  25213. * @param radius is the radius value of the lathe
  25214. * @param tessellation is the side number of the lathe.
  25215. * @param scene defines the hosting scene
  25216. * @param updatable defines if the mesh must be flagged as updatable
  25217. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25218. * @returns a new Mesh
  25219. */
  25220. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25221. /**
  25222. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25223. * @param name defines the name of the mesh to create
  25224. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25225. * @param scene defines the hosting scene
  25226. * @param updatable defines if the mesh must be flagged as updatable
  25227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25228. * @returns a new Mesh
  25229. */
  25230. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25231. /**
  25232. * Creates a ground mesh.
  25233. * Please consider using the same method from the MeshBuilder class instead
  25234. * @param name defines the name of the mesh to create
  25235. * @param width set the width of the ground
  25236. * @param height set the height of the ground
  25237. * @param subdivisions sets the number of subdivisions per side
  25238. * @param scene defines the hosting scene
  25239. * @param updatable defines if the mesh must be flagged as updatable
  25240. * @returns a new Mesh
  25241. */
  25242. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25243. /**
  25244. * Creates a tiled ground mesh.
  25245. * Please consider using the same method from the MeshBuilder class instead
  25246. * @param name defines the name of the mesh to create
  25247. * @param xmin set the ground minimum X coordinate
  25248. * @param zmin set the ground minimum Y coordinate
  25249. * @param xmax set the ground maximum X coordinate
  25250. * @param zmax set the ground maximum Z coordinate
  25251. * @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
  25252. * @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
  25253. * @param scene defines the hosting scene
  25254. * @param updatable defines if the mesh must be flagged as updatable
  25255. * @returns a new Mesh
  25256. */
  25257. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25258. w: number;
  25259. h: number;
  25260. }, precision: {
  25261. w: number;
  25262. h: number;
  25263. }, scene: Scene, updatable?: boolean): Mesh;
  25264. /**
  25265. * Creates a ground mesh from a height map.
  25266. * Please consider using the same method from the MeshBuilder class instead
  25267. * @see http://doc.babylonjs.com/babylon101/height_map
  25268. * @param name defines the name of the mesh to create
  25269. * @param url sets the URL of the height map image resource
  25270. * @param width set the ground width size
  25271. * @param height set the ground height size
  25272. * @param subdivisions sets the number of subdivision per side
  25273. * @param minHeight is the minimum altitude on the ground
  25274. * @param maxHeight is the maximum altitude on the ground
  25275. * @param scene defines the hosting scene
  25276. * @param updatable defines if the mesh must be flagged as updatable
  25277. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25278. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25279. * @returns a new Mesh
  25280. */
  25281. 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;
  25282. /**
  25283. * Creates a tube mesh.
  25284. * The tube is a parametric shape.
  25285. * It has no predefined shape. Its final shape will depend on the input parameters.
  25286. * Please consider using the same method from the MeshBuilder class instead
  25287. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25288. * @param name defines the name of the mesh to create
  25289. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25290. * @param radius sets the tube radius size
  25291. * @param tessellation is the number of sides on the tubular surface
  25292. * @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
  25293. * @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
  25294. * @param scene defines the hosting scene
  25295. * @param updatable defines if the mesh must be flagged as updatable
  25296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25297. * @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)
  25298. * @returns a new Mesh
  25299. */
  25300. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25301. (i: number, distance: number): number;
  25302. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25303. /**
  25304. * Creates a polyhedron mesh.
  25305. * Please consider using the same method from the MeshBuilder class instead.
  25306. * * 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
  25307. * * The parameter `size` (positive float, default 1) sets the polygon size
  25308. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25309. * * 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`
  25310. * * 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
  25311. * * 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)`)
  25312. * * 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
  25313. * * 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
  25314. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25315. * * If you create a double-sided mesh, you can choose what parts of 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
  25316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25317. * @param name defines the name of the mesh to create
  25318. * @param options defines the options used to create the mesh
  25319. * @param scene defines the hosting scene
  25320. * @returns a new Mesh
  25321. */
  25322. static CreatePolyhedron(name: string, options: {
  25323. type?: number;
  25324. size?: number;
  25325. sizeX?: number;
  25326. sizeY?: number;
  25327. sizeZ?: number;
  25328. custom?: any;
  25329. faceUV?: Vector4[];
  25330. faceColors?: Color4[];
  25331. updatable?: boolean;
  25332. sideOrientation?: number;
  25333. }, scene: Scene): Mesh;
  25334. /**
  25335. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25336. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25337. * * 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`)
  25338. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25339. * * 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
  25340. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25341. * * If you create a double-sided mesh, you can choose what parts of 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
  25342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25343. * @param name defines the name of the mesh
  25344. * @param options defines the options used to create the mesh
  25345. * @param scene defines the hosting scene
  25346. * @returns a new Mesh
  25347. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25348. */
  25349. static CreateIcoSphere(name: string, options: {
  25350. radius?: number;
  25351. flat?: boolean;
  25352. subdivisions?: number;
  25353. sideOrientation?: number;
  25354. updatable?: boolean;
  25355. }, scene: Scene): Mesh;
  25356. /**
  25357. * Creates a decal mesh.
  25358. * Please consider using the same method from the MeshBuilder class instead.
  25359. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25360. * @param name defines the name of the mesh
  25361. * @param sourceMesh defines the mesh receiving the decal
  25362. * @param position sets the position of the decal in world coordinates
  25363. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25364. * @param size sets the decal scaling
  25365. * @param angle sets the angle to rotate the decal
  25366. * @returns a new Mesh
  25367. */
  25368. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25369. /**
  25370. * Prepare internal position array for software CPU skinning
  25371. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25372. */
  25373. setPositionsForCPUSkinning(): Float32Array;
  25374. /**
  25375. * Prepare internal normal array for software CPU skinning
  25376. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25377. */
  25378. setNormalsForCPUSkinning(): Float32Array;
  25379. /**
  25380. * Updates the vertex buffer by applying transformation from the bones
  25381. * @param skeleton defines the skeleton to apply to current mesh
  25382. * @returns the current mesh
  25383. */
  25384. applySkeleton(skeleton: Skeleton): Mesh;
  25385. /**
  25386. * 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
  25387. * @param meshes defines the list of meshes to scan
  25388. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25389. */
  25390. static MinMax(meshes: AbstractMesh[]): {
  25391. min: Vector3;
  25392. max: Vector3;
  25393. };
  25394. /**
  25395. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25396. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25397. * @returns a vector3
  25398. */
  25399. static Center(meshesOrMinMaxVector: {
  25400. min: Vector3;
  25401. max: Vector3;
  25402. } | AbstractMesh[]): Vector3;
  25403. /**
  25404. * Merge the array of meshes into a single mesh for performance reasons.
  25405. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25406. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25407. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25408. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25409. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25410. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25411. * @returns a new mesh
  25412. */
  25413. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25414. /** @hidden */
  25415. addInstance(instance: InstancedMesh): void;
  25416. /** @hidden */
  25417. removeInstance(instance: InstancedMesh): void;
  25418. }
  25419. }
  25420. declare module "babylonjs/Cameras/camera" {
  25421. import { SmartArray } from "babylonjs/Misc/smartArray";
  25422. import { Observable } from "babylonjs/Misc/observable";
  25423. import { Nullable } from "babylonjs/types";
  25424. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25425. import { Scene } from "babylonjs/scene";
  25426. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25427. import { Node } from "babylonjs/node";
  25428. import { Mesh } from "babylonjs/Meshes/mesh";
  25429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25430. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25431. import { Viewport } from "babylonjs/Maths/math.viewport";
  25432. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25433. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25434. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25435. import { Ray } from "babylonjs/Culling/ray";
  25436. /**
  25437. * This is the base class of all the camera used in the application.
  25438. * @see http://doc.babylonjs.com/features/cameras
  25439. */
  25440. export class Camera extends Node {
  25441. /** @hidden */
  25442. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25443. /**
  25444. * This is the default projection mode used by the cameras.
  25445. * It helps recreating a feeling of perspective and better appreciate depth.
  25446. * This is the best way to simulate real life cameras.
  25447. */
  25448. static readonly PERSPECTIVE_CAMERA: number;
  25449. /**
  25450. * This helps creating camera with an orthographic mode.
  25451. * 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.
  25452. */
  25453. static readonly ORTHOGRAPHIC_CAMERA: number;
  25454. /**
  25455. * This is the default FOV mode for perspective cameras.
  25456. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25457. */
  25458. static readonly FOVMODE_VERTICAL_FIXED: number;
  25459. /**
  25460. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25461. */
  25462. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25463. /**
  25464. * This specifies ther is no need for a camera rig.
  25465. * Basically only one eye is rendered corresponding to the camera.
  25466. */
  25467. static readonly RIG_MODE_NONE: number;
  25468. /**
  25469. * Simulates a camera Rig with one blue eye and one red eye.
  25470. * This can be use with 3d blue and red glasses.
  25471. */
  25472. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25473. /**
  25474. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25475. */
  25476. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25477. /**
  25478. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25479. */
  25480. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25481. /**
  25482. * Defines that both eyes of the camera will be rendered over under each other.
  25483. */
  25484. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25485. /**
  25486. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25487. */
  25488. static readonly RIG_MODE_VR: number;
  25489. /**
  25490. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25491. */
  25492. static readonly RIG_MODE_WEBVR: number;
  25493. /**
  25494. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25495. */
  25496. static readonly RIG_MODE_CUSTOM: number;
  25497. /**
  25498. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25499. */
  25500. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25501. /**
  25502. * Define the input manager associated with the camera.
  25503. */
  25504. inputs: CameraInputsManager<Camera>;
  25505. /** @hidden */
  25506. _position: Vector3;
  25507. /**
  25508. * Define the current local position of the camera in the scene
  25509. */
  25510. position: Vector3;
  25511. /**
  25512. * The vector the camera should consider as up.
  25513. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25514. */
  25515. upVector: Vector3;
  25516. /**
  25517. * Define the current limit on the left side for an orthographic camera
  25518. * In scene unit
  25519. */
  25520. orthoLeft: Nullable<number>;
  25521. /**
  25522. * Define the current limit on the right side for an orthographic camera
  25523. * In scene unit
  25524. */
  25525. orthoRight: Nullable<number>;
  25526. /**
  25527. * Define the current limit on the bottom side for an orthographic camera
  25528. * In scene unit
  25529. */
  25530. orthoBottom: Nullable<number>;
  25531. /**
  25532. * Define the current limit on the top side for an orthographic camera
  25533. * In scene unit
  25534. */
  25535. orthoTop: Nullable<number>;
  25536. /**
  25537. * Field Of View is set in Radians. (default is 0.8)
  25538. */
  25539. fov: number;
  25540. /**
  25541. * Define the minimum distance the camera can see from.
  25542. * This is important to note that the depth buffer are not infinite and the closer it starts
  25543. * the more your scene might encounter depth fighting issue.
  25544. */
  25545. minZ: number;
  25546. /**
  25547. * Define the maximum distance the camera can see to.
  25548. * This is important to note that the depth buffer are not infinite and the further it end
  25549. * the more your scene might encounter depth fighting issue.
  25550. */
  25551. maxZ: number;
  25552. /**
  25553. * Define the default inertia of the camera.
  25554. * This helps giving a smooth feeling to the camera movement.
  25555. */
  25556. inertia: number;
  25557. /**
  25558. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25559. */
  25560. mode: number;
  25561. /**
  25562. * Define wether the camera is intermediate.
  25563. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25564. */
  25565. isIntermediate: boolean;
  25566. /**
  25567. * Define the viewport of the camera.
  25568. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25569. */
  25570. viewport: Viewport;
  25571. /**
  25572. * Restricts the camera to viewing objects with the same layerMask.
  25573. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25574. */
  25575. layerMask: number;
  25576. /**
  25577. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25578. */
  25579. fovMode: number;
  25580. /**
  25581. * Rig mode of the camera.
  25582. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25583. * This is normally controlled byt the camera themselves as internal use.
  25584. */
  25585. cameraRigMode: number;
  25586. /**
  25587. * Defines the distance between both "eyes" in case of a RIG
  25588. */
  25589. interaxialDistance: number;
  25590. /**
  25591. * Defines if stereoscopic rendering is done side by side or over under.
  25592. */
  25593. isStereoscopicSideBySide: boolean;
  25594. /**
  25595. * 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
  25596. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25597. * else in the scene. (Eg. security camera)
  25598. *
  25599. * 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)
  25600. */
  25601. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25602. /**
  25603. * When set, the camera will render to this render target instead of the default canvas
  25604. *
  25605. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25606. */
  25607. outputRenderTarget: Nullable<RenderTargetTexture>;
  25608. /**
  25609. * Observable triggered when the camera view matrix has changed.
  25610. */
  25611. onViewMatrixChangedObservable: Observable<Camera>;
  25612. /**
  25613. * Observable triggered when the camera Projection matrix has changed.
  25614. */
  25615. onProjectionMatrixChangedObservable: Observable<Camera>;
  25616. /**
  25617. * Observable triggered when the inputs have been processed.
  25618. */
  25619. onAfterCheckInputsObservable: Observable<Camera>;
  25620. /**
  25621. * Observable triggered when reset has been called and applied to the camera.
  25622. */
  25623. onRestoreStateObservable: Observable<Camera>;
  25624. /** @hidden */
  25625. _cameraRigParams: any;
  25626. /** @hidden */
  25627. _rigCameras: Camera[];
  25628. /** @hidden */
  25629. _rigPostProcess: Nullable<PostProcess>;
  25630. protected _webvrViewMatrix: Matrix;
  25631. /** @hidden */
  25632. _skipRendering: boolean;
  25633. /** @hidden */
  25634. _projectionMatrix: Matrix;
  25635. /** @hidden */
  25636. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25637. /** @hidden */
  25638. _activeMeshes: SmartArray<AbstractMesh>;
  25639. protected _globalPosition: Vector3;
  25640. /** @hidden */
  25641. _computedViewMatrix: Matrix;
  25642. private _doNotComputeProjectionMatrix;
  25643. private _transformMatrix;
  25644. private _frustumPlanes;
  25645. private _refreshFrustumPlanes;
  25646. private _storedFov;
  25647. private _stateStored;
  25648. /**
  25649. * Instantiates a new camera object.
  25650. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25651. * @see http://doc.babylonjs.com/features/cameras
  25652. * @param name Defines the name of the camera in the scene
  25653. * @param position Defines the position of the camera
  25654. * @param scene Defines the scene the camera belongs too
  25655. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25656. */
  25657. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25658. /**
  25659. * Store current camera state (fov, position, etc..)
  25660. * @returns the camera
  25661. */
  25662. storeState(): Camera;
  25663. /**
  25664. * Restores the camera state values if it has been stored. You must call storeState() first
  25665. */
  25666. protected _restoreStateValues(): boolean;
  25667. /**
  25668. * Restored camera state. You must call storeState() first.
  25669. * @returns true if restored and false otherwise
  25670. */
  25671. restoreState(): boolean;
  25672. /**
  25673. * Gets the class name of the camera.
  25674. * @returns the class name
  25675. */
  25676. getClassName(): string;
  25677. /** @hidden */
  25678. readonly _isCamera: boolean;
  25679. /**
  25680. * Gets a string representation of the camera useful for debug purpose.
  25681. * @param fullDetails Defines that a more verboe level of logging is required
  25682. * @returns the string representation
  25683. */
  25684. toString(fullDetails?: boolean): string;
  25685. /**
  25686. * Gets the current world space position of the camera.
  25687. */
  25688. readonly globalPosition: Vector3;
  25689. /**
  25690. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25691. * @returns the active meshe list
  25692. */
  25693. getActiveMeshes(): SmartArray<AbstractMesh>;
  25694. /**
  25695. * Check wether a mesh is part of the current active mesh list of the camera
  25696. * @param mesh Defines the mesh to check
  25697. * @returns true if active, false otherwise
  25698. */
  25699. isActiveMesh(mesh: Mesh): boolean;
  25700. /**
  25701. * Is this camera ready to be used/rendered
  25702. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25703. * @return true if the camera is ready
  25704. */
  25705. isReady(completeCheck?: boolean): boolean;
  25706. /** @hidden */
  25707. _initCache(): void;
  25708. /** @hidden */
  25709. _updateCache(ignoreParentClass?: boolean): void;
  25710. /** @hidden */
  25711. _isSynchronized(): boolean;
  25712. /** @hidden */
  25713. _isSynchronizedViewMatrix(): boolean;
  25714. /** @hidden */
  25715. _isSynchronizedProjectionMatrix(): boolean;
  25716. /**
  25717. * Attach the input controls to a specific dom element to get the input from.
  25718. * @param element Defines the element the controls should be listened from
  25719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25720. */
  25721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25722. /**
  25723. * Detach the current controls from the specified dom element.
  25724. * @param element Defines the element to stop listening the inputs from
  25725. */
  25726. detachControl(element: HTMLElement): void;
  25727. /**
  25728. * Update the camera state according to the different inputs gathered during the frame.
  25729. */
  25730. update(): void;
  25731. /** @hidden */
  25732. _checkInputs(): void;
  25733. /** @hidden */
  25734. readonly rigCameras: Camera[];
  25735. /**
  25736. * Gets the post process used by the rig cameras
  25737. */
  25738. readonly rigPostProcess: Nullable<PostProcess>;
  25739. /**
  25740. * Internal, gets the first post proces.
  25741. * @returns the first post process to be run on this camera.
  25742. */
  25743. _getFirstPostProcess(): Nullable<PostProcess>;
  25744. private _cascadePostProcessesToRigCams;
  25745. /**
  25746. * Attach a post process to the camera.
  25747. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25748. * @param postProcess The post process to attach to the camera
  25749. * @param insertAt The position of the post process in case several of them are in use in the scene
  25750. * @returns the position the post process has been inserted at
  25751. */
  25752. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25753. /**
  25754. * Detach a post process to the camera.
  25755. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25756. * @param postProcess The post process to detach from the camera
  25757. */
  25758. detachPostProcess(postProcess: PostProcess): void;
  25759. /**
  25760. * Gets the current world matrix of the camera
  25761. */
  25762. getWorldMatrix(): Matrix;
  25763. /** @hidden */
  25764. _getViewMatrix(): Matrix;
  25765. /**
  25766. * Gets the current view matrix of the camera.
  25767. * @param force forces the camera to recompute the matrix without looking at the cached state
  25768. * @returns the view matrix
  25769. */
  25770. getViewMatrix(force?: boolean): Matrix;
  25771. /**
  25772. * Freeze the projection matrix.
  25773. * It will prevent the cache check of the camera projection compute and can speed up perf
  25774. * if no parameter of the camera are meant to change
  25775. * @param projection Defines manually a projection if necessary
  25776. */
  25777. freezeProjectionMatrix(projection?: Matrix): void;
  25778. /**
  25779. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25780. */
  25781. unfreezeProjectionMatrix(): void;
  25782. /**
  25783. * Gets the current projection matrix of the camera.
  25784. * @param force forces the camera to recompute the matrix without looking at the cached state
  25785. * @returns the projection matrix
  25786. */
  25787. getProjectionMatrix(force?: boolean): Matrix;
  25788. /**
  25789. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25790. * @returns a Matrix
  25791. */
  25792. getTransformationMatrix(): Matrix;
  25793. private _updateFrustumPlanes;
  25794. /**
  25795. * Checks if a cullable object (mesh...) is in the camera frustum
  25796. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25797. * @param target The object to check
  25798. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25799. * @returns true if the object is in frustum otherwise false
  25800. */
  25801. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25802. /**
  25803. * Checks if a cullable object (mesh...) is in the camera frustum
  25804. * Unlike isInFrustum this cheks the full bounding box
  25805. * @param target The object to check
  25806. * @returns true if the object is in frustum otherwise false
  25807. */
  25808. isCompletelyInFrustum(target: ICullable): boolean;
  25809. /**
  25810. * Gets a ray in the forward direction from the camera.
  25811. * @param length Defines the length of the ray to create
  25812. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25813. * @param origin Defines the start point of the ray which defaults to the camera position
  25814. * @returns the forward ray
  25815. */
  25816. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25817. /**
  25818. * Releases resources associated with this node.
  25819. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25820. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25821. */
  25822. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25823. /** @hidden */
  25824. _isLeftCamera: boolean;
  25825. /**
  25826. * Gets the left camera of a rig setup in case of Rigged Camera
  25827. */
  25828. readonly isLeftCamera: boolean;
  25829. /** @hidden */
  25830. _isRightCamera: boolean;
  25831. /**
  25832. * Gets the right camera of a rig setup in case of Rigged Camera
  25833. */
  25834. readonly isRightCamera: boolean;
  25835. /**
  25836. * Gets the left camera of a rig setup in case of Rigged Camera
  25837. */
  25838. readonly leftCamera: Nullable<FreeCamera>;
  25839. /**
  25840. * Gets the right camera of a rig setup in case of Rigged Camera
  25841. */
  25842. readonly rightCamera: Nullable<FreeCamera>;
  25843. /**
  25844. * Gets the left camera target of a rig setup in case of Rigged Camera
  25845. * @returns the target position
  25846. */
  25847. getLeftTarget(): Nullable<Vector3>;
  25848. /**
  25849. * Gets the right camera target of a rig setup in case of Rigged Camera
  25850. * @returns the target position
  25851. */
  25852. getRightTarget(): Nullable<Vector3>;
  25853. /**
  25854. * @hidden
  25855. */
  25856. setCameraRigMode(mode: number, rigParams: any): void;
  25857. /** @hidden */
  25858. static _setStereoscopicRigMode(camera: Camera): void;
  25859. /** @hidden */
  25860. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25861. /** @hidden */
  25862. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25863. /** @hidden */
  25864. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25865. /** @hidden */
  25866. _getVRProjectionMatrix(): Matrix;
  25867. protected _updateCameraRotationMatrix(): void;
  25868. protected _updateWebVRCameraRotationMatrix(): void;
  25869. /**
  25870. * This function MUST be overwritten by the different WebVR cameras available.
  25871. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25872. * @hidden
  25873. */
  25874. _getWebVRProjectionMatrix(): Matrix;
  25875. /**
  25876. * This function MUST be overwritten by the different WebVR cameras available.
  25877. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25878. * @hidden
  25879. */
  25880. _getWebVRViewMatrix(): Matrix;
  25881. /** @hidden */
  25882. setCameraRigParameter(name: string, value: any): void;
  25883. /**
  25884. * needs to be overridden by children so sub has required properties to be copied
  25885. * @hidden
  25886. */
  25887. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25888. /**
  25889. * May need to be overridden by children
  25890. * @hidden
  25891. */
  25892. _updateRigCameras(): void;
  25893. /** @hidden */
  25894. _setupInputs(): void;
  25895. /**
  25896. * Serialiaze the camera setup to a json represention
  25897. * @returns the JSON representation
  25898. */
  25899. serialize(): any;
  25900. /**
  25901. * Clones the current camera.
  25902. * @param name The cloned camera name
  25903. * @returns the cloned camera
  25904. */
  25905. clone(name: string): Camera;
  25906. /**
  25907. * Gets the direction of the camera relative to a given local axis.
  25908. * @param localAxis Defines the reference axis to provide a relative direction.
  25909. * @return the direction
  25910. */
  25911. getDirection(localAxis: Vector3): Vector3;
  25912. /**
  25913. * Returns the current camera absolute rotation
  25914. */
  25915. readonly absoluteRotation: Quaternion;
  25916. /**
  25917. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25918. * @param localAxis Defines the reference axis to provide a relative direction.
  25919. * @param result Defines the vector to store the result in
  25920. */
  25921. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25922. /**
  25923. * Gets a camera constructor for a given camera type
  25924. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25925. * @param name The name of the camera the result will be able to instantiate
  25926. * @param scene The scene the result will construct the camera in
  25927. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25928. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25929. * @returns a factory method to construc the camera
  25930. */
  25931. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25932. /**
  25933. * Compute the world matrix of the camera.
  25934. * @returns the camera workd matrix
  25935. */
  25936. computeWorldMatrix(): Matrix;
  25937. /**
  25938. * Parse a JSON and creates the camera from the parsed information
  25939. * @param parsedCamera The JSON to parse
  25940. * @param scene The scene to instantiate the camera in
  25941. * @returns the newly constructed camera
  25942. */
  25943. static Parse(parsedCamera: any, scene: Scene): Camera;
  25944. }
  25945. }
  25946. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25947. import { Nullable } from "babylonjs/types";
  25948. import { Scene } from "babylonjs/scene";
  25949. import { Vector4 } from "babylonjs/Maths/math.vector";
  25950. import { Mesh } from "babylonjs/Meshes/mesh";
  25951. /**
  25952. * Class containing static functions to help procedurally build meshes
  25953. */
  25954. export class DiscBuilder {
  25955. /**
  25956. * Creates a plane polygonal mesh. By default, this is a disc
  25957. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25958. * * 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
  25959. * * 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
  25960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25963. * @param name defines the name of the mesh
  25964. * @param options defines the options used to create the mesh
  25965. * @param scene defines the hosting scene
  25966. * @returns the plane polygonal mesh
  25967. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25968. */
  25969. static CreateDisc(name: string, options: {
  25970. radius?: number;
  25971. tessellation?: number;
  25972. arc?: number;
  25973. updatable?: boolean;
  25974. sideOrientation?: number;
  25975. frontUVs?: Vector4;
  25976. backUVs?: Vector4;
  25977. }, scene?: Nullable<Scene>): Mesh;
  25978. }
  25979. }
  25980. declare module "babylonjs/Particles/solidParticleSystem" {
  25981. import { Vector3 } from "babylonjs/Maths/math.vector";
  25982. import { Mesh } from "babylonjs/Meshes/mesh";
  25983. import { Scene, IDisposable } from "babylonjs/scene";
  25984. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25985. /**
  25986. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25987. *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.
  25988. * The SPS is also a particle system. It provides some methods to manage the particles.
  25989. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25990. *
  25991. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25992. */
  25993. export class SolidParticleSystem implements IDisposable {
  25994. /**
  25995. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25996. * Example : var p = SPS.particles[i];
  25997. */
  25998. particles: SolidParticle[];
  25999. /**
  26000. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26001. */
  26002. nbParticles: number;
  26003. /**
  26004. * If the particles must ever face the camera (default false). Useful for planar particles.
  26005. */
  26006. billboard: boolean;
  26007. /**
  26008. * Recompute normals when adding a shape
  26009. */
  26010. recomputeNormals: boolean;
  26011. /**
  26012. * This a counter ofr your own usage. It's not set by any SPS functions.
  26013. */
  26014. counter: number;
  26015. /**
  26016. * The SPS name. This name is also given to the underlying mesh.
  26017. */
  26018. name: string;
  26019. /**
  26020. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26021. */
  26022. mesh: Mesh;
  26023. /**
  26024. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26025. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26026. */
  26027. vars: any;
  26028. /**
  26029. * This array is populated when the SPS is set as 'pickable'.
  26030. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26031. * Each element of this array is an object `{idx: int, faceId: int}`.
  26032. * `idx` is the picked particle index in the `SPS.particles` array
  26033. * `faceId` is the picked face index counted within this particle.
  26034. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26035. */
  26036. pickedParticles: {
  26037. idx: number;
  26038. faceId: number;
  26039. }[];
  26040. /**
  26041. * This array is populated when `enableDepthSort` is set to true.
  26042. * Each element of this array is an instance of the class DepthSortedParticle.
  26043. */
  26044. depthSortedParticles: DepthSortedParticle[];
  26045. /**
  26046. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26047. * @hidden
  26048. */
  26049. _bSphereOnly: boolean;
  26050. /**
  26051. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26052. * @hidden
  26053. */
  26054. _bSphereRadiusFactor: number;
  26055. private _scene;
  26056. private _positions;
  26057. private _indices;
  26058. private _normals;
  26059. private _colors;
  26060. private _uvs;
  26061. private _indices32;
  26062. private _positions32;
  26063. private _normals32;
  26064. private _fixedNormal32;
  26065. private _colors32;
  26066. private _uvs32;
  26067. private _index;
  26068. private _updatable;
  26069. private _pickable;
  26070. private _isVisibilityBoxLocked;
  26071. private _alwaysVisible;
  26072. private _depthSort;
  26073. private _shapeCounter;
  26074. private _copy;
  26075. private _color;
  26076. private _computeParticleColor;
  26077. private _computeParticleTexture;
  26078. private _computeParticleRotation;
  26079. private _computeParticleVertex;
  26080. private _computeBoundingBox;
  26081. private _depthSortParticles;
  26082. private _camera;
  26083. private _mustUnrotateFixedNormals;
  26084. private _particlesIntersect;
  26085. private _needs32Bits;
  26086. /**
  26087. * Creates a SPS (Solid Particle System) object.
  26088. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26089. * @param scene (Scene) is the scene in which the SPS is added.
  26090. * @param options defines the options of the sps e.g.
  26091. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26092. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26093. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26094. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26095. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26096. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26097. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26098. */
  26099. constructor(name: string, scene: Scene, options?: {
  26100. updatable?: boolean;
  26101. isPickable?: boolean;
  26102. enableDepthSort?: boolean;
  26103. particleIntersection?: boolean;
  26104. boundingSphereOnly?: boolean;
  26105. bSphereRadiusFactor?: number;
  26106. });
  26107. /**
  26108. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26109. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26110. * @returns the created mesh
  26111. */
  26112. buildMesh(): Mesh;
  26113. /**
  26114. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26115. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26116. * Thus the particles generated from `digest()` have their property `position` set yet.
  26117. * @param mesh ( Mesh ) is the mesh to be digested
  26118. * @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
  26119. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26120. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26121. * @returns the current SPS
  26122. */
  26123. digest(mesh: Mesh, options?: {
  26124. facetNb?: number;
  26125. number?: number;
  26126. delta?: number;
  26127. }): SolidParticleSystem;
  26128. private _unrotateFixedNormals;
  26129. private _resetCopy;
  26130. private _meshBuilder;
  26131. private _posToShape;
  26132. private _uvsToShapeUV;
  26133. private _addParticle;
  26134. /**
  26135. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26136. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26137. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26138. * @param nb (positive integer) the number of particles to be created from this model
  26139. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26140. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26141. * @returns the number of shapes in the system
  26142. */
  26143. addShape(mesh: Mesh, nb: number, options?: {
  26144. positionFunction?: any;
  26145. vertexFunction?: any;
  26146. }): number;
  26147. private _rebuildParticle;
  26148. /**
  26149. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26150. * @returns the SPS.
  26151. */
  26152. rebuildMesh(): SolidParticleSystem;
  26153. /**
  26154. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26155. * This method calls `updateParticle()` for each particle of the SPS.
  26156. * For an animated SPS, it is usually called within the render loop.
  26157. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26158. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26159. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26160. * @returns the SPS.
  26161. */
  26162. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26163. /**
  26164. * Disposes the SPS.
  26165. */
  26166. dispose(): void;
  26167. /**
  26168. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26169. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26170. * @returns the SPS.
  26171. */
  26172. refreshVisibleSize(): SolidParticleSystem;
  26173. /**
  26174. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26175. * @param size the size (float) of the visibility box
  26176. * note : this doesn't lock the SPS mesh bounding box.
  26177. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26178. */
  26179. setVisibilityBox(size: number): void;
  26180. /**
  26181. * Gets whether the SPS as always visible or not
  26182. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26183. */
  26184. /**
  26185. * Sets the SPS as always visible or not
  26186. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26187. */
  26188. isAlwaysVisible: boolean;
  26189. /**
  26190. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26192. */
  26193. /**
  26194. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26196. */
  26197. isVisibilityBoxLocked: boolean;
  26198. /**
  26199. * Tells to `setParticles()` to compute the particle rotations or not.
  26200. * Default value : true. The SPS is faster when it's set to false.
  26201. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26202. */
  26203. /**
  26204. * Gets if `setParticles()` computes the particle rotations or not.
  26205. * Default value : true. The SPS is faster when it's set to false.
  26206. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26207. */
  26208. computeParticleRotation: boolean;
  26209. /**
  26210. * Tells to `setParticles()` to compute the particle colors or not.
  26211. * Default value : true. The SPS is faster when it's set to false.
  26212. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26213. */
  26214. /**
  26215. * Gets if `setParticles()` computes the particle colors or not.
  26216. * Default value : true. The SPS is faster when it's set to false.
  26217. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26218. */
  26219. computeParticleColor: boolean;
  26220. /**
  26221. * Gets if `setParticles()` computes the particle textures or not.
  26222. * Default value : true. The SPS is faster when it's set to false.
  26223. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26224. */
  26225. computeParticleTexture: boolean;
  26226. /**
  26227. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26228. * Default value : false. The SPS is faster when it's set to false.
  26229. * Note : the particle custom vertex positions aren't stored values.
  26230. */
  26231. /**
  26232. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26233. * Default value : false. The SPS is faster when it's set to false.
  26234. * Note : the particle custom vertex positions aren't stored values.
  26235. */
  26236. computeParticleVertex: boolean;
  26237. /**
  26238. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26239. */
  26240. /**
  26241. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26242. */
  26243. computeBoundingBox: boolean;
  26244. /**
  26245. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26246. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26247. * Default : `true`
  26248. */
  26249. /**
  26250. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26251. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26252. * Default : `true`
  26253. */
  26254. depthSortParticles: boolean;
  26255. /**
  26256. * This function does nothing. It may be overwritten to set all the particle first values.
  26257. * The SPS doesn't call this function, you may have to call it by your own.
  26258. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26259. */
  26260. initParticles(): void;
  26261. /**
  26262. * This function does nothing. It may be overwritten to recycle a particle.
  26263. * The SPS doesn't call this function, you may have to call it by your own.
  26264. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26265. * @param particle The particle to recycle
  26266. * @returns the recycled particle
  26267. */
  26268. recycleParticle(particle: SolidParticle): SolidParticle;
  26269. /**
  26270. * Updates a particle : this function should be overwritten by the user.
  26271. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26272. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26273. * @example : just set a particle position or velocity and recycle conditions
  26274. * @param particle The particle to update
  26275. * @returns the updated particle
  26276. */
  26277. updateParticle(particle: SolidParticle): SolidParticle;
  26278. /**
  26279. * Updates a vertex of a particle : it can be overwritten by the user.
  26280. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26281. * @param particle the current particle
  26282. * @param vertex the current index of the current particle
  26283. * @param pt the index of the current vertex in the particle shape
  26284. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26285. * @example : just set a vertex particle position
  26286. * @returns the updated vertex
  26287. */
  26288. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26289. /**
  26290. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26291. * This does nothing and may be overwritten by the user.
  26292. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26293. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26294. * @param update the boolean update value actually passed to setParticles()
  26295. */
  26296. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26297. /**
  26298. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26299. * This will be passed three parameters.
  26300. * This does nothing and may be overwritten by the user.
  26301. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26302. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26303. * @param update the boolean update value actually passed to setParticles()
  26304. */
  26305. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26306. }
  26307. }
  26308. declare module "babylonjs/Particles/solidParticle" {
  26309. import { Nullable } from "babylonjs/types";
  26310. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26311. import { Color4 } from "babylonjs/Maths/math.color";
  26312. import { Mesh } from "babylonjs/Meshes/mesh";
  26313. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26314. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26315. import { Plane } from "babylonjs/Maths/math.plane";
  26316. /**
  26317. * Represents one particle of a solid particle system.
  26318. */
  26319. export class SolidParticle {
  26320. /**
  26321. * particle global index
  26322. */
  26323. idx: number;
  26324. /**
  26325. * The color of the particle
  26326. */
  26327. color: Nullable<Color4>;
  26328. /**
  26329. * The world space position of the particle.
  26330. */
  26331. position: Vector3;
  26332. /**
  26333. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26334. */
  26335. rotation: Vector3;
  26336. /**
  26337. * The world space rotation quaternion of the particle.
  26338. */
  26339. rotationQuaternion: Nullable<Quaternion>;
  26340. /**
  26341. * The scaling of the particle.
  26342. */
  26343. scaling: Vector3;
  26344. /**
  26345. * The uvs of the particle.
  26346. */
  26347. uvs: Vector4;
  26348. /**
  26349. * The current speed of the particle.
  26350. */
  26351. velocity: Vector3;
  26352. /**
  26353. * The pivot point in the particle local space.
  26354. */
  26355. pivot: Vector3;
  26356. /**
  26357. * Must the particle be translated from its pivot point in its local space ?
  26358. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26359. * Default : false
  26360. */
  26361. translateFromPivot: boolean;
  26362. /**
  26363. * Is the particle active or not ?
  26364. */
  26365. alive: boolean;
  26366. /**
  26367. * Is the particle visible or not ?
  26368. */
  26369. isVisible: boolean;
  26370. /**
  26371. * Index of this particle in the global "positions" array (Internal use)
  26372. * @hidden
  26373. */
  26374. _pos: number;
  26375. /**
  26376. * @hidden Index of this particle in the global "indices" array (Internal use)
  26377. */
  26378. _ind: number;
  26379. /**
  26380. * @hidden ModelShape of this particle (Internal use)
  26381. */
  26382. _model: ModelShape;
  26383. /**
  26384. * ModelShape id of this particle
  26385. */
  26386. shapeId: number;
  26387. /**
  26388. * Index of the particle in its shape id
  26389. */
  26390. idxInShape: number;
  26391. /**
  26392. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26393. */
  26394. _modelBoundingInfo: BoundingInfo;
  26395. /**
  26396. * @hidden Particle BoundingInfo object (Internal use)
  26397. */
  26398. _boundingInfo: BoundingInfo;
  26399. /**
  26400. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26401. */
  26402. _sps: SolidParticleSystem;
  26403. /**
  26404. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26405. */
  26406. _stillInvisible: boolean;
  26407. /**
  26408. * @hidden Last computed particle rotation matrix
  26409. */
  26410. _rotationMatrix: number[];
  26411. /**
  26412. * Parent particle Id, if any.
  26413. * Default null.
  26414. */
  26415. parentId: Nullable<number>;
  26416. /**
  26417. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26418. * The possible values are :
  26419. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26420. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26421. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26422. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26423. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26424. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26425. * */
  26426. cullingStrategy: number;
  26427. /**
  26428. * @hidden Internal global position in the SPS.
  26429. */
  26430. _globalPosition: Vector3;
  26431. /**
  26432. * Creates a Solid Particle object.
  26433. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26434. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26435. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26436. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26437. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26438. * @param shapeId (integer) is the model shape identifier in the SPS.
  26439. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26440. * @param sps defines the sps it is associated to
  26441. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26442. */
  26443. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26444. /**
  26445. * Legacy support, changed scale to scaling
  26446. */
  26447. /**
  26448. * Legacy support, changed scale to scaling
  26449. */
  26450. scale: Vector3;
  26451. /**
  26452. * Legacy support, changed quaternion to rotationQuaternion
  26453. */
  26454. /**
  26455. * Legacy support, changed quaternion to rotationQuaternion
  26456. */
  26457. quaternion: Nullable<Quaternion>;
  26458. /**
  26459. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26460. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26461. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26462. * @returns true if it intersects
  26463. */
  26464. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26465. /**
  26466. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26467. * A particle is in the frustum if its bounding box intersects the frustum
  26468. * @param frustumPlanes defines the frustum to test
  26469. * @returns true if the particle is in the frustum planes
  26470. */
  26471. isInFrustum(frustumPlanes: Plane[]): boolean;
  26472. /**
  26473. * get the rotation matrix of the particle
  26474. * @hidden
  26475. */
  26476. getRotationMatrix(m: Matrix): void;
  26477. }
  26478. /**
  26479. * Represents the shape of the model used by one particle of a solid particle system.
  26480. * SPS internal tool, don't use it manually.
  26481. */
  26482. export class ModelShape {
  26483. /**
  26484. * The shape id
  26485. * @hidden
  26486. */
  26487. shapeID: number;
  26488. /**
  26489. * flat array of model positions (internal use)
  26490. * @hidden
  26491. */
  26492. _shape: Vector3[];
  26493. /**
  26494. * flat array of model UVs (internal use)
  26495. * @hidden
  26496. */
  26497. _shapeUV: number[];
  26498. /**
  26499. * length of the shape in the model indices array (internal use)
  26500. * @hidden
  26501. */
  26502. _indicesLength: number;
  26503. /**
  26504. * Custom position function (internal use)
  26505. * @hidden
  26506. */
  26507. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26508. /**
  26509. * Custom vertex function (internal use)
  26510. * @hidden
  26511. */
  26512. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26513. /**
  26514. * 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.
  26515. * SPS internal tool, don't use it manually.
  26516. * @hidden
  26517. */
  26518. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26519. }
  26520. /**
  26521. * Represents a Depth Sorted Particle in the solid particle system.
  26522. */
  26523. export class DepthSortedParticle {
  26524. /**
  26525. * Index of the particle in the "indices" array
  26526. */
  26527. ind: number;
  26528. /**
  26529. * Length of the particle shape in the "indices" array
  26530. */
  26531. indicesLength: number;
  26532. /**
  26533. * Squared distance from the particle to the camera
  26534. */
  26535. sqDistance: number;
  26536. }
  26537. }
  26538. declare module "babylonjs/Collisions/meshCollisionData" {
  26539. import { Collider } from "babylonjs/Collisions/collider";
  26540. import { Vector3 } from "babylonjs/Maths/math.vector";
  26541. import { Nullable } from "babylonjs/types";
  26542. import { Observer } from "babylonjs/Misc/observable";
  26543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26544. /**
  26545. * @hidden
  26546. */
  26547. export class _MeshCollisionData {
  26548. _checkCollisions: boolean;
  26549. _collisionMask: number;
  26550. _collisionGroup: number;
  26551. _collider: Nullable<Collider>;
  26552. _oldPositionForCollisions: Vector3;
  26553. _diffPositionForCollisions: Vector3;
  26554. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26555. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26556. }
  26557. }
  26558. declare module "babylonjs/Meshes/abstractMesh" {
  26559. import { Observable } from "babylonjs/Misc/observable";
  26560. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26561. import { Camera } from "babylonjs/Cameras/camera";
  26562. import { Scene, IDisposable } from "babylonjs/scene";
  26563. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26564. import { Node } from "babylonjs/node";
  26565. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26566. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26567. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26568. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26569. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26570. import { Material } from "babylonjs/Materials/material";
  26571. import { Light } from "babylonjs/Lights/light";
  26572. import { Skeleton } from "babylonjs/Bones/skeleton";
  26573. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26574. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26575. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26576. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26577. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26578. import { Plane } from "babylonjs/Maths/math.plane";
  26579. import { Ray } from "babylonjs/Culling/ray";
  26580. import { Collider } from "babylonjs/Collisions/collider";
  26581. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26582. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26583. /** @hidden */
  26584. class _FacetDataStorage {
  26585. facetPositions: Vector3[];
  26586. facetNormals: Vector3[];
  26587. facetPartitioning: number[][];
  26588. facetNb: number;
  26589. partitioningSubdivisions: number;
  26590. partitioningBBoxRatio: number;
  26591. facetDataEnabled: boolean;
  26592. facetParameters: any;
  26593. bbSize: Vector3;
  26594. subDiv: {
  26595. max: number;
  26596. X: number;
  26597. Y: number;
  26598. Z: number;
  26599. };
  26600. facetDepthSort: boolean;
  26601. facetDepthSortEnabled: boolean;
  26602. depthSortedIndices: IndicesArray;
  26603. depthSortedFacets: {
  26604. ind: number;
  26605. sqDistance: number;
  26606. }[];
  26607. facetDepthSortFunction: (f1: {
  26608. ind: number;
  26609. sqDistance: number;
  26610. }, f2: {
  26611. ind: number;
  26612. sqDistance: number;
  26613. }) => number;
  26614. facetDepthSortFrom: Vector3;
  26615. facetDepthSortOrigin: Vector3;
  26616. invertedMatrix: Matrix;
  26617. }
  26618. /**
  26619. * @hidden
  26620. **/
  26621. class _InternalAbstractMeshDataInfo {
  26622. _hasVertexAlpha: boolean;
  26623. _useVertexColors: boolean;
  26624. _numBoneInfluencers: number;
  26625. _applyFog: boolean;
  26626. _receiveShadows: boolean;
  26627. _facetData: _FacetDataStorage;
  26628. _visibility: number;
  26629. _skeleton: Nullable<Skeleton>;
  26630. _layerMask: number;
  26631. _computeBonesUsingShaders: boolean;
  26632. _isActive: boolean;
  26633. _onlyForInstances: boolean;
  26634. _isActiveIntermediate: boolean;
  26635. _onlyForInstancesIntermediate: boolean;
  26636. }
  26637. /**
  26638. * Class used to store all common mesh properties
  26639. */
  26640. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26641. /** No occlusion */
  26642. static OCCLUSION_TYPE_NONE: number;
  26643. /** Occlusion set to optimisitic */
  26644. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26645. /** Occlusion set to strict */
  26646. static OCCLUSION_TYPE_STRICT: number;
  26647. /** Use an accurante occlusion algorithm */
  26648. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26649. /** Use a conservative occlusion algorithm */
  26650. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26651. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26652. * Test order :
  26653. * Is the bounding sphere outside the frustum ?
  26654. * If not, are the bounding box vertices outside the frustum ?
  26655. * It not, then the cullable object is in the frustum.
  26656. */
  26657. static readonly CULLINGSTRATEGY_STANDARD: number;
  26658. /** Culling strategy : Bounding Sphere Only.
  26659. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26660. * It's also less accurate than the standard because some not visible objects can still be selected.
  26661. * Test : is the bounding sphere outside the frustum ?
  26662. * If not, then the cullable object is in the frustum.
  26663. */
  26664. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26665. /** Culling strategy : Optimistic Inclusion.
  26666. * This in an inclusion test first, then the standard exclusion test.
  26667. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26668. * 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.
  26669. * Anyway, it's as accurate as the standard strategy.
  26670. * Test :
  26671. * Is the cullable object bounding sphere center in the frustum ?
  26672. * If not, apply the default culling strategy.
  26673. */
  26674. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26675. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26676. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26677. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26678. * 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.
  26679. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26680. * Test :
  26681. * Is the cullable object bounding sphere center in the frustum ?
  26682. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26683. */
  26684. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26685. /**
  26686. * No billboard
  26687. */
  26688. static readonly BILLBOARDMODE_NONE: number;
  26689. /** Billboard on X axis */
  26690. static readonly BILLBOARDMODE_X: number;
  26691. /** Billboard on Y axis */
  26692. static readonly BILLBOARDMODE_Y: number;
  26693. /** Billboard on Z axis */
  26694. static readonly BILLBOARDMODE_Z: number;
  26695. /** Billboard on all axes */
  26696. static readonly BILLBOARDMODE_ALL: number;
  26697. /** Billboard on using position instead of orientation */
  26698. static readonly BILLBOARDMODE_USE_POSITION: number;
  26699. /** @hidden */
  26700. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26701. /**
  26702. * The culling strategy to use to check whether the mesh must be rendered or not.
  26703. * This value can be changed at any time and will be used on the next render mesh selection.
  26704. * The possible values are :
  26705. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26706. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26707. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26708. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26709. * Please read each static variable documentation to get details about the culling process.
  26710. * */
  26711. cullingStrategy: number;
  26712. /**
  26713. * Gets the number of facets in the mesh
  26714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26715. */
  26716. readonly facetNb: number;
  26717. /**
  26718. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26720. */
  26721. partitioningSubdivisions: number;
  26722. /**
  26723. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26724. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26726. */
  26727. partitioningBBoxRatio: number;
  26728. /**
  26729. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26730. * Works only for updatable meshes.
  26731. * Doesn't work with multi-materials
  26732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26733. */
  26734. mustDepthSortFacets: boolean;
  26735. /**
  26736. * The location (Vector3) where the facet depth sort must be computed from.
  26737. * By default, the active camera position.
  26738. * Used only when facet depth sort is enabled
  26739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26740. */
  26741. facetDepthSortFrom: Vector3;
  26742. /**
  26743. * gets a boolean indicating if facetData is enabled
  26744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26745. */
  26746. readonly isFacetDataEnabled: boolean;
  26747. /** @hidden */
  26748. _updateNonUniformScalingState(value: boolean): boolean;
  26749. /**
  26750. * An event triggered when this mesh collides with another one
  26751. */
  26752. onCollideObservable: Observable<AbstractMesh>;
  26753. /** Set a function to call when this mesh collides with another one */
  26754. onCollide: () => void;
  26755. /**
  26756. * An event triggered when the collision's position changes
  26757. */
  26758. onCollisionPositionChangeObservable: Observable<Vector3>;
  26759. /** Set a function to call when the collision's position changes */
  26760. onCollisionPositionChange: () => void;
  26761. /**
  26762. * An event triggered when material is changed
  26763. */
  26764. onMaterialChangedObservable: Observable<AbstractMesh>;
  26765. /**
  26766. * Gets or sets the orientation for POV movement & rotation
  26767. */
  26768. definedFacingForward: boolean;
  26769. /** @hidden */
  26770. _occlusionQuery: Nullable<WebGLQuery>;
  26771. /** @hidden */
  26772. _renderingGroup: Nullable<RenderingGroup>;
  26773. /**
  26774. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26775. */
  26776. /**
  26777. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26778. */
  26779. visibility: number;
  26780. /** Gets or sets the alpha index used to sort transparent meshes
  26781. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26782. */
  26783. alphaIndex: number;
  26784. /**
  26785. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26786. */
  26787. isVisible: boolean;
  26788. /**
  26789. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26790. */
  26791. isPickable: boolean;
  26792. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26793. showSubMeshesBoundingBox: boolean;
  26794. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26795. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26796. */
  26797. isBlocker: boolean;
  26798. /**
  26799. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26800. */
  26801. enablePointerMoveEvents: boolean;
  26802. /**
  26803. * Specifies the rendering group id for this mesh (0 by default)
  26804. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26805. */
  26806. renderingGroupId: number;
  26807. private _material;
  26808. /** Gets or sets current material */
  26809. material: Nullable<Material>;
  26810. /**
  26811. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26812. * @see http://doc.babylonjs.com/babylon101/shadows
  26813. */
  26814. receiveShadows: boolean;
  26815. /** Defines color to use when rendering outline */
  26816. outlineColor: Color3;
  26817. /** Define width to use when rendering outline */
  26818. outlineWidth: number;
  26819. /** Defines color to use when rendering overlay */
  26820. overlayColor: Color3;
  26821. /** Defines alpha to use when rendering overlay */
  26822. overlayAlpha: number;
  26823. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26824. hasVertexAlpha: boolean;
  26825. /** 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) */
  26826. useVertexColors: boolean;
  26827. /**
  26828. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26829. */
  26830. computeBonesUsingShaders: boolean;
  26831. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26832. numBoneInfluencers: number;
  26833. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26834. applyFog: boolean;
  26835. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26836. useOctreeForRenderingSelection: boolean;
  26837. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26838. useOctreeForPicking: boolean;
  26839. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26840. useOctreeForCollisions: boolean;
  26841. /**
  26842. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26843. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26844. */
  26845. layerMask: number;
  26846. /**
  26847. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26848. */
  26849. alwaysSelectAsActiveMesh: boolean;
  26850. /**
  26851. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26852. */
  26853. doNotSyncBoundingInfo: boolean;
  26854. /**
  26855. * Gets or sets the current action manager
  26856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26857. */
  26858. actionManager: Nullable<AbstractActionManager>;
  26859. private _meshCollisionData;
  26860. /**
  26861. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26862. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26863. */
  26864. ellipsoid: Vector3;
  26865. /**
  26866. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26867. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26868. */
  26869. ellipsoidOffset: Vector3;
  26870. /**
  26871. * Gets or sets a collision mask used to mask collisions (default is -1).
  26872. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26873. */
  26874. collisionMask: number;
  26875. /**
  26876. * Gets or sets the current collision group mask (-1 by default).
  26877. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26878. */
  26879. collisionGroup: number;
  26880. /**
  26881. * Defines edge width used when edgesRenderer is enabled
  26882. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26883. */
  26884. edgesWidth: number;
  26885. /**
  26886. * Defines edge color used when edgesRenderer is enabled
  26887. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26888. */
  26889. edgesColor: Color4;
  26890. /** @hidden */
  26891. _edgesRenderer: Nullable<IEdgesRenderer>;
  26892. /** @hidden */
  26893. _masterMesh: Nullable<AbstractMesh>;
  26894. /** @hidden */
  26895. _boundingInfo: Nullable<BoundingInfo>;
  26896. /** @hidden */
  26897. _renderId: number;
  26898. /**
  26899. * Gets or sets the list of subMeshes
  26900. * @see http://doc.babylonjs.com/how_to/multi_materials
  26901. */
  26902. subMeshes: SubMesh[];
  26903. /** @hidden */
  26904. _intersectionsInProgress: AbstractMesh[];
  26905. /** @hidden */
  26906. _unIndexed: boolean;
  26907. /** @hidden */
  26908. _lightSources: Light[];
  26909. /** Gets the list of lights affecting that mesh */
  26910. readonly lightSources: Light[];
  26911. /** @hidden */
  26912. readonly _positions: Nullable<Vector3[]>;
  26913. /** @hidden */
  26914. _waitingData: {
  26915. lods: Nullable<any>;
  26916. actions: Nullable<any>;
  26917. freezeWorldMatrix: Nullable<boolean>;
  26918. };
  26919. /** @hidden */
  26920. _bonesTransformMatrices: Nullable<Float32Array>;
  26921. /** @hidden */
  26922. _transformMatrixTexture: Nullable<RawTexture>;
  26923. /**
  26924. * Gets or sets a skeleton to apply skining transformations
  26925. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26926. */
  26927. skeleton: Nullable<Skeleton>;
  26928. /**
  26929. * An event triggered when the mesh is rebuilt.
  26930. */
  26931. onRebuildObservable: Observable<AbstractMesh>;
  26932. /**
  26933. * Creates a new AbstractMesh
  26934. * @param name defines the name of the mesh
  26935. * @param scene defines the hosting scene
  26936. */
  26937. constructor(name: string, scene?: Nullable<Scene>);
  26938. /**
  26939. * Returns the string "AbstractMesh"
  26940. * @returns "AbstractMesh"
  26941. */
  26942. getClassName(): string;
  26943. /**
  26944. * Gets a string representation of the current mesh
  26945. * @param fullDetails defines a boolean indicating if full details must be included
  26946. * @returns a string representation of the current mesh
  26947. */
  26948. toString(fullDetails?: boolean): string;
  26949. /**
  26950. * @hidden
  26951. */
  26952. protected _getEffectiveParent(): Nullable<Node>;
  26953. /** @hidden */
  26954. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26955. /** @hidden */
  26956. _rebuild(): void;
  26957. /** @hidden */
  26958. _resyncLightSources(): void;
  26959. /** @hidden */
  26960. _resyncLighSource(light: Light): void;
  26961. /** @hidden */
  26962. _unBindEffect(): void;
  26963. /** @hidden */
  26964. _removeLightSource(light: Light, dispose: boolean): void;
  26965. private _markSubMeshesAsDirty;
  26966. /** @hidden */
  26967. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26968. /** @hidden */
  26969. _markSubMeshesAsAttributesDirty(): void;
  26970. /** @hidden */
  26971. _markSubMeshesAsMiscDirty(): void;
  26972. /**
  26973. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26974. */
  26975. scaling: Vector3;
  26976. /**
  26977. * Returns true if the mesh is blocked. Implemented by child classes
  26978. */
  26979. readonly isBlocked: boolean;
  26980. /**
  26981. * Returns the mesh itself by default. Implemented by child classes
  26982. * @param camera defines the camera to use to pick the right LOD level
  26983. * @returns the currentAbstractMesh
  26984. */
  26985. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26986. /**
  26987. * Returns 0 by default. Implemented by child classes
  26988. * @returns an integer
  26989. */
  26990. getTotalVertices(): number;
  26991. /**
  26992. * Returns a positive integer : the total number of indices in this mesh geometry.
  26993. * @returns the numner of indices or zero if the mesh has no geometry.
  26994. */
  26995. getTotalIndices(): number;
  26996. /**
  26997. * Returns null by default. Implemented by child classes
  26998. * @returns null
  26999. */
  27000. getIndices(): Nullable<IndicesArray>;
  27001. /**
  27002. * Returns the array of the requested vertex data kind. Implemented by child classes
  27003. * @param kind defines the vertex data kind to use
  27004. * @returns null
  27005. */
  27006. getVerticesData(kind: string): Nullable<FloatArray>;
  27007. /**
  27008. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27009. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27010. * Note that a new underlying VertexBuffer object is created each call.
  27011. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27012. * @param kind defines vertex data kind:
  27013. * * VertexBuffer.PositionKind
  27014. * * VertexBuffer.UVKind
  27015. * * VertexBuffer.UV2Kind
  27016. * * VertexBuffer.UV3Kind
  27017. * * VertexBuffer.UV4Kind
  27018. * * VertexBuffer.UV5Kind
  27019. * * VertexBuffer.UV6Kind
  27020. * * VertexBuffer.ColorKind
  27021. * * VertexBuffer.MatricesIndicesKind
  27022. * * VertexBuffer.MatricesIndicesExtraKind
  27023. * * VertexBuffer.MatricesWeightsKind
  27024. * * VertexBuffer.MatricesWeightsExtraKind
  27025. * @param data defines the data source
  27026. * @param updatable defines if the data must be flagged as updatable (or static)
  27027. * @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
  27028. * @returns the current mesh
  27029. */
  27030. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27031. /**
  27032. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27033. * If the mesh has no geometry, it is simply returned as it is.
  27034. * @param kind defines vertex data kind:
  27035. * * VertexBuffer.PositionKind
  27036. * * VertexBuffer.UVKind
  27037. * * VertexBuffer.UV2Kind
  27038. * * VertexBuffer.UV3Kind
  27039. * * VertexBuffer.UV4Kind
  27040. * * VertexBuffer.UV5Kind
  27041. * * VertexBuffer.UV6Kind
  27042. * * VertexBuffer.ColorKind
  27043. * * VertexBuffer.MatricesIndicesKind
  27044. * * VertexBuffer.MatricesIndicesExtraKind
  27045. * * VertexBuffer.MatricesWeightsKind
  27046. * * VertexBuffer.MatricesWeightsExtraKind
  27047. * @param data defines the data source
  27048. * @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
  27049. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27050. * @returns the current mesh
  27051. */
  27052. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27053. /**
  27054. * Sets the mesh indices,
  27055. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27056. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27057. * @param totalVertices Defines the total number of vertices
  27058. * @returns the current mesh
  27059. */
  27060. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27061. /**
  27062. * Gets a boolean indicating if specific vertex data is present
  27063. * @param kind defines the vertex data kind to use
  27064. * @returns true is data kind is present
  27065. */
  27066. isVerticesDataPresent(kind: string): boolean;
  27067. /**
  27068. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27069. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27070. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27071. * @returns a BoundingInfo
  27072. */
  27073. getBoundingInfo(): BoundingInfo;
  27074. /**
  27075. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27076. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27077. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27078. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27079. * @returns the current mesh
  27080. */
  27081. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27082. /**
  27083. * Overwrite the current bounding info
  27084. * @param boundingInfo defines the new bounding info
  27085. * @returns the current mesh
  27086. */
  27087. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27088. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27089. readonly useBones: boolean;
  27090. /** @hidden */
  27091. _preActivate(): void;
  27092. /** @hidden */
  27093. _preActivateForIntermediateRendering(renderId: number): void;
  27094. /** @hidden */
  27095. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27096. /** @hidden */
  27097. _postActivate(): void;
  27098. /** @hidden */
  27099. _freeze(): void;
  27100. /** @hidden */
  27101. _unFreeze(): void;
  27102. /**
  27103. * Gets the current world matrix
  27104. * @returns a Matrix
  27105. */
  27106. getWorldMatrix(): Matrix;
  27107. /** @hidden */
  27108. _getWorldMatrixDeterminant(): number;
  27109. /**
  27110. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27111. */
  27112. readonly isAnInstance: boolean;
  27113. /**
  27114. * Gets a boolean indicating if this mesh has instances
  27115. */
  27116. readonly hasInstances: boolean;
  27117. /**
  27118. * Perform relative position change from the point of view of behind the front of the mesh.
  27119. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27120. * Supports definition of mesh facing forward or backward
  27121. * @param amountRight defines the distance on the right axis
  27122. * @param amountUp defines the distance on the up axis
  27123. * @param amountForward defines the distance on the forward axis
  27124. * @returns the current mesh
  27125. */
  27126. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27127. /**
  27128. * Calculate relative position change from the point of view of behind the front of the mesh.
  27129. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27130. * Supports definition of mesh facing forward or backward
  27131. * @param amountRight defines the distance on the right axis
  27132. * @param amountUp defines the distance on the up axis
  27133. * @param amountForward defines the distance on the forward axis
  27134. * @returns the new displacement vector
  27135. */
  27136. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27137. /**
  27138. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27139. * Supports definition of mesh facing forward or backward
  27140. * @param flipBack defines the flip
  27141. * @param twirlClockwise defines the twirl
  27142. * @param tiltRight defines the tilt
  27143. * @returns the current mesh
  27144. */
  27145. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27146. /**
  27147. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27148. * Supports definition of mesh facing forward or backward.
  27149. * @param flipBack defines the flip
  27150. * @param twirlClockwise defines the twirl
  27151. * @param tiltRight defines the tilt
  27152. * @returns the new rotation vector
  27153. */
  27154. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27155. /**
  27156. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27157. * This means the mesh underlying bounding box and sphere are recomputed.
  27158. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27159. * @returns the current mesh
  27160. */
  27161. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27162. /** @hidden */
  27163. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27164. /** @hidden */
  27165. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27166. /** @hidden */
  27167. _updateBoundingInfo(): AbstractMesh;
  27168. /** @hidden */
  27169. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27170. /** @hidden */
  27171. protected _afterComputeWorldMatrix(): void;
  27172. /** @hidden */
  27173. readonly _effectiveMesh: AbstractMesh;
  27174. /**
  27175. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27176. * A mesh is in the frustum if its bounding box intersects the frustum
  27177. * @param frustumPlanes defines the frustum to test
  27178. * @returns true if the mesh is in the frustum planes
  27179. */
  27180. isInFrustum(frustumPlanes: Plane[]): boolean;
  27181. /**
  27182. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27183. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27184. * @param frustumPlanes defines the frustum to test
  27185. * @returns true if the mesh is completely in the frustum planes
  27186. */
  27187. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27188. /**
  27189. * True if the mesh intersects another mesh or a SolidParticle object
  27190. * @param mesh defines a target mesh or SolidParticle to test
  27191. * @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)
  27192. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27193. * @returns true if there is an intersection
  27194. */
  27195. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27196. /**
  27197. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27198. * @param point defines the point to test
  27199. * @returns true if there is an intersection
  27200. */
  27201. intersectsPoint(point: Vector3): boolean;
  27202. /**
  27203. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27204. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27205. */
  27206. checkCollisions: boolean;
  27207. /**
  27208. * Gets Collider object used to compute collisions (not physics)
  27209. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27210. */
  27211. readonly collider: Nullable<Collider>;
  27212. /**
  27213. * Move the mesh using collision engine
  27214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27215. * @param displacement defines the requested displacement vector
  27216. * @returns the current mesh
  27217. */
  27218. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27219. private _onCollisionPositionChange;
  27220. /** @hidden */
  27221. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27222. /** @hidden */
  27223. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27224. /** @hidden */
  27225. _checkCollision(collider: Collider): AbstractMesh;
  27226. /** @hidden */
  27227. _generatePointsArray(): boolean;
  27228. /**
  27229. * Checks if the passed Ray intersects with the mesh
  27230. * @param ray defines the ray to use
  27231. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27232. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27233. * @returns the picking info
  27234. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27235. */
  27236. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27237. /**
  27238. * Clones the current mesh
  27239. * @param name defines the mesh name
  27240. * @param newParent defines the new mesh parent
  27241. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27242. * @returns the new mesh
  27243. */
  27244. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27245. /**
  27246. * Disposes all the submeshes of the current meshnp
  27247. * @returns the current mesh
  27248. */
  27249. releaseSubMeshes(): AbstractMesh;
  27250. /**
  27251. * Releases resources associated with this abstract mesh.
  27252. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27253. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27254. */
  27255. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27256. /**
  27257. * Adds the passed mesh as a child to the current mesh
  27258. * @param mesh defines the child mesh
  27259. * @returns the current mesh
  27260. */
  27261. addChild(mesh: AbstractMesh): AbstractMesh;
  27262. /**
  27263. * Removes the passed mesh from the current mesh children list
  27264. * @param mesh defines the child mesh
  27265. * @returns the current mesh
  27266. */
  27267. removeChild(mesh: AbstractMesh): AbstractMesh;
  27268. /** @hidden */
  27269. private _initFacetData;
  27270. /**
  27271. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27272. * This method can be called within the render loop.
  27273. * 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
  27274. * @returns the current mesh
  27275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27276. */
  27277. updateFacetData(): AbstractMesh;
  27278. /**
  27279. * Returns the facetLocalNormals array.
  27280. * The normals are expressed in the mesh local spac
  27281. * @returns an array of Vector3
  27282. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27283. */
  27284. getFacetLocalNormals(): Vector3[];
  27285. /**
  27286. * Returns the facetLocalPositions array.
  27287. * The facet positions are expressed in the mesh local space
  27288. * @returns an array of Vector3
  27289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27290. */
  27291. getFacetLocalPositions(): Vector3[];
  27292. /**
  27293. * Returns the facetLocalPartioning array
  27294. * @returns an array of array of numbers
  27295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27296. */
  27297. getFacetLocalPartitioning(): number[][];
  27298. /**
  27299. * Returns the i-th facet position in the world system.
  27300. * This method allocates a new Vector3 per call
  27301. * @param i defines the facet index
  27302. * @returns a new Vector3
  27303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27304. */
  27305. getFacetPosition(i: number): Vector3;
  27306. /**
  27307. * Sets the reference Vector3 with the i-th facet position in the world system
  27308. * @param i defines the facet index
  27309. * @param ref defines the target vector
  27310. * @returns the current mesh
  27311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27312. */
  27313. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27314. /**
  27315. * Returns the i-th facet normal in the world system.
  27316. * This method allocates a new Vector3 per call
  27317. * @param i defines the facet index
  27318. * @returns a new Vector3
  27319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27320. */
  27321. getFacetNormal(i: number): Vector3;
  27322. /**
  27323. * Sets the reference Vector3 with the i-th facet normal in the world system
  27324. * @param i defines the facet index
  27325. * @param ref defines the target vector
  27326. * @returns the current mesh
  27327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27328. */
  27329. getFacetNormalToRef(i: number, ref: Vector3): this;
  27330. /**
  27331. * 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)
  27332. * @param x defines x coordinate
  27333. * @param y defines y coordinate
  27334. * @param z defines z coordinate
  27335. * @returns the array of facet indexes
  27336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27337. */
  27338. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27339. /**
  27340. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27341. * @param projected sets as the (x,y,z) world projection on the facet
  27342. * @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
  27343. * @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
  27344. * @param x defines x coordinate
  27345. * @param y defines y coordinate
  27346. * @param z defines z coordinate
  27347. * @returns the face index if found (or null instead)
  27348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27349. */
  27350. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27351. /**
  27352. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27353. * @param projected sets as the (x,y,z) local projection on the facet
  27354. * @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
  27355. * @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
  27356. * @param x defines x coordinate
  27357. * @param y defines y coordinate
  27358. * @param z defines z coordinate
  27359. * @returns the face index if found (or null instead)
  27360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27361. */
  27362. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27363. /**
  27364. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27365. * @returns the parameters
  27366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27367. */
  27368. getFacetDataParameters(): any;
  27369. /**
  27370. * Disables the feature FacetData and frees the related memory
  27371. * @returns the current mesh
  27372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27373. */
  27374. disableFacetData(): AbstractMesh;
  27375. /**
  27376. * Updates the AbstractMesh indices array
  27377. * @param indices defines the data source
  27378. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27379. * @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)
  27380. * @returns the current mesh
  27381. */
  27382. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27383. /**
  27384. * Creates new normals data for the mesh
  27385. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27386. * @returns the current mesh
  27387. */
  27388. createNormals(updatable: boolean): AbstractMesh;
  27389. /**
  27390. * Align the mesh with a normal
  27391. * @param normal defines the normal to use
  27392. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27393. * @returns the current mesh
  27394. */
  27395. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27396. /** @hidden */
  27397. _checkOcclusionQuery(): boolean;
  27398. /**
  27399. * Disables the mesh edge rendering mode
  27400. * @returns the currentAbstractMesh
  27401. */
  27402. disableEdgesRendering(): AbstractMesh;
  27403. /**
  27404. * Enables the edge rendering mode on the mesh.
  27405. * This mode makes the mesh edges visible
  27406. * @param epsilon defines the maximal distance between two angles to detect a face
  27407. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27408. * @returns the currentAbstractMesh
  27409. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27410. */
  27411. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27412. }
  27413. }
  27414. declare module "babylonjs/Actions/actionEvent" {
  27415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27416. import { Nullable } from "babylonjs/types";
  27417. import { Sprite } from "babylonjs/Sprites/sprite";
  27418. import { Scene } from "babylonjs/scene";
  27419. import { Vector2 } from "babylonjs/Maths/math.vector";
  27420. /**
  27421. * Interface used to define ActionEvent
  27422. */
  27423. export interface IActionEvent {
  27424. /** The mesh or sprite that triggered the action */
  27425. source: any;
  27426. /** The X mouse cursor position at the time of the event */
  27427. pointerX: number;
  27428. /** The Y mouse cursor position at the time of the event */
  27429. pointerY: number;
  27430. /** The mesh that is currently pointed at (can be null) */
  27431. meshUnderPointer: Nullable<AbstractMesh>;
  27432. /** the original (browser) event that triggered the ActionEvent */
  27433. sourceEvent?: any;
  27434. /** additional data for the event */
  27435. additionalData?: any;
  27436. }
  27437. /**
  27438. * ActionEvent is the event being sent when an action is triggered.
  27439. */
  27440. export class ActionEvent implements IActionEvent {
  27441. /** The mesh or sprite that triggered the action */
  27442. source: any;
  27443. /** The X mouse cursor position at the time of the event */
  27444. pointerX: number;
  27445. /** The Y mouse cursor position at the time of the event */
  27446. pointerY: number;
  27447. /** The mesh that is currently pointed at (can be null) */
  27448. meshUnderPointer: Nullable<AbstractMesh>;
  27449. /** the original (browser) event that triggered the ActionEvent */
  27450. sourceEvent?: any;
  27451. /** additional data for the event */
  27452. additionalData?: any;
  27453. /**
  27454. * Creates a new ActionEvent
  27455. * @param source The mesh or sprite that triggered the action
  27456. * @param pointerX The X mouse cursor position at the time of the event
  27457. * @param pointerY The Y mouse cursor position at the time of the event
  27458. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27459. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27460. * @param additionalData additional data for the event
  27461. */
  27462. constructor(
  27463. /** The mesh or sprite that triggered the action */
  27464. source: any,
  27465. /** The X mouse cursor position at the time of the event */
  27466. pointerX: number,
  27467. /** The Y mouse cursor position at the time of the event */
  27468. pointerY: number,
  27469. /** The mesh that is currently pointed at (can be null) */
  27470. meshUnderPointer: Nullable<AbstractMesh>,
  27471. /** the original (browser) event that triggered the ActionEvent */
  27472. sourceEvent?: any,
  27473. /** additional data for the event */
  27474. additionalData?: any);
  27475. /**
  27476. * Helper function to auto-create an ActionEvent from a source mesh.
  27477. * @param source The source mesh that triggered the event
  27478. * @param evt The original (browser) event
  27479. * @param additionalData additional data for the event
  27480. * @returns the new ActionEvent
  27481. */
  27482. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27483. /**
  27484. * Helper function to auto-create an ActionEvent from a source sprite
  27485. * @param source The source sprite that triggered the event
  27486. * @param scene Scene associated with the sprite
  27487. * @param evt The original (browser) event
  27488. * @param additionalData additional data for the event
  27489. * @returns the new ActionEvent
  27490. */
  27491. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27492. /**
  27493. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27494. * @param scene the scene where the event occurred
  27495. * @param evt The original (browser) event
  27496. * @returns the new ActionEvent
  27497. */
  27498. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27499. /**
  27500. * Helper function to auto-create an ActionEvent from a primitive
  27501. * @param prim defines the target primitive
  27502. * @param pointerPos defines the pointer position
  27503. * @param evt The original (browser) event
  27504. * @param additionalData additional data for the event
  27505. * @returns the new ActionEvent
  27506. */
  27507. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27508. }
  27509. }
  27510. declare module "babylonjs/Actions/abstractActionManager" {
  27511. import { IDisposable } from "babylonjs/scene";
  27512. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27513. import { IAction } from "babylonjs/Actions/action";
  27514. import { Nullable } from "babylonjs/types";
  27515. /**
  27516. * Abstract class used to decouple action Manager from scene and meshes.
  27517. * Do not instantiate.
  27518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27519. */
  27520. export abstract class AbstractActionManager implements IDisposable {
  27521. /** Gets the list of active triggers */
  27522. static Triggers: {
  27523. [key: string]: number;
  27524. };
  27525. /** Gets the cursor to use when hovering items */
  27526. hoverCursor: string;
  27527. /** Gets the list of actions */
  27528. actions: IAction[];
  27529. /**
  27530. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27531. */
  27532. isRecursive: boolean;
  27533. /**
  27534. * Releases all associated resources
  27535. */
  27536. abstract dispose(): void;
  27537. /**
  27538. * Does this action manager has pointer triggers
  27539. */
  27540. abstract readonly hasPointerTriggers: boolean;
  27541. /**
  27542. * Does this action manager has pick triggers
  27543. */
  27544. abstract readonly hasPickTriggers: boolean;
  27545. /**
  27546. * Process a specific trigger
  27547. * @param trigger defines the trigger to process
  27548. * @param evt defines the event details to be processed
  27549. */
  27550. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27551. /**
  27552. * Does this action manager handles actions of any of the given triggers
  27553. * @param triggers defines the triggers to be tested
  27554. * @return a boolean indicating whether one (or more) of the triggers is handled
  27555. */
  27556. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27557. /**
  27558. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27559. * speed.
  27560. * @param triggerA defines the trigger to be tested
  27561. * @param triggerB defines the trigger to be tested
  27562. * @return a boolean indicating whether one (or more) of the triggers is handled
  27563. */
  27564. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27565. /**
  27566. * Does this action manager handles actions of a given trigger
  27567. * @param trigger defines the trigger to be tested
  27568. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27569. * @return whether the trigger is handled
  27570. */
  27571. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27572. /**
  27573. * Serialize this manager to a JSON object
  27574. * @param name defines the property name to store this manager
  27575. * @returns a JSON representation of this manager
  27576. */
  27577. abstract serialize(name: string): any;
  27578. /**
  27579. * Registers an action to this action manager
  27580. * @param action defines the action to be registered
  27581. * @return the action amended (prepared) after registration
  27582. */
  27583. abstract registerAction(action: IAction): Nullable<IAction>;
  27584. /**
  27585. * Unregisters an action to this action manager
  27586. * @param action defines the action to be unregistered
  27587. * @return a boolean indicating whether the action has been unregistered
  27588. */
  27589. abstract unregisterAction(action: IAction): Boolean;
  27590. /**
  27591. * Does exist one action manager with at least one trigger
  27592. **/
  27593. static readonly HasTriggers: boolean;
  27594. /**
  27595. * Does exist one action manager with at least one pick trigger
  27596. **/
  27597. static readonly HasPickTriggers: boolean;
  27598. /**
  27599. * Does exist one action manager that handles actions of a given trigger
  27600. * @param trigger defines the trigger to be tested
  27601. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27602. **/
  27603. static HasSpecificTrigger(trigger: number): boolean;
  27604. }
  27605. }
  27606. declare module "babylonjs/node" {
  27607. import { Scene } from "babylonjs/scene";
  27608. import { Nullable } from "babylonjs/types";
  27609. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27610. import { Engine } from "babylonjs/Engines/engine";
  27611. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27612. import { Observable } from "babylonjs/Misc/observable";
  27613. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27614. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27615. import { Animatable } from "babylonjs/Animations/animatable";
  27616. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27617. import { Animation } from "babylonjs/Animations/animation";
  27618. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27620. /**
  27621. * Defines how a node can be built from a string name.
  27622. */
  27623. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27624. /**
  27625. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27626. */
  27627. export class Node implements IBehaviorAware<Node> {
  27628. /** @hidden */
  27629. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27630. private static _NodeConstructors;
  27631. /**
  27632. * Add a new node constructor
  27633. * @param type defines the type name of the node to construct
  27634. * @param constructorFunc defines the constructor function
  27635. */
  27636. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27637. /**
  27638. * Returns a node constructor based on type name
  27639. * @param type defines the type name
  27640. * @param name defines the new node name
  27641. * @param scene defines the hosting scene
  27642. * @param options defines optional options to transmit to constructors
  27643. * @returns the new constructor or null
  27644. */
  27645. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27646. /**
  27647. * Gets or sets the name of the node
  27648. */
  27649. name: string;
  27650. /**
  27651. * Gets or sets the id of the node
  27652. */
  27653. id: string;
  27654. /**
  27655. * Gets or sets the unique id of the node
  27656. */
  27657. uniqueId: number;
  27658. /**
  27659. * Gets or sets a string used to store user defined state for the node
  27660. */
  27661. state: string;
  27662. /**
  27663. * Gets or sets an object used to store user defined information for the node
  27664. */
  27665. metadata: any;
  27666. /**
  27667. * For internal use only. Please do not use.
  27668. */
  27669. reservedDataStore: any;
  27670. /**
  27671. * List of inspectable custom properties (used by the Inspector)
  27672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27673. */
  27674. inspectableCustomProperties: IInspectable[];
  27675. /**
  27676. * Gets or sets a boolean used to define if the node must be serialized
  27677. */
  27678. doNotSerialize: boolean;
  27679. /** @hidden */
  27680. _isDisposed: boolean;
  27681. /**
  27682. * Gets a list of Animations associated with the node
  27683. */
  27684. animations: import("babylonjs/Animations/animation").Animation[];
  27685. protected _ranges: {
  27686. [name: string]: Nullable<AnimationRange>;
  27687. };
  27688. /**
  27689. * Callback raised when the node is ready to be used
  27690. */
  27691. onReady: Nullable<(node: Node) => void>;
  27692. private _isEnabled;
  27693. private _isParentEnabled;
  27694. private _isReady;
  27695. /** @hidden */
  27696. _currentRenderId: number;
  27697. private _parentUpdateId;
  27698. /** @hidden */
  27699. _childUpdateId: number;
  27700. /** @hidden */
  27701. _waitingParentId: Nullable<string>;
  27702. /** @hidden */
  27703. _scene: Scene;
  27704. /** @hidden */
  27705. _cache: any;
  27706. private _parentNode;
  27707. private _children;
  27708. /** @hidden */
  27709. _worldMatrix: Matrix;
  27710. /** @hidden */
  27711. _worldMatrixDeterminant: number;
  27712. /** @hidden */
  27713. _worldMatrixDeterminantIsDirty: boolean;
  27714. /** @hidden */
  27715. private _sceneRootNodesIndex;
  27716. /**
  27717. * Gets a boolean indicating if the node has been disposed
  27718. * @returns true if the node was disposed
  27719. */
  27720. isDisposed(): boolean;
  27721. /**
  27722. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27723. * @see https://doc.babylonjs.com/how_to/parenting
  27724. */
  27725. parent: Nullable<Node>;
  27726. private addToSceneRootNodes;
  27727. private removeFromSceneRootNodes;
  27728. private _animationPropertiesOverride;
  27729. /**
  27730. * Gets or sets the animation properties override
  27731. */
  27732. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27733. /**
  27734. * Gets a string idenfifying the name of the class
  27735. * @returns "Node" string
  27736. */
  27737. getClassName(): string;
  27738. /** @hidden */
  27739. readonly _isNode: boolean;
  27740. /**
  27741. * An event triggered when the mesh is disposed
  27742. */
  27743. onDisposeObservable: Observable<Node>;
  27744. private _onDisposeObserver;
  27745. /**
  27746. * Sets a callback that will be raised when the node will be disposed
  27747. */
  27748. onDispose: () => void;
  27749. /**
  27750. * Creates a new Node
  27751. * @param name the name and id to be given to this node
  27752. * @param scene the scene this node will be added to
  27753. * @param addToRootNodes the node will be added to scene.rootNodes
  27754. */
  27755. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27756. /**
  27757. * Gets the scene of the node
  27758. * @returns a scene
  27759. */
  27760. getScene(): Scene;
  27761. /**
  27762. * Gets the engine of the node
  27763. * @returns a Engine
  27764. */
  27765. getEngine(): Engine;
  27766. private _behaviors;
  27767. /**
  27768. * Attach a behavior to the node
  27769. * @see http://doc.babylonjs.com/features/behaviour
  27770. * @param behavior defines the behavior to attach
  27771. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27772. * @returns the current Node
  27773. */
  27774. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27775. /**
  27776. * Remove an attached behavior
  27777. * @see http://doc.babylonjs.com/features/behaviour
  27778. * @param behavior defines the behavior to attach
  27779. * @returns the current Node
  27780. */
  27781. removeBehavior(behavior: Behavior<Node>): Node;
  27782. /**
  27783. * Gets the list of attached behaviors
  27784. * @see http://doc.babylonjs.com/features/behaviour
  27785. */
  27786. readonly behaviors: Behavior<Node>[];
  27787. /**
  27788. * Gets an attached behavior by name
  27789. * @param name defines the name of the behavior to look for
  27790. * @see http://doc.babylonjs.com/features/behaviour
  27791. * @returns null if behavior was not found else the requested behavior
  27792. */
  27793. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27794. /**
  27795. * Returns the latest update of the World matrix
  27796. * @returns a Matrix
  27797. */
  27798. getWorldMatrix(): Matrix;
  27799. /** @hidden */
  27800. _getWorldMatrixDeterminant(): number;
  27801. /**
  27802. * Returns directly the latest state of the mesh World matrix.
  27803. * A Matrix is returned.
  27804. */
  27805. readonly worldMatrixFromCache: Matrix;
  27806. /** @hidden */
  27807. _initCache(): void;
  27808. /** @hidden */
  27809. updateCache(force?: boolean): void;
  27810. /** @hidden */
  27811. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27812. /** @hidden */
  27813. _updateCache(ignoreParentClass?: boolean): void;
  27814. /** @hidden */
  27815. _isSynchronized(): boolean;
  27816. /** @hidden */
  27817. _markSyncedWithParent(): void;
  27818. /** @hidden */
  27819. isSynchronizedWithParent(): boolean;
  27820. /** @hidden */
  27821. isSynchronized(): boolean;
  27822. /**
  27823. * Is this node ready to be used/rendered
  27824. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27825. * @return true if the node is ready
  27826. */
  27827. isReady(completeCheck?: boolean): boolean;
  27828. /**
  27829. * Is this node enabled?
  27830. * 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
  27831. * @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
  27832. * @return whether this node (and its parent) is enabled
  27833. */
  27834. isEnabled(checkAncestors?: boolean): boolean;
  27835. /** @hidden */
  27836. protected _syncParentEnabledState(): void;
  27837. /**
  27838. * Set the enabled state of this node
  27839. * @param value defines the new enabled state
  27840. */
  27841. setEnabled(value: boolean): void;
  27842. /**
  27843. * Is this node a descendant of the given node?
  27844. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27845. * @param ancestor defines the parent node to inspect
  27846. * @returns a boolean indicating if this node is a descendant of the given node
  27847. */
  27848. isDescendantOf(ancestor: Node): boolean;
  27849. /** @hidden */
  27850. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27851. /**
  27852. * Will return all nodes that have this node as ascendant
  27853. * @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
  27854. * @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
  27855. * @return all children nodes of all types
  27856. */
  27857. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27858. /**
  27859. * Get all child-meshes of this node
  27860. * @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)
  27861. * @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
  27862. * @returns an array of AbstractMesh
  27863. */
  27864. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27865. /**
  27866. * Get all direct children of this node
  27867. * @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
  27868. * @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)
  27869. * @returns an array of Node
  27870. */
  27871. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27872. /** @hidden */
  27873. _setReady(state: boolean): void;
  27874. /**
  27875. * Get an animation by name
  27876. * @param name defines the name of the animation to look for
  27877. * @returns null if not found else the requested animation
  27878. */
  27879. getAnimationByName(name: string): Nullable<Animation>;
  27880. /**
  27881. * Creates an animation range for this node
  27882. * @param name defines the name of the range
  27883. * @param from defines the starting key
  27884. * @param to defines the end key
  27885. */
  27886. createAnimationRange(name: string, from: number, to: number): void;
  27887. /**
  27888. * Delete a specific animation range
  27889. * @param name defines the name of the range to delete
  27890. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27891. */
  27892. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27893. /**
  27894. * Get an animation range by name
  27895. * @param name defines the name of the animation range to look for
  27896. * @returns null if not found else the requested animation range
  27897. */
  27898. getAnimationRange(name: string): Nullable<AnimationRange>;
  27899. /**
  27900. * Gets the list of all animation ranges defined on this node
  27901. * @returns an array
  27902. */
  27903. getAnimationRanges(): Nullable<AnimationRange>[];
  27904. /**
  27905. * Will start the animation sequence
  27906. * @param name defines the range frames for animation sequence
  27907. * @param loop defines if the animation should loop (false by default)
  27908. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27909. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27910. * @returns the object created for this animation. If range does not exist, it will return null
  27911. */
  27912. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27913. /**
  27914. * Serialize animation ranges into a JSON compatible object
  27915. * @returns serialization object
  27916. */
  27917. serializeAnimationRanges(): any;
  27918. /**
  27919. * Computes the world matrix of the node
  27920. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27921. * @returns the world matrix
  27922. */
  27923. computeWorldMatrix(force?: boolean): Matrix;
  27924. /**
  27925. * Releases resources associated with this node.
  27926. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27927. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27928. */
  27929. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27930. /**
  27931. * Parse animation range data from a serialization object and store them into a given node
  27932. * @param node defines where to store the animation ranges
  27933. * @param parsedNode defines the serialization object to read data from
  27934. * @param scene defines the hosting scene
  27935. */
  27936. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27937. /**
  27938. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27939. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27940. * @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
  27941. * @returns the new bounding vectors
  27942. */
  27943. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27944. min: Vector3;
  27945. max: Vector3;
  27946. };
  27947. }
  27948. }
  27949. declare module "babylonjs/Animations/animation" {
  27950. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27951. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27952. import { Color3 } from "babylonjs/Maths/math.color";
  27953. import { Nullable } from "babylonjs/types";
  27954. import { Scene } from "babylonjs/scene";
  27955. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27956. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27957. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27958. import { Node } from "babylonjs/node";
  27959. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27960. import { Size } from "babylonjs/Maths/math.size";
  27961. import { Animatable } from "babylonjs/Animations/animatable";
  27962. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27963. /**
  27964. * @hidden
  27965. */
  27966. export class _IAnimationState {
  27967. key: number;
  27968. repeatCount: number;
  27969. workValue?: any;
  27970. loopMode?: number;
  27971. offsetValue?: any;
  27972. highLimitValue?: any;
  27973. }
  27974. /**
  27975. * Class used to store any kind of animation
  27976. */
  27977. export class Animation {
  27978. /**Name of the animation */
  27979. name: string;
  27980. /**Property to animate */
  27981. targetProperty: string;
  27982. /**The frames per second of the animation */
  27983. framePerSecond: number;
  27984. /**The data type of the animation */
  27985. dataType: number;
  27986. /**The loop mode of the animation */
  27987. loopMode?: number | undefined;
  27988. /**Specifies if blending should be enabled */
  27989. enableBlending?: boolean | undefined;
  27990. /**
  27991. * Use matrix interpolation instead of using direct key value when animating matrices
  27992. */
  27993. static AllowMatricesInterpolation: boolean;
  27994. /**
  27995. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27996. */
  27997. static AllowMatrixDecomposeForInterpolation: boolean;
  27998. /**
  27999. * Stores the key frames of the animation
  28000. */
  28001. private _keys;
  28002. /**
  28003. * Stores the easing function of the animation
  28004. */
  28005. private _easingFunction;
  28006. /**
  28007. * @hidden Internal use only
  28008. */
  28009. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28010. /**
  28011. * The set of event that will be linked to this animation
  28012. */
  28013. private _events;
  28014. /**
  28015. * Stores an array of target property paths
  28016. */
  28017. targetPropertyPath: string[];
  28018. /**
  28019. * Stores the blending speed of the animation
  28020. */
  28021. blendingSpeed: number;
  28022. /**
  28023. * Stores the animation ranges for the animation
  28024. */
  28025. private _ranges;
  28026. /**
  28027. * @hidden Internal use
  28028. */
  28029. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28030. /**
  28031. * Sets up an animation
  28032. * @param property The property to animate
  28033. * @param animationType The animation type to apply
  28034. * @param framePerSecond The frames per second of the animation
  28035. * @param easingFunction The easing function used in the animation
  28036. * @returns The created animation
  28037. */
  28038. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28039. /**
  28040. * Create and start an animation on a node
  28041. * @param name defines the name of the global animation that will be run on all nodes
  28042. * @param node defines the root node where the animation will take place
  28043. * @param targetProperty defines property to animate
  28044. * @param framePerSecond defines the number of frame per second yo use
  28045. * @param totalFrame defines the number of frames in total
  28046. * @param from defines the initial value
  28047. * @param to defines the final value
  28048. * @param loopMode defines which loop mode you want to use (off by default)
  28049. * @param easingFunction defines the easing function to use (linear by default)
  28050. * @param onAnimationEnd defines the callback to call when animation end
  28051. * @returns the animatable created for this animation
  28052. */
  28053. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28054. /**
  28055. * Create and start an animation on a node and its descendants
  28056. * @param name defines the name of the global animation that will be run on all nodes
  28057. * @param node defines the root node where the animation will take place
  28058. * @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
  28059. * @param targetProperty defines property to animate
  28060. * @param framePerSecond defines the number of frame per second to use
  28061. * @param totalFrame defines the number of frames in total
  28062. * @param from defines the initial value
  28063. * @param to defines the final value
  28064. * @param loopMode defines which loop mode you want to use (off by default)
  28065. * @param easingFunction defines the easing function to use (linear by default)
  28066. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28067. * @returns the list of animatables created for all nodes
  28068. * @example https://www.babylonjs-playground.com/#MH0VLI
  28069. */
  28070. 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[]>;
  28071. /**
  28072. * Creates a new animation, merges it with the existing animations and starts it
  28073. * @param name Name of the animation
  28074. * @param node Node which contains the scene that begins the animations
  28075. * @param targetProperty Specifies which property to animate
  28076. * @param framePerSecond The frames per second of the animation
  28077. * @param totalFrame The total number of frames
  28078. * @param from The frame at the beginning of the animation
  28079. * @param to The frame at the end of the animation
  28080. * @param loopMode Specifies the loop mode of the animation
  28081. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28082. * @param onAnimationEnd Callback to run once the animation is complete
  28083. * @returns Nullable animation
  28084. */
  28085. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28086. /**
  28087. * Transition property of an host to the target Value
  28088. * @param property The property to transition
  28089. * @param targetValue The target Value of the property
  28090. * @param host The object where the property to animate belongs
  28091. * @param scene Scene used to run the animation
  28092. * @param frameRate Framerate (in frame/s) to use
  28093. * @param transition The transition type we want to use
  28094. * @param duration The duration of the animation, in milliseconds
  28095. * @param onAnimationEnd Callback trigger at the end of the animation
  28096. * @returns Nullable animation
  28097. */
  28098. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28099. /**
  28100. * Return the array of runtime animations currently using this animation
  28101. */
  28102. readonly runtimeAnimations: RuntimeAnimation[];
  28103. /**
  28104. * Specifies if any of the runtime animations are currently running
  28105. */
  28106. readonly hasRunningRuntimeAnimations: boolean;
  28107. /**
  28108. * Initializes the animation
  28109. * @param name Name of the animation
  28110. * @param targetProperty Property to animate
  28111. * @param framePerSecond The frames per second of the animation
  28112. * @param dataType The data type of the animation
  28113. * @param loopMode The loop mode of the animation
  28114. * @param enableBlending Specifies if blending should be enabled
  28115. */
  28116. constructor(
  28117. /**Name of the animation */
  28118. name: string,
  28119. /**Property to animate */
  28120. targetProperty: string,
  28121. /**The frames per second of the animation */
  28122. framePerSecond: number,
  28123. /**The data type of the animation */
  28124. dataType: number,
  28125. /**The loop mode of the animation */
  28126. loopMode?: number | undefined,
  28127. /**Specifies if blending should be enabled */
  28128. enableBlending?: boolean | undefined);
  28129. /**
  28130. * Converts the animation to a string
  28131. * @param fullDetails support for multiple levels of logging within scene loading
  28132. * @returns String form of the animation
  28133. */
  28134. toString(fullDetails?: boolean): string;
  28135. /**
  28136. * Add an event to this animation
  28137. * @param event Event to add
  28138. */
  28139. addEvent(event: AnimationEvent): void;
  28140. /**
  28141. * Remove all events found at the given frame
  28142. * @param frame The frame to remove events from
  28143. */
  28144. removeEvents(frame: number): void;
  28145. /**
  28146. * Retrieves all the events from the animation
  28147. * @returns Events from the animation
  28148. */
  28149. getEvents(): AnimationEvent[];
  28150. /**
  28151. * Creates an animation range
  28152. * @param name Name of the animation range
  28153. * @param from Starting frame of the animation range
  28154. * @param to Ending frame of the animation
  28155. */
  28156. createRange(name: string, from: number, to: number): void;
  28157. /**
  28158. * Deletes an animation range by name
  28159. * @param name Name of the animation range to delete
  28160. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28161. */
  28162. deleteRange(name: string, deleteFrames?: boolean): void;
  28163. /**
  28164. * Gets the animation range by name, or null if not defined
  28165. * @param name Name of the animation range
  28166. * @returns Nullable animation range
  28167. */
  28168. getRange(name: string): Nullable<AnimationRange>;
  28169. /**
  28170. * Gets the key frames from the animation
  28171. * @returns The key frames of the animation
  28172. */
  28173. getKeys(): Array<IAnimationKey>;
  28174. /**
  28175. * Gets the highest frame rate of the animation
  28176. * @returns Highest frame rate of the animation
  28177. */
  28178. getHighestFrame(): number;
  28179. /**
  28180. * Gets the easing function of the animation
  28181. * @returns Easing function of the animation
  28182. */
  28183. getEasingFunction(): IEasingFunction;
  28184. /**
  28185. * Sets the easing function of the animation
  28186. * @param easingFunction A custom mathematical formula for animation
  28187. */
  28188. setEasingFunction(easingFunction: EasingFunction): void;
  28189. /**
  28190. * Interpolates a scalar linearly
  28191. * @param startValue Start value of the animation curve
  28192. * @param endValue End value of the animation curve
  28193. * @param gradient Scalar amount to interpolate
  28194. * @returns Interpolated scalar value
  28195. */
  28196. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28197. /**
  28198. * Interpolates a scalar cubically
  28199. * @param startValue Start value of the animation curve
  28200. * @param outTangent End tangent of the animation
  28201. * @param endValue End value of the animation curve
  28202. * @param inTangent Start tangent of the animation curve
  28203. * @param gradient Scalar amount to interpolate
  28204. * @returns Interpolated scalar value
  28205. */
  28206. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28207. /**
  28208. * Interpolates a quaternion using a spherical linear interpolation
  28209. * @param startValue Start value of the animation curve
  28210. * @param endValue End value of the animation curve
  28211. * @param gradient Scalar amount to interpolate
  28212. * @returns Interpolated quaternion value
  28213. */
  28214. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28215. /**
  28216. * Interpolates a quaternion cubically
  28217. * @param startValue Start value of the animation curve
  28218. * @param outTangent End tangent of the animation curve
  28219. * @param endValue End value of the animation curve
  28220. * @param inTangent Start tangent of the animation curve
  28221. * @param gradient Scalar amount to interpolate
  28222. * @returns Interpolated quaternion value
  28223. */
  28224. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28225. /**
  28226. * Interpolates a Vector3 linearl
  28227. * @param startValue Start value of the animation curve
  28228. * @param endValue End value of the animation curve
  28229. * @param gradient Scalar amount to interpolate
  28230. * @returns Interpolated scalar value
  28231. */
  28232. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28233. /**
  28234. * Interpolates a Vector3 cubically
  28235. * @param startValue Start value of the animation curve
  28236. * @param outTangent End tangent of the animation
  28237. * @param endValue End value of the animation curve
  28238. * @param inTangent Start tangent of the animation curve
  28239. * @param gradient Scalar amount to interpolate
  28240. * @returns InterpolatedVector3 value
  28241. */
  28242. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28243. /**
  28244. * Interpolates a Vector2 linearly
  28245. * @param startValue Start value of the animation curve
  28246. * @param endValue End value of the animation curve
  28247. * @param gradient Scalar amount to interpolate
  28248. * @returns Interpolated Vector2 value
  28249. */
  28250. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28251. /**
  28252. * Interpolates a Vector2 cubically
  28253. * @param startValue Start value of the animation curve
  28254. * @param outTangent End tangent of the animation
  28255. * @param endValue End value of the animation curve
  28256. * @param inTangent Start tangent of the animation curve
  28257. * @param gradient Scalar amount to interpolate
  28258. * @returns Interpolated Vector2 value
  28259. */
  28260. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28261. /**
  28262. * Interpolates a size linearly
  28263. * @param startValue Start value of the animation curve
  28264. * @param endValue End value of the animation curve
  28265. * @param gradient Scalar amount to interpolate
  28266. * @returns Interpolated Size value
  28267. */
  28268. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28269. /**
  28270. * Interpolates a Color3 linearly
  28271. * @param startValue Start value of the animation curve
  28272. * @param endValue End value of the animation curve
  28273. * @param gradient Scalar amount to interpolate
  28274. * @returns Interpolated Color3 value
  28275. */
  28276. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28277. /**
  28278. * @hidden Internal use only
  28279. */
  28280. _getKeyValue(value: any): any;
  28281. /**
  28282. * @hidden Internal use only
  28283. */
  28284. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28285. /**
  28286. * Defines the function to use to interpolate matrices
  28287. * @param startValue defines the start matrix
  28288. * @param endValue defines the end matrix
  28289. * @param gradient defines the gradient between both matrices
  28290. * @param result defines an optional target matrix where to store the interpolation
  28291. * @returns the interpolated matrix
  28292. */
  28293. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28294. /**
  28295. * Makes a copy of the animation
  28296. * @returns Cloned animation
  28297. */
  28298. clone(): Animation;
  28299. /**
  28300. * Sets the key frames of the animation
  28301. * @param values The animation key frames to set
  28302. */
  28303. setKeys(values: Array<IAnimationKey>): void;
  28304. /**
  28305. * Serializes the animation to an object
  28306. * @returns Serialized object
  28307. */
  28308. serialize(): any;
  28309. /**
  28310. * Float animation type
  28311. */
  28312. private static _ANIMATIONTYPE_FLOAT;
  28313. /**
  28314. * Vector3 animation type
  28315. */
  28316. private static _ANIMATIONTYPE_VECTOR3;
  28317. /**
  28318. * Quaternion animation type
  28319. */
  28320. private static _ANIMATIONTYPE_QUATERNION;
  28321. /**
  28322. * Matrix animation type
  28323. */
  28324. private static _ANIMATIONTYPE_MATRIX;
  28325. /**
  28326. * Color3 animation type
  28327. */
  28328. private static _ANIMATIONTYPE_COLOR3;
  28329. /**
  28330. * Vector2 animation type
  28331. */
  28332. private static _ANIMATIONTYPE_VECTOR2;
  28333. /**
  28334. * Size animation type
  28335. */
  28336. private static _ANIMATIONTYPE_SIZE;
  28337. /**
  28338. * Relative Loop Mode
  28339. */
  28340. private static _ANIMATIONLOOPMODE_RELATIVE;
  28341. /**
  28342. * Cycle Loop Mode
  28343. */
  28344. private static _ANIMATIONLOOPMODE_CYCLE;
  28345. /**
  28346. * Constant Loop Mode
  28347. */
  28348. private static _ANIMATIONLOOPMODE_CONSTANT;
  28349. /**
  28350. * Get the float animation type
  28351. */
  28352. static readonly ANIMATIONTYPE_FLOAT: number;
  28353. /**
  28354. * Get the Vector3 animation type
  28355. */
  28356. static readonly ANIMATIONTYPE_VECTOR3: number;
  28357. /**
  28358. * Get the Vector2 animation type
  28359. */
  28360. static readonly ANIMATIONTYPE_VECTOR2: number;
  28361. /**
  28362. * Get the Size animation type
  28363. */
  28364. static readonly ANIMATIONTYPE_SIZE: number;
  28365. /**
  28366. * Get the Quaternion animation type
  28367. */
  28368. static readonly ANIMATIONTYPE_QUATERNION: number;
  28369. /**
  28370. * Get the Matrix animation type
  28371. */
  28372. static readonly ANIMATIONTYPE_MATRIX: number;
  28373. /**
  28374. * Get the Color3 animation type
  28375. */
  28376. static readonly ANIMATIONTYPE_COLOR3: number;
  28377. /**
  28378. * Get the Relative Loop Mode
  28379. */
  28380. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28381. /**
  28382. * Get the Cycle Loop Mode
  28383. */
  28384. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28385. /**
  28386. * Get the Constant Loop Mode
  28387. */
  28388. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28389. /** @hidden */
  28390. static _UniversalLerp(left: any, right: any, amount: number): any;
  28391. /**
  28392. * Parses an animation object and creates an animation
  28393. * @param parsedAnimation Parsed animation object
  28394. * @returns Animation object
  28395. */
  28396. static Parse(parsedAnimation: any): Animation;
  28397. /**
  28398. * Appends the serialized animations from the source animations
  28399. * @param source Source containing the animations
  28400. * @param destination Target to store the animations
  28401. */
  28402. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28403. }
  28404. }
  28405. declare module "babylonjs/Animations/animatable.interface" {
  28406. import { Nullable } from "babylonjs/types";
  28407. import { Animation } from "babylonjs/Animations/animation";
  28408. /**
  28409. * Interface containing an array of animations
  28410. */
  28411. export interface IAnimatable {
  28412. /**
  28413. * Array of animations
  28414. */
  28415. animations: Nullable<Array<Animation>>;
  28416. }
  28417. }
  28418. declare module "babylonjs/Materials/fresnelParameters" {
  28419. import { Color3 } from "babylonjs/Maths/math.color";
  28420. /**
  28421. * This represents all the required information to add a fresnel effect on a material:
  28422. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28423. */
  28424. export class FresnelParameters {
  28425. private _isEnabled;
  28426. /**
  28427. * Define if the fresnel effect is enable or not.
  28428. */
  28429. isEnabled: boolean;
  28430. /**
  28431. * Define the color used on edges (grazing angle)
  28432. */
  28433. leftColor: Color3;
  28434. /**
  28435. * Define the color used on center
  28436. */
  28437. rightColor: Color3;
  28438. /**
  28439. * Define bias applied to computed fresnel term
  28440. */
  28441. bias: number;
  28442. /**
  28443. * Defined the power exponent applied to fresnel term
  28444. */
  28445. power: number;
  28446. /**
  28447. * Clones the current fresnel and its valuues
  28448. * @returns a clone fresnel configuration
  28449. */
  28450. clone(): FresnelParameters;
  28451. /**
  28452. * Serializes the current fresnel parameters to a JSON representation.
  28453. * @return the JSON serialization
  28454. */
  28455. serialize(): any;
  28456. /**
  28457. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28458. * @param parsedFresnelParameters Define the JSON representation
  28459. * @returns the parsed parameters
  28460. */
  28461. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28462. }
  28463. }
  28464. declare module "babylonjs/Misc/decorators" {
  28465. import { Nullable } from "babylonjs/types";
  28466. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28467. import { Scene } from "babylonjs/scene";
  28468. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28469. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28470. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28471. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28472. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28473. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28474. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28475. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28476. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28477. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28478. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28479. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28480. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28481. /**
  28482. * Decorator used to define property that can be serialized as reference to a camera
  28483. * @param sourceName defines the name of the property to decorate
  28484. */
  28485. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28486. /**
  28487. * Class used to help serialization objects
  28488. */
  28489. export class SerializationHelper {
  28490. /** @hidden */
  28491. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28492. /** @hidden */
  28493. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28494. /** @hidden */
  28495. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28496. /** @hidden */
  28497. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28498. /**
  28499. * Appends the serialized animations from the source animations
  28500. * @param source Source containing the animations
  28501. * @param destination Target to store the animations
  28502. */
  28503. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28504. /**
  28505. * Static function used to serialized a specific entity
  28506. * @param entity defines the entity to serialize
  28507. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28508. * @returns a JSON compatible object representing the serialization of the entity
  28509. */
  28510. static Serialize<T>(entity: T, serializationObject?: any): any;
  28511. /**
  28512. * Creates a new entity from a serialization data object
  28513. * @param creationFunction defines a function used to instanciated the new entity
  28514. * @param source defines the source serialization data
  28515. * @param scene defines the hosting scene
  28516. * @param rootUrl defines the root url for resources
  28517. * @returns a new entity
  28518. */
  28519. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28520. /**
  28521. * Clones an object
  28522. * @param creationFunction defines the function used to instanciate the new object
  28523. * @param source defines the source object
  28524. * @returns the cloned object
  28525. */
  28526. static Clone<T>(creationFunction: () => T, source: T): T;
  28527. /**
  28528. * Instanciates a new object based on a source one (some data will be shared between both object)
  28529. * @param creationFunction defines the function used to instanciate the new object
  28530. * @param source defines the source object
  28531. * @returns the new object
  28532. */
  28533. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28534. }
  28535. }
  28536. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28537. import { Nullable } from "babylonjs/types";
  28538. /**
  28539. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28540. */
  28541. export interface CubeMapInfo {
  28542. /**
  28543. * The pixel array for the front face.
  28544. * This is stored in format, left to right, up to down format.
  28545. */
  28546. front: Nullable<ArrayBufferView>;
  28547. /**
  28548. * The pixel array for the back face.
  28549. * This is stored in format, left to right, up to down format.
  28550. */
  28551. back: Nullable<ArrayBufferView>;
  28552. /**
  28553. * The pixel array for the left face.
  28554. * This is stored in format, left to right, up to down format.
  28555. */
  28556. left: Nullable<ArrayBufferView>;
  28557. /**
  28558. * The pixel array for the right face.
  28559. * This is stored in format, left to right, up to down format.
  28560. */
  28561. right: Nullable<ArrayBufferView>;
  28562. /**
  28563. * The pixel array for the up face.
  28564. * This is stored in format, left to right, up to down format.
  28565. */
  28566. up: Nullable<ArrayBufferView>;
  28567. /**
  28568. * The pixel array for the down face.
  28569. * This is stored in format, left to right, up to down format.
  28570. */
  28571. down: Nullable<ArrayBufferView>;
  28572. /**
  28573. * The size of the cubemap stored.
  28574. *
  28575. * Each faces will be size * size pixels.
  28576. */
  28577. size: number;
  28578. /**
  28579. * The format of the texture.
  28580. *
  28581. * RGBA, RGB.
  28582. */
  28583. format: number;
  28584. /**
  28585. * The type of the texture data.
  28586. *
  28587. * UNSIGNED_INT, FLOAT.
  28588. */
  28589. type: number;
  28590. /**
  28591. * Specifies whether the texture is in gamma space.
  28592. */
  28593. gammaSpace: boolean;
  28594. }
  28595. /**
  28596. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28597. */
  28598. export class PanoramaToCubeMapTools {
  28599. private static FACE_FRONT;
  28600. private static FACE_BACK;
  28601. private static FACE_RIGHT;
  28602. private static FACE_LEFT;
  28603. private static FACE_DOWN;
  28604. private static FACE_UP;
  28605. /**
  28606. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28607. *
  28608. * @param float32Array The source data.
  28609. * @param inputWidth The width of the input panorama.
  28610. * @param inputHeight The height of the input panorama.
  28611. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28612. * @return The cubemap data
  28613. */
  28614. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28615. private static CreateCubemapTexture;
  28616. private static CalcProjectionSpherical;
  28617. }
  28618. }
  28619. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28620. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28622. import { Nullable } from "babylonjs/types";
  28623. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28624. /**
  28625. * Helper class dealing with the extraction of spherical polynomial dataArray
  28626. * from a cube map.
  28627. */
  28628. export class CubeMapToSphericalPolynomialTools {
  28629. private static FileFaces;
  28630. /**
  28631. * Converts a texture to the according Spherical Polynomial data.
  28632. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28633. *
  28634. * @param texture The texture to extract the information from.
  28635. * @return The Spherical Polynomial data.
  28636. */
  28637. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28638. /**
  28639. * Converts a cubemap to the according Spherical Polynomial data.
  28640. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28641. *
  28642. * @param cubeInfo The Cube map to extract the information from.
  28643. * @return The Spherical Polynomial data.
  28644. */
  28645. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28646. }
  28647. }
  28648. declare module "babylonjs/Misc/guid" {
  28649. /**
  28650. * Class used to manipulate GUIDs
  28651. */
  28652. export class GUID {
  28653. /**
  28654. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28655. * Be aware Math.random() could cause collisions, but:
  28656. * "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"
  28657. * @returns a pseudo random id
  28658. */
  28659. static RandomId(): string;
  28660. }
  28661. }
  28662. declare module "babylonjs/Materials/Textures/baseTexture" {
  28663. import { Observable } from "babylonjs/Misc/observable";
  28664. import { Nullable } from "babylonjs/types";
  28665. import { Scene } from "babylonjs/scene";
  28666. import { Matrix } from "babylonjs/Maths/math.vector";
  28667. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28668. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28669. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28670. import { ISize } from "babylonjs/Maths/math.size";
  28671. /**
  28672. * Base class of all the textures in babylon.
  28673. * It groups all the common properties the materials, post process, lights... might need
  28674. * in order to make a correct use of the texture.
  28675. */
  28676. export class BaseTexture implements IAnimatable {
  28677. /**
  28678. * Default anisotropic filtering level for the application.
  28679. * It is set to 4 as a good tradeoff between perf and quality.
  28680. */
  28681. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28682. /**
  28683. * Gets or sets the unique id of the texture
  28684. */
  28685. uniqueId: number;
  28686. /**
  28687. * Define the name of the texture.
  28688. */
  28689. name: string;
  28690. /**
  28691. * Gets or sets an object used to store user defined information.
  28692. */
  28693. metadata: any;
  28694. /**
  28695. * For internal use only. Please do not use.
  28696. */
  28697. reservedDataStore: any;
  28698. private _hasAlpha;
  28699. /**
  28700. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28701. */
  28702. hasAlpha: boolean;
  28703. /**
  28704. * Defines if the alpha value should be determined via the rgb values.
  28705. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28706. */
  28707. getAlphaFromRGB: boolean;
  28708. /**
  28709. * Intensity or strength of the texture.
  28710. * It is commonly used by materials to fine tune the intensity of the texture
  28711. */
  28712. level: number;
  28713. /**
  28714. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28715. * This is part of the texture as textures usually maps to one uv set.
  28716. */
  28717. coordinatesIndex: number;
  28718. private _coordinatesMode;
  28719. /**
  28720. * How a texture is mapped.
  28721. *
  28722. * | Value | Type | Description |
  28723. * | ----- | ----------------------------------- | ----------- |
  28724. * | 0 | EXPLICIT_MODE | |
  28725. * | 1 | SPHERICAL_MODE | |
  28726. * | 2 | PLANAR_MODE | |
  28727. * | 3 | CUBIC_MODE | |
  28728. * | 4 | PROJECTION_MODE | |
  28729. * | 5 | SKYBOX_MODE | |
  28730. * | 6 | INVCUBIC_MODE | |
  28731. * | 7 | EQUIRECTANGULAR_MODE | |
  28732. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28733. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28734. */
  28735. coordinatesMode: number;
  28736. /**
  28737. * | Value | Type | Description |
  28738. * | ----- | ------------------ | ----------- |
  28739. * | 0 | CLAMP_ADDRESSMODE | |
  28740. * | 1 | WRAP_ADDRESSMODE | |
  28741. * | 2 | MIRROR_ADDRESSMODE | |
  28742. */
  28743. wrapU: number;
  28744. /**
  28745. * | Value | Type | Description |
  28746. * | ----- | ------------------ | ----------- |
  28747. * | 0 | CLAMP_ADDRESSMODE | |
  28748. * | 1 | WRAP_ADDRESSMODE | |
  28749. * | 2 | MIRROR_ADDRESSMODE | |
  28750. */
  28751. wrapV: number;
  28752. /**
  28753. * | Value | Type | Description |
  28754. * | ----- | ------------------ | ----------- |
  28755. * | 0 | CLAMP_ADDRESSMODE | |
  28756. * | 1 | WRAP_ADDRESSMODE | |
  28757. * | 2 | MIRROR_ADDRESSMODE | |
  28758. */
  28759. wrapR: number;
  28760. /**
  28761. * With compliant hardware and browser (supporting anisotropic filtering)
  28762. * this defines the level of anisotropic filtering in the texture.
  28763. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28764. */
  28765. anisotropicFilteringLevel: number;
  28766. /**
  28767. * Define if the texture is a cube texture or if false a 2d texture.
  28768. */
  28769. isCube: boolean;
  28770. /**
  28771. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28772. */
  28773. is3D: boolean;
  28774. /**
  28775. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28776. * HDR texture are usually stored in linear space.
  28777. * This only impacts the PBR and Background materials
  28778. */
  28779. gammaSpace: boolean;
  28780. /**
  28781. * Gets or sets whether or not the texture contains RGBD data.
  28782. */
  28783. isRGBD: boolean;
  28784. /**
  28785. * Is Z inverted in the texture (useful in a cube texture).
  28786. */
  28787. invertZ: boolean;
  28788. /**
  28789. * Are mip maps generated for this texture or not.
  28790. */
  28791. readonly noMipmap: boolean;
  28792. /**
  28793. * @hidden
  28794. */
  28795. lodLevelInAlpha: boolean;
  28796. /**
  28797. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28798. */
  28799. lodGenerationOffset: number;
  28800. /**
  28801. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28802. */
  28803. lodGenerationScale: number;
  28804. /**
  28805. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28806. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28807. * average roughness values.
  28808. */
  28809. linearSpecularLOD: boolean;
  28810. /**
  28811. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28812. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28813. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28814. */
  28815. irradianceTexture: Nullable<BaseTexture>;
  28816. /**
  28817. * Define if the texture is a render target.
  28818. */
  28819. isRenderTarget: boolean;
  28820. /**
  28821. * Define the unique id of the texture in the scene.
  28822. */
  28823. readonly uid: string;
  28824. /**
  28825. * Return a string representation of the texture.
  28826. * @returns the texture as a string
  28827. */
  28828. toString(): string;
  28829. /**
  28830. * Get the class name of the texture.
  28831. * @returns "BaseTexture"
  28832. */
  28833. getClassName(): string;
  28834. /**
  28835. * Define the list of animation attached to the texture.
  28836. */
  28837. animations: import("babylonjs/Animations/animation").Animation[];
  28838. /**
  28839. * An event triggered when the texture is disposed.
  28840. */
  28841. onDisposeObservable: Observable<BaseTexture>;
  28842. private _onDisposeObserver;
  28843. /**
  28844. * Callback triggered when the texture has been disposed.
  28845. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28846. */
  28847. onDispose: () => void;
  28848. /**
  28849. * Define the current state of the loading sequence when in delayed load mode.
  28850. */
  28851. delayLoadState: number;
  28852. private _scene;
  28853. /** @hidden */
  28854. _texture: Nullable<InternalTexture>;
  28855. private _uid;
  28856. /**
  28857. * Define if the texture is preventinga material to render or not.
  28858. * If not and the texture is not ready, the engine will use a default black texture instead.
  28859. */
  28860. readonly isBlocking: boolean;
  28861. /**
  28862. * Instantiates a new BaseTexture.
  28863. * Base class of all the textures in babylon.
  28864. * It groups all the common properties the materials, post process, lights... might need
  28865. * in order to make a correct use of the texture.
  28866. * @param scene Define the scene the texture blongs to
  28867. */
  28868. constructor(scene: Nullable<Scene>);
  28869. /**
  28870. * Get the scene the texture belongs to.
  28871. * @returns the scene or null if undefined
  28872. */
  28873. getScene(): Nullable<Scene>;
  28874. /**
  28875. * Get the texture transform matrix used to offset tile the texture for istance.
  28876. * @returns the transformation matrix
  28877. */
  28878. getTextureMatrix(): Matrix;
  28879. /**
  28880. * Get the texture reflection matrix used to rotate/transform the reflection.
  28881. * @returns the reflection matrix
  28882. */
  28883. getReflectionTextureMatrix(): Matrix;
  28884. /**
  28885. * Get the underlying lower level texture from Babylon.
  28886. * @returns the insternal texture
  28887. */
  28888. getInternalTexture(): Nullable<InternalTexture>;
  28889. /**
  28890. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28891. * @returns true if ready or not blocking
  28892. */
  28893. isReadyOrNotBlocking(): boolean;
  28894. /**
  28895. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28896. * @returns true if fully ready
  28897. */
  28898. isReady(): boolean;
  28899. private _cachedSize;
  28900. /**
  28901. * Get the size of the texture.
  28902. * @returns the texture size.
  28903. */
  28904. getSize(): ISize;
  28905. /**
  28906. * Get the base size of the texture.
  28907. * It can be different from the size if the texture has been resized for POT for instance
  28908. * @returns the base size
  28909. */
  28910. getBaseSize(): ISize;
  28911. /**
  28912. * Update the sampling mode of the texture.
  28913. * Default is Trilinear mode.
  28914. *
  28915. * | Value | Type | Description |
  28916. * | ----- | ------------------ | ----------- |
  28917. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28918. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28919. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28920. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28921. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28922. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28923. * | 7 | NEAREST_LINEAR | |
  28924. * | 8 | NEAREST_NEAREST | |
  28925. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28926. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28927. * | 11 | LINEAR_LINEAR | |
  28928. * | 12 | LINEAR_NEAREST | |
  28929. *
  28930. * > _mag_: magnification filter (close to the viewer)
  28931. * > _min_: minification filter (far from the viewer)
  28932. * > _mip_: filter used between mip map levels
  28933. *@param samplingMode Define the new sampling mode of the texture
  28934. */
  28935. updateSamplingMode(samplingMode: number): void;
  28936. /**
  28937. * Scales the texture if is `canRescale()`
  28938. * @param ratio the resize factor we want to use to rescale
  28939. */
  28940. scale(ratio: number): void;
  28941. /**
  28942. * Get if the texture can rescale.
  28943. */
  28944. readonly canRescale: boolean;
  28945. /** @hidden */
  28946. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28947. /** @hidden */
  28948. _rebuild(): void;
  28949. /**
  28950. * Triggers the load sequence in delayed load mode.
  28951. */
  28952. delayLoad(): void;
  28953. /**
  28954. * Clones the texture.
  28955. * @returns the cloned texture
  28956. */
  28957. clone(): Nullable<BaseTexture>;
  28958. /**
  28959. * Get the texture underlying type (INT, FLOAT...)
  28960. */
  28961. readonly textureType: number;
  28962. /**
  28963. * Get the texture underlying format (RGB, RGBA...)
  28964. */
  28965. readonly textureFormat: number;
  28966. /**
  28967. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28968. * This will returns an RGBA array buffer containing either in values (0-255) or
  28969. * float values (0-1) depending of the underlying buffer type.
  28970. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28971. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28972. * @param buffer defines a user defined buffer to fill with data (can be null)
  28973. * @returns The Array buffer containing the pixels data.
  28974. */
  28975. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28976. /**
  28977. * Release and destroy the underlying lower level texture aka internalTexture.
  28978. */
  28979. releaseInternalTexture(): void;
  28980. /**
  28981. * Get the polynomial representation of the texture data.
  28982. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28983. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28984. */
  28985. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28986. /** @hidden */
  28987. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28988. /** @hidden */
  28989. readonly _lodTextureMid: Nullable<BaseTexture>;
  28990. /** @hidden */
  28991. readonly _lodTextureLow: Nullable<BaseTexture>;
  28992. /**
  28993. * Dispose the texture and release its associated resources.
  28994. */
  28995. dispose(): void;
  28996. /**
  28997. * Serialize the texture into a JSON representation that can be parsed later on.
  28998. * @returns the JSON representation of the texture
  28999. */
  29000. serialize(): any;
  29001. /**
  29002. * Helper function to be called back once a list of texture contains only ready textures.
  29003. * @param textures Define the list of textures to wait for
  29004. * @param callback Define the callback triggered once the entire list will be ready
  29005. */
  29006. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29007. }
  29008. }
  29009. declare module "babylonjs/Materials/effect" {
  29010. import { Observable } from "babylonjs/Misc/observable";
  29011. import { Nullable } from "babylonjs/types";
  29012. import { IDisposable } from "babylonjs/scene";
  29013. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29014. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29015. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29016. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29017. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29018. import { Engine } from "babylonjs/Engines/engine";
  29019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29020. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29021. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29022. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29023. /**
  29024. * Options to be used when creating an effect.
  29025. */
  29026. export class EffectCreationOptions {
  29027. /**
  29028. * Atrributes that will be used in the shader.
  29029. */
  29030. attributes: string[];
  29031. /**
  29032. * Uniform varible names that will be set in the shader.
  29033. */
  29034. uniformsNames: string[];
  29035. /**
  29036. * Uniform buffer varible names that will be set in the shader.
  29037. */
  29038. uniformBuffersNames: string[];
  29039. /**
  29040. * Sampler texture variable names that will be set in the shader.
  29041. */
  29042. samplers: string[];
  29043. /**
  29044. * Define statements that will be set in the shader.
  29045. */
  29046. defines: any;
  29047. /**
  29048. * Possible fallbacks for this effect to improve performance when needed.
  29049. */
  29050. fallbacks: Nullable<IEffectFallbacks>;
  29051. /**
  29052. * Callback that will be called when the shader is compiled.
  29053. */
  29054. onCompiled: Nullable<(effect: Effect) => void>;
  29055. /**
  29056. * Callback that will be called if an error occurs during shader compilation.
  29057. */
  29058. onError: Nullable<(effect: Effect, errors: string) => void>;
  29059. /**
  29060. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29061. */
  29062. indexParameters?: any;
  29063. /**
  29064. * Max number of lights that can be used in the shader.
  29065. */
  29066. maxSimultaneousLights?: number;
  29067. /**
  29068. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29069. */
  29070. transformFeedbackVaryings?: Nullable<string[]>;
  29071. }
  29072. /**
  29073. * Effect containing vertex and fragment shader that can be executed on an object.
  29074. */
  29075. export class Effect implements IDisposable {
  29076. /**
  29077. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29078. */
  29079. static ShadersRepository: string;
  29080. /**
  29081. * Name of the effect.
  29082. */
  29083. name: any;
  29084. /**
  29085. * String container all the define statements that should be set on the shader.
  29086. */
  29087. defines: string;
  29088. /**
  29089. * Callback that will be called when the shader is compiled.
  29090. */
  29091. onCompiled: Nullable<(effect: Effect) => void>;
  29092. /**
  29093. * Callback that will be called if an error occurs during shader compilation.
  29094. */
  29095. onError: Nullable<(effect: Effect, errors: string) => void>;
  29096. /**
  29097. * Callback that will be called when effect is bound.
  29098. */
  29099. onBind: Nullable<(effect: Effect) => void>;
  29100. /**
  29101. * Unique ID of the effect.
  29102. */
  29103. uniqueId: number;
  29104. /**
  29105. * Observable that will be called when the shader is compiled.
  29106. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29107. */
  29108. onCompileObservable: Observable<Effect>;
  29109. /**
  29110. * Observable that will be called if an error occurs during shader compilation.
  29111. */
  29112. onErrorObservable: Observable<Effect>;
  29113. /** @hidden */
  29114. _onBindObservable: Nullable<Observable<Effect>>;
  29115. /**
  29116. * Observable that will be called when effect is bound.
  29117. */
  29118. readonly onBindObservable: Observable<Effect>;
  29119. /** @hidden */
  29120. _bonesComputationForcedToCPU: boolean;
  29121. private static _uniqueIdSeed;
  29122. private _engine;
  29123. private _uniformBuffersNames;
  29124. private _uniformsNames;
  29125. private _samplerList;
  29126. private _samplers;
  29127. private _isReady;
  29128. private _compilationError;
  29129. private _attributesNames;
  29130. private _attributes;
  29131. private _uniforms;
  29132. /**
  29133. * Key for the effect.
  29134. * @hidden
  29135. */
  29136. _key: string;
  29137. private _indexParameters;
  29138. private _fallbacks;
  29139. private _vertexSourceCode;
  29140. private _fragmentSourceCode;
  29141. private _vertexSourceCodeOverride;
  29142. private _fragmentSourceCodeOverride;
  29143. private _transformFeedbackVaryings;
  29144. /**
  29145. * Compiled shader to webGL program.
  29146. * @hidden
  29147. */
  29148. _pipelineContext: Nullable<IPipelineContext>;
  29149. private _valueCache;
  29150. private static _baseCache;
  29151. /**
  29152. * Instantiates an effect.
  29153. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29154. * @param baseName Name of the effect.
  29155. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29156. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29157. * @param samplers List of sampler variables that will be passed to the shader.
  29158. * @param engine Engine to be used to render the effect
  29159. * @param defines Define statements to be added to the shader.
  29160. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29161. * @param onCompiled Callback that will be called when the shader is compiled.
  29162. * @param onError Callback that will be called if an error occurs during shader compilation.
  29163. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29164. */
  29165. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  29166. private _useFinalCode;
  29167. /**
  29168. * Unique key for this effect
  29169. */
  29170. readonly key: string;
  29171. /**
  29172. * If the effect has been compiled and prepared.
  29173. * @returns if the effect is compiled and prepared.
  29174. */
  29175. isReady(): boolean;
  29176. private _isReadyInternal;
  29177. /**
  29178. * The engine the effect was initialized with.
  29179. * @returns the engine.
  29180. */
  29181. getEngine(): Engine;
  29182. /**
  29183. * The pipeline context for this effect
  29184. * @returns the associated pipeline context
  29185. */
  29186. getPipelineContext(): Nullable<IPipelineContext>;
  29187. /**
  29188. * The set of names of attribute variables for the shader.
  29189. * @returns An array of attribute names.
  29190. */
  29191. getAttributesNames(): string[];
  29192. /**
  29193. * Returns the attribute at the given index.
  29194. * @param index The index of the attribute.
  29195. * @returns The location of the attribute.
  29196. */
  29197. getAttributeLocation(index: number): number;
  29198. /**
  29199. * Returns the attribute based on the name of the variable.
  29200. * @param name of the attribute to look up.
  29201. * @returns the attribute location.
  29202. */
  29203. getAttributeLocationByName(name: string): number;
  29204. /**
  29205. * The number of attributes.
  29206. * @returns the numnber of attributes.
  29207. */
  29208. getAttributesCount(): number;
  29209. /**
  29210. * Gets the index of a uniform variable.
  29211. * @param uniformName of the uniform to look up.
  29212. * @returns the index.
  29213. */
  29214. getUniformIndex(uniformName: string): number;
  29215. /**
  29216. * Returns the attribute based on the name of the variable.
  29217. * @param uniformName of the uniform to look up.
  29218. * @returns the location of the uniform.
  29219. */
  29220. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29221. /**
  29222. * Returns an array of sampler variable names
  29223. * @returns The array of sampler variable neames.
  29224. */
  29225. getSamplers(): string[];
  29226. /**
  29227. * The error from the last compilation.
  29228. * @returns the error string.
  29229. */
  29230. getCompilationError(): string;
  29231. /**
  29232. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29233. * @param func The callback to be used.
  29234. */
  29235. executeWhenCompiled(func: (effect: Effect) => void): void;
  29236. private _checkIsReady;
  29237. /** @hidden */
  29238. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29239. /** @hidden */
  29240. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29241. /** @hidden */
  29242. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29243. /**
  29244. * Recompiles the webGL program
  29245. * @param vertexSourceCode The source code for the vertex shader.
  29246. * @param fragmentSourceCode The source code for the fragment shader.
  29247. * @param onCompiled Callback called when completed.
  29248. * @param onError Callback called on error.
  29249. * @hidden
  29250. */
  29251. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29252. /**
  29253. * Prepares the effect
  29254. * @hidden
  29255. */
  29256. _prepareEffect(): void;
  29257. private _processCompilationErrors;
  29258. /**
  29259. * Checks if the effect is supported. (Must be called after compilation)
  29260. */
  29261. readonly isSupported: boolean;
  29262. /**
  29263. * Binds a texture to the engine to be used as output of the shader.
  29264. * @param channel Name of the output variable.
  29265. * @param texture Texture to bind.
  29266. * @hidden
  29267. */
  29268. _bindTexture(channel: string, texture: InternalTexture): void;
  29269. /**
  29270. * Sets a texture on the engine to be used in the shader.
  29271. * @param channel Name of the sampler variable.
  29272. * @param texture Texture to set.
  29273. */
  29274. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29275. /**
  29276. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29277. * @param channel Name of the sampler variable.
  29278. * @param texture Texture to set.
  29279. */
  29280. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29281. /**
  29282. * Sets an array of textures on the engine to be used in the shader.
  29283. * @param channel Name of the variable.
  29284. * @param textures Textures to set.
  29285. */
  29286. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29287. /**
  29288. * 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)
  29289. * @param channel Name of the sampler variable.
  29290. * @param postProcess Post process to get the input texture from.
  29291. */
  29292. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29293. /**
  29294. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29295. * 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)
  29296. * @param channel Name of the sampler variable.
  29297. * @param postProcess Post process to get the output texture from.
  29298. */
  29299. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29300. /** @hidden */
  29301. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29302. /** @hidden */
  29303. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29304. /** @hidden */
  29305. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29306. /** @hidden */
  29307. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29308. /**
  29309. * Binds a buffer to a uniform.
  29310. * @param buffer Buffer to bind.
  29311. * @param name Name of the uniform variable to bind to.
  29312. */
  29313. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29314. /**
  29315. * Binds block to a uniform.
  29316. * @param blockName Name of the block to bind.
  29317. * @param index Index to bind.
  29318. */
  29319. bindUniformBlock(blockName: string, index: number): void;
  29320. /**
  29321. * Sets an interger value on a uniform variable.
  29322. * @param uniformName Name of the variable.
  29323. * @param value Value to be set.
  29324. * @returns this effect.
  29325. */
  29326. setInt(uniformName: string, value: number): Effect;
  29327. /**
  29328. * Sets an int array on a uniform variable.
  29329. * @param uniformName Name of the variable.
  29330. * @param array array to be set.
  29331. * @returns this effect.
  29332. */
  29333. setIntArray(uniformName: string, array: Int32Array): Effect;
  29334. /**
  29335. * 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)
  29336. * @param uniformName Name of the variable.
  29337. * @param array array to be set.
  29338. * @returns this effect.
  29339. */
  29340. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29341. /**
  29342. * 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)
  29343. * @param uniformName Name of the variable.
  29344. * @param array array to be set.
  29345. * @returns this effect.
  29346. */
  29347. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29348. /**
  29349. * 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)
  29350. * @param uniformName Name of the variable.
  29351. * @param array array to be set.
  29352. * @returns this effect.
  29353. */
  29354. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29355. /**
  29356. * Sets an float array on a uniform variable.
  29357. * @param uniformName Name of the variable.
  29358. * @param array array to be set.
  29359. * @returns this effect.
  29360. */
  29361. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29362. /**
  29363. * 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)
  29364. * @param uniformName Name of the variable.
  29365. * @param array array to be set.
  29366. * @returns this effect.
  29367. */
  29368. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29369. /**
  29370. * 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)
  29371. * @param uniformName Name of the variable.
  29372. * @param array array to be set.
  29373. * @returns this effect.
  29374. */
  29375. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29376. /**
  29377. * 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)
  29378. * @param uniformName Name of the variable.
  29379. * @param array array to be set.
  29380. * @returns this effect.
  29381. */
  29382. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29383. /**
  29384. * Sets an array on a uniform variable.
  29385. * @param uniformName Name of the variable.
  29386. * @param array array to be set.
  29387. * @returns this effect.
  29388. */
  29389. setArray(uniformName: string, array: number[]): Effect;
  29390. /**
  29391. * 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)
  29392. * @param uniformName Name of the variable.
  29393. * @param array array to be set.
  29394. * @returns this effect.
  29395. */
  29396. setArray2(uniformName: string, array: number[]): Effect;
  29397. /**
  29398. * 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)
  29399. * @param uniformName Name of the variable.
  29400. * @param array array to be set.
  29401. * @returns this effect.
  29402. */
  29403. setArray3(uniformName: string, array: number[]): Effect;
  29404. /**
  29405. * 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)
  29406. * @param uniformName Name of the variable.
  29407. * @param array array to be set.
  29408. * @returns this effect.
  29409. */
  29410. setArray4(uniformName: string, array: number[]): Effect;
  29411. /**
  29412. * Sets matrices on a uniform variable.
  29413. * @param uniformName Name of the variable.
  29414. * @param matrices matrices to be set.
  29415. * @returns this effect.
  29416. */
  29417. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29418. /**
  29419. * Sets matrix on a uniform variable.
  29420. * @param uniformName Name of the variable.
  29421. * @param matrix matrix to be set.
  29422. * @returns this effect.
  29423. */
  29424. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29425. /**
  29426. * 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)
  29427. * @param uniformName Name of the variable.
  29428. * @param matrix matrix to be set.
  29429. * @returns this effect.
  29430. */
  29431. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29432. /**
  29433. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29434. * @param uniformName Name of the variable.
  29435. * @param matrix matrix to be set.
  29436. * @returns this effect.
  29437. */
  29438. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29439. /**
  29440. * Sets a float on a uniform variable.
  29441. * @param uniformName Name of the variable.
  29442. * @param value value to be set.
  29443. * @returns this effect.
  29444. */
  29445. setFloat(uniformName: string, value: number): Effect;
  29446. /**
  29447. * Sets a boolean on a uniform variable.
  29448. * @param uniformName Name of the variable.
  29449. * @param bool value to be set.
  29450. * @returns this effect.
  29451. */
  29452. setBool(uniformName: string, bool: boolean): Effect;
  29453. /**
  29454. * Sets a Vector2 on a uniform variable.
  29455. * @param uniformName Name of the variable.
  29456. * @param vector2 vector2 to be set.
  29457. * @returns this effect.
  29458. */
  29459. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29460. /**
  29461. * Sets a float2 on a uniform variable.
  29462. * @param uniformName Name of the variable.
  29463. * @param x First float in float2.
  29464. * @param y Second float in float2.
  29465. * @returns this effect.
  29466. */
  29467. setFloat2(uniformName: string, x: number, y: number): Effect;
  29468. /**
  29469. * Sets a Vector3 on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param vector3 Value to be set.
  29472. * @returns this effect.
  29473. */
  29474. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29475. /**
  29476. * Sets a float3 on a uniform variable.
  29477. * @param uniformName Name of the variable.
  29478. * @param x First float in float3.
  29479. * @param y Second float in float3.
  29480. * @param z Third float in float3.
  29481. * @returns this effect.
  29482. */
  29483. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29484. /**
  29485. * Sets a Vector4 on a uniform variable.
  29486. * @param uniformName Name of the variable.
  29487. * @param vector4 Value to be set.
  29488. * @returns this effect.
  29489. */
  29490. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29491. /**
  29492. * Sets a float4 on a uniform variable.
  29493. * @param uniformName Name of the variable.
  29494. * @param x First float in float4.
  29495. * @param y Second float in float4.
  29496. * @param z Third float in float4.
  29497. * @param w Fourth float in float4.
  29498. * @returns this effect.
  29499. */
  29500. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29501. /**
  29502. * Sets a Color3 on a uniform variable.
  29503. * @param uniformName Name of the variable.
  29504. * @param color3 Value to be set.
  29505. * @returns this effect.
  29506. */
  29507. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29508. /**
  29509. * Sets a Color4 on a uniform variable.
  29510. * @param uniformName Name of the variable.
  29511. * @param color3 Value to be set.
  29512. * @param alpha Alpha value to be set.
  29513. * @returns this effect.
  29514. */
  29515. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29516. /**
  29517. * Sets a Color4 on a uniform variable
  29518. * @param uniformName defines the name of the variable
  29519. * @param color4 defines the value to be set
  29520. * @returns this effect.
  29521. */
  29522. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29523. /** Release all associated resources */
  29524. dispose(): void;
  29525. /**
  29526. * This function will add a new shader to the shader store
  29527. * @param name the name of the shader
  29528. * @param pixelShader optional pixel shader content
  29529. * @param vertexShader optional vertex shader content
  29530. */
  29531. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29532. /**
  29533. * Store of each shader (The can be looked up using effect.key)
  29534. */
  29535. static ShadersStore: {
  29536. [key: string]: string;
  29537. };
  29538. /**
  29539. * Store of each included file for a shader (The can be looked up using effect.key)
  29540. */
  29541. static IncludesShadersStore: {
  29542. [key: string]: string;
  29543. };
  29544. /**
  29545. * Resets the cache of effects.
  29546. */
  29547. static ResetCache(): void;
  29548. }
  29549. }
  29550. declare module "babylonjs/Engines/engineCapabilities" {
  29551. import { Nullable } from "babylonjs/types";
  29552. /**
  29553. * Class used to describe the capabilities of the engine relatively to the current browser
  29554. */
  29555. export class EngineCapabilities {
  29556. /** Maximum textures units per fragment shader */
  29557. maxTexturesImageUnits: number;
  29558. /** Maximum texture units per vertex shader */
  29559. maxVertexTextureImageUnits: number;
  29560. /** Maximum textures units in the entire pipeline */
  29561. maxCombinedTexturesImageUnits: number;
  29562. /** Maximum texture size */
  29563. maxTextureSize: number;
  29564. /** Maximum cube texture size */
  29565. maxCubemapTextureSize: number;
  29566. /** Maximum render texture size */
  29567. maxRenderTextureSize: number;
  29568. /** Maximum number of vertex attributes */
  29569. maxVertexAttribs: number;
  29570. /** Maximum number of varyings */
  29571. maxVaryingVectors: number;
  29572. /** Maximum number of uniforms per vertex shader */
  29573. maxVertexUniformVectors: number;
  29574. /** Maximum number of uniforms per fragment shader */
  29575. maxFragmentUniformVectors: number;
  29576. /** Defines if standard derivates (dx/dy) are supported */
  29577. standardDerivatives: boolean;
  29578. /** Defines if s3tc texture compression is supported */
  29579. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29580. /** Defines if pvrtc texture compression is supported */
  29581. pvrtc: any;
  29582. /** Defines if etc1 texture compression is supported */
  29583. etc1: any;
  29584. /** Defines if etc2 texture compression is supported */
  29585. etc2: any;
  29586. /** Defines if astc texture compression is supported */
  29587. astc: any;
  29588. /** Defines if float textures are supported */
  29589. textureFloat: boolean;
  29590. /** Defines if vertex array objects are supported */
  29591. vertexArrayObject: boolean;
  29592. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29593. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29594. /** Gets the maximum level of anisotropy supported */
  29595. maxAnisotropy: number;
  29596. /** Defines if instancing is supported */
  29597. instancedArrays: boolean;
  29598. /** Defines if 32 bits indices are supported */
  29599. uintIndices: boolean;
  29600. /** Defines if high precision shaders are supported */
  29601. highPrecisionShaderSupported: boolean;
  29602. /** Defines if depth reading in the fragment shader is supported */
  29603. fragmentDepthSupported: boolean;
  29604. /** Defines if float texture linear filtering is supported*/
  29605. textureFloatLinearFiltering: boolean;
  29606. /** Defines if rendering to float textures is supported */
  29607. textureFloatRender: boolean;
  29608. /** Defines if half float textures are supported*/
  29609. textureHalfFloat: boolean;
  29610. /** Defines if half float texture linear filtering is supported*/
  29611. textureHalfFloatLinearFiltering: boolean;
  29612. /** Defines if rendering to half float textures is supported */
  29613. textureHalfFloatRender: boolean;
  29614. /** Defines if textureLOD shader command is supported */
  29615. textureLOD: boolean;
  29616. /** Defines if draw buffers extension is supported */
  29617. drawBuffersExtension: boolean;
  29618. /** Defines if depth textures are supported */
  29619. depthTextureExtension: boolean;
  29620. /** Defines if float color buffer are supported */
  29621. colorBufferFloat: boolean;
  29622. /** Gets disjoint timer query extension (null if not supported) */
  29623. timerQuery: EXT_disjoint_timer_query;
  29624. /** Defines if timestamp can be used with timer query */
  29625. canUseTimestampForTimerQuery: boolean;
  29626. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29627. multiview: any;
  29628. /** Function used to let the system compiles shaders in background */
  29629. parallelShaderCompile: {
  29630. COMPLETION_STATUS_KHR: number;
  29631. };
  29632. /** Max number of texture samples for MSAA */
  29633. maxMSAASamples: number;
  29634. /** Defines if the blend min max extension is supported */
  29635. blendMinMax: boolean;
  29636. }
  29637. }
  29638. declare module "babylonjs/Misc/perfCounter" {
  29639. /**
  29640. * This class is used to track a performance counter which is number based.
  29641. * The user has access to many properties which give statistics of different nature.
  29642. *
  29643. * The implementer can track two kinds of Performance Counter: time and count.
  29644. * 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.
  29645. * 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.
  29646. */
  29647. export class PerfCounter {
  29648. /**
  29649. * Gets or sets a global boolean to turn on and off all the counters
  29650. */
  29651. static Enabled: boolean;
  29652. /**
  29653. * Returns the smallest value ever
  29654. */
  29655. readonly min: number;
  29656. /**
  29657. * Returns the biggest value ever
  29658. */
  29659. readonly max: number;
  29660. /**
  29661. * Returns the average value since the performance counter is running
  29662. */
  29663. readonly average: number;
  29664. /**
  29665. * Returns the average value of the last second the counter was monitored
  29666. */
  29667. readonly lastSecAverage: number;
  29668. /**
  29669. * Returns the current value
  29670. */
  29671. readonly current: number;
  29672. /**
  29673. * Gets the accumulated total
  29674. */
  29675. readonly total: number;
  29676. /**
  29677. * Gets the total value count
  29678. */
  29679. readonly count: number;
  29680. /**
  29681. * Creates a new counter
  29682. */
  29683. constructor();
  29684. /**
  29685. * Call this method to start monitoring a new frame.
  29686. * 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.
  29687. */
  29688. fetchNewFrame(): void;
  29689. /**
  29690. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29691. * @param newCount the count value to add to the monitored count
  29692. * @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.
  29693. */
  29694. addCount(newCount: number, fetchResult: boolean): void;
  29695. /**
  29696. * Start monitoring this performance counter
  29697. */
  29698. beginMonitoring(): void;
  29699. /**
  29700. * Compute the time lapsed since the previous beginMonitoring() call.
  29701. * @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
  29702. */
  29703. endMonitoring(newFrame?: boolean): void;
  29704. private _fetchResult;
  29705. private _startMonitoringTime;
  29706. private _min;
  29707. private _max;
  29708. private _average;
  29709. private _current;
  29710. private _totalValueCount;
  29711. private _totalAccumulated;
  29712. private _lastSecAverage;
  29713. private _lastSecAccumulated;
  29714. private _lastSecTime;
  29715. private _lastSecValueCount;
  29716. }
  29717. }
  29718. declare module "babylonjs/States/depthCullingState" {
  29719. import { Nullable } from "babylonjs/types";
  29720. /**
  29721. * @hidden
  29722. **/
  29723. export class DepthCullingState {
  29724. private _isDepthTestDirty;
  29725. private _isDepthMaskDirty;
  29726. private _isDepthFuncDirty;
  29727. private _isCullFaceDirty;
  29728. private _isCullDirty;
  29729. private _isZOffsetDirty;
  29730. private _isFrontFaceDirty;
  29731. private _depthTest;
  29732. private _depthMask;
  29733. private _depthFunc;
  29734. private _cull;
  29735. private _cullFace;
  29736. private _zOffset;
  29737. private _frontFace;
  29738. /**
  29739. * Initializes the state.
  29740. */
  29741. constructor();
  29742. readonly isDirty: boolean;
  29743. zOffset: number;
  29744. cullFace: Nullable<number>;
  29745. cull: Nullable<boolean>;
  29746. depthFunc: Nullable<number>;
  29747. depthMask: boolean;
  29748. depthTest: boolean;
  29749. frontFace: Nullable<number>;
  29750. reset(): void;
  29751. apply(gl: WebGLRenderingContext): void;
  29752. }
  29753. }
  29754. declare module "babylonjs/States/stencilState" {
  29755. /**
  29756. * @hidden
  29757. **/
  29758. export class StencilState {
  29759. /** 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 */
  29760. static readonly ALWAYS: number;
  29761. /** Passed to stencilOperation to specify that stencil value must be kept */
  29762. static readonly KEEP: number;
  29763. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29764. static readonly REPLACE: number;
  29765. private _isStencilTestDirty;
  29766. private _isStencilMaskDirty;
  29767. private _isStencilFuncDirty;
  29768. private _isStencilOpDirty;
  29769. private _stencilTest;
  29770. private _stencilMask;
  29771. private _stencilFunc;
  29772. private _stencilFuncRef;
  29773. private _stencilFuncMask;
  29774. private _stencilOpStencilFail;
  29775. private _stencilOpDepthFail;
  29776. private _stencilOpStencilDepthPass;
  29777. readonly isDirty: boolean;
  29778. stencilFunc: number;
  29779. stencilFuncRef: number;
  29780. stencilFuncMask: number;
  29781. stencilOpStencilFail: number;
  29782. stencilOpDepthFail: number;
  29783. stencilOpStencilDepthPass: number;
  29784. stencilMask: number;
  29785. stencilTest: boolean;
  29786. constructor();
  29787. reset(): void;
  29788. apply(gl: WebGLRenderingContext): void;
  29789. }
  29790. }
  29791. declare module "babylonjs/States/alphaCullingState" {
  29792. /**
  29793. * @hidden
  29794. **/
  29795. export class AlphaState {
  29796. private _isAlphaBlendDirty;
  29797. private _isBlendFunctionParametersDirty;
  29798. private _isBlendEquationParametersDirty;
  29799. private _isBlendConstantsDirty;
  29800. private _alphaBlend;
  29801. private _blendFunctionParameters;
  29802. private _blendEquationParameters;
  29803. private _blendConstants;
  29804. /**
  29805. * Initializes the state.
  29806. */
  29807. constructor();
  29808. readonly isDirty: boolean;
  29809. alphaBlend: boolean;
  29810. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29811. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29812. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29813. reset(): void;
  29814. apply(gl: WebGLRenderingContext): void;
  29815. }
  29816. }
  29817. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29818. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29819. /** @hidden */
  29820. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29821. attributeProcessor(attribute: string): string;
  29822. varyingProcessor(varying: string, isFragment: boolean): string;
  29823. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29824. }
  29825. }
  29826. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29827. /**
  29828. * Interface for attribute information associated with buffer instanciation
  29829. */
  29830. export class InstancingAttributeInfo {
  29831. /**
  29832. * Index/offset of the attribute in the vertex shader
  29833. */
  29834. index: number;
  29835. /**
  29836. * size of the attribute, 1, 2, 3 or 4
  29837. */
  29838. attributeSize: number;
  29839. /**
  29840. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29841. * default is FLOAT
  29842. */
  29843. attribyteType: number;
  29844. /**
  29845. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29846. */
  29847. normalized: boolean;
  29848. /**
  29849. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29850. */
  29851. offset: number;
  29852. /**
  29853. * Name of the GLSL attribute, for debugging purpose only
  29854. */
  29855. attributeName: string;
  29856. }
  29857. }
  29858. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29859. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29860. import { Nullable } from "babylonjs/types";
  29861. module "babylonjs/Engines/thinEngine" {
  29862. interface ThinEngine {
  29863. /**
  29864. * Update a video texture
  29865. * @param texture defines the texture to update
  29866. * @param video defines the video element to use
  29867. * @param invertY defines if data must be stored with Y axis inverted
  29868. */
  29869. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29870. }
  29871. }
  29872. }
  29873. declare module "babylonjs/Materials/Textures/videoTexture" {
  29874. import { Observable } from "babylonjs/Misc/observable";
  29875. import { Nullable } from "babylonjs/types";
  29876. import { Scene } from "babylonjs/scene";
  29877. import { Texture } from "babylonjs/Materials/Textures/texture";
  29878. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29879. /**
  29880. * Settings for finer control over video usage
  29881. */
  29882. export interface VideoTextureSettings {
  29883. /**
  29884. * Applies `autoplay` to video, if specified
  29885. */
  29886. autoPlay?: boolean;
  29887. /**
  29888. * Applies `loop` to video, if specified
  29889. */
  29890. loop?: boolean;
  29891. /**
  29892. * Automatically updates internal texture from video at every frame in the render loop
  29893. */
  29894. autoUpdateTexture: boolean;
  29895. /**
  29896. * Image src displayed during the video loading or until the user interacts with the video.
  29897. */
  29898. poster?: string;
  29899. }
  29900. /**
  29901. * If you want to display a video in your scene, this is the special texture for that.
  29902. * This special texture works similar to other textures, with the exception of a few parameters.
  29903. * @see https://doc.babylonjs.com/how_to/video_texture
  29904. */
  29905. export class VideoTexture extends Texture {
  29906. /**
  29907. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29908. */
  29909. readonly autoUpdateTexture: boolean;
  29910. /**
  29911. * The video instance used by the texture internally
  29912. */
  29913. readonly video: HTMLVideoElement;
  29914. private _onUserActionRequestedObservable;
  29915. /**
  29916. * Event triggerd when a dom action is required by the user to play the video.
  29917. * This happens due to recent changes in browser policies preventing video to auto start.
  29918. */
  29919. readonly onUserActionRequestedObservable: Observable<Texture>;
  29920. private _generateMipMaps;
  29921. private _engine;
  29922. private _stillImageCaptured;
  29923. private _displayingPosterTexture;
  29924. private _settings;
  29925. private _createInternalTextureOnEvent;
  29926. private _frameId;
  29927. /**
  29928. * Creates a video texture.
  29929. * If you want to display a video in your scene, this is the special texture for that.
  29930. * This special texture works similar to other textures, with the exception of a few parameters.
  29931. * @see https://doc.babylonjs.com/how_to/video_texture
  29932. * @param name optional name, will detect from video source, if not defined
  29933. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29934. * @param scene is obviously the current scene.
  29935. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29936. * @param invertY is false by default but can be used to invert video on Y axis
  29937. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29938. * @param settings allows finer control over video usage
  29939. */
  29940. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29941. private _getName;
  29942. private _getVideo;
  29943. private _createInternalTexture;
  29944. private reset;
  29945. /**
  29946. * @hidden Internal method to initiate `update`.
  29947. */
  29948. _rebuild(): void;
  29949. /**
  29950. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29951. */
  29952. update(): void;
  29953. /**
  29954. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29955. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29956. */
  29957. updateTexture(isVisible: boolean): void;
  29958. protected _updateInternalTexture: () => void;
  29959. /**
  29960. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29961. * @param url New url.
  29962. */
  29963. updateURL(url: string): void;
  29964. /**
  29965. * Dispose the texture and release its associated resources.
  29966. */
  29967. dispose(): void;
  29968. /**
  29969. * Creates a video texture straight from a stream.
  29970. * @param scene Define the scene the texture should be created in
  29971. * @param stream Define the stream the texture should be created from
  29972. * @returns The created video texture as a promise
  29973. */
  29974. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29975. /**
  29976. * Creates a video texture straight from your WebCam video feed.
  29977. * @param scene Define the scene the texture should be created in
  29978. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29979. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29980. * @returns The created video texture as a promise
  29981. */
  29982. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29983. minWidth: number;
  29984. maxWidth: number;
  29985. minHeight: number;
  29986. maxHeight: number;
  29987. deviceId: string;
  29988. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29989. /**
  29990. * Creates a video texture straight from your WebCam video feed.
  29991. * @param scene Define the scene the texture should be created in
  29992. * @param onReady Define a callback to triggered once the texture will be ready
  29993. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29994. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29995. */
  29996. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29997. minWidth: number;
  29998. maxWidth: number;
  29999. minHeight: number;
  30000. maxHeight: number;
  30001. deviceId: string;
  30002. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30003. }
  30004. }
  30005. declare module "babylonjs/Engines/thinEngine" {
  30006. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30007. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  30008. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30009. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30010. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30011. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30012. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30013. import { Observable } from "babylonjs/Misc/observable";
  30014. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30015. import { StencilState } from "babylonjs/States/stencilState";
  30016. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30017. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30018. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30019. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30020. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30021. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30022. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30023. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30024. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30025. import { WebRequest } from "babylonjs/Misc/webRequest";
  30026. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  30027. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30028. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30029. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30030. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30031. /**
  30032. * Defines the interface used by objects working like Scene
  30033. * @hidden
  30034. */
  30035. interface ISceneLike {
  30036. _addPendingData(data: any): void;
  30037. _removePendingData(data: any): void;
  30038. offlineProvider: IOfflineProvider;
  30039. }
  30040. /** Interface defining initialization parameters for Engine class */
  30041. export interface EngineOptions extends WebGLContextAttributes {
  30042. /**
  30043. * Defines if the engine should no exceed a specified device ratio
  30044. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30045. */
  30046. limitDeviceRatio?: number;
  30047. /**
  30048. * Defines if webvr should be enabled automatically
  30049. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30050. */
  30051. autoEnableWebVR?: boolean;
  30052. /**
  30053. * Defines if webgl2 should be turned off even if supported
  30054. * @see http://doc.babylonjs.com/features/webgl2
  30055. */
  30056. disableWebGL2Support?: boolean;
  30057. /**
  30058. * Defines if webaudio should be initialized as well
  30059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30060. */
  30061. audioEngine?: boolean;
  30062. /**
  30063. * Defines if animations should run using a deterministic lock step
  30064. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30065. */
  30066. deterministicLockstep?: boolean;
  30067. /** Defines the maximum steps to use with deterministic lock step mode */
  30068. lockstepMaxSteps?: number;
  30069. /**
  30070. * Defines that engine should ignore context lost events
  30071. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30072. */
  30073. doNotHandleContextLost?: boolean;
  30074. /**
  30075. * Defines that engine should ignore modifying touch action attribute and style
  30076. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30077. */
  30078. doNotHandleTouchAction?: boolean;
  30079. /**
  30080. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30081. */
  30082. useHighPrecisionFloats?: boolean;
  30083. }
  30084. /**
  30085. * The base engine class (root of all engines)
  30086. */
  30087. export class ThinEngine {
  30088. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30089. static ExceptionList: ({
  30090. key: string;
  30091. capture: string;
  30092. captureConstraint: number;
  30093. targets: string[];
  30094. } | {
  30095. key: string;
  30096. capture: null;
  30097. captureConstraint: null;
  30098. targets: string[];
  30099. })[];
  30100. /** @hidden */
  30101. static _TextureLoaders: IInternalTextureLoader[];
  30102. /**
  30103. * Returns the current npm package of the sdk
  30104. */
  30105. static readonly NpmPackage: string;
  30106. /**
  30107. * Returns the current version of the framework
  30108. */
  30109. static readonly Version: string;
  30110. /**
  30111. * Returns a string describing the current engine
  30112. */
  30113. readonly description: string;
  30114. /**
  30115. * Gets or sets the epsilon value used by collision engine
  30116. */
  30117. static CollisionsEpsilon: number;
  30118. /**
  30119. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30120. */
  30121. static ShadersRepository: string;
  30122. /** @hidden */
  30123. _shaderProcessor: IShaderProcessor;
  30124. /**
  30125. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30126. */
  30127. forcePOTTextures: boolean;
  30128. /**
  30129. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30130. */
  30131. isFullscreen: boolean;
  30132. /**
  30133. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30134. */
  30135. cullBackFaces: boolean;
  30136. /**
  30137. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30138. */
  30139. renderEvenInBackground: boolean;
  30140. /**
  30141. * Gets or sets a boolean indicating that cache can be kept between frames
  30142. */
  30143. preventCacheWipeBetweenFrames: boolean;
  30144. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30145. validateShaderPrograms: boolean;
  30146. /**
  30147. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30148. */
  30149. disableUniformBuffers: boolean;
  30150. /** @hidden */
  30151. _uniformBuffers: UniformBuffer[];
  30152. /**
  30153. * Gets a boolean indicating that the engine supports uniform buffers
  30154. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30155. */
  30156. readonly supportsUniformBuffers: boolean;
  30157. /** @hidden */
  30158. _gl: WebGLRenderingContext;
  30159. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30160. protected _windowIsBackground: boolean;
  30161. protected _webGLVersion: number;
  30162. protected _highPrecisionShadersAllowed: boolean;
  30163. /** @hidden */
  30164. readonly _shouldUseHighPrecisionShader: boolean;
  30165. /**
  30166. * Gets a boolean indicating that only power of 2 textures are supported
  30167. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30168. */
  30169. readonly needPOTTextures: boolean;
  30170. /** @hidden */
  30171. _badOS: boolean;
  30172. /** @hidden */
  30173. _badDesktopOS: boolean;
  30174. private _hardwareScalingLevel;
  30175. /** @hidden */
  30176. _caps: EngineCapabilities;
  30177. private _isStencilEnable;
  30178. protected _colorWrite: boolean;
  30179. /** @hidden */
  30180. _drawCalls: PerfCounter;
  30181. private _glVersion;
  30182. private _glRenderer;
  30183. private _glVendor;
  30184. /** @hidden */
  30185. _videoTextureSupported: boolean;
  30186. protected _renderingQueueLaunched: boolean;
  30187. protected _activeRenderLoops: (() => void)[];
  30188. /**
  30189. * Observable signaled when a context lost event is raised
  30190. */
  30191. onContextLostObservable: Observable<ThinEngine>;
  30192. /**
  30193. * Observable signaled when a context restored event is raised
  30194. */
  30195. onContextRestoredObservable: Observable<ThinEngine>;
  30196. private _onContextLost;
  30197. private _onContextRestored;
  30198. protected _contextWasLost: boolean;
  30199. /** @hidden */
  30200. _doNotHandleContextLost: boolean;
  30201. /**
  30202. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30203. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30204. */
  30205. doNotHandleContextLost: boolean;
  30206. /**
  30207. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30208. */
  30209. disableVertexArrayObjects: boolean;
  30210. /** @hidden */
  30211. protected _depthCullingState: DepthCullingState;
  30212. /** @hidden */
  30213. protected _stencilState: StencilState;
  30214. /** @hidden */
  30215. protected _alphaState: AlphaState;
  30216. /** @hidden */
  30217. _internalTexturesCache: InternalTexture[];
  30218. /** @hidden */
  30219. protected _activeChannel: number;
  30220. private _currentTextureChannel;
  30221. /** @hidden */
  30222. protected _boundTexturesCache: {
  30223. [key: string]: Nullable<InternalTexture>;
  30224. };
  30225. /** @hidden */
  30226. protected _currentEffect: Nullable<Effect>;
  30227. /** @hidden */
  30228. protected _currentProgram: Nullable<WebGLProgram>;
  30229. private _compiledEffects;
  30230. private _vertexAttribArraysEnabled;
  30231. /** @hidden */
  30232. protected _cachedViewport: Nullable<IViewportLike>;
  30233. private _cachedVertexArrayObject;
  30234. /** @hidden */
  30235. protected _cachedVertexBuffers: any;
  30236. /** @hidden */
  30237. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30238. /** @hidden */
  30239. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30240. /** @hidden */
  30241. _currentRenderTarget: Nullable<InternalTexture>;
  30242. private _uintIndicesCurrentlySet;
  30243. private _currentBoundBuffer;
  30244. /** @hidden */
  30245. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30246. private _currentBufferPointers;
  30247. private _currentInstanceLocations;
  30248. private _currentInstanceBuffers;
  30249. private _textureUnits;
  30250. /** @hidden */
  30251. _workingCanvas: Nullable<HTMLCanvasElement>;
  30252. /** @hidden */
  30253. _workingContext: Nullable<CanvasRenderingContext2D>;
  30254. /** @hidden */
  30255. _bindedRenderFunction: any;
  30256. private _vaoRecordInProgress;
  30257. private _mustWipeVertexAttributes;
  30258. private _emptyTexture;
  30259. private _emptyCubeTexture;
  30260. private _emptyTexture3D;
  30261. /** @hidden */
  30262. _frameHandler: number;
  30263. private _nextFreeTextureSlots;
  30264. private _maxSimultaneousTextures;
  30265. private _activeRequests;
  30266. protected _texturesSupported: string[];
  30267. /** @hidden */
  30268. _textureFormatInUse: Nullable<string>;
  30269. protected readonly _supportsHardwareTextureRescaling: boolean;
  30270. /**
  30271. * Gets the list of texture formats supported
  30272. */
  30273. readonly texturesSupported: Array<string>;
  30274. /**
  30275. * Gets the list of texture formats in use
  30276. */
  30277. readonly textureFormatInUse: Nullable<string>;
  30278. /**
  30279. * Gets the current viewport
  30280. */
  30281. readonly currentViewport: Nullable<IViewportLike>;
  30282. /**
  30283. * Gets the default empty texture
  30284. */
  30285. readonly emptyTexture: InternalTexture;
  30286. /**
  30287. * Gets the default empty 3D texture
  30288. */
  30289. readonly emptyTexture3D: InternalTexture;
  30290. /**
  30291. * Gets the default empty cube texture
  30292. */
  30293. readonly emptyCubeTexture: InternalTexture;
  30294. /**
  30295. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30296. */
  30297. readonly premultipliedAlpha: boolean;
  30298. /**
  30299. * Creates a new engine
  30300. * @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
  30301. * @param antialias defines enable antialiasing (default: false)
  30302. * @param options defines further options to be sent to the getContext() function
  30303. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30304. */
  30305. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30306. private _rebuildInternalTextures;
  30307. private _rebuildEffects;
  30308. /**
  30309. * Gets a boolean indicating if all created effects are ready
  30310. * @returns true if all effects are ready
  30311. */
  30312. areAllEffectsReady(): boolean;
  30313. protected _rebuildBuffers(): void;
  30314. private _initGLContext;
  30315. /**
  30316. * Gets version of the current webGL context
  30317. */
  30318. readonly webGLVersion: number;
  30319. /**
  30320. * Gets a string idenfifying the name of the class
  30321. * @returns "Engine" string
  30322. */
  30323. getClassName(): string;
  30324. /**
  30325. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30326. */
  30327. readonly isStencilEnable: boolean;
  30328. /** @hidden */
  30329. _prepareWorkingCanvas(): void;
  30330. /**
  30331. * Reset the texture cache to empty state
  30332. */
  30333. resetTextureCache(): void;
  30334. /**
  30335. * Gets an object containing information about the current webGL context
  30336. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30337. */
  30338. getGlInfo(): {
  30339. vendor: string;
  30340. renderer: string;
  30341. version: string;
  30342. };
  30343. /**
  30344. * Defines the hardware scaling level.
  30345. * By default the hardware scaling level is computed from the window device ratio.
  30346. * 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.
  30347. * @param level defines the level to use
  30348. */
  30349. setHardwareScalingLevel(level: number): void;
  30350. /**
  30351. * Gets the current hardware scaling level.
  30352. * By default the hardware scaling level is computed from the window device ratio.
  30353. * 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.
  30354. * @returns a number indicating the current hardware scaling level
  30355. */
  30356. getHardwareScalingLevel(): number;
  30357. /**
  30358. * Gets the list of loaded textures
  30359. * @returns an array containing all loaded textures
  30360. */
  30361. getLoadedTexturesCache(): InternalTexture[];
  30362. /**
  30363. * Gets the object containing all engine capabilities
  30364. * @returns the EngineCapabilities object
  30365. */
  30366. getCaps(): EngineCapabilities;
  30367. /**
  30368. * stop executing a render loop function and remove it from the execution array
  30369. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30370. */
  30371. stopRenderLoop(renderFunction?: () => void): void;
  30372. /** @hidden */
  30373. _renderLoop(): void;
  30374. /**
  30375. * Gets the HTML canvas attached with the current webGL context
  30376. * @returns a HTML canvas
  30377. */
  30378. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30379. /**
  30380. * Gets host window
  30381. * @returns the host window object
  30382. */
  30383. getHostWindow(): Window;
  30384. /**
  30385. * Gets the current render width
  30386. * @param useScreen defines if screen size must be used (or the current render target if any)
  30387. * @returns a number defining the current render width
  30388. */
  30389. getRenderWidth(useScreen?: boolean): number;
  30390. /**
  30391. * Gets the current render height
  30392. * @param useScreen defines if screen size must be used (or the current render target if any)
  30393. * @returns a number defining the current render height
  30394. */
  30395. getRenderHeight(useScreen?: boolean): number;
  30396. /**
  30397. * Can be used to override the current requestAnimationFrame requester.
  30398. * @hidden
  30399. */
  30400. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30401. /**
  30402. * Register and execute a render loop. The engine can have more than one render function
  30403. * @param renderFunction defines the function to continuously execute
  30404. */
  30405. runRenderLoop(renderFunction: () => void): void;
  30406. /**
  30407. * Clear the current render buffer or the current render target (if any is set up)
  30408. * @param color defines the color to use
  30409. * @param backBuffer defines if the back buffer must be cleared
  30410. * @param depth defines if the depth buffer must be cleared
  30411. * @param stencil defines if the stencil buffer must be cleared
  30412. */
  30413. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30414. private _viewportCached;
  30415. /** @hidden */
  30416. _viewport(x: number, y: number, width: number, height: number): void;
  30417. /**
  30418. * Set the WebGL's viewport
  30419. * @param viewport defines the viewport element to be used
  30420. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30421. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30422. */
  30423. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30424. /**
  30425. * Begin a new frame
  30426. */
  30427. beginFrame(): void;
  30428. /**
  30429. * Enf the current frame
  30430. */
  30431. endFrame(): void;
  30432. /**
  30433. * Resize the view according to the canvas' size
  30434. */
  30435. resize(): void;
  30436. /**
  30437. * Force a specific size of the canvas
  30438. * @param width defines the new canvas' width
  30439. * @param height defines the new canvas' height
  30440. */
  30441. setSize(width: number, height: number): void;
  30442. /**
  30443. * Binds the frame buffer to the specified texture.
  30444. * @param texture The texture to render to or null for the default canvas
  30445. * @param faceIndex The face of the texture to render to in case of cube texture
  30446. * @param requiredWidth The width of the target to render to
  30447. * @param requiredHeight The height of the target to render to
  30448. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30449. * @param depthStencilTexture The depth stencil texture to use to render
  30450. * @param lodLevel defines le lod level to bind to the frame buffer
  30451. */
  30452. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30453. /** @hidden */
  30454. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30455. /**
  30456. * Unbind the current render target texture from the webGL context
  30457. * @param texture defines the render target texture to unbind
  30458. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30459. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30460. */
  30461. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30462. /**
  30463. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30464. */
  30465. flushFramebuffer(): void;
  30466. /**
  30467. * Unbind the current render target and bind the default framebuffer
  30468. */
  30469. restoreDefaultFramebuffer(): void;
  30470. private _resetVertexBufferBinding;
  30471. /**
  30472. * Creates a vertex buffer
  30473. * @param data the data for the vertex buffer
  30474. * @returns the new WebGL static buffer
  30475. */
  30476. createVertexBuffer(data: DataArray): DataBuffer;
  30477. private _createVertexBuffer;
  30478. /**
  30479. * Creates a dynamic vertex buffer
  30480. * @param data the data for the dynamic vertex buffer
  30481. * @returns the new WebGL dynamic buffer
  30482. */
  30483. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30484. /**
  30485. * Update a dynamic index buffer
  30486. * @param indexBuffer defines the target index buffer
  30487. * @param indices defines the data to update
  30488. * @param offset defines the offset in the target index buffer where update should start
  30489. */
  30490. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30491. /**
  30492. * Updates a dynamic vertex buffer.
  30493. * @param vertexBuffer the vertex buffer to update
  30494. * @param data the data used to update the vertex buffer
  30495. * @param byteOffset the byte offset of the data
  30496. * @param byteLength the byte length of the data
  30497. */
  30498. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30499. private _resetIndexBufferBinding;
  30500. /**
  30501. * Creates a new index buffer
  30502. * @param indices defines the content of the index buffer
  30503. * @param updatable defines if the index buffer must be updatable
  30504. * @returns a new webGL buffer
  30505. */
  30506. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30507. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30508. /**
  30509. * Bind a webGL buffer to the webGL context
  30510. * @param buffer defines the buffer to bind
  30511. */
  30512. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30513. private bindIndexBuffer;
  30514. private bindBuffer;
  30515. /**
  30516. * update the bound buffer with the given data
  30517. * @param data defines the data to update
  30518. */
  30519. updateArrayBuffer(data: Float32Array): void;
  30520. private _vertexAttribPointer;
  30521. private _bindIndexBufferWithCache;
  30522. private _bindVertexBuffersAttributes;
  30523. /**
  30524. * Records a vertex array object
  30525. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30526. * @param vertexBuffers defines the list of vertex buffers to store
  30527. * @param indexBuffer defines the index buffer to store
  30528. * @param effect defines the effect to store
  30529. * @returns the new vertex array object
  30530. */
  30531. recordVertexArrayObject(vertexBuffers: {
  30532. [key: string]: VertexBuffer;
  30533. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30534. /**
  30535. * Bind a specific vertex array object
  30536. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30537. * @param vertexArrayObject defines the vertex array object to bind
  30538. * @param indexBuffer defines the index buffer to bind
  30539. */
  30540. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30541. /**
  30542. * Bind webGl buffers directly to the webGL context
  30543. * @param vertexBuffer defines the vertex buffer to bind
  30544. * @param indexBuffer defines the index buffer to bind
  30545. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30546. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30547. * @param effect defines the effect associated with the vertex buffer
  30548. */
  30549. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30550. private _unbindVertexArrayObject;
  30551. /**
  30552. * Bind a list of vertex buffers to the webGL context
  30553. * @param vertexBuffers defines the list of vertex buffers to bind
  30554. * @param indexBuffer defines the index buffer to bind
  30555. * @param effect defines the effect associated with the vertex buffers
  30556. */
  30557. bindBuffers(vertexBuffers: {
  30558. [key: string]: Nullable<VertexBuffer>;
  30559. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30560. /**
  30561. * Unbind all instance attributes
  30562. */
  30563. unbindInstanceAttributes(): void;
  30564. /**
  30565. * Release and free the memory of a vertex array object
  30566. * @param vao defines the vertex array object to delete
  30567. */
  30568. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30569. /** @hidden */
  30570. _releaseBuffer(buffer: DataBuffer): boolean;
  30571. protected _deleteBuffer(buffer: DataBuffer): void;
  30572. /**
  30573. * Creates a webGL buffer to use with instanciation
  30574. * @param capacity defines the size of the buffer
  30575. * @returns the webGL buffer
  30576. */
  30577. createInstancesBuffer(capacity: number): DataBuffer;
  30578. /**
  30579. * Delete a webGL buffer used with instanciation
  30580. * @param buffer defines the webGL buffer to delete
  30581. */
  30582. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30583. /**
  30584. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30585. * @param instancesBuffer defines the webGL buffer to update and bind
  30586. * @param data defines the data to store in the buffer
  30587. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30588. */
  30589. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30590. /**
  30591. * Apply all cached states (depth, culling, stencil and alpha)
  30592. */
  30593. applyStates(): void;
  30594. /**
  30595. * Send a draw order
  30596. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30597. * @param indexStart defines the starting index
  30598. * @param indexCount defines the number of index to draw
  30599. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30600. */
  30601. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30602. /**
  30603. * Draw a list of points
  30604. * @param verticesStart defines the index of first vertex to draw
  30605. * @param verticesCount defines the count of vertices to draw
  30606. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30607. */
  30608. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30609. /**
  30610. * Draw a list of unindexed primitives
  30611. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30612. * @param verticesStart defines the index of first vertex to draw
  30613. * @param verticesCount defines the count of vertices to draw
  30614. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30615. */
  30616. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30617. /**
  30618. * Draw a list of indexed primitives
  30619. * @param fillMode defines the primitive to use
  30620. * @param indexStart defines the starting index
  30621. * @param indexCount defines the number of index to draw
  30622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30623. */
  30624. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30625. /**
  30626. * Draw a list of unindexed primitives
  30627. * @param fillMode defines the primitive to use
  30628. * @param verticesStart defines the index of first vertex to draw
  30629. * @param verticesCount defines the count of vertices to draw
  30630. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30631. */
  30632. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30633. private _drawMode;
  30634. /** @hidden */
  30635. _releaseEffect(effect: Effect): void;
  30636. /** @hidden */
  30637. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30638. /**
  30639. * Create a new effect (used to store vertex/fragment shaders)
  30640. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30641. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30642. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30643. * @param samplers defines an array of string used to represent textures
  30644. * @param defines defines the string containing the defines to use to compile the shaders
  30645. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30646. * @param onCompiled defines a function to call when the effect creation is successful
  30647. * @param onError defines a function to call when the effect creation has failed
  30648. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30649. * @returns the new Effect
  30650. */
  30651. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30652. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30653. private _compileShader;
  30654. private _compileRawShader;
  30655. /**
  30656. * Directly creates a webGL program
  30657. * @param pipelineContext defines the pipeline context to attach to
  30658. * @param vertexCode defines the vertex shader code to use
  30659. * @param fragmentCode defines the fragment shader code to use
  30660. * @param context defines the webGL context to use (if not set, the current one will be used)
  30661. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30662. * @returns the new webGL program
  30663. */
  30664. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30665. /**
  30666. * Creates a webGL program
  30667. * @param pipelineContext defines the pipeline context to attach to
  30668. * @param vertexCode defines the vertex shader code to use
  30669. * @param fragmentCode defines the fragment shader code to use
  30670. * @param defines defines the string containing the defines to use to compile the shaders
  30671. * @param context defines the webGL context to use (if not set, the current one will be used)
  30672. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30673. * @returns the new webGL program
  30674. */
  30675. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30676. /**
  30677. * Creates a new pipeline context
  30678. * @returns the new pipeline
  30679. */
  30680. createPipelineContext(): IPipelineContext;
  30681. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30682. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30683. /** @hidden */
  30684. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30685. /** @hidden */
  30686. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30687. /** @hidden */
  30688. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30689. /**
  30690. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30691. * @param pipelineContext defines the pipeline context to use
  30692. * @param uniformsNames defines the list of uniform names
  30693. * @returns an array of webGL uniform locations
  30694. */
  30695. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30696. /**
  30697. * Gets the lsit of active attributes for a given webGL program
  30698. * @param pipelineContext defines the pipeline context to use
  30699. * @param attributesNames defines the list of attribute names to get
  30700. * @returns an array of indices indicating the offset of each attribute
  30701. */
  30702. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30703. /**
  30704. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30705. * @param effect defines the effect to activate
  30706. */
  30707. enableEffect(effect: Nullable<Effect>): void;
  30708. /**
  30709. * Set the value of an uniform to an array of int32
  30710. * @param uniform defines the webGL uniform location where to store the value
  30711. * @param array defines the array of int32 to store
  30712. */
  30713. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30714. /**
  30715. * Set the value of an uniform to an array of int32 (stored as vec2)
  30716. * @param uniform defines the webGL uniform location where to store the value
  30717. * @param array defines the array of int32 to store
  30718. */
  30719. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30720. /**
  30721. * Set the value of an uniform to an array of int32 (stored as vec3)
  30722. * @param uniform defines the webGL uniform location where to store the value
  30723. * @param array defines the array of int32 to store
  30724. */
  30725. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30726. /**
  30727. * Set the value of an uniform to an array of int32 (stored as vec4)
  30728. * @param uniform defines the webGL uniform location where to store the value
  30729. * @param array defines the array of int32 to store
  30730. */
  30731. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30732. /**
  30733. * Set the value of an uniform to an array of float32
  30734. * @param uniform defines the webGL uniform location where to store the value
  30735. * @param array defines the array of float32 to store
  30736. */
  30737. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30738. /**
  30739. * Set the value of an uniform to an array of float32 (stored as vec2)
  30740. * @param uniform defines the webGL uniform location where to store the value
  30741. * @param array defines the array of float32 to store
  30742. */
  30743. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30744. /**
  30745. * Set the value of an uniform to an array of float32 (stored as vec3)
  30746. * @param uniform defines the webGL uniform location where to store the value
  30747. * @param array defines the array of float32 to store
  30748. */
  30749. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30750. /**
  30751. * Set the value of an uniform to an array of float32 (stored as vec4)
  30752. * @param uniform defines the webGL uniform location where to store the value
  30753. * @param array defines the array of float32 to store
  30754. */
  30755. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30756. /**
  30757. * Set the value of an uniform to an array of number
  30758. * @param uniform defines the webGL uniform location where to store the value
  30759. * @param array defines the array of number to store
  30760. */
  30761. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30762. /**
  30763. * Set the value of an uniform to an array of number (stored as vec2)
  30764. * @param uniform defines the webGL uniform location where to store the value
  30765. * @param array defines the array of number to store
  30766. */
  30767. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30768. /**
  30769. * Set the value of an uniform to an array of number (stored as vec3)
  30770. * @param uniform defines the webGL uniform location where to store the value
  30771. * @param array defines the array of number to store
  30772. */
  30773. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30774. /**
  30775. * Set the value of an uniform to an array of number (stored as vec4)
  30776. * @param uniform defines the webGL uniform location where to store the value
  30777. * @param array defines the array of number to store
  30778. */
  30779. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30780. /**
  30781. * Set the value of an uniform to an array of float32 (stored as matrices)
  30782. * @param uniform defines the webGL uniform location where to store the value
  30783. * @param matrices defines the array of float32 to store
  30784. */
  30785. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30786. /**
  30787. * Set the value of an uniform to a matrix (3x3)
  30788. * @param uniform defines the webGL uniform location where to store the value
  30789. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30790. */
  30791. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30792. /**
  30793. * Set the value of an uniform to a matrix (2x2)
  30794. * @param uniform defines the webGL uniform location where to store the value
  30795. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30796. */
  30797. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30798. /**
  30799. * Set the value of an uniform to a number (int)
  30800. * @param uniform defines the webGL uniform location where to store the value
  30801. * @param value defines the int number to store
  30802. */
  30803. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30804. /**
  30805. * Set the value of an uniform to a number (float)
  30806. * @param uniform defines the webGL uniform location where to store the value
  30807. * @param value defines the float number to store
  30808. */
  30809. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30810. /**
  30811. * Set the value of an uniform to a vec2
  30812. * @param uniform defines the webGL uniform location where to store the value
  30813. * @param x defines the 1st component of the value
  30814. * @param y defines the 2nd component of the value
  30815. */
  30816. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30817. /**
  30818. * Set the value of an uniform to a vec3
  30819. * @param uniform defines the webGL uniform location where to store the value
  30820. * @param x defines the 1st component of the value
  30821. * @param y defines the 2nd component of the value
  30822. * @param z defines the 3rd component of the value
  30823. */
  30824. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30825. /**
  30826. * Set the value of an uniform to a boolean
  30827. * @param uniform defines the webGL uniform location where to store the value
  30828. * @param bool defines the boolean to store
  30829. */
  30830. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30831. /**
  30832. * Set the value of an uniform to a vec4
  30833. * @param uniform defines the webGL uniform location where to store the value
  30834. * @param x defines the 1st component of the value
  30835. * @param y defines the 2nd component of the value
  30836. * @param z defines the 3rd component of the value
  30837. * @param w defines the 4th component of the value
  30838. */
  30839. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30840. /**
  30841. * Sets a Color4 on a uniform variable
  30842. * @param uniform defines the uniform location
  30843. * @param color4 defines the value to be set
  30844. */
  30845. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30846. /**
  30847. * Gets the depth culling state manager
  30848. */
  30849. readonly depthCullingState: DepthCullingState;
  30850. /**
  30851. * Gets the alpha state manager
  30852. */
  30853. readonly alphaState: AlphaState;
  30854. /**
  30855. * Gets the stencil state manager
  30856. */
  30857. readonly stencilState: StencilState;
  30858. /**
  30859. * Clears the list of texture accessible through engine.
  30860. * This can help preventing texture load conflict due to name collision.
  30861. */
  30862. clearInternalTexturesCache(): void;
  30863. /**
  30864. * Force the entire cache to be cleared
  30865. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30866. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30867. */
  30868. wipeCaches(bruteForce?: boolean): void;
  30869. /** @hidden */
  30870. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30871. min: number;
  30872. mag: number;
  30873. };
  30874. /** @hidden */
  30875. _createTexture(): WebGLTexture;
  30876. /**
  30877. * Usually called from Texture.ts.
  30878. * Passed information to create a WebGLTexture
  30879. * @param urlArg defines a value which contains one of the following:
  30880. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30881. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30882. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30883. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30884. * @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)
  30885. * @param scene needed for loading to the correct scene
  30886. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30887. * @param onLoad optional callback to be called upon successful completion
  30888. * @param onError optional callback to be called upon failure
  30889. * @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
  30890. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30891. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30892. * @param forcedExtension defines the extension to use to pick the right loader
  30893. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30894. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30895. */
  30896. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30897. /**
  30898. * @hidden
  30899. */
  30900. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30901. /**
  30902. * Creates a raw texture
  30903. * @param data defines the data to store in the texture
  30904. * @param width defines the width of the texture
  30905. * @param height defines the height of the texture
  30906. * @param format defines the format of the data
  30907. * @param generateMipMaps defines if the engine should generate the mip levels
  30908. * @param invertY defines if data must be stored with Y axis inverted
  30909. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30910. * @param compression defines the compression used (null by default)
  30911. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30912. * @returns the raw texture inside an InternalTexture
  30913. */
  30914. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30915. /**
  30916. * Creates a new raw cube texture
  30917. * @param data defines the array of data to use to create each face
  30918. * @param size defines the size of the textures
  30919. * @param format defines the format of the data
  30920. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30921. * @param generateMipMaps defines if the engine should generate the mip levels
  30922. * @param invertY defines if data must be stored with Y axis inverted
  30923. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30924. * @param compression defines the compression used (null by default)
  30925. * @returns the cube texture as an InternalTexture
  30926. */
  30927. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30928. /**
  30929. * Creates a new raw 3D texture
  30930. * @param data defines the data used to create the texture
  30931. * @param width defines the width of the texture
  30932. * @param height defines the height of the texture
  30933. * @param depth defines the depth of the texture
  30934. * @param format defines the format of the texture
  30935. * @param generateMipMaps defines if the engine must generate mip levels
  30936. * @param invertY defines if data must be stored with Y axis inverted
  30937. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30938. * @param compression defines the compressed used (can be null)
  30939. * @param textureType defines the compressed used (can be null)
  30940. * @returns a new raw 3D texture (stored in an InternalTexture)
  30941. */
  30942. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30943. private _unpackFlipYCached;
  30944. /**
  30945. * In case you are sharing the context with other applications, it might
  30946. * be interested to not cache the unpack flip y state to ensure a consistent
  30947. * value would be set.
  30948. */
  30949. enableUnpackFlipYCached: boolean;
  30950. /** @hidden */
  30951. _unpackFlipY(value: boolean): void;
  30952. /** @hidden */
  30953. _getUnpackAlignement(): number;
  30954. /**
  30955. * Update the sampling mode of a given texture
  30956. * @param samplingMode defines the required sampling mode
  30957. * @param texture defines the texture to update
  30958. */
  30959. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30960. /**
  30961. * Updates a depth texture Comparison Mode and Function.
  30962. * If the comparison Function is equal to 0, the mode will be set to none.
  30963. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30964. * @param texture The texture to set the comparison function for
  30965. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30966. */
  30967. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30968. /** @hidden */
  30969. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30970. width: number;
  30971. height: number;
  30972. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30973. /**
  30974. * Creates a depth stencil texture.
  30975. * This is only available in WebGL 2 or with the depth texture extension available.
  30976. * @param size The size of face edge in the texture.
  30977. * @param options The options defining the texture.
  30978. * @returns The texture
  30979. */
  30980. createDepthStencilTexture(size: number | {
  30981. width: number;
  30982. height: number;
  30983. }, options: DepthTextureCreationOptions): InternalTexture;
  30984. /**
  30985. * Creates a depth stencil texture.
  30986. * This is only available in WebGL 2 or with the depth texture extension available.
  30987. * @param size The size of face edge in the texture.
  30988. * @param options The options defining the texture.
  30989. * @returns The texture
  30990. */
  30991. private _createDepthStencilTexture;
  30992. /**
  30993. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30994. * @param renderTarget The render target to set the frame buffer for
  30995. */
  30996. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30997. /** @hidden */
  30998. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30999. /** @hidden */
  31000. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31001. /** @hidden */
  31002. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31003. /** @hidden */
  31004. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31005. /** @hidden */
  31006. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31007. /**
  31008. * @hidden
  31009. */
  31010. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31011. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31012. private _prepareWebGLTexture;
  31013. /** @hidden */
  31014. _releaseFramebufferObjects(texture: InternalTexture): void;
  31015. /** @hidden */
  31016. _releaseTexture(texture: InternalTexture): void;
  31017. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31018. protected _setProgram(program: WebGLProgram): void;
  31019. protected _boundUniforms: {
  31020. [key: number]: WebGLUniformLocation;
  31021. };
  31022. /**
  31023. * Binds an effect to the webGL context
  31024. * @param effect defines the effect to bind
  31025. */
  31026. bindSamplers(effect: Effect): void;
  31027. private _activateCurrentTexture;
  31028. /** @hidden */
  31029. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31030. /** @hidden */
  31031. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31032. /**
  31033. * Unbind all textures from the webGL context
  31034. */
  31035. unbindAllTextures(): void;
  31036. /**
  31037. * Sets a texture to the according uniform.
  31038. * @param channel The texture channel
  31039. * @param uniform The uniform to set
  31040. * @param texture The texture to apply
  31041. */
  31042. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31043. private _bindSamplerUniformToChannel;
  31044. private _getTextureWrapMode;
  31045. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31046. /**
  31047. * Sets an array of texture to the webGL context
  31048. * @param channel defines the channel where the texture array must be set
  31049. * @param uniform defines the associated uniform location
  31050. * @param textures defines the array of textures to bind
  31051. */
  31052. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31053. /** @hidden */
  31054. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31055. private _setTextureParameterFloat;
  31056. private _setTextureParameterInteger;
  31057. /**
  31058. * Unbind all vertex attributes from the webGL context
  31059. */
  31060. unbindAllAttributes(): void;
  31061. /**
  31062. * 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
  31063. */
  31064. releaseEffects(): void;
  31065. /**
  31066. * Dispose and release all associated resources
  31067. */
  31068. dispose(): void;
  31069. /**
  31070. * Attach a new callback raised when context lost event is fired
  31071. * @param callback defines the callback to call
  31072. */
  31073. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31074. /**
  31075. * Attach a new callback raised when context restored event is fired
  31076. * @param callback defines the callback to call
  31077. */
  31078. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31079. /**
  31080. * Get the current error code of the webGL context
  31081. * @returns the error code
  31082. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31083. */
  31084. getError(): number;
  31085. private _canRenderToFloatFramebuffer;
  31086. private _canRenderToHalfFloatFramebuffer;
  31087. private _canRenderToFramebuffer;
  31088. /** @hidden */
  31089. _getWebGLTextureType(type: number): number;
  31090. /** @hidden */
  31091. _getInternalFormat(format: number): number;
  31092. /** @hidden */
  31093. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31094. /** @hidden */
  31095. _getRGBAMultiSampleBufferFormat(type: number): number;
  31096. /** @hidden */
  31097. _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;
  31098. /**
  31099. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31100. * @returns true if the engine can be created
  31101. * @ignorenaming
  31102. */
  31103. static isSupported(): boolean;
  31104. /**
  31105. * Find the next highest power of two.
  31106. * @param x Number to start search from.
  31107. * @return Next highest power of two.
  31108. */
  31109. static CeilingPOT(x: number): number;
  31110. /**
  31111. * Find the next lowest power of two.
  31112. * @param x Number to start search from.
  31113. * @return Next lowest power of two.
  31114. */
  31115. static FloorPOT(x: number): number;
  31116. /**
  31117. * Find the nearest power of two.
  31118. * @param x Number to start search from.
  31119. * @return Next nearest power of two.
  31120. */
  31121. static NearestPOT(x: number): number;
  31122. /**
  31123. * Get the closest exponent of two
  31124. * @param value defines the value to approximate
  31125. * @param max defines the maximum value to return
  31126. * @param mode defines how to define the closest value
  31127. * @returns closest exponent of two of the given value
  31128. */
  31129. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31130. /**
  31131. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31132. * @param func - the function to be called
  31133. * @param requester - the object that will request the next frame. Falls back to window.
  31134. * @returns frame number
  31135. */
  31136. static QueueNewFrame(func: () => void, requester?: any): number;
  31137. }
  31138. }
  31139. declare module "babylonjs/Materials/Textures/internalTexture" {
  31140. import { Observable } from "babylonjs/Misc/observable";
  31141. import { Nullable, int } from "babylonjs/types";
  31142. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31143. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31144. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31145. /**
  31146. * Class used to store data associated with WebGL texture data for the engine
  31147. * This class should not be used directly
  31148. */
  31149. export class InternalTexture {
  31150. /** @hidden */
  31151. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31152. /**
  31153. * The source of the texture data is unknown
  31154. */
  31155. static DATASOURCE_UNKNOWN: number;
  31156. /**
  31157. * Texture data comes from an URL
  31158. */
  31159. static DATASOURCE_URL: number;
  31160. /**
  31161. * Texture data is only used for temporary storage
  31162. */
  31163. static DATASOURCE_TEMP: number;
  31164. /**
  31165. * Texture data comes from raw data (ArrayBuffer)
  31166. */
  31167. static DATASOURCE_RAW: number;
  31168. /**
  31169. * Texture content is dynamic (video or dynamic texture)
  31170. */
  31171. static DATASOURCE_DYNAMIC: number;
  31172. /**
  31173. * Texture content is generated by rendering to it
  31174. */
  31175. static DATASOURCE_RENDERTARGET: number;
  31176. /**
  31177. * Texture content is part of a multi render target process
  31178. */
  31179. static DATASOURCE_MULTIRENDERTARGET: number;
  31180. /**
  31181. * Texture data comes from a cube data file
  31182. */
  31183. static DATASOURCE_CUBE: number;
  31184. /**
  31185. * Texture data comes from a raw cube data
  31186. */
  31187. static DATASOURCE_CUBERAW: number;
  31188. /**
  31189. * Texture data come from a prefiltered cube data file
  31190. */
  31191. static DATASOURCE_CUBEPREFILTERED: number;
  31192. /**
  31193. * Texture content is raw 3D data
  31194. */
  31195. static DATASOURCE_RAW3D: number;
  31196. /**
  31197. * Texture content is a depth texture
  31198. */
  31199. static DATASOURCE_DEPTHTEXTURE: number;
  31200. /**
  31201. * Texture data comes from a raw cube data encoded with RGBD
  31202. */
  31203. static DATASOURCE_CUBERAW_RGBD: number;
  31204. /**
  31205. * Defines if the texture is ready
  31206. */
  31207. isReady: boolean;
  31208. /**
  31209. * Defines if the texture is a cube texture
  31210. */
  31211. isCube: boolean;
  31212. /**
  31213. * Defines if the texture contains 3D data
  31214. */
  31215. is3D: boolean;
  31216. /**
  31217. * Defines if the texture contains multiview data
  31218. */
  31219. isMultiview: boolean;
  31220. /**
  31221. * Gets the URL used to load this texture
  31222. */
  31223. url: string;
  31224. /**
  31225. * Gets the sampling mode of the texture
  31226. */
  31227. samplingMode: number;
  31228. /**
  31229. * Gets a boolean indicating if the texture needs mipmaps generation
  31230. */
  31231. generateMipMaps: boolean;
  31232. /**
  31233. * Gets the number of samples used by the texture (WebGL2+ only)
  31234. */
  31235. samples: number;
  31236. /**
  31237. * Gets the type of the texture (int, float...)
  31238. */
  31239. type: number;
  31240. /**
  31241. * Gets the format of the texture (RGB, RGBA...)
  31242. */
  31243. format: number;
  31244. /**
  31245. * Observable called when the texture is loaded
  31246. */
  31247. onLoadedObservable: Observable<InternalTexture>;
  31248. /**
  31249. * Gets the width of the texture
  31250. */
  31251. width: number;
  31252. /**
  31253. * Gets the height of the texture
  31254. */
  31255. height: number;
  31256. /**
  31257. * Gets the depth of the texture
  31258. */
  31259. depth: number;
  31260. /**
  31261. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31262. */
  31263. baseWidth: number;
  31264. /**
  31265. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31266. */
  31267. baseHeight: number;
  31268. /**
  31269. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31270. */
  31271. baseDepth: number;
  31272. /**
  31273. * Gets a boolean indicating if the texture is inverted on Y axis
  31274. */
  31275. invertY: boolean;
  31276. /** @hidden */
  31277. _invertVScale: boolean;
  31278. /** @hidden */
  31279. _associatedChannel: number;
  31280. /** @hidden */
  31281. _dataSource: number;
  31282. /** @hidden */
  31283. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31284. /** @hidden */
  31285. _bufferView: Nullable<ArrayBufferView>;
  31286. /** @hidden */
  31287. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31288. /** @hidden */
  31289. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31290. /** @hidden */
  31291. _size: number;
  31292. /** @hidden */
  31293. _extension: string;
  31294. /** @hidden */
  31295. _files: Nullable<string[]>;
  31296. /** @hidden */
  31297. _workingCanvas: Nullable<HTMLCanvasElement>;
  31298. /** @hidden */
  31299. _workingContext: Nullable<CanvasRenderingContext2D>;
  31300. /** @hidden */
  31301. _framebuffer: Nullable<WebGLFramebuffer>;
  31302. /** @hidden */
  31303. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31304. /** @hidden */
  31305. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31306. /** @hidden */
  31307. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31308. /** @hidden */
  31309. _attachments: Nullable<number[]>;
  31310. /** @hidden */
  31311. _cachedCoordinatesMode: Nullable<number>;
  31312. /** @hidden */
  31313. _cachedWrapU: Nullable<number>;
  31314. /** @hidden */
  31315. _cachedWrapV: Nullable<number>;
  31316. /** @hidden */
  31317. _cachedWrapR: Nullable<number>;
  31318. /** @hidden */
  31319. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31320. /** @hidden */
  31321. _isDisabled: boolean;
  31322. /** @hidden */
  31323. _compression: Nullable<string>;
  31324. /** @hidden */
  31325. _generateStencilBuffer: boolean;
  31326. /** @hidden */
  31327. _generateDepthBuffer: boolean;
  31328. /** @hidden */
  31329. _comparisonFunction: number;
  31330. /** @hidden */
  31331. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31332. /** @hidden */
  31333. _lodGenerationScale: number;
  31334. /** @hidden */
  31335. _lodGenerationOffset: number;
  31336. /** @hidden */
  31337. _colorTextureArray: Nullable<WebGLTexture>;
  31338. /** @hidden */
  31339. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31340. /** @hidden */
  31341. _lodTextureHigh: Nullable<BaseTexture>;
  31342. /** @hidden */
  31343. _lodTextureMid: Nullable<BaseTexture>;
  31344. /** @hidden */
  31345. _lodTextureLow: Nullable<BaseTexture>;
  31346. /** @hidden */
  31347. _isRGBD: boolean;
  31348. /** @hidden */
  31349. _linearSpecularLOD: boolean;
  31350. /** @hidden */
  31351. _irradianceTexture: Nullable<BaseTexture>;
  31352. /** @hidden */
  31353. _webGLTexture: Nullable<WebGLTexture>;
  31354. /** @hidden */
  31355. _references: number;
  31356. private _engine;
  31357. /**
  31358. * Gets the Engine the texture belongs to.
  31359. * @returns The babylon engine
  31360. */
  31361. getEngine(): ThinEngine;
  31362. /**
  31363. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  31364. */
  31365. readonly dataSource: number;
  31366. /**
  31367. * Creates a new InternalTexture
  31368. * @param engine defines the engine to use
  31369. * @param dataSource defines the type of data that will be used
  31370. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31371. */
  31372. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  31373. /**
  31374. * Increments the number of references (ie. the number of Texture that point to it)
  31375. */
  31376. incrementReferences(): void;
  31377. /**
  31378. * Change the size of the texture (not the size of the content)
  31379. * @param width defines the new width
  31380. * @param height defines the new height
  31381. * @param depth defines the new depth (1 by default)
  31382. */
  31383. updateSize(width: int, height: int, depth?: int): void;
  31384. /** @hidden */
  31385. _rebuild(): void;
  31386. /** @hidden */
  31387. _swapAndDie(target: InternalTexture): void;
  31388. /**
  31389. * Dispose the current allocated resources
  31390. */
  31391. dispose(): void;
  31392. }
  31393. }
  31394. declare module "babylonjs/Audio/analyser" {
  31395. import { Scene } from "babylonjs/scene";
  31396. /**
  31397. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31399. */
  31400. export class Analyser {
  31401. /**
  31402. * Gets or sets the smoothing
  31403. * @ignorenaming
  31404. */
  31405. SMOOTHING: number;
  31406. /**
  31407. * Gets or sets the FFT table size
  31408. * @ignorenaming
  31409. */
  31410. FFT_SIZE: number;
  31411. /**
  31412. * Gets or sets the bar graph amplitude
  31413. * @ignorenaming
  31414. */
  31415. BARGRAPHAMPLITUDE: number;
  31416. /**
  31417. * Gets or sets the position of the debug canvas
  31418. * @ignorenaming
  31419. */
  31420. DEBUGCANVASPOS: {
  31421. x: number;
  31422. y: number;
  31423. };
  31424. /**
  31425. * Gets or sets the debug canvas size
  31426. * @ignorenaming
  31427. */
  31428. DEBUGCANVASSIZE: {
  31429. width: number;
  31430. height: number;
  31431. };
  31432. private _byteFreqs;
  31433. private _byteTime;
  31434. private _floatFreqs;
  31435. private _webAudioAnalyser;
  31436. private _debugCanvas;
  31437. private _debugCanvasContext;
  31438. private _scene;
  31439. private _registerFunc;
  31440. private _audioEngine;
  31441. /**
  31442. * Creates a new analyser
  31443. * @param scene defines hosting scene
  31444. */
  31445. constructor(scene: Scene);
  31446. /**
  31447. * Get the number of data values you will have to play with for the visualization
  31448. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31449. * @returns a number
  31450. */
  31451. getFrequencyBinCount(): number;
  31452. /**
  31453. * Gets the current frequency data as a byte array
  31454. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31455. * @returns a Uint8Array
  31456. */
  31457. getByteFrequencyData(): Uint8Array;
  31458. /**
  31459. * Gets the current waveform as a byte array
  31460. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31461. * @returns a Uint8Array
  31462. */
  31463. getByteTimeDomainData(): Uint8Array;
  31464. /**
  31465. * Gets the current frequency data as a float array
  31466. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31467. * @returns a Float32Array
  31468. */
  31469. getFloatFrequencyData(): Float32Array;
  31470. /**
  31471. * Renders the debug canvas
  31472. */
  31473. drawDebugCanvas(): void;
  31474. /**
  31475. * Stops rendering the debug canvas and removes it
  31476. */
  31477. stopDebugCanvas(): void;
  31478. /**
  31479. * Connects two audio nodes
  31480. * @param inputAudioNode defines first node to connect
  31481. * @param outputAudioNode defines second node to connect
  31482. */
  31483. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31484. /**
  31485. * Releases all associated resources
  31486. */
  31487. dispose(): void;
  31488. }
  31489. }
  31490. declare module "babylonjs/Audio/audioEngine" {
  31491. import { IDisposable } from "babylonjs/scene";
  31492. import { Analyser } from "babylonjs/Audio/analyser";
  31493. import { Nullable } from "babylonjs/types";
  31494. import { Observable } from "babylonjs/Misc/observable";
  31495. /**
  31496. * This represents an audio engine and it is responsible
  31497. * to play, synchronize and analyse sounds throughout the application.
  31498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31499. */
  31500. export interface IAudioEngine extends IDisposable {
  31501. /**
  31502. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31503. */
  31504. readonly canUseWebAudio: boolean;
  31505. /**
  31506. * Gets the current AudioContext if available.
  31507. */
  31508. readonly audioContext: Nullable<AudioContext>;
  31509. /**
  31510. * The master gain node defines the global audio volume of your audio engine.
  31511. */
  31512. readonly masterGain: GainNode;
  31513. /**
  31514. * Gets whether or not mp3 are supported by your browser.
  31515. */
  31516. readonly isMP3supported: boolean;
  31517. /**
  31518. * Gets whether or not ogg are supported by your browser.
  31519. */
  31520. readonly isOGGsupported: boolean;
  31521. /**
  31522. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31523. * @ignoreNaming
  31524. */
  31525. WarnedWebAudioUnsupported: boolean;
  31526. /**
  31527. * Defines if the audio engine relies on a custom unlocked button.
  31528. * In this case, the embedded button will not be displayed.
  31529. */
  31530. useCustomUnlockedButton: boolean;
  31531. /**
  31532. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31533. */
  31534. readonly unlocked: boolean;
  31535. /**
  31536. * Event raised when audio has been unlocked on the browser.
  31537. */
  31538. onAudioUnlockedObservable: Observable<AudioEngine>;
  31539. /**
  31540. * Event raised when audio has been locked on the browser.
  31541. */
  31542. onAudioLockedObservable: Observable<AudioEngine>;
  31543. /**
  31544. * Flags the audio engine in Locked state.
  31545. * This happens due to new browser policies preventing audio to autoplay.
  31546. */
  31547. lock(): void;
  31548. /**
  31549. * Unlocks the audio engine once a user action has been done on the dom.
  31550. * This is helpful to resume play once browser policies have been satisfied.
  31551. */
  31552. unlock(): void;
  31553. }
  31554. /**
  31555. * This represents the default audio engine used in babylon.
  31556. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31558. */
  31559. export class AudioEngine implements IAudioEngine {
  31560. private _audioContext;
  31561. private _audioContextInitialized;
  31562. private _muteButton;
  31563. private _hostElement;
  31564. /**
  31565. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31566. */
  31567. canUseWebAudio: boolean;
  31568. /**
  31569. * The master gain node defines the global audio volume of your audio engine.
  31570. */
  31571. masterGain: GainNode;
  31572. /**
  31573. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31574. * @ignoreNaming
  31575. */
  31576. WarnedWebAudioUnsupported: boolean;
  31577. /**
  31578. * Gets whether or not mp3 are supported by your browser.
  31579. */
  31580. isMP3supported: boolean;
  31581. /**
  31582. * Gets whether or not ogg are supported by your browser.
  31583. */
  31584. isOGGsupported: boolean;
  31585. /**
  31586. * Gets whether audio has been unlocked on the device.
  31587. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31588. * a user interaction has happened.
  31589. */
  31590. unlocked: boolean;
  31591. /**
  31592. * Defines if the audio engine relies on a custom unlocked button.
  31593. * In this case, the embedded button will not be displayed.
  31594. */
  31595. useCustomUnlockedButton: boolean;
  31596. /**
  31597. * Event raised when audio has been unlocked on the browser.
  31598. */
  31599. onAudioUnlockedObservable: Observable<AudioEngine>;
  31600. /**
  31601. * Event raised when audio has been locked on the browser.
  31602. */
  31603. onAudioLockedObservable: Observable<AudioEngine>;
  31604. /**
  31605. * Gets the current AudioContext if available.
  31606. */
  31607. readonly audioContext: Nullable<AudioContext>;
  31608. private _connectedAnalyser;
  31609. /**
  31610. * Instantiates a new audio engine.
  31611. *
  31612. * There should be only one per page as some browsers restrict the number
  31613. * of audio contexts you can create.
  31614. * @param hostElement defines the host element where to display the mute icon if necessary
  31615. */
  31616. constructor(hostElement?: Nullable<HTMLElement>);
  31617. /**
  31618. * Flags the audio engine in Locked state.
  31619. * This happens due to new browser policies preventing audio to autoplay.
  31620. */
  31621. lock(): void;
  31622. /**
  31623. * Unlocks the audio engine once a user action has been done on the dom.
  31624. * This is helpful to resume play once browser policies have been satisfied.
  31625. */
  31626. unlock(): void;
  31627. private _resumeAudioContext;
  31628. private _initializeAudioContext;
  31629. private _tryToRun;
  31630. private _triggerRunningState;
  31631. private _triggerSuspendedState;
  31632. private _displayMuteButton;
  31633. private _moveButtonToTopLeft;
  31634. private _onResize;
  31635. private _hideMuteButton;
  31636. /**
  31637. * Destroy and release the resources associated with the audio ccontext.
  31638. */
  31639. dispose(): void;
  31640. /**
  31641. * Gets the global volume sets on the master gain.
  31642. * @returns the global volume if set or -1 otherwise
  31643. */
  31644. getGlobalVolume(): number;
  31645. /**
  31646. * Sets the global volume of your experience (sets on the master gain).
  31647. * @param newVolume Defines the new global volume of the application
  31648. */
  31649. setGlobalVolume(newVolume: number): void;
  31650. /**
  31651. * Connect the audio engine to an audio analyser allowing some amazing
  31652. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31654. * @param analyser The analyser to connect to the engine
  31655. */
  31656. connectToAnalyser(analyser: Analyser): void;
  31657. }
  31658. }
  31659. declare module "babylonjs/Loading/loadingScreen" {
  31660. /**
  31661. * Interface used to present a loading screen while loading a scene
  31662. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31663. */
  31664. export interface ILoadingScreen {
  31665. /**
  31666. * Function called to display the loading screen
  31667. */
  31668. displayLoadingUI: () => void;
  31669. /**
  31670. * Function called to hide the loading screen
  31671. */
  31672. hideLoadingUI: () => void;
  31673. /**
  31674. * Gets or sets the color to use for the background
  31675. */
  31676. loadingUIBackgroundColor: string;
  31677. /**
  31678. * Gets or sets the text to display while loading
  31679. */
  31680. loadingUIText: string;
  31681. }
  31682. /**
  31683. * Class used for the default loading screen
  31684. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31685. */
  31686. export class DefaultLoadingScreen implements ILoadingScreen {
  31687. private _renderingCanvas;
  31688. private _loadingText;
  31689. private _loadingDivBackgroundColor;
  31690. private _loadingDiv;
  31691. private _loadingTextDiv;
  31692. /** Gets or sets the logo url to use for the default loading screen */
  31693. static DefaultLogoUrl: string;
  31694. /** Gets or sets the spinner url to use for the default loading screen */
  31695. static DefaultSpinnerUrl: string;
  31696. /**
  31697. * Creates a new default loading screen
  31698. * @param _renderingCanvas defines the canvas used to render the scene
  31699. * @param _loadingText defines the default text to display
  31700. * @param _loadingDivBackgroundColor defines the default background color
  31701. */
  31702. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31703. /**
  31704. * Function called to display the loading screen
  31705. */
  31706. displayLoadingUI(): void;
  31707. /**
  31708. * Function called to hide the loading screen
  31709. */
  31710. hideLoadingUI(): void;
  31711. /**
  31712. * Gets or sets the text to display while loading
  31713. */
  31714. loadingUIText: string;
  31715. /**
  31716. * Gets or sets the color to use for the background
  31717. */
  31718. loadingUIBackgroundColor: string;
  31719. private _resizeLoadingUI;
  31720. }
  31721. }
  31722. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31723. /**
  31724. * Interface for any object that can request an animation frame
  31725. */
  31726. export interface ICustomAnimationFrameRequester {
  31727. /**
  31728. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31729. */
  31730. renderFunction?: Function;
  31731. /**
  31732. * Called to request the next frame to render to
  31733. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31734. */
  31735. requestAnimationFrame: Function;
  31736. /**
  31737. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31738. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31739. */
  31740. requestID?: number;
  31741. }
  31742. }
  31743. declare module "babylonjs/Misc/performanceMonitor" {
  31744. /**
  31745. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31746. */
  31747. export class PerformanceMonitor {
  31748. private _enabled;
  31749. private _rollingFrameTime;
  31750. private _lastFrameTimeMs;
  31751. /**
  31752. * constructor
  31753. * @param frameSampleSize The number of samples required to saturate the sliding window
  31754. */
  31755. constructor(frameSampleSize?: number);
  31756. /**
  31757. * Samples current frame
  31758. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31759. */
  31760. sampleFrame(timeMs?: number): void;
  31761. /**
  31762. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31763. */
  31764. readonly averageFrameTime: number;
  31765. /**
  31766. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31767. */
  31768. readonly averageFrameTimeVariance: number;
  31769. /**
  31770. * Returns the frame time of the most recent frame
  31771. */
  31772. readonly instantaneousFrameTime: number;
  31773. /**
  31774. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31775. */
  31776. readonly averageFPS: number;
  31777. /**
  31778. * Returns the average framerate in frames per second using the most recent frame time
  31779. */
  31780. readonly instantaneousFPS: number;
  31781. /**
  31782. * Returns true if enough samples have been taken to completely fill the sliding window
  31783. */
  31784. readonly isSaturated: boolean;
  31785. /**
  31786. * Enables contributions to the sliding window sample set
  31787. */
  31788. enable(): void;
  31789. /**
  31790. * Disables contributions to the sliding window sample set
  31791. * Samples will not be interpolated over the disabled period
  31792. */
  31793. disable(): void;
  31794. /**
  31795. * Returns true if sampling is enabled
  31796. */
  31797. readonly isEnabled: boolean;
  31798. /**
  31799. * Resets performance monitor
  31800. */
  31801. reset(): void;
  31802. }
  31803. /**
  31804. * RollingAverage
  31805. *
  31806. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31807. */
  31808. export class RollingAverage {
  31809. /**
  31810. * Current average
  31811. */
  31812. average: number;
  31813. /**
  31814. * Current variance
  31815. */
  31816. variance: number;
  31817. protected _samples: Array<number>;
  31818. protected _sampleCount: number;
  31819. protected _pos: number;
  31820. protected _m2: number;
  31821. /**
  31822. * constructor
  31823. * @param length The number of samples required to saturate the sliding window
  31824. */
  31825. constructor(length: number);
  31826. /**
  31827. * Adds a sample to the sample set
  31828. * @param v The sample value
  31829. */
  31830. add(v: number): void;
  31831. /**
  31832. * Returns previously added values or null if outside of history or outside the sliding window domain
  31833. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31834. * @return Value previously recorded with add() or null if outside of range
  31835. */
  31836. history(i: number): number;
  31837. /**
  31838. * Returns true if enough samples have been taken to completely fill the sliding window
  31839. * @return true if sample-set saturated
  31840. */
  31841. isSaturated(): boolean;
  31842. /**
  31843. * Resets the rolling average (equivalent to 0 samples taken so far)
  31844. */
  31845. reset(): void;
  31846. /**
  31847. * Wraps a value around the sample range boundaries
  31848. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31849. * @return Wrapped position in sample range
  31850. */
  31851. protected _wrapPosition(i: number): number;
  31852. }
  31853. }
  31854. declare module "babylonjs/Engines/engine" {
  31855. import { Observable } from "babylonjs/Misc/observable";
  31856. import { Nullable } from "babylonjs/types";
  31857. import { Scene } from "babylonjs/scene";
  31858. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31859. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31860. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31861. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31862. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31863. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31864. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31865. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31866. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31867. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  31868. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31869. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31870. import { Material } from "babylonjs/Materials/material";
  31871. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31872. /**
  31873. * Defines the interface used by display changed events
  31874. */
  31875. export interface IDisplayChangedEventArgs {
  31876. /** Gets the vrDisplay object (if any) */
  31877. vrDisplay: Nullable<any>;
  31878. /** Gets a boolean indicating if webVR is supported */
  31879. vrSupported: boolean;
  31880. }
  31881. /**
  31882. * Defines the interface used by objects containing a viewport (like a camera)
  31883. */
  31884. interface IViewportOwnerLike {
  31885. /**
  31886. * Gets or sets the viewport
  31887. */
  31888. viewport: IViewportLike;
  31889. }
  31890. /**
  31891. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31892. */
  31893. export class Engine extends ThinEngine {
  31894. /** Defines that alpha blending is disabled */
  31895. static readonly ALPHA_DISABLE: number;
  31896. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31897. static readonly ALPHA_ADD: number;
  31898. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31899. static readonly ALPHA_COMBINE: number;
  31900. /** Defines that alpha blending to DEST - SRC * DEST */
  31901. static readonly ALPHA_SUBTRACT: number;
  31902. /** Defines that alpha blending to SRC * DEST */
  31903. static readonly ALPHA_MULTIPLY: number;
  31904. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31905. static readonly ALPHA_MAXIMIZED: number;
  31906. /** Defines that alpha blending to SRC + DEST */
  31907. static readonly ALPHA_ONEONE: number;
  31908. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31909. static readonly ALPHA_PREMULTIPLIED: number;
  31910. /**
  31911. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31912. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31913. */
  31914. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31915. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31916. static readonly ALPHA_INTERPOLATE: number;
  31917. /**
  31918. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31919. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31920. */
  31921. static readonly ALPHA_SCREENMODE: number;
  31922. /** Defines that the ressource is not delayed*/
  31923. static readonly DELAYLOADSTATE_NONE: number;
  31924. /** Defines that the ressource was successfully delay loaded */
  31925. static readonly DELAYLOADSTATE_LOADED: number;
  31926. /** Defines that the ressource is currently delay loading */
  31927. static readonly DELAYLOADSTATE_LOADING: number;
  31928. /** Defines that the ressource is delayed and has not started loading */
  31929. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31930. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31931. static readonly NEVER: number;
  31932. /** 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 */
  31933. static readonly ALWAYS: number;
  31934. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31935. static readonly LESS: number;
  31936. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31937. static readonly EQUAL: number;
  31938. /** 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 */
  31939. static readonly LEQUAL: number;
  31940. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31941. static readonly GREATER: number;
  31942. /** 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 */
  31943. static readonly GEQUAL: number;
  31944. /** 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 */
  31945. static readonly NOTEQUAL: number;
  31946. /** Passed to stencilOperation to specify that stencil value must be kept */
  31947. static readonly KEEP: number;
  31948. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31949. static readonly REPLACE: number;
  31950. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31951. static readonly INCR: number;
  31952. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31953. static readonly DECR: number;
  31954. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31955. static readonly INVERT: number;
  31956. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31957. static readonly INCR_WRAP: number;
  31958. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31959. static readonly DECR_WRAP: number;
  31960. /** Texture is not repeating outside of 0..1 UVs */
  31961. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31962. /** Texture is repeating outside of 0..1 UVs */
  31963. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31964. /** Texture is repeating and mirrored */
  31965. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31966. /** ALPHA */
  31967. static readonly TEXTUREFORMAT_ALPHA: number;
  31968. /** LUMINANCE */
  31969. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31970. /** LUMINANCE_ALPHA */
  31971. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31972. /** RGB */
  31973. static readonly TEXTUREFORMAT_RGB: number;
  31974. /** RGBA */
  31975. static readonly TEXTUREFORMAT_RGBA: number;
  31976. /** RED */
  31977. static readonly TEXTUREFORMAT_RED: number;
  31978. /** RED (2nd reference) */
  31979. static readonly TEXTUREFORMAT_R: number;
  31980. /** RG */
  31981. static readonly TEXTUREFORMAT_RG: number;
  31982. /** RED_INTEGER */
  31983. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31984. /** RED_INTEGER (2nd reference) */
  31985. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31986. /** RG_INTEGER */
  31987. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31988. /** RGB_INTEGER */
  31989. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31990. /** RGBA_INTEGER */
  31991. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31992. /** UNSIGNED_BYTE */
  31993. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31994. /** UNSIGNED_BYTE (2nd reference) */
  31995. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31996. /** FLOAT */
  31997. static readonly TEXTURETYPE_FLOAT: number;
  31998. /** HALF_FLOAT */
  31999. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32000. /** BYTE */
  32001. static readonly TEXTURETYPE_BYTE: number;
  32002. /** SHORT */
  32003. static readonly TEXTURETYPE_SHORT: number;
  32004. /** UNSIGNED_SHORT */
  32005. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32006. /** INT */
  32007. static readonly TEXTURETYPE_INT: number;
  32008. /** UNSIGNED_INT */
  32009. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32010. /** UNSIGNED_SHORT_4_4_4_4 */
  32011. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32012. /** UNSIGNED_SHORT_5_5_5_1 */
  32013. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32014. /** UNSIGNED_SHORT_5_6_5 */
  32015. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32016. /** UNSIGNED_INT_2_10_10_10_REV */
  32017. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32018. /** UNSIGNED_INT_24_8 */
  32019. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32020. /** UNSIGNED_INT_10F_11F_11F_REV */
  32021. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32022. /** UNSIGNED_INT_5_9_9_9_REV */
  32023. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32024. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32025. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32026. /** nearest is mag = nearest and min = nearest and mip = linear */
  32027. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32028. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32029. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32030. /** Trilinear is mag = linear and min = linear and mip = linear */
  32031. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32032. /** nearest is mag = nearest and min = nearest and mip = linear */
  32033. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32034. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32035. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32036. /** Trilinear is mag = linear and min = linear and mip = linear */
  32037. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32038. /** mag = nearest and min = nearest and mip = nearest */
  32039. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32040. /** mag = nearest and min = linear and mip = nearest */
  32041. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32042. /** mag = nearest and min = linear and mip = linear */
  32043. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32044. /** mag = nearest and min = linear and mip = none */
  32045. static readonly TEXTURE_NEAREST_LINEAR: number;
  32046. /** mag = nearest and min = nearest and mip = none */
  32047. static readonly TEXTURE_NEAREST_NEAREST: number;
  32048. /** mag = linear and min = nearest and mip = nearest */
  32049. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32050. /** mag = linear and min = nearest and mip = linear */
  32051. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32052. /** mag = linear and min = linear and mip = none */
  32053. static readonly TEXTURE_LINEAR_LINEAR: number;
  32054. /** mag = linear and min = nearest and mip = none */
  32055. static readonly TEXTURE_LINEAR_NEAREST: number;
  32056. /** Explicit coordinates mode */
  32057. static readonly TEXTURE_EXPLICIT_MODE: number;
  32058. /** Spherical coordinates mode */
  32059. static readonly TEXTURE_SPHERICAL_MODE: number;
  32060. /** Planar coordinates mode */
  32061. static readonly TEXTURE_PLANAR_MODE: number;
  32062. /** Cubic coordinates mode */
  32063. static readonly TEXTURE_CUBIC_MODE: number;
  32064. /** Projection coordinates mode */
  32065. static readonly TEXTURE_PROJECTION_MODE: number;
  32066. /** Skybox coordinates mode */
  32067. static readonly TEXTURE_SKYBOX_MODE: number;
  32068. /** Inverse Cubic coordinates mode */
  32069. static readonly TEXTURE_INVCUBIC_MODE: number;
  32070. /** Equirectangular coordinates mode */
  32071. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32072. /** Equirectangular Fixed coordinates mode */
  32073. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32074. /** Equirectangular Fixed Mirrored coordinates mode */
  32075. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32076. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32077. static readonly SCALEMODE_FLOOR: number;
  32078. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32079. static readonly SCALEMODE_NEAREST: number;
  32080. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32081. static readonly SCALEMODE_CEILING: number;
  32082. /**
  32083. * Returns the current npm package of the sdk
  32084. */
  32085. static readonly NpmPackage: string;
  32086. /**
  32087. * Returns the current version of the framework
  32088. */
  32089. static readonly Version: string;
  32090. /** Gets the list of created engines */
  32091. static readonly Instances: Engine[];
  32092. /**
  32093. * Gets the latest created engine
  32094. */
  32095. static readonly LastCreatedEngine: Nullable<Engine>;
  32096. /**
  32097. * Gets the latest created scene
  32098. */
  32099. static readonly LastCreatedScene: Nullable<Scene>;
  32100. /**
  32101. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32102. * @param flag defines which part of the materials must be marked as dirty
  32103. * @param predicate defines a predicate used to filter which materials should be affected
  32104. */
  32105. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32106. /**
  32107. * Method called to create the default loading screen.
  32108. * This can be overriden in your own app.
  32109. * @param canvas The rendering canvas element
  32110. * @returns The loading screen
  32111. */
  32112. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32113. /**
  32114. * Method called to create the default rescale post process on each engine.
  32115. */
  32116. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32117. /**
  32118. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32119. **/
  32120. enableOfflineSupport: boolean;
  32121. /**
  32122. * 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)
  32123. **/
  32124. disableManifestCheck: boolean;
  32125. /**
  32126. * Gets the list of created scenes
  32127. */
  32128. scenes: Scene[];
  32129. /**
  32130. * Event raised when a new scene is created
  32131. */
  32132. onNewSceneAddedObservable: Observable<Scene>;
  32133. /**
  32134. * Gets the list of created postprocesses
  32135. */
  32136. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32137. /**
  32138. * Gets a boolean indicating if the pointer is currently locked
  32139. */
  32140. isPointerLock: boolean;
  32141. /**
  32142. * Observable event triggered each time the rendering canvas is resized
  32143. */
  32144. onResizeObservable: Observable<Engine>;
  32145. /**
  32146. * Observable event triggered each time the canvas loses focus
  32147. */
  32148. onCanvasBlurObservable: Observable<Engine>;
  32149. /**
  32150. * Observable event triggered each time the canvas gains focus
  32151. */
  32152. onCanvasFocusObservable: Observable<Engine>;
  32153. /**
  32154. * Observable event triggered each time the canvas receives pointerout event
  32155. */
  32156. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32157. /**
  32158. * Observable event triggered before each texture is initialized
  32159. */
  32160. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32161. /**
  32162. * Observable raised when the engine begins a new frame
  32163. */
  32164. onBeginFrameObservable: Observable<Engine>;
  32165. /**
  32166. * If set, will be used to request the next animation frame for the render loop
  32167. */
  32168. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32169. /**
  32170. * Observable raised when the engine ends the current frame
  32171. */
  32172. onEndFrameObservable: Observable<Engine>;
  32173. /**
  32174. * Observable raised when the engine is about to compile a shader
  32175. */
  32176. onBeforeShaderCompilationObservable: Observable<Engine>;
  32177. /**
  32178. * Observable raised when the engine has jsut compiled a shader
  32179. */
  32180. onAfterShaderCompilationObservable: Observable<Engine>;
  32181. /**
  32182. * Gets the audio engine
  32183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32184. * @ignorenaming
  32185. */
  32186. static audioEngine: IAudioEngine;
  32187. /**
  32188. * Default AudioEngine factory responsible of creating the Audio Engine.
  32189. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32190. */
  32191. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32192. /**
  32193. * Default offline support factory responsible of creating a tool used to store data locally.
  32194. * By default, this will create a Database object if the workload has been embedded.
  32195. */
  32196. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32197. private _loadingScreen;
  32198. private _pointerLockRequested;
  32199. private _dummyFramebuffer;
  32200. private _rescalePostProcess;
  32201. /** @hidden */
  32202. protected _alphaMode: number;
  32203. /** @hidden */
  32204. protected _alphaEquation: number;
  32205. private _deterministicLockstep;
  32206. private _lockstepMaxSteps;
  32207. protected readonly _supportsHardwareTextureRescaling: boolean;
  32208. private _fps;
  32209. private _deltaTime;
  32210. /**
  32211. * Turn this value on if you want to pause FPS computation when in background
  32212. */
  32213. disablePerformanceMonitorInBackground: boolean;
  32214. private _performanceMonitor;
  32215. /**
  32216. * Gets the performance monitor attached to this engine
  32217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32218. */
  32219. readonly performanceMonitor: PerformanceMonitor;
  32220. private _onFocus;
  32221. private _onBlur;
  32222. private _onCanvasPointerOut;
  32223. private _onCanvasBlur;
  32224. private _onCanvasFocus;
  32225. private _onFullscreenChange;
  32226. private _onPointerLockChange;
  32227. /**
  32228. * Creates a new engine
  32229. * @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
  32230. * @param antialias defines enable antialiasing (default: false)
  32231. * @param options defines further options to be sent to the getContext() function
  32232. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32233. */
  32234. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32235. /**
  32236. * Gets current aspect ratio
  32237. * @param viewportOwner defines the camera to use to get the aspect ratio
  32238. * @param useScreen defines if screen size must be used (or the current render target if any)
  32239. * @returns a number defining the aspect ratio
  32240. */
  32241. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32242. /**
  32243. * Gets current screen aspect ratio
  32244. * @returns a number defining the aspect ratio
  32245. */
  32246. getScreenAspectRatio(): number;
  32247. /**
  32248. * Gets host document
  32249. * @returns the host document object
  32250. */
  32251. getHostDocument(): Document;
  32252. /**
  32253. * Gets the client rect of the HTML canvas attached with the current webGL context
  32254. * @returns a client rectanglee
  32255. */
  32256. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32257. /**
  32258. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32259. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32260. * @returns true if engine is in deterministic lock step mode
  32261. */
  32262. isDeterministicLockStep(): boolean;
  32263. /**
  32264. * Gets the max steps when engine is running in deterministic lock step
  32265. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32266. * @returns the max steps
  32267. */
  32268. getLockstepMaxSteps(): number;
  32269. /**
  32270. * Force the mipmap generation for the given render target texture
  32271. * @param texture defines the render target texture to use
  32272. */
  32273. generateMipMapsForCubemap(texture: InternalTexture): void;
  32274. /** States */
  32275. /**
  32276. * Set various states to the webGL context
  32277. * @param culling defines backface culling state
  32278. * @param zOffset defines the value to apply to zOffset (0 by default)
  32279. * @param force defines if states must be applied even if cache is up to date
  32280. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32281. */
  32282. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32283. /**
  32284. * Set the z offset to apply to current rendering
  32285. * @param value defines the offset to apply
  32286. */
  32287. setZOffset(value: number): void;
  32288. /**
  32289. * Gets the current value of the zOffset
  32290. * @returns the current zOffset state
  32291. */
  32292. getZOffset(): number;
  32293. /**
  32294. * Enable or disable depth buffering
  32295. * @param enable defines the state to set
  32296. */
  32297. setDepthBuffer(enable: boolean): void;
  32298. /**
  32299. * Gets a boolean indicating if depth writing is enabled
  32300. * @returns the current depth writing state
  32301. */
  32302. getDepthWrite(): boolean;
  32303. /**
  32304. * Enable or disable depth writing
  32305. * @param enable defines the state to set
  32306. */
  32307. setDepthWrite(enable: boolean): void;
  32308. /**
  32309. * Enable or disable color writing
  32310. * @param enable defines the state to set
  32311. */
  32312. setColorWrite(enable: boolean): void;
  32313. /**
  32314. * Gets a boolean indicating if color writing is enabled
  32315. * @returns the current color writing state
  32316. */
  32317. getColorWrite(): boolean;
  32318. /**
  32319. * Sets alpha constants used by some alpha blending modes
  32320. * @param r defines the red component
  32321. * @param g defines the green component
  32322. * @param b defines the blue component
  32323. * @param a defines the alpha component
  32324. */
  32325. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32326. /**
  32327. * Sets the current alpha mode
  32328. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32329. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32330. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32331. */
  32332. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32333. /**
  32334. * Gets the current alpha mode
  32335. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32336. * @returns the current alpha mode
  32337. */
  32338. getAlphaMode(): number;
  32339. /**
  32340. * Sets the current alpha equation
  32341. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32342. */
  32343. setAlphaEquation(equation: number): void;
  32344. /**
  32345. * Gets the current alpha equation.
  32346. * @returns the current alpha equation
  32347. */
  32348. getAlphaEquation(): number;
  32349. /**
  32350. * Gets a boolean indicating if stencil buffer is enabled
  32351. * @returns the current stencil buffer state
  32352. */
  32353. getStencilBuffer(): boolean;
  32354. /**
  32355. * Enable or disable the stencil buffer
  32356. * @param enable defines if the stencil buffer must be enabled or disabled
  32357. */
  32358. setStencilBuffer(enable: boolean): void;
  32359. /**
  32360. * Gets the current stencil mask
  32361. * @returns a number defining the new stencil mask to use
  32362. */
  32363. getStencilMask(): number;
  32364. /**
  32365. * Sets the current stencil mask
  32366. * @param mask defines the new stencil mask to use
  32367. */
  32368. setStencilMask(mask: number): void;
  32369. /**
  32370. * Gets the current stencil function
  32371. * @returns a number defining the stencil function to use
  32372. */
  32373. getStencilFunction(): number;
  32374. /**
  32375. * Gets the current stencil reference value
  32376. * @returns a number defining the stencil reference value to use
  32377. */
  32378. getStencilFunctionReference(): number;
  32379. /**
  32380. * Gets the current stencil mask
  32381. * @returns a number defining the stencil mask to use
  32382. */
  32383. getStencilFunctionMask(): number;
  32384. /**
  32385. * Sets the current stencil function
  32386. * @param stencilFunc defines the new stencil function to use
  32387. */
  32388. setStencilFunction(stencilFunc: number): void;
  32389. /**
  32390. * Sets the current stencil reference
  32391. * @param reference defines the new stencil reference to use
  32392. */
  32393. setStencilFunctionReference(reference: number): void;
  32394. /**
  32395. * Sets the current stencil mask
  32396. * @param mask defines the new stencil mask to use
  32397. */
  32398. setStencilFunctionMask(mask: number): void;
  32399. /**
  32400. * Gets the current stencil operation when stencil fails
  32401. * @returns a number defining stencil operation to use when stencil fails
  32402. */
  32403. getStencilOperationFail(): number;
  32404. /**
  32405. * Gets the current stencil operation when depth fails
  32406. * @returns a number defining stencil operation to use when depth fails
  32407. */
  32408. getStencilOperationDepthFail(): number;
  32409. /**
  32410. * Gets the current stencil operation when stencil passes
  32411. * @returns a number defining stencil operation to use when stencil passes
  32412. */
  32413. getStencilOperationPass(): number;
  32414. /**
  32415. * Sets the stencil operation to use when stencil fails
  32416. * @param operation defines the stencil operation to use when stencil fails
  32417. */
  32418. setStencilOperationFail(operation: number): void;
  32419. /**
  32420. * Sets the stencil operation to use when depth fails
  32421. * @param operation defines the stencil operation to use when depth fails
  32422. */
  32423. setStencilOperationDepthFail(operation: number): void;
  32424. /**
  32425. * Sets the stencil operation to use when stencil passes
  32426. * @param operation defines the stencil operation to use when stencil passes
  32427. */
  32428. setStencilOperationPass(operation: number): void;
  32429. /**
  32430. * Sets a boolean indicating if the dithering state is enabled or disabled
  32431. * @param value defines the dithering state
  32432. */
  32433. setDitheringState(value: boolean): void;
  32434. /**
  32435. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32436. * @param value defines the rasterizer state
  32437. */
  32438. setRasterizerState(value: boolean): void;
  32439. /**
  32440. * Gets the current depth function
  32441. * @returns a number defining the depth function
  32442. */
  32443. getDepthFunction(): Nullable<number>;
  32444. /**
  32445. * Sets the current depth function
  32446. * @param depthFunc defines the function to use
  32447. */
  32448. setDepthFunction(depthFunc: number): void;
  32449. /**
  32450. * Sets the current depth function to GREATER
  32451. */
  32452. setDepthFunctionToGreater(): void;
  32453. /**
  32454. * Sets the current depth function to GEQUAL
  32455. */
  32456. setDepthFunctionToGreaterOrEqual(): void;
  32457. /**
  32458. * Sets the current depth function to LESS
  32459. */
  32460. setDepthFunctionToLess(): void;
  32461. /**
  32462. * Sets the current depth function to LEQUAL
  32463. */
  32464. setDepthFunctionToLessOrEqual(): void;
  32465. private _cachedStencilBuffer;
  32466. private _cachedStencilFunction;
  32467. private _cachedStencilMask;
  32468. private _cachedStencilOperationPass;
  32469. private _cachedStencilOperationFail;
  32470. private _cachedStencilOperationDepthFail;
  32471. private _cachedStencilReference;
  32472. /**
  32473. * Caches the the state of the stencil buffer
  32474. */
  32475. cacheStencilState(): void;
  32476. /**
  32477. * Restores the state of the stencil buffer
  32478. */
  32479. restoreStencilState(): void;
  32480. /**
  32481. * Directly set the WebGL Viewport
  32482. * @param x defines the x coordinate of the viewport (in screen space)
  32483. * @param y defines the y coordinate of the viewport (in screen space)
  32484. * @param width defines the width of the viewport (in screen space)
  32485. * @param height defines the height of the viewport (in screen space)
  32486. * @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
  32487. */
  32488. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32489. /**
  32490. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32491. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32492. * @param y defines the y-coordinate of the corner of the clear rectangle
  32493. * @param width defines the width of the clear rectangle
  32494. * @param height defines the height of the clear rectangle
  32495. * @param clearColor defines the clear color
  32496. */
  32497. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32498. /**
  32499. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32500. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32501. * @param y defines the y-coordinate of the corner of the clear rectangle
  32502. * @param width defines the width of the clear rectangle
  32503. * @param height defines the height of the clear rectangle
  32504. */
  32505. enableScissor(x: number, y: number, width: number, height: number): void;
  32506. /**
  32507. * Disable previously set scissor test rectangle
  32508. */
  32509. disableScissor(): void;
  32510. /**
  32511. * Initializes a webVR display and starts listening to display change events
  32512. * The onVRDisplayChangedObservable will be notified upon these changes
  32513. * @returns The onVRDisplayChangedObservable
  32514. */
  32515. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32516. /** @hidden */
  32517. _prepareVRComponent(): void;
  32518. /** @hidden */
  32519. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32520. /** @hidden */
  32521. _submitVRFrame(): void;
  32522. /**
  32523. * Call this function to leave webVR mode
  32524. * Will do nothing if webVR is not supported or if there is no webVR device
  32525. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32526. */
  32527. disableVR(): void;
  32528. /**
  32529. * Gets a boolean indicating that the system is in VR mode and is presenting
  32530. * @returns true if VR mode is engaged
  32531. */
  32532. isVRPresenting(): boolean;
  32533. /** @hidden */
  32534. _requestVRFrame(): void;
  32535. /** @hidden */
  32536. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32537. /**
  32538. * Gets the source code of the vertex shader associated with a specific webGL program
  32539. * @param program defines the program to use
  32540. * @returns a string containing the source code of the vertex shader associated with the program
  32541. */
  32542. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32543. /**
  32544. * Gets the source code of the fragment shader associated with a specific webGL program
  32545. * @param program defines the program to use
  32546. * @returns a string containing the source code of the fragment shader associated with the program
  32547. */
  32548. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32549. /**
  32550. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32551. * @param x defines the x coordinate of the rectangle where pixels must be read
  32552. * @param y defines the y coordinate of the rectangle where pixels must be read
  32553. * @param width defines the width of the rectangle where pixels must be read
  32554. * @param height defines the height of the rectangle where pixels must be read
  32555. * @returns a Uint8Array containing RGBA colors
  32556. */
  32557. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32558. /**
  32559. * Sets a depth stencil texture from a render target to the according uniform.
  32560. * @param channel The texture channel
  32561. * @param uniform The uniform to set
  32562. * @param texture The render target texture containing the depth stencil texture to apply
  32563. */
  32564. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32565. /**
  32566. * Sets a texture to the webGL context from a postprocess
  32567. * @param channel defines the channel to use
  32568. * @param postProcess defines the source postprocess
  32569. */
  32570. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32571. /**
  32572. * Binds the output of the passed in post process to the texture channel specified
  32573. * @param channel The channel the texture should be bound to
  32574. * @param postProcess The post process which's output should be bound
  32575. */
  32576. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32577. /** @hidden */
  32578. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32579. protected _rebuildBuffers(): void;
  32580. _renderLoop(): void;
  32581. /**
  32582. * Toggle full screen mode
  32583. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32584. */
  32585. switchFullscreen(requestPointerLock: boolean): void;
  32586. /**
  32587. * Enters full screen mode
  32588. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32589. */
  32590. enterFullscreen(requestPointerLock: boolean): void;
  32591. /**
  32592. * Exits full screen mode
  32593. */
  32594. exitFullscreen(): void;
  32595. /**
  32596. * Enters Pointerlock mode
  32597. */
  32598. enterPointerlock(): void;
  32599. /**
  32600. * Exits Pointerlock mode
  32601. */
  32602. exitPointerlock(): void;
  32603. /**
  32604. * Begin a new frame
  32605. */
  32606. beginFrame(): void;
  32607. /**
  32608. * Enf the current frame
  32609. */
  32610. endFrame(): void;
  32611. resize(): void;
  32612. /**
  32613. * Set the compressed texture format to use, based on the formats you have, and the formats
  32614. * supported by the hardware / browser.
  32615. *
  32616. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32617. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32618. * to API arguments needed to compressed textures. This puts the burden on the container
  32619. * generator to house the arcane code for determining these for current & future formats.
  32620. *
  32621. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32622. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32623. *
  32624. * Note: The result of this call is not taken into account when a texture is base64.
  32625. *
  32626. * @param formatsAvailable defines the list of those format families you have created
  32627. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32628. *
  32629. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32630. * @returns The extension selected.
  32631. */
  32632. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32633. /**
  32634. * Force a specific size of the canvas
  32635. * @param width defines the new canvas' width
  32636. * @param height defines the new canvas' height
  32637. */
  32638. setSize(width: number, height: number): void;
  32639. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32640. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32641. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32642. _releaseTexture(texture: InternalTexture): void;
  32643. /**
  32644. * @hidden
  32645. * Rescales a texture
  32646. * @param source input texutre
  32647. * @param destination destination texture
  32648. * @param scene scene to use to render the resize
  32649. * @param internalFormat format to use when resizing
  32650. * @param onComplete callback to be called when resize has completed
  32651. */
  32652. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32653. /**
  32654. * Gets the current framerate
  32655. * @returns a number representing the framerate
  32656. */
  32657. getFps(): number;
  32658. /**
  32659. * Gets the time spent between current and previous frame
  32660. * @returns a number representing the delta time in ms
  32661. */
  32662. getDeltaTime(): number;
  32663. private _measureFps;
  32664. /**
  32665. * Creates a new render target texture
  32666. * @param size defines the size of the texture
  32667. * @param options defines the options used to create the texture
  32668. * @returns a new render target texture stored in an InternalTexture
  32669. */
  32670. createRenderTargetTexture(size: number | {
  32671. width: number;
  32672. height: number;
  32673. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32674. /**
  32675. * Updates the sample count of a render target texture
  32676. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32677. * @param texture defines the texture to update
  32678. * @param samples defines the sample count to set
  32679. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32680. */
  32681. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32682. /** @hidden */
  32683. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32684. dispose(): void;
  32685. private _disableTouchAction;
  32686. /**
  32687. * Display the loading screen
  32688. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32689. */
  32690. displayLoadingUI(): void;
  32691. /**
  32692. * Hide the loading screen
  32693. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32694. */
  32695. hideLoadingUI(): void;
  32696. /**
  32697. * Gets the current loading screen object
  32698. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32699. */
  32700. /**
  32701. * Sets the current loading screen object
  32702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32703. */
  32704. loadingScreen: ILoadingScreen;
  32705. /**
  32706. * Sets the current loading screen text
  32707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32708. */
  32709. loadingUIText: string;
  32710. /**
  32711. * Sets the current loading screen background color
  32712. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32713. */
  32714. loadingUIBackgroundColor: string;
  32715. /** Pointerlock and fullscreen */
  32716. /**
  32717. * Ask the browser to promote the current element to pointerlock mode
  32718. * @param element defines the DOM element to promote
  32719. */
  32720. static _RequestPointerlock(element: HTMLElement): void;
  32721. /**
  32722. * Asks the browser to exit pointerlock mode
  32723. */
  32724. static _ExitPointerlock(): void;
  32725. /**
  32726. * Ask the browser to promote the current element to fullscreen rendering mode
  32727. * @param element defines the DOM element to promote
  32728. */
  32729. static _RequestFullscreen(element: HTMLElement): void;
  32730. /**
  32731. * Asks the browser to exit fullscreen mode
  32732. */
  32733. static _ExitFullscreen(): void;
  32734. }
  32735. }
  32736. declare module "babylonjs/Engines/engineStore" {
  32737. import { Nullable } from "babylonjs/types";
  32738. import { Engine } from "babylonjs/Engines/engine";
  32739. import { Scene } from "babylonjs/scene";
  32740. /**
  32741. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32742. * during the life time of the application.
  32743. */
  32744. export class EngineStore {
  32745. /** Gets the list of created engines */
  32746. static Instances: import("babylonjs/Engines/engine").Engine[];
  32747. /** @hidden */
  32748. static _LastCreatedScene: Nullable<Scene>;
  32749. /**
  32750. * Gets the latest created engine
  32751. */
  32752. static readonly LastCreatedEngine: Nullable<Engine>;
  32753. /**
  32754. * Gets the latest created scene
  32755. */
  32756. static readonly LastCreatedScene: Nullable<Scene>;
  32757. /**
  32758. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32759. * @ignorenaming
  32760. */
  32761. static UseFallbackTexture: boolean;
  32762. /**
  32763. * Texture content used if a texture cannot loaded
  32764. * @ignorenaming
  32765. */
  32766. static FallbackTexture: string;
  32767. }
  32768. }
  32769. declare module "babylonjs/Misc/promise" {
  32770. /**
  32771. * Helper class that provides a small promise polyfill
  32772. */
  32773. export class PromisePolyfill {
  32774. /**
  32775. * Static function used to check if the polyfill is required
  32776. * If this is the case then the function will inject the polyfill to window.Promise
  32777. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32778. */
  32779. static Apply(force?: boolean): void;
  32780. }
  32781. }
  32782. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32783. /**
  32784. * Interface for screenshot methods with describe argument called `size` as object with options
  32785. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32786. */
  32787. export interface IScreenshotSize {
  32788. /**
  32789. * number in pixels for canvas height
  32790. */
  32791. height?: number;
  32792. /**
  32793. * multiplier allowing render at a higher or lower resolution
  32794. * If value is defined then height and width will be ignored and taken from camera
  32795. */
  32796. precision?: number;
  32797. /**
  32798. * number in pixels for canvas width
  32799. */
  32800. width?: number;
  32801. }
  32802. }
  32803. declare module "babylonjs/Misc/tools" {
  32804. import { Nullable, float } from "babylonjs/types";
  32805. import { DomManagement } from "babylonjs/Misc/domManagement";
  32806. import { WebRequest } from "babylonjs/Misc/webRequest";
  32807. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32808. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32809. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32810. import { Camera } from "babylonjs/Cameras/camera";
  32811. import { Engine } from "babylonjs/Engines/engine";
  32812. interface IColor4Like {
  32813. r: float;
  32814. g: float;
  32815. b: float;
  32816. a: float;
  32817. }
  32818. /**
  32819. * Class containing a set of static utilities functions
  32820. */
  32821. export class Tools {
  32822. /**
  32823. * Gets or sets the base URL to use to load assets
  32824. */
  32825. static BaseUrl: string;
  32826. /**
  32827. * Enable/Disable Custom HTTP Request Headers globally.
  32828. * default = false
  32829. * @see CustomRequestHeaders
  32830. */
  32831. static UseCustomRequestHeaders: boolean;
  32832. /**
  32833. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32834. * i.e. when loading files, where the server/service expects an Authorization header
  32835. */
  32836. static CustomRequestHeaders: {
  32837. [key: string]: string;
  32838. };
  32839. /**
  32840. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32841. */
  32842. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32843. /**
  32844. * Default behaviour for cors in the application.
  32845. * It can be a string if the expected behavior is identical in the entire app.
  32846. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32847. */
  32848. static CorsBehavior: string | ((url: string | string[]) => string);
  32849. /**
  32850. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32851. * @ignorenaming
  32852. */
  32853. static UseFallbackTexture: boolean;
  32854. /**
  32855. * Use this object to register external classes like custom textures or material
  32856. * to allow the laoders to instantiate them
  32857. */
  32858. static RegisteredExternalClasses: {
  32859. [key: string]: Object;
  32860. };
  32861. /**
  32862. * Texture content used if a texture cannot loaded
  32863. * @ignorenaming
  32864. */
  32865. static fallbackTexture: string;
  32866. /**
  32867. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32868. * @param u defines the coordinate on X axis
  32869. * @param v defines the coordinate on Y axis
  32870. * @param width defines the width of the source data
  32871. * @param height defines the height of the source data
  32872. * @param pixels defines the source byte array
  32873. * @param color defines the output color
  32874. */
  32875. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32876. /**
  32877. * Interpolates between a and b via alpha
  32878. * @param a The lower value (returned when alpha = 0)
  32879. * @param b The upper value (returned when alpha = 1)
  32880. * @param alpha The interpolation-factor
  32881. * @return The mixed value
  32882. */
  32883. static Mix(a: number, b: number, alpha: number): number;
  32884. /**
  32885. * Tries to instantiate a new object from a given class name
  32886. * @param className defines the class name to instantiate
  32887. * @returns the new object or null if the system was not able to do the instantiation
  32888. */
  32889. static Instantiate(className: string): any;
  32890. /**
  32891. * Provides a slice function that will work even on IE
  32892. * @param data defines the array to slice
  32893. * @param start defines the start of the data (optional)
  32894. * @param end defines the end of the data (optional)
  32895. * @returns the new sliced array
  32896. */
  32897. static Slice<T>(data: T, start?: number, end?: number): T;
  32898. /**
  32899. * Polyfill for setImmediate
  32900. * @param action defines the action to execute after the current execution block
  32901. */
  32902. static SetImmediate(action: () => void): void;
  32903. /**
  32904. * Function indicating if a number is an exponent of 2
  32905. * @param value defines the value to test
  32906. * @returns true if the value is an exponent of 2
  32907. */
  32908. static IsExponentOfTwo(value: number): boolean;
  32909. private static _tmpFloatArray;
  32910. /**
  32911. * Returns the nearest 32-bit single precision float representation of a Number
  32912. * @param value A Number. If the parameter is of a different type, it will get converted
  32913. * to a number or to NaN if it cannot be converted
  32914. * @returns number
  32915. */
  32916. static FloatRound(value: number): number;
  32917. /**
  32918. * Extracts the filename from a path
  32919. * @param path defines the path to use
  32920. * @returns the filename
  32921. */
  32922. static GetFilename(path: string): string;
  32923. /**
  32924. * Extracts the "folder" part of a path (everything before the filename).
  32925. * @param uri The URI to extract the info from
  32926. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32927. * @returns The "folder" part of the path
  32928. */
  32929. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32930. /**
  32931. * Extracts text content from a DOM element hierarchy
  32932. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32933. */
  32934. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32935. /**
  32936. * Convert an angle in radians to degrees
  32937. * @param angle defines the angle to convert
  32938. * @returns the angle in degrees
  32939. */
  32940. static ToDegrees(angle: number): number;
  32941. /**
  32942. * Convert an angle in degrees to radians
  32943. * @param angle defines the angle to convert
  32944. * @returns the angle in radians
  32945. */
  32946. static ToRadians(angle: number): number;
  32947. /**
  32948. * Encode a buffer to a base64 string
  32949. * @param buffer defines the buffer to encode
  32950. * @returns the encoded string
  32951. */
  32952. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32953. /**
  32954. * Returns an array if obj is not an array
  32955. * @param obj defines the object to evaluate as an array
  32956. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32957. * @returns either obj directly if obj is an array or a new array containing obj
  32958. */
  32959. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32960. /**
  32961. * Gets the pointer prefix to use
  32962. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32963. */
  32964. static GetPointerPrefix(): string;
  32965. /**
  32966. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32967. * @param url define the url we are trying
  32968. * @param element define the dom element where to configure the cors policy
  32969. */
  32970. static SetCorsBehavior(url: string | string[], element: {
  32971. crossOrigin: string | null;
  32972. }): void;
  32973. /**
  32974. * Removes unwanted characters from an url
  32975. * @param url defines the url to clean
  32976. * @returns the cleaned url
  32977. */
  32978. static CleanUrl(url: string): string;
  32979. /**
  32980. * Gets or sets a function used to pre-process url before using them to load assets
  32981. */
  32982. static PreprocessUrl: (url: string) => string;
  32983. /**
  32984. * Loads an image as an HTMLImageElement.
  32985. * @param input url string, ArrayBuffer, or Blob to load
  32986. * @param onLoad callback called when the image successfully loads
  32987. * @param onError callback called when the image fails to load
  32988. * @param offlineProvider offline provider for caching
  32989. * @returns the HTMLImageElement of the loaded image
  32990. */
  32991. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32992. /**
  32993. * Loads a file
  32994. * @param url url string, ArrayBuffer, or Blob to load
  32995. * @param onSuccess callback called when the file successfully loads
  32996. * @param onProgress callback called while file is loading (if the server supports this mode)
  32997. * @param offlineProvider defines the offline provider for caching
  32998. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32999. * @param onError callback called when the file fails to load
  33000. * @returns a file request object
  33001. */
  33002. 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;
  33003. /**
  33004. * Loads a file from a url
  33005. * @param url the file url to load
  33006. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33007. */
  33008. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33009. /**
  33010. * Load a script (identified by an url). When the url returns, the
  33011. * content of this file is added into a new script element, attached to the DOM (body element)
  33012. * @param scriptUrl defines the url of the script to laod
  33013. * @param onSuccess defines the callback called when the script is loaded
  33014. * @param onError defines the callback to call if an error occurs
  33015. * @param scriptId defines the id of the script element
  33016. */
  33017. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33018. /**
  33019. * Load an asynchronous script (identified by an url). When the url returns, the
  33020. * content of this file is added into a new script element, attached to the DOM (body element)
  33021. * @param scriptUrl defines the url of the script to laod
  33022. * @param scriptId defines the id of the script element
  33023. * @returns a promise request object
  33024. */
  33025. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33026. /**
  33027. * Loads a file from a blob
  33028. * @param fileToLoad defines the blob to use
  33029. * @param callback defines the callback to call when data is loaded
  33030. * @param progressCallback defines the callback to call during loading process
  33031. * @returns a file request object
  33032. */
  33033. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33034. /**
  33035. * Loads a file
  33036. * @param fileToLoad defines the file to load
  33037. * @param callback defines the callback to call when data is loaded
  33038. * @param progressCallBack defines the callback to call during loading process
  33039. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33040. * @returns a file request object
  33041. */
  33042. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33043. /**
  33044. * Creates a data url from a given string content
  33045. * @param content defines the content to convert
  33046. * @returns the new data url link
  33047. */
  33048. static FileAsURL(content: string): string;
  33049. /**
  33050. * Format the given number to a specific decimal format
  33051. * @param value defines the number to format
  33052. * @param decimals defines the number of decimals to use
  33053. * @returns the formatted string
  33054. */
  33055. static Format(value: number, decimals?: number): string;
  33056. /**
  33057. * Tries to copy an object by duplicating every property
  33058. * @param source defines the source object
  33059. * @param destination defines the target object
  33060. * @param doNotCopyList defines a list of properties to avoid
  33061. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33062. */
  33063. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33064. /**
  33065. * Gets a boolean indicating if the given object has no own property
  33066. * @param obj defines the object to test
  33067. * @returns true if object has no own property
  33068. */
  33069. static IsEmpty(obj: any): boolean;
  33070. /**
  33071. * Function used to register events at window level
  33072. * @param windowElement defines the Window object to use
  33073. * @param events defines the events to register
  33074. */
  33075. static RegisterTopRootEvents(windowElement: Window, events: {
  33076. name: string;
  33077. handler: Nullable<(e: FocusEvent) => any>;
  33078. }[]): void;
  33079. /**
  33080. * Function used to unregister events from window level
  33081. * @param windowElement defines the Window object to use
  33082. * @param events defines the events to unregister
  33083. */
  33084. static UnregisterTopRootEvents(windowElement: Window, events: {
  33085. name: string;
  33086. handler: Nullable<(e: FocusEvent) => any>;
  33087. }[]): void;
  33088. /**
  33089. * @ignore
  33090. */
  33091. static _ScreenshotCanvas: HTMLCanvasElement;
  33092. /**
  33093. * Dumps the current bound framebuffer
  33094. * @param width defines the rendering width
  33095. * @param height defines the rendering height
  33096. * @param engine defines the hosting engine
  33097. * @param successCallback defines the callback triggered once the data are available
  33098. * @param mimeType defines the mime type of the result
  33099. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33100. */
  33101. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33102. /**
  33103. * Converts the canvas data to blob.
  33104. * This acts as a polyfill for browsers not supporting the to blob function.
  33105. * @param canvas Defines the canvas to extract the data from
  33106. * @param successCallback Defines the callback triggered once the data are available
  33107. * @param mimeType Defines the mime type of the result
  33108. */
  33109. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33110. /**
  33111. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33112. * @param successCallback defines the callback triggered once the data are available
  33113. * @param mimeType defines the mime type of the result
  33114. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33115. */
  33116. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33117. /**
  33118. * Downloads a blob in the browser
  33119. * @param blob defines the blob to download
  33120. * @param fileName defines the name of the downloaded file
  33121. */
  33122. static Download(blob: Blob, fileName: string): void;
  33123. /**
  33124. * Captures a screenshot of the current rendering
  33125. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33126. * @param engine defines the rendering engine
  33127. * @param camera defines the source camera
  33128. * @param size This parameter can be set to a single number or to an object with the
  33129. * following (optional) properties: precision, width, height. If a single number is passed,
  33130. * it will be used for both width and height. If an object is passed, the screenshot size
  33131. * will be derived from the parameters. The precision property is a multiplier allowing
  33132. * rendering at a higher or lower resolution
  33133. * @param successCallback defines the callback receives a single parameter which contains the
  33134. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33135. * src parameter of an <img> to display it
  33136. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33137. * Check your browser for supported MIME types
  33138. */
  33139. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33140. /**
  33141. * Captures a screenshot of the current rendering
  33142. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33143. * @param engine defines the rendering engine
  33144. * @param camera defines the source camera
  33145. * @param size This parameter can be set to a single number or to an object with the
  33146. * following (optional) properties: precision, width, height. If a single number is passed,
  33147. * it will be used for both width and height. If an object is passed, the screenshot size
  33148. * will be derived from the parameters. The precision property is a multiplier allowing
  33149. * rendering at a higher or lower resolution
  33150. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33151. * Check your browser for supported MIME types
  33152. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33153. * to the src parameter of an <img> to display it
  33154. */
  33155. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33156. /**
  33157. * Generates an image screenshot from the specified camera.
  33158. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33159. * @param engine The engine to use for rendering
  33160. * @param camera The camera to use for rendering
  33161. * @param size This parameter can be set to a single number or to an object with the
  33162. * following (optional) properties: precision, width, height. If a single number is passed,
  33163. * it will be used for both width and height. If an object is passed, the screenshot size
  33164. * will be derived from the parameters. The precision property is a multiplier allowing
  33165. * rendering at a higher or lower resolution
  33166. * @param successCallback The callback receives a single parameter which contains the
  33167. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33168. * src parameter of an <img> to display it
  33169. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33170. * Check your browser for supported MIME types
  33171. * @param samples Texture samples (default: 1)
  33172. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33173. * @param fileName A name for for the downloaded file.
  33174. */
  33175. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33176. /**
  33177. * Generates an image screenshot from the specified camera.
  33178. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33179. * @param engine The engine to use for rendering
  33180. * @param camera The camera to use for rendering
  33181. * @param size This parameter can be set to a single number or to an object with the
  33182. * following (optional) properties: precision, width, height. If a single number is passed,
  33183. * it will be used for both width and height. If an object is passed, the screenshot size
  33184. * will be derived from the parameters. The precision property is a multiplier allowing
  33185. * rendering at a higher or lower resolution
  33186. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33187. * Check your browser for supported MIME types
  33188. * @param samples Texture samples (default: 1)
  33189. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33190. * @param fileName A name for for the downloaded file.
  33191. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33192. * to the src parameter of an <img> to display it
  33193. */
  33194. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33195. /**
  33196. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33197. * Be aware Math.random() could cause collisions, but:
  33198. * "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"
  33199. * @returns a pseudo random id
  33200. */
  33201. static RandomId(): string;
  33202. /**
  33203. * Test if the given uri is a base64 string
  33204. * @param uri The uri to test
  33205. * @return True if the uri is a base64 string or false otherwise
  33206. */
  33207. static IsBase64(uri: string): boolean;
  33208. /**
  33209. * Decode the given base64 uri.
  33210. * @param uri The uri to decode
  33211. * @return The decoded base64 data.
  33212. */
  33213. static DecodeBase64(uri: string): ArrayBuffer;
  33214. /**
  33215. * Gets the absolute url.
  33216. * @param url the input url
  33217. * @return the absolute url
  33218. */
  33219. static GetAbsoluteUrl(url: string): string;
  33220. /**
  33221. * No log
  33222. */
  33223. static readonly NoneLogLevel: number;
  33224. /**
  33225. * Only message logs
  33226. */
  33227. static readonly MessageLogLevel: number;
  33228. /**
  33229. * Only warning logs
  33230. */
  33231. static readonly WarningLogLevel: number;
  33232. /**
  33233. * Only error logs
  33234. */
  33235. static readonly ErrorLogLevel: number;
  33236. /**
  33237. * All logs
  33238. */
  33239. static readonly AllLogLevel: number;
  33240. /**
  33241. * Gets a value indicating the number of loading errors
  33242. * @ignorenaming
  33243. */
  33244. static readonly errorsCount: number;
  33245. /**
  33246. * Callback called when a new log is added
  33247. */
  33248. static OnNewCacheEntry: (entry: string) => void;
  33249. /**
  33250. * Log a message to the console
  33251. * @param message defines the message to log
  33252. */
  33253. static Log(message: string): void;
  33254. /**
  33255. * Write a warning message to the console
  33256. * @param message defines the message to log
  33257. */
  33258. static Warn(message: string): void;
  33259. /**
  33260. * Write an error message to the console
  33261. * @param message defines the message to log
  33262. */
  33263. static Error(message: string): void;
  33264. /**
  33265. * Gets current log cache (list of logs)
  33266. */
  33267. static readonly LogCache: string;
  33268. /**
  33269. * Clears the log cache
  33270. */
  33271. static ClearLogCache(): void;
  33272. /**
  33273. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33274. */
  33275. static LogLevels: number;
  33276. /**
  33277. * Checks if the window object exists
  33278. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33279. */
  33280. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33281. /**
  33282. * No performance log
  33283. */
  33284. static readonly PerformanceNoneLogLevel: number;
  33285. /**
  33286. * Use user marks to log performance
  33287. */
  33288. static readonly PerformanceUserMarkLogLevel: number;
  33289. /**
  33290. * Log performance to the console
  33291. */
  33292. static readonly PerformanceConsoleLogLevel: number;
  33293. private static _performance;
  33294. /**
  33295. * Sets the current performance log level
  33296. */
  33297. static PerformanceLogLevel: number;
  33298. private static _StartPerformanceCounterDisabled;
  33299. private static _EndPerformanceCounterDisabled;
  33300. private static _StartUserMark;
  33301. private static _EndUserMark;
  33302. private static _StartPerformanceConsole;
  33303. private static _EndPerformanceConsole;
  33304. /**
  33305. * Starts a performance counter
  33306. */
  33307. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33308. /**
  33309. * Ends a specific performance coutner
  33310. */
  33311. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33312. /**
  33313. * Gets either window.performance.now() if supported or Date.now() else
  33314. */
  33315. static readonly Now: number;
  33316. /**
  33317. * This method will return the name of the class used to create the instance of the given object.
  33318. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33319. * @param object the object to get the class name from
  33320. * @param isType defines if the object is actually a type
  33321. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33322. */
  33323. static GetClassName(object: any, isType?: boolean): string;
  33324. /**
  33325. * Gets the first element of an array satisfying a given predicate
  33326. * @param array defines the array to browse
  33327. * @param predicate defines the predicate to use
  33328. * @returns null if not found or the element
  33329. */
  33330. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33331. /**
  33332. * This method will return the name of the full name of the class, including its owning module (if any).
  33333. * 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).
  33334. * @param object the object to get the class name from
  33335. * @param isType defines if the object is actually a type
  33336. * @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.
  33337. * @ignorenaming
  33338. */
  33339. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33340. /**
  33341. * Returns a promise that resolves after the given amount of time.
  33342. * @param delay Number of milliseconds to delay
  33343. * @returns Promise that resolves after the given amount of time
  33344. */
  33345. static DelayAsync(delay: number): Promise<void>;
  33346. }
  33347. /**
  33348. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33349. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33350. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33351. * @param name The name of the class, case should be preserved
  33352. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33353. */
  33354. export function className(name: string, module?: string): (target: Object) => void;
  33355. /**
  33356. * An implementation of a loop for asynchronous functions.
  33357. */
  33358. export class AsyncLoop {
  33359. /**
  33360. * Defines the number of iterations for the loop
  33361. */
  33362. iterations: number;
  33363. /**
  33364. * Defines the current index of the loop.
  33365. */
  33366. index: number;
  33367. private _done;
  33368. private _fn;
  33369. private _successCallback;
  33370. /**
  33371. * Constructor.
  33372. * @param iterations the number of iterations.
  33373. * @param func the function to run each iteration
  33374. * @param successCallback the callback that will be called upon succesful execution
  33375. * @param offset starting offset.
  33376. */
  33377. constructor(
  33378. /**
  33379. * Defines the number of iterations for the loop
  33380. */
  33381. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33382. /**
  33383. * Execute the next iteration. Must be called after the last iteration was finished.
  33384. */
  33385. executeNext(): void;
  33386. /**
  33387. * Break the loop and run the success callback.
  33388. */
  33389. breakLoop(): void;
  33390. /**
  33391. * Create and run an async loop.
  33392. * @param iterations the number of iterations.
  33393. * @param fn the function to run each iteration
  33394. * @param successCallback the callback that will be called upon succesful execution
  33395. * @param offset starting offset.
  33396. * @returns the created async loop object
  33397. */
  33398. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33399. /**
  33400. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33401. * @param iterations total number of iterations
  33402. * @param syncedIterations number of synchronous iterations in each async iteration.
  33403. * @param fn the function to call each iteration.
  33404. * @param callback a success call back that will be called when iterating stops.
  33405. * @param breakFunction a break condition (optional)
  33406. * @param timeout timeout settings for the setTimeout function. default - 0.
  33407. * @returns the created async loop object
  33408. */
  33409. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33410. }
  33411. }
  33412. declare module "babylonjs/Misc/stringDictionary" {
  33413. import { Nullable } from "babylonjs/types";
  33414. /**
  33415. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33416. * The underlying implementation relies on an associative array to ensure the best performances.
  33417. * The value can be anything including 'null' but except 'undefined'
  33418. */
  33419. export class StringDictionary<T> {
  33420. /**
  33421. * This will clear this dictionary and copy the content from the 'source' one.
  33422. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33423. * @param source the dictionary to take the content from and copy to this dictionary
  33424. */
  33425. copyFrom(source: StringDictionary<T>): void;
  33426. /**
  33427. * Get a value based from its key
  33428. * @param key the given key to get the matching value from
  33429. * @return the value if found, otherwise undefined is returned
  33430. */
  33431. get(key: string): T | undefined;
  33432. /**
  33433. * Get a value from its key or add it if it doesn't exist.
  33434. * This method will ensure you that a given key/data will be present in the dictionary.
  33435. * @param key the given key to get the matching value from
  33436. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33437. * The factory will only be invoked if there's no data for the given key.
  33438. * @return the value corresponding to the key.
  33439. */
  33440. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33441. /**
  33442. * Get a value from its key if present in the dictionary otherwise add it
  33443. * @param key the key to get the value from
  33444. * @param val if there's no such key/value pair in the dictionary add it with this value
  33445. * @return the value corresponding to the key
  33446. */
  33447. getOrAdd(key: string, val: T): T;
  33448. /**
  33449. * Check if there's a given key in the dictionary
  33450. * @param key the key to check for
  33451. * @return true if the key is present, false otherwise
  33452. */
  33453. contains(key: string): boolean;
  33454. /**
  33455. * Add a new key and its corresponding value
  33456. * @param key the key to add
  33457. * @param value the value corresponding to the key
  33458. * @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
  33459. */
  33460. add(key: string, value: T): boolean;
  33461. /**
  33462. * Update a specific value associated to a key
  33463. * @param key defines the key to use
  33464. * @param value defines the value to store
  33465. * @returns true if the value was updated (or false if the key was not found)
  33466. */
  33467. set(key: string, value: T): boolean;
  33468. /**
  33469. * Get the element of the given key and remove it from the dictionary
  33470. * @param key defines the key to search
  33471. * @returns the value associated with the key or null if not found
  33472. */
  33473. getAndRemove(key: string): Nullable<T>;
  33474. /**
  33475. * Remove a key/value from the dictionary.
  33476. * @param key the key to remove
  33477. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33478. */
  33479. remove(key: string): boolean;
  33480. /**
  33481. * Clear the whole content of the dictionary
  33482. */
  33483. clear(): void;
  33484. /**
  33485. * Gets the current count
  33486. */
  33487. readonly count: number;
  33488. /**
  33489. * Execute a callback on each key/val of the dictionary.
  33490. * Note that you can remove any element in this dictionary in the callback implementation
  33491. * @param callback the callback to execute on a given key/value pair
  33492. */
  33493. forEach(callback: (key: string, val: T) => void): void;
  33494. /**
  33495. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33496. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33497. * Note that you can remove any element in this dictionary in the callback implementation
  33498. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33499. * @returns the first item
  33500. */
  33501. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33502. private _count;
  33503. private _data;
  33504. }
  33505. }
  33506. declare module "babylonjs/Collisions/collisionCoordinator" {
  33507. import { Nullable } from "babylonjs/types";
  33508. import { Scene } from "babylonjs/scene";
  33509. import { Vector3 } from "babylonjs/Maths/math.vector";
  33510. import { Collider } from "babylonjs/Collisions/collider";
  33511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33512. /** @hidden */
  33513. export interface ICollisionCoordinator {
  33514. createCollider(): Collider;
  33515. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33516. init(scene: Scene): void;
  33517. }
  33518. /** @hidden */
  33519. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33520. private _scene;
  33521. private _scaledPosition;
  33522. private _scaledVelocity;
  33523. private _finalPosition;
  33524. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33525. createCollider(): Collider;
  33526. init(scene: Scene): void;
  33527. private _collideWithWorld;
  33528. }
  33529. }
  33530. declare module "babylonjs/Inputs/scene.inputManager" {
  33531. import { Nullable } from "babylonjs/types";
  33532. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33533. import { Vector2 } from "babylonjs/Maths/math.vector";
  33534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33535. import { Scene } from "babylonjs/scene";
  33536. /**
  33537. * Class used to manage all inputs for the scene.
  33538. */
  33539. export class InputManager {
  33540. /** The distance in pixel that you have to move to prevent some events */
  33541. static DragMovementThreshold: number;
  33542. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33543. static LongPressDelay: number;
  33544. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33545. static DoubleClickDelay: number;
  33546. /** If you need to check double click without raising a single click at first click, enable this flag */
  33547. static ExclusiveDoubleClickMode: boolean;
  33548. private _wheelEventName;
  33549. private _onPointerMove;
  33550. private _onPointerDown;
  33551. private _onPointerUp;
  33552. private _initClickEvent;
  33553. private _initActionManager;
  33554. private _delayedSimpleClick;
  33555. private _delayedSimpleClickTimeout;
  33556. private _previousDelayedSimpleClickTimeout;
  33557. private _meshPickProceed;
  33558. private _previousButtonPressed;
  33559. private _currentPickResult;
  33560. private _previousPickResult;
  33561. private _totalPointersPressed;
  33562. private _doubleClickOccured;
  33563. private _pointerOverMesh;
  33564. private _pickedDownMesh;
  33565. private _pickedUpMesh;
  33566. private _pointerX;
  33567. private _pointerY;
  33568. private _unTranslatedPointerX;
  33569. private _unTranslatedPointerY;
  33570. private _startingPointerPosition;
  33571. private _previousStartingPointerPosition;
  33572. private _startingPointerTime;
  33573. private _previousStartingPointerTime;
  33574. private _pointerCaptures;
  33575. private _onKeyDown;
  33576. private _onKeyUp;
  33577. private _onCanvasFocusObserver;
  33578. private _onCanvasBlurObserver;
  33579. private _scene;
  33580. /**
  33581. * Creates a new InputManager
  33582. * @param scene defines the hosting scene
  33583. */
  33584. constructor(scene: Scene);
  33585. /**
  33586. * Gets the mesh that is currently under the pointer
  33587. */
  33588. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33589. /**
  33590. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33591. */
  33592. readonly unTranslatedPointer: Vector2;
  33593. /**
  33594. * Gets or sets the current on-screen X position of the pointer
  33595. */
  33596. pointerX: number;
  33597. /**
  33598. * Gets or sets the current on-screen Y position of the pointer
  33599. */
  33600. pointerY: number;
  33601. private _updatePointerPosition;
  33602. private _processPointerMove;
  33603. private _setRayOnPointerInfo;
  33604. private _checkPrePointerObservable;
  33605. /**
  33606. * Use this method to simulate a pointer move on a mesh
  33607. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33608. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33609. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33610. */
  33611. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33612. /**
  33613. * Use this method to simulate a pointer down on a mesh
  33614. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33615. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33616. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33617. */
  33618. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33619. private _processPointerDown;
  33620. /** @hidden */
  33621. _isPointerSwiping(): boolean;
  33622. /**
  33623. * Use this method to simulate a pointer up on a mesh
  33624. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33625. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33626. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33627. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33628. */
  33629. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33630. private _processPointerUp;
  33631. /**
  33632. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33633. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33634. * @returns true if the pointer was captured
  33635. */
  33636. isPointerCaptured(pointerId?: number): boolean;
  33637. /**
  33638. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33639. * @param attachUp defines if you want to attach events to pointerup
  33640. * @param attachDown defines if you want to attach events to pointerdown
  33641. * @param attachMove defines if you want to attach events to pointermove
  33642. */
  33643. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33644. /**
  33645. * Detaches all event handlers
  33646. */
  33647. detachControl(): void;
  33648. /**
  33649. * Force the value of meshUnderPointer
  33650. * @param mesh defines the mesh to use
  33651. */
  33652. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33653. /**
  33654. * Gets the mesh under the pointer
  33655. * @returns a Mesh or null if no mesh is under the pointer
  33656. */
  33657. getPointerOverMesh(): Nullable<AbstractMesh>;
  33658. }
  33659. }
  33660. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33661. /**
  33662. * Helper class used to generate session unique ID
  33663. */
  33664. export class UniqueIdGenerator {
  33665. private static _UniqueIdCounter;
  33666. /**
  33667. * Gets an unique (relatively to the current scene) Id
  33668. */
  33669. static readonly UniqueId: number;
  33670. }
  33671. }
  33672. declare module "babylonjs/Animations/animationGroup" {
  33673. import { Animatable } from "babylonjs/Animations/animatable";
  33674. import { Animation } from "babylonjs/Animations/animation";
  33675. import { Scene, IDisposable } from "babylonjs/scene";
  33676. import { Observable } from "babylonjs/Misc/observable";
  33677. import { Nullable } from "babylonjs/types";
  33678. import "babylonjs/Animations/animatable";
  33679. /**
  33680. * This class defines the direct association between an animation and a target
  33681. */
  33682. export class TargetedAnimation {
  33683. /**
  33684. * Animation to perform
  33685. */
  33686. animation: Animation;
  33687. /**
  33688. * Target to animate
  33689. */
  33690. target: any;
  33691. /**
  33692. * Serialize the object
  33693. * @returns the JSON object representing the current entity
  33694. */
  33695. serialize(): any;
  33696. }
  33697. /**
  33698. * Use this class to create coordinated animations on multiple targets
  33699. */
  33700. export class AnimationGroup implements IDisposable {
  33701. /** The name of the animation group */
  33702. name: string;
  33703. private _scene;
  33704. private _targetedAnimations;
  33705. private _animatables;
  33706. private _from;
  33707. private _to;
  33708. private _isStarted;
  33709. private _isPaused;
  33710. private _speedRatio;
  33711. private _loopAnimation;
  33712. /**
  33713. * Gets or sets the unique id of the node
  33714. */
  33715. uniqueId: number;
  33716. /**
  33717. * This observable will notify when one animation have ended
  33718. */
  33719. onAnimationEndObservable: Observable<TargetedAnimation>;
  33720. /**
  33721. * Observer raised when one animation loops
  33722. */
  33723. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33724. /**
  33725. * This observable will notify when all animations have ended.
  33726. */
  33727. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33728. /**
  33729. * This observable will notify when all animations have paused.
  33730. */
  33731. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33732. /**
  33733. * This observable will notify when all animations are playing.
  33734. */
  33735. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33736. /**
  33737. * Gets the first frame
  33738. */
  33739. readonly from: number;
  33740. /**
  33741. * Gets the last frame
  33742. */
  33743. readonly to: number;
  33744. /**
  33745. * Define if the animations are started
  33746. */
  33747. readonly isStarted: boolean;
  33748. /**
  33749. * Gets a value indicating that the current group is playing
  33750. */
  33751. readonly isPlaying: boolean;
  33752. /**
  33753. * Gets or sets the speed ratio to use for all animations
  33754. */
  33755. /**
  33756. * Gets or sets the speed ratio to use for all animations
  33757. */
  33758. speedRatio: number;
  33759. /**
  33760. * Gets or sets if all animations should loop or not
  33761. */
  33762. loopAnimation: boolean;
  33763. /**
  33764. * Gets the targeted animations for this animation group
  33765. */
  33766. readonly targetedAnimations: Array<TargetedAnimation>;
  33767. /**
  33768. * returning the list of animatables controlled by this animation group.
  33769. */
  33770. readonly animatables: Array<Animatable>;
  33771. /**
  33772. * Instantiates a new Animation Group.
  33773. * This helps managing several animations at once.
  33774. * @see http://doc.babylonjs.com/how_to/group
  33775. * @param name Defines the name of the group
  33776. * @param scene Defines the scene the group belongs to
  33777. */
  33778. constructor(
  33779. /** The name of the animation group */
  33780. name: string, scene?: Nullable<Scene>);
  33781. /**
  33782. * Add an animation (with its target) in the group
  33783. * @param animation defines the animation we want to add
  33784. * @param target defines the target of the animation
  33785. * @returns the TargetedAnimation object
  33786. */
  33787. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33788. /**
  33789. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33790. * It can add constant keys at begin or end
  33791. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33792. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33793. * @returns the animation group
  33794. */
  33795. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33796. /**
  33797. * Start all animations on given targets
  33798. * @param loop defines if animations must loop
  33799. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33800. * @param from defines the from key (optional)
  33801. * @param to defines the to key (optional)
  33802. * @returns the current animation group
  33803. */
  33804. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33805. /**
  33806. * Pause all animations
  33807. * @returns the animation group
  33808. */
  33809. pause(): AnimationGroup;
  33810. /**
  33811. * Play all animations to initial state
  33812. * This function will start() the animations if they were not started or will restart() them if they were paused
  33813. * @param loop defines if animations must loop
  33814. * @returns the animation group
  33815. */
  33816. play(loop?: boolean): AnimationGroup;
  33817. /**
  33818. * Reset all animations to initial state
  33819. * @returns the animation group
  33820. */
  33821. reset(): AnimationGroup;
  33822. /**
  33823. * Restart animations from key 0
  33824. * @returns the animation group
  33825. */
  33826. restart(): AnimationGroup;
  33827. /**
  33828. * Stop all animations
  33829. * @returns the animation group
  33830. */
  33831. stop(): AnimationGroup;
  33832. /**
  33833. * Set animation weight for all animatables
  33834. * @param weight defines the weight to use
  33835. * @return the animationGroup
  33836. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33837. */
  33838. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33839. /**
  33840. * Synchronize and normalize all animatables with a source animatable
  33841. * @param root defines the root animatable to synchronize with
  33842. * @return the animationGroup
  33843. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33844. */
  33845. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33846. /**
  33847. * Goes to a specific frame in this animation group
  33848. * @param frame the frame number to go to
  33849. * @return the animationGroup
  33850. */
  33851. goToFrame(frame: number): AnimationGroup;
  33852. /**
  33853. * Dispose all associated resources
  33854. */
  33855. dispose(): void;
  33856. private _checkAnimationGroupEnded;
  33857. /**
  33858. * Clone the current animation group and returns a copy
  33859. * @param newName defines the name of the new group
  33860. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33861. * @returns the new aniamtion group
  33862. */
  33863. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33864. /**
  33865. * Serializes the animationGroup to an object
  33866. * @returns Serialized object
  33867. */
  33868. serialize(): any;
  33869. /**
  33870. * Returns a new AnimationGroup object parsed from the source provided.
  33871. * @param parsedAnimationGroup defines the source
  33872. * @param scene defines the scene that will receive the animationGroup
  33873. * @returns a new AnimationGroup
  33874. */
  33875. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33876. /**
  33877. * Returns the string "AnimationGroup"
  33878. * @returns "AnimationGroup"
  33879. */
  33880. getClassName(): string;
  33881. /**
  33882. * Creates a detailled string about the object
  33883. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33884. * @returns a string representing the object
  33885. */
  33886. toString(fullDetails?: boolean): string;
  33887. }
  33888. }
  33889. declare module "babylonjs/scene" {
  33890. import { Nullable } from "babylonjs/types";
  33891. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33892. import { Observable } from "babylonjs/Misc/observable";
  33893. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33894. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33895. import { Geometry } from "babylonjs/Meshes/geometry";
  33896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33897. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33899. import { Mesh } from "babylonjs/Meshes/mesh";
  33900. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33901. import { Bone } from "babylonjs/Bones/bone";
  33902. import { Skeleton } from "babylonjs/Bones/skeleton";
  33903. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33904. import { Camera } from "babylonjs/Cameras/camera";
  33905. import { AbstractScene } from "babylonjs/abstractScene";
  33906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33907. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33908. import { Material } from "babylonjs/Materials/material";
  33909. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33910. import { Effect } from "babylonjs/Materials/effect";
  33911. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33912. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33913. import { Light } from "babylonjs/Lights/light";
  33914. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33915. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33916. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33917. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33918. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33919. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33920. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33921. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33922. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33923. import { Engine } from "babylonjs/Engines/engine";
  33924. import { Node } from "babylonjs/node";
  33925. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33926. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33927. import { WebRequest } from "babylonjs/Misc/webRequest";
  33928. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33929. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33930. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33931. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33932. import { Plane } from "babylonjs/Maths/math.plane";
  33933. import { Ray } from "babylonjs/Culling/ray";
  33934. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33935. import { Animation } from "babylonjs/Animations/animation";
  33936. import { Animatable } from "babylonjs/Animations/animatable";
  33937. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33938. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33939. import { Collider } from "babylonjs/Collisions/collider";
  33940. /**
  33941. * Define an interface for all classes that will hold resources
  33942. */
  33943. export interface IDisposable {
  33944. /**
  33945. * Releases all held resources
  33946. */
  33947. dispose(): void;
  33948. }
  33949. /** Interface defining initialization parameters for Scene class */
  33950. export interface SceneOptions {
  33951. /**
  33952. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33953. * It will improve performance when the number of geometries becomes important.
  33954. */
  33955. useGeometryUniqueIdsMap?: boolean;
  33956. /**
  33957. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33958. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33959. */
  33960. useMaterialMeshMap?: boolean;
  33961. /**
  33962. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33963. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33964. */
  33965. useClonedMeshhMap?: boolean;
  33966. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33967. virtual?: boolean;
  33968. }
  33969. /**
  33970. * Represents a scene to be rendered by the engine.
  33971. * @see http://doc.babylonjs.com/features/scene
  33972. */
  33973. export class Scene extends AbstractScene implements IAnimatable {
  33974. /** The fog is deactivated */
  33975. static readonly FOGMODE_NONE: number;
  33976. /** The fog density is following an exponential function */
  33977. static readonly FOGMODE_EXP: number;
  33978. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33979. static readonly FOGMODE_EXP2: number;
  33980. /** The fog density is following a linear function. */
  33981. static readonly FOGMODE_LINEAR: number;
  33982. /**
  33983. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33984. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33985. */
  33986. static MinDeltaTime: number;
  33987. /**
  33988. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33989. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33990. */
  33991. static MaxDeltaTime: number;
  33992. /**
  33993. * Factory used to create the default material.
  33994. * @param name The name of the material to create
  33995. * @param scene The scene to create the material for
  33996. * @returns The default material
  33997. */
  33998. static DefaultMaterialFactory(scene: Scene): Material;
  33999. /**
  34000. * Factory used to create the a collision coordinator.
  34001. * @returns The collision coordinator
  34002. */
  34003. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34004. /** @hidden */
  34005. _inputManager: InputManager;
  34006. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34007. cameraToUseForPointers: Nullable<Camera>;
  34008. /** @hidden */
  34009. readonly _isScene: boolean;
  34010. /**
  34011. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34012. */
  34013. autoClear: boolean;
  34014. /**
  34015. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34016. */
  34017. autoClearDepthAndStencil: boolean;
  34018. /**
  34019. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34020. */
  34021. clearColor: Color4;
  34022. /**
  34023. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34024. */
  34025. ambientColor: Color3;
  34026. /**
  34027. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34028. * It should only be one of the following (if not the default embedded one):
  34029. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34030. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34031. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34032. * The material properties need to be setup according to the type of texture in use.
  34033. */
  34034. environmentBRDFTexture: BaseTexture;
  34035. /** @hidden */
  34036. protected _environmentTexture: Nullable<BaseTexture>;
  34037. /**
  34038. * Texture used in all pbr material as the reflection texture.
  34039. * As in the majority of the scene they are the same (exception for multi room and so on),
  34040. * this is easier to reference from here than from all the materials.
  34041. */
  34042. /**
  34043. * Texture used in all pbr material as the reflection texture.
  34044. * As in the majority of the scene they are the same (exception for multi room and so on),
  34045. * this is easier to set here than in all the materials.
  34046. */
  34047. environmentTexture: Nullable<BaseTexture>;
  34048. /** @hidden */
  34049. protected _environmentIntensity: number;
  34050. /**
  34051. * Intensity of the environment in all pbr material.
  34052. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34053. * As in the majority of the scene they are the same (exception for multi room and so on),
  34054. * this is easier to reference from here than from all the materials.
  34055. */
  34056. /**
  34057. * Intensity of the environment in all pbr material.
  34058. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34059. * As in the majority of the scene they are the same (exception for multi room and so on),
  34060. * this is easier to set here than in all the materials.
  34061. */
  34062. environmentIntensity: number;
  34063. /** @hidden */
  34064. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34065. /**
  34066. * Default image processing configuration used either in the rendering
  34067. * Forward main pass or through the imageProcessingPostProcess if present.
  34068. * As in the majority of the scene they are the same (exception for multi camera),
  34069. * this is easier to reference from here than from all the materials and post process.
  34070. *
  34071. * No setter as we it is a shared configuration, you can set the values instead.
  34072. */
  34073. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34074. private _forceWireframe;
  34075. /**
  34076. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34077. */
  34078. forceWireframe: boolean;
  34079. private _forcePointsCloud;
  34080. /**
  34081. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34082. */
  34083. forcePointsCloud: boolean;
  34084. /**
  34085. * Gets or sets the active clipplane 1
  34086. */
  34087. clipPlane: Nullable<Plane>;
  34088. /**
  34089. * Gets or sets the active clipplane 2
  34090. */
  34091. clipPlane2: Nullable<Plane>;
  34092. /**
  34093. * Gets or sets the active clipplane 3
  34094. */
  34095. clipPlane3: Nullable<Plane>;
  34096. /**
  34097. * Gets or sets the active clipplane 4
  34098. */
  34099. clipPlane4: Nullable<Plane>;
  34100. /**
  34101. * Gets or sets a boolean indicating if animations are enabled
  34102. */
  34103. animationsEnabled: boolean;
  34104. private _animationPropertiesOverride;
  34105. /**
  34106. * Gets or sets the animation properties override
  34107. */
  34108. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34109. /**
  34110. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34111. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34112. */
  34113. useConstantAnimationDeltaTime: boolean;
  34114. /**
  34115. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34116. * Please note that it requires to run a ray cast through the scene on every frame
  34117. */
  34118. constantlyUpdateMeshUnderPointer: boolean;
  34119. /**
  34120. * Defines the HTML cursor to use when hovering over interactive elements
  34121. */
  34122. hoverCursor: string;
  34123. /**
  34124. * Defines the HTML default cursor to use (empty by default)
  34125. */
  34126. defaultCursor: string;
  34127. /**
  34128. * This is used to call preventDefault() on pointer down
  34129. * in order to block unwanted artifacts like system double clicks
  34130. */
  34131. preventDefaultOnPointerDown: boolean;
  34132. /**
  34133. * This is used to call preventDefault() on pointer up
  34134. * in order to block unwanted artifacts like system double clicks
  34135. */
  34136. preventDefaultOnPointerUp: boolean;
  34137. /**
  34138. * Gets or sets user defined metadata
  34139. */
  34140. metadata: any;
  34141. /**
  34142. * For internal use only. Please do not use.
  34143. */
  34144. reservedDataStore: any;
  34145. /**
  34146. * Gets the name of the plugin used to load this scene (null by default)
  34147. */
  34148. loadingPluginName: string;
  34149. /**
  34150. * Use this array to add regular expressions used to disable offline support for specific urls
  34151. */
  34152. disableOfflineSupportExceptionRules: RegExp[];
  34153. /**
  34154. * An event triggered when the scene is disposed.
  34155. */
  34156. onDisposeObservable: Observable<Scene>;
  34157. private _onDisposeObserver;
  34158. /** Sets a function to be executed when this scene is disposed. */
  34159. onDispose: () => void;
  34160. /**
  34161. * An event triggered before rendering the scene (right after animations and physics)
  34162. */
  34163. onBeforeRenderObservable: Observable<Scene>;
  34164. private _onBeforeRenderObserver;
  34165. /** Sets a function to be executed before rendering this scene */
  34166. beforeRender: Nullable<() => void>;
  34167. /**
  34168. * An event triggered after rendering the scene
  34169. */
  34170. onAfterRenderObservable: Observable<Scene>;
  34171. /**
  34172. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34173. */
  34174. onAfterRenderCameraObservable: Observable<Camera>;
  34175. private _onAfterRenderObserver;
  34176. /** Sets a function to be executed after rendering this scene */
  34177. afterRender: Nullable<() => void>;
  34178. /**
  34179. * An event triggered before animating the scene
  34180. */
  34181. onBeforeAnimationsObservable: Observable<Scene>;
  34182. /**
  34183. * An event triggered after animations processing
  34184. */
  34185. onAfterAnimationsObservable: Observable<Scene>;
  34186. /**
  34187. * An event triggered before draw calls are ready to be sent
  34188. */
  34189. onBeforeDrawPhaseObservable: Observable<Scene>;
  34190. /**
  34191. * An event triggered after draw calls have been sent
  34192. */
  34193. onAfterDrawPhaseObservable: Observable<Scene>;
  34194. /**
  34195. * An event triggered when the scene is ready
  34196. */
  34197. onReadyObservable: Observable<Scene>;
  34198. /**
  34199. * An event triggered before rendering a camera
  34200. */
  34201. onBeforeCameraRenderObservable: Observable<Camera>;
  34202. private _onBeforeCameraRenderObserver;
  34203. /** Sets a function to be executed before rendering a camera*/
  34204. beforeCameraRender: () => void;
  34205. /**
  34206. * An event triggered after rendering a camera
  34207. */
  34208. onAfterCameraRenderObservable: Observable<Camera>;
  34209. private _onAfterCameraRenderObserver;
  34210. /** Sets a function to be executed after rendering a camera*/
  34211. afterCameraRender: () => void;
  34212. /**
  34213. * An event triggered when active meshes evaluation is about to start
  34214. */
  34215. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34216. /**
  34217. * An event triggered when active meshes evaluation is done
  34218. */
  34219. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34220. /**
  34221. * An event triggered when particles rendering is about to start
  34222. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34223. */
  34224. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34225. /**
  34226. * An event triggered when particles rendering is done
  34227. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34228. */
  34229. onAfterParticlesRenderingObservable: Observable<Scene>;
  34230. /**
  34231. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34232. */
  34233. onDataLoadedObservable: Observable<Scene>;
  34234. /**
  34235. * An event triggered when a camera is created
  34236. */
  34237. onNewCameraAddedObservable: Observable<Camera>;
  34238. /**
  34239. * An event triggered when a camera is removed
  34240. */
  34241. onCameraRemovedObservable: Observable<Camera>;
  34242. /**
  34243. * An event triggered when a light is created
  34244. */
  34245. onNewLightAddedObservable: Observable<Light>;
  34246. /**
  34247. * An event triggered when a light is removed
  34248. */
  34249. onLightRemovedObservable: Observable<Light>;
  34250. /**
  34251. * An event triggered when a geometry is created
  34252. */
  34253. onNewGeometryAddedObservable: Observable<Geometry>;
  34254. /**
  34255. * An event triggered when a geometry is removed
  34256. */
  34257. onGeometryRemovedObservable: Observable<Geometry>;
  34258. /**
  34259. * An event triggered when a transform node is created
  34260. */
  34261. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34262. /**
  34263. * An event triggered when a transform node is removed
  34264. */
  34265. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34266. /**
  34267. * An event triggered when a mesh is created
  34268. */
  34269. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34270. /**
  34271. * An event triggered when a mesh is removed
  34272. */
  34273. onMeshRemovedObservable: Observable<AbstractMesh>;
  34274. /**
  34275. * An event triggered when a skeleton is created
  34276. */
  34277. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34278. /**
  34279. * An event triggered when a skeleton is removed
  34280. */
  34281. onSkeletonRemovedObservable: Observable<Skeleton>;
  34282. /**
  34283. * An event triggered when a material is created
  34284. */
  34285. onNewMaterialAddedObservable: Observable<Material>;
  34286. /**
  34287. * An event triggered when a material is removed
  34288. */
  34289. onMaterialRemovedObservable: Observable<Material>;
  34290. /**
  34291. * An event triggered when a texture is created
  34292. */
  34293. onNewTextureAddedObservable: Observable<BaseTexture>;
  34294. /**
  34295. * An event triggered when a texture is removed
  34296. */
  34297. onTextureRemovedObservable: Observable<BaseTexture>;
  34298. /**
  34299. * An event triggered when render targets are about to be rendered
  34300. * Can happen multiple times per frame.
  34301. */
  34302. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34303. /**
  34304. * An event triggered when render targets were rendered.
  34305. * Can happen multiple times per frame.
  34306. */
  34307. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34308. /**
  34309. * An event triggered before calculating deterministic simulation step
  34310. */
  34311. onBeforeStepObservable: Observable<Scene>;
  34312. /**
  34313. * An event triggered after calculating deterministic simulation step
  34314. */
  34315. onAfterStepObservable: Observable<Scene>;
  34316. /**
  34317. * An event triggered when the activeCamera property is updated
  34318. */
  34319. onActiveCameraChanged: Observable<Scene>;
  34320. /**
  34321. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34322. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34323. * 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)
  34324. */
  34325. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34326. /**
  34327. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34328. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34329. * 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)
  34330. */
  34331. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34332. /**
  34333. * This Observable will when a mesh has been imported into the scene.
  34334. */
  34335. onMeshImportedObservable: Observable<AbstractMesh>;
  34336. /**
  34337. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34338. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34339. */
  34340. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34341. /** @hidden */
  34342. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34343. /**
  34344. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34345. */
  34346. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34347. /**
  34348. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34349. */
  34350. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34351. /**
  34352. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34353. */
  34354. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34355. /** Callback called when a pointer move is detected */
  34356. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34357. /** Callback called when a pointer down is detected */
  34358. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34359. /** Callback called when a pointer up is detected */
  34360. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34361. /** Callback called when a pointer pick is detected */
  34362. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34363. /**
  34364. * 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).
  34365. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34366. */
  34367. onPrePointerObservable: Observable<PointerInfoPre>;
  34368. /**
  34369. * Observable event triggered each time an input event is received from the rendering canvas
  34370. */
  34371. onPointerObservable: Observable<PointerInfo>;
  34372. /**
  34373. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34374. */
  34375. readonly unTranslatedPointer: Vector2;
  34376. /**
  34377. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34378. */
  34379. static DragMovementThreshold: number;
  34380. /**
  34381. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34382. */
  34383. static LongPressDelay: number;
  34384. /**
  34385. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34386. */
  34387. static DoubleClickDelay: number;
  34388. /** If you need to check double click without raising a single click at first click, enable this flag */
  34389. static ExclusiveDoubleClickMode: boolean;
  34390. /** @hidden */
  34391. _mirroredCameraPosition: Nullable<Vector3>;
  34392. /**
  34393. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34394. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34395. */
  34396. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34397. /**
  34398. * Observable event triggered each time an keyboard event is received from the hosting window
  34399. */
  34400. onKeyboardObservable: Observable<KeyboardInfo>;
  34401. private _useRightHandedSystem;
  34402. /**
  34403. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34404. */
  34405. useRightHandedSystem: boolean;
  34406. private _timeAccumulator;
  34407. private _currentStepId;
  34408. private _currentInternalStep;
  34409. /**
  34410. * Sets the step Id used by deterministic lock step
  34411. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34412. * @param newStepId defines the step Id
  34413. */
  34414. setStepId(newStepId: number): void;
  34415. /**
  34416. * Gets the step Id used by deterministic lock step
  34417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34418. * @returns the step Id
  34419. */
  34420. getStepId(): number;
  34421. /**
  34422. * Gets the internal step used by deterministic lock step
  34423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34424. * @returns the internal step
  34425. */
  34426. getInternalStep(): number;
  34427. private _fogEnabled;
  34428. /**
  34429. * Gets or sets a boolean indicating if fog is enabled on this scene
  34430. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34431. * (Default is true)
  34432. */
  34433. fogEnabled: boolean;
  34434. private _fogMode;
  34435. /**
  34436. * Gets or sets the fog mode to use
  34437. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34438. * | mode | value |
  34439. * | --- | --- |
  34440. * | FOGMODE_NONE | 0 |
  34441. * | FOGMODE_EXP | 1 |
  34442. * | FOGMODE_EXP2 | 2 |
  34443. * | FOGMODE_LINEAR | 3 |
  34444. */
  34445. fogMode: number;
  34446. /**
  34447. * Gets or sets the fog color to use
  34448. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34449. * (Default is Color3(0.2, 0.2, 0.3))
  34450. */
  34451. fogColor: Color3;
  34452. /**
  34453. * Gets or sets the fog density to use
  34454. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34455. * (Default is 0.1)
  34456. */
  34457. fogDensity: number;
  34458. /**
  34459. * Gets or sets the fog start distance to use
  34460. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34461. * (Default is 0)
  34462. */
  34463. fogStart: number;
  34464. /**
  34465. * Gets or sets the fog end distance to use
  34466. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34467. * (Default is 1000)
  34468. */
  34469. fogEnd: number;
  34470. private _shadowsEnabled;
  34471. /**
  34472. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34473. */
  34474. shadowsEnabled: boolean;
  34475. private _lightsEnabled;
  34476. /**
  34477. * Gets or sets a boolean indicating if lights are enabled on this scene
  34478. */
  34479. lightsEnabled: boolean;
  34480. /** All of the active cameras added to this scene. */
  34481. activeCameras: Camera[];
  34482. /** @hidden */
  34483. _activeCamera: Nullable<Camera>;
  34484. /** Gets or sets the current active camera */
  34485. activeCamera: Nullable<Camera>;
  34486. private _defaultMaterial;
  34487. /** The default material used on meshes when no material is affected */
  34488. /** The default material used on meshes when no material is affected */
  34489. defaultMaterial: Material;
  34490. private _texturesEnabled;
  34491. /**
  34492. * Gets or sets a boolean indicating if textures are enabled on this scene
  34493. */
  34494. texturesEnabled: boolean;
  34495. /**
  34496. * Gets or sets a boolean indicating if particles are enabled on this scene
  34497. */
  34498. particlesEnabled: boolean;
  34499. /**
  34500. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34501. */
  34502. spritesEnabled: boolean;
  34503. private _skeletonsEnabled;
  34504. /**
  34505. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34506. */
  34507. skeletonsEnabled: boolean;
  34508. /**
  34509. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34510. */
  34511. lensFlaresEnabled: boolean;
  34512. /**
  34513. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34514. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34515. */
  34516. collisionsEnabled: boolean;
  34517. private _collisionCoordinator;
  34518. /** @hidden */
  34519. readonly collisionCoordinator: ICollisionCoordinator;
  34520. /**
  34521. * Defines the gravity applied to this scene (used only for collisions)
  34522. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34523. */
  34524. gravity: Vector3;
  34525. /**
  34526. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34527. */
  34528. postProcessesEnabled: boolean;
  34529. /**
  34530. * The list of postprocesses added to the scene
  34531. */
  34532. postProcesses: PostProcess[];
  34533. /**
  34534. * Gets the current postprocess manager
  34535. */
  34536. postProcessManager: PostProcessManager;
  34537. /**
  34538. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34539. */
  34540. renderTargetsEnabled: boolean;
  34541. /**
  34542. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34543. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34544. */
  34545. dumpNextRenderTargets: boolean;
  34546. /**
  34547. * The list of user defined render targets added to the scene
  34548. */
  34549. customRenderTargets: RenderTargetTexture[];
  34550. /**
  34551. * Defines if texture loading must be delayed
  34552. * If true, textures will only be loaded when they need to be rendered
  34553. */
  34554. useDelayedTextureLoading: boolean;
  34555. /**
  34556. * Gets the list of meshes imported to the scene through SceneLoader
  34557. */
  34558. importedMeshesFiles: String[];
  34559. /**
  34560. * Gets or sets a boolean indicating if probes are enabled on this scene
  34561. */
  34562. probesEnabled: boolean;
  34563. /**
  34564. * Gets or sets the current offline provider to use to store scene data
  34565. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34566. */
  34567. offlineProvider: IOfflineProvider;
  34568. /**
  34569. * Gets or sets the action manager associated with the scene
  34570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34571. */
  34572. actionManager: AbstractActionManager;
  34573. private _meshesForIntersections;
  34574. /**
  34575. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34576. */
  34577. proceduralTexturesEnabled: boolean;
  34578. private _engine;
  34579. private _totalVertices;
  34580. /** @hidden */
  34581. _activeIndices: PerfCounter;
  34582. /** @hidden */
  34583. _activeParticles: PerfCounter;
  34584. /** @hidden */
  34585. _activeBones: PerfCounter;
  34586. private _animationRatio;
  34587. /** @hidden */
  34588. _animationTimeLast: number;
  34589. /** @hidden */
  34590. _animationTime: number;
  34591. /**
  34592. * Gets or sets a general scale for animation speed
  34593. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34594. */
  34595. animationTimeScale: number;
  34596. /** @hidden */
  34597. _cachedMaterial: Nullable<Material>;
  34598. /** @hidden */
  34599. _cachedEffect: Nullable<Effect>;
  34600. /** @hidden */
  34601. _cachedVisibility: Nullable<number>;
  34602. private _renderId;
  34603. private _frameId;
  34604. private _executeWhenReadyTimeoutId;
  34605. private _intermediateRendering;
  34606. private _viewUpdateFlag;
  34607. private _projectionUpdateFlag;
  34608. /** @hidden */
  34609. _toBeDisposed: Nullable<IDisposable>[];
  34610. private _activeRequests;
  34611. /** @hidden */
  34612. _pendingData: any[];
  34613. private _isDisposed;
  34614. /**
  34615. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34616. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34617. */
  34618. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34619. private _activeMeshes;
  34620. private _processedMaterials;
  34621. private _renderTargets;
  34622. /** @hidden */
  34623. _activeParticleSystems: SmartArray<IParticleSystem>;
  34624. private _activeSkeletons;
  34625. private _softwareSkinnedMeshes;
  34626. private _renderingManager;
  34627. /** @hidden */
  34628. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34629. private _transformMatrix;
  34630. private _sceneUbo;
  34631. /** @hidden */
  34632. _viewMatrix: Matrix;
  34633. private _projectionMatrix;
  34634. /** @hidden */
  34635. _forcedViewPosition: Nullable<Vector3>;
  34636. /** @hidden */
  34637. _frustumPlanes: Plane[];
  34638. /**
  34639. * Gets the list of frustum planes (built from the active camera)
  34640. */
  34641. readonly frustumPlanes: Plane[];
  34642. /**
  34643. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34644. * This is useful if there are more lights that the maximum simulteanous authorized
  34645. */
  34646. requireLightSorting: boolean;
  34647. /** @hidden */
  34648. readonly useMaterialMeshMap: boolean;
  34649. /** @hidden */
  34650. readonly useClonedMeshhMap: boolean;
  34651. private _externalData;
  34652. private _uid;
  34653. /**
  34654. * @hidden
  34655. * Backing store of defined scene components.
  34656. */
  34657. _components: ISceneComponent[];
  34658. /**
  34659. * @hidden
  34660. * Backing store of defined scene components.
  34661. */
  34662. _serializableComponents: ISceneSerializableComponent[];
  34663. /**
  34664. * List of components to register on the next registration step.
  34665. */
  34666. private _transientComponents;
  34667. /**
  34668. * Registers the transient components if needed.
  34669. */
  34670. private _registerTransientComponents;
  34671. /**
  34672. * @hidden
  34673. * Add a component to the scene.
  34674. * Note that the ccomponent could be registered on th next frame if this is called after
  34675. * the register component stage.
  34676. * @param component Defines the component to add to the scene
  34677. */
  34678. _addComponent(component: ISceneComponent): void;
  34679. /**
  34680. * @hidden
  34681. * Gets a component from the scene.
  34682. * @param name defines the name of the component to retrieve
  34683. * @returns the component or null if not present
  34684. */
  34685. _getComponent(name: string): Nullable<ISceneComponent>;
  34686. /**
  34687. * @hidden
  34688. * Defines the actions happening before camera updates.
  34689. */
  34690. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34691. /**
  34692. * @hidden
  34693. * Defines the actions happening before clear the canvas.
  34694. */
  34695. _beforeClearStage: Stage<SimpleStageAction>;
  34696. /**
  34697. * @hidden
  34698. * Defines the actions when collecting render targets for the frame.
  34699. */
  34700. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34701. /**
  34702. * @hidden
  34703. * Defines the actions happening for one camera in the frame.
  34704. */
  34705. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34706. /**
  34707. * @hidden
  34708. * Defines the actions happening during the per mesh ready checks.
  34709. */
  34710. _isReadyForMeshStage: Stage<MeshStageAction>;
  34711. /**
  34712. * @hidden
  34713. * Defines the actions happening before evaluate active mesh checks.
  34714. */
  34715. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34716. /**
  34717. * @hidden
  34718. * Defines the actions happening during the evaluate sub mesh checks.
  34719. */
  34720. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34721. /**
  34722. * @hidden
  34723. * Defines the actions happening during the active mesh stage.
  34724. */
  34725. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34726. /**
  34727. * @hidden
  34728. * Defines the actions happening during the per camera render target step.
  34729. */
  34730. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34731. /**
  34732. * @hidden
  34733. * Defines the actions happening just before the active camera is drawing.
  34734. */
  34735. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34736. /**
  34737. * @hidden
  34738. * Defines the actions happening just before a render target is drawing.
  34739. */
  34740. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34741. /**
  34742. * @hidden
  34743. * Defines the actions happening just before a rendering group is drawing.
  34744. */
  34745. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34746. /**
  34747. * @hidden
  34748. * Defines the actions happening just before a mesh is drawing.
  34749. */
  34750. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34751. /**
  34752. * @hidden
  34753. * Defines the actions happening just after a mesh has been drawn.
  34754. */
  34755. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34756. /**
  34757. * @hidden
  34758. * Defines the actions happening just after a rendering group has been drawn.
  34759. */
  34760. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34761. /**
  34762. * @hidden
  34763. * Defines the actions happening just after the active camera has been drawn.
  34764. */
  34765. _afterCameraDrawStage: Stage<CameraStageAction>;
  34766. /**
  34767. * @hidden
  34768. * Defines the actions happening just after a render target has been drawn.
  34769. */
  34770. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34771. /**
  34772. * @hidden
  34773. * Defines the actions happening just after rendering all cameras and computing intersections.
  34774. */
  34775. _afterRenderStage: Stage<SimpleStageAction>;
  34776. /**
  34777. * @hidden
  34778. * Defines the actions happening when a pointer move event happens.
  34779. */
  34780. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34781. /**
  34782. * @hidden
  34783. * Defines the actions happening when a pointer down event happens.
  34784. */
  34785. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34786. /**
  34787. * @hidden
  34788. * Defines the actions happening when a pointer up event happens.
  34789. */
  34790. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34791. /**
  34792. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34793. */
  34794. private geometriesByUniqueId;
  34795. /**
  34796. * Creates a new Scene
  34797. * @param engine defines the engine to use to render this scene
  34798. * @param options defines the scene options
  34799. */
  34800. constructor(engine: Engine, options?: SceneOptions);
  34801. /**
  34802. * Gets a string idenfifying the name of the class
  34803. * @returns "Scene" string
  34804. */
  34805. getClassName(): string;
  34806. private _defaultMeshCandidates;
  34807. /**
  34808. * @hidden
  34809. */
  34810. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34811. private _defaultSubMeshCandidates;
  34812. /**
  34813. * @hidden
  34814. */
  34815. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34816. /**
  34817. * Sets the default candidate providers for the scene.
  34818. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34819. * and getCollidingSubMeshCandidates to their default function
  34820. */
  34821. setDefaultCandidateProviders(): void;
  34822. /**
  34823. * Gets the mesh that is currently under the pointer
  34824. */
  34825. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34826. /**
  34827. * Gets or sets the current on-screen X position of the pointer
  34828. */
  34829. pointerX: number;
  34830. /**
  34831. * Gets or sets the current on-screen Y position of the pointer
  34832. */
  34833. pointerY: number;
  34834. /**
  34835. * Gets the cached material (ie. the latest rendered one)
  34836. * @returns the cached material
  34837. */
  34838. getCachedMaterial(): Nullable<Material>;
  34839. /**
  34840. * Gets the cached effect (ie. the latest rendered one)
  34841. * @returns the cached effect
  34842. */
  34843. getCachedEffect(): Nullable<Effect>;
  34844. /**
  34845. * Gets the cached visibility state (ie. the latest rendered one)
  34846. * @returns the cached visibility state
  34847. */
  34848. getCachedVisibility(): Nullable<number>;
  34849. /**
  34850. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34851. * @param material defines the current material
  34852. * @param effect defines the current effect
  34853. * @param visibility defines the current visibility state
  34854. * @returns true if one parameter is not cached
  34855. */
  34856. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34857. /**
  34858. * Gets the engine associated with the scene
  34859. * @returns an Engine
  34860. */
  34861. getEngine(): Engine;
  34862. /**
  34863. * Gets the total number of vertices rendered per frame
  34864. * @returns the total number of vertices rendered per frame
  34865. */
  34866. getTotalVertices(): number;
  34867. /**
  34868. * Gets the performance counter for total vertices
  34869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34870. */
  34871. readonly totalVerticesPerfCounter: PerfCounter;
  34872. /**
  34873. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34874. * @returns the total number of active indices rendered per frame
  34875. */
  34876. getActiveIndices(): number;
  34877. /**
  34878. * Gets the performance counter for active indices
  34879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34880. */
  34881. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34882. /**
  34883. * Gets the total number of active particles rendered per frame
  34884. * @returns the total number of active particles rendered per frame
  34885. */
  34886. getActiveParticles(): number;
  34887. /**
  34888. * Gets the performance counter for active particles
  34889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34890. */
  34891. readonly activeParticlesPerfCounter: PerfCounter;
  34892. /**
  34893. * Gets the total number of active bones rendered per frame
  34894. * @returns the total number of active bones rendered per frame
  34895. */
  34896. getActiveBones(): number;
  34897. /**
  34898. * Gets the performance counter for active bones
  34899. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34900. */
  34901. readonly activeBonesPerfCounter: PerfCounter;
  34902. /**
  34903. * Gets the array of active meshes
  34904. * @returns an array of AbstractMesh
  34905. */
  34906. getActiveMeshes(): SmartArray<AbstractMesh>;
  34907. /**
  34908. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34909. * @returns a number
  34910. */
  34911. getAnimationRatio(): number;
  34912. /**
  34913. * Gets an unique Id for the current render phase
  34914. * @returns a number
  34915. */
  34916. getRenderId(): number;
  34917. /**
  34918. * Gets an unique Id for the current frame
  34919. * @returns a number
  34920. */
  34921. getFrameId(): number;
  34922. /** Call this function if you want to manually increment the render Id*/
  34923. incrementRenderId(): void;
  34924. private _createUbo;
  34925. /**
  34926. * Use this method to simulate a pointer move on a mesh
  34927. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34928. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34929. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34930. * @returns the current scene
  34931. */
  34932. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34933. /**
  34934. * Use this method to simulate a pointer down on a mesh
  34935. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34936. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34937. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34938. * @returns the current scene
  34939. */
  34940. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34941. /**
  34942. * Use this method to simulate a pointer up on a mesh
  34943. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34944. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34945. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34946. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34947. * @returns the current scene
  34948. */
  34949. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34950. /**
  34951. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34952. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34953. * @returns true if the pointer was captured
  34954. */
  34955. isPointerCaptured(pointerId?: number): boolean;
  34956. /**
  34957. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34958. * @param attachUp defines if you want to attach events to pointerup
  34959. * @param attachDown defines if you want to attach events to pointerdown
  34960. * @param attachMove defines if you want to attach events to pointermove
  34961. */
  34962. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34963. /** Detaches all event handlers*/
  34964. detachControl(): void;
  34965. /**
  34966. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34967. * Delay loaded resources are not taking in account
  34968. * @return true if all required resources are ready
  34969. */
  34970. isReady(): boolean;
  34971. /** Resets all cached information relative to material (including effect and visibility) */
  34972. resetCachedMaterial(): void;
  34973. /**
  34974. * Registers a function to be called before every frame render
  34975. * @param func defines the function to register
  34976. */
  34977. registerBeforeRender(func: () => void): void;
  34978. /**
  34979. * Unregisters a function called before every frame render
  34980. * @param func defines the function to unregister
  34981. */
  34982. unregisterBeforeRender(func: () => void): void;
  34983. /**
  34984. * Registers a function to be called after every frame render
  34985. * @param func defines the function to register
  34986. */
  34987. registerAfterRender(func: () => void): void;
  34988. /**
  34989. * Unregisters a function called after every frame render
  34990. * @param func defines the function to unregister
  34991. */
  34992. unregisterAfterRender(func: () => void): void;
  34993. private _executeOnceBeforeRender;
  34994. /**
  34995. * The provided function will run before render once and will be disposed afterwards.
  34996. * A timeout delay can be provided so that the function will be executed in N ms.
  34997. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34998. * @param func The function to be executed.
  34999. * @param timeout optional delay in ms
  35000. */
  35001. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35002. /** @hidden */
  35003. _addPendingData(data: any): void;
  35004. /** @hidden */
  35005. _removePendingData(data: any): void;
  35006. /**
  35007. * Returns the number of items waiting to be loaded
  35008. * @returns the number of items waiting to be loaded
  35009. */
  35010. getWaitingItemsCount(): number;
  35011. /**
  35012. * Returns a boolean indicating if the scene is still loading data
  35013. */
  35014. readonly isLoading: boolean;
  35015. /**
  35016. * Registers a function to be executed when the scene is ready
  35017. * @param {Function} func - the function to be executed
  35018. */
  35019. executeWhenReady(func: () => void): void;
  35020. /**
  35021. * Returns a promise that resolves when the scene is ready
  35022. * @returns A promise that resolves when the scene is ready
  35023. */
  35024. whenReadyAsync(): Promise<void>;
  35025. /** @hidden */
  35026. _checkIsReady(): void;
  35027. /**
  35028. * Gets all animatable attached to the scene
  35029. */
  35030. readonly animatables: Animatable[];
  35031. /**
  35032. * Resets the last animation time frame.
  35033. * Useful to override when animations start running when loading a scene for the first time.
  35034. */
  35035. resetLastAnimationTimeFrame(): void;
  35036. /**
  35037. * Gets the current view matrix
  35038. * @returns a Matrix
  35039. */
  35040. getViewMatrix(): Matrix;
  35041. /**
  35042. * Gets the current projection matrix
  35043. * @returns a Matrix
  35044. */
  35045. getProjectionMatrix(): Matrix;
  35046. /**
  35047. * Gets the current transform matrix
  35048. * @returns a Matrix made of View * Projection
  35049. */
  35050. getTransformMatrix(): Matrix;
  35051. /**
  35052. * Sets the current transform matrix
  35053. * @param viewL defines the View matrix to use
  35054. * @param projectionL defines the Projection matrix to use
  35055. * @param viewR defines the right View matrix to use (if provided)
  35056. * @param projectionR defines the right Projection matrix to use (if provided)
  35057. */
  35058. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35059. /**
  35060. * Gets the uniform buffer used to store scene data
  35061. * @returns a UniformBuffer
  35062. */
  35063. getSceneUniformBuffer(): UniformBuffer;
  35064. /**
  35065. * Gets an unique (relatively to the current scene) Id
  35066. * @returns an unique number for the scene
  35067. */
  35068. getUniqueId(): number;
  35069. /**
  35070. * Add a mesh to the list of scene's meshes
  35071. * @param newMesh defines the mesh to add
  35072. * @param recursive if all child meshes should also be added to the scene
  35073. */
  35074. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35075. /**
  35076. * Remove a mesh for the list of scene's meshes
  35077. * @param toRemove defines the mesh to remove
  35078. * @param recursive if all child meshes should also be removed from the scene
  35079. * @returns the index where the mesh was in the mesh list
  35080. */
  35081. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35082. /**
  35083. * Add a transform node to the list of scene's transform nodes
  35084. * @param newTransformNode defines the transform node to add
  35085. */
  35086. addTransformNode(newTransformNode: TransformNode): void;
  35087. /**
  35088. * Remove a transform node for the list of scene's transform nodes
  35089. * @param toRemove defines the transform node to remove
  35090. * @returns the index where the transform node was in the transform node list
  35091. */
  35092. removeTransformNode(toRemove: TransformNode): number;
  35093. /**
  35094. * Remove a skeleton for the list of scene's skeletons
  35095. * @param toRemove defines the skeleton to remove
  35096. * @returns the index where the skeleton was in the skeleton list
  35097. */
  35098. removeSkeleton(toRemove: Skeleton): number;
  35099. /**
  35100. * Remove a morph target for the list of scene's morph targets
  35101. * @param toRemove defines the morph target to remove
  35102. * @returns the index where the morph target was in the morph target list
  35103. */
  35104. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35105. /**
  35106. * Remove a light for the list of scene's lights
  35107. * @param toRemove defines the light to remove
  35108. * @returns the index where the light was in the light list
  35109. */
  35110. removeLight(toRemove: Light): number;
  35111. /**
  35112. * Remove a camera for the list of scene's cameras
  35113. * @param toRemove defines the camera to remove
  35114. * @returns the index where the camera was in the camera list
  35115. */
  35116. removeCamera(toRemove: Camera): number;
  35117. /**
  35118. * Remove a particle system for the list of scene's particle systems
  35119. * @param toRemove defines the particle system to remove
  35120. * @returns the index where the particle system was in the particle system list
  35121. */
  35122. removeParticleSystem(toRemove: IParticleSystem): number;
  35123. /**
  35124. * Remove a animation for the list of scene's animations
  35125. * @param toRemove defines the animation to remove
  35126. * @returns the index where the animation was in the animation list
  35127. */
  35128. removeAnimation(toRemove: Animation): number;
  35129. /**
  35130. * Will stop the animation of the given target
  35131. * @param target - the target
  35132. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35133. * @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)
  35134. */
  35135. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35136. /**
  35137. * Removes the given animation group from this scene.
  35138. * @param toRemove The animation group to remove
  35139. * @returns The index of the removed animation group
  35140. */
  35141. removeAnimationGroup(toRemove: AnimationGroup): number;
  35142. /**
  35143. * Removes the given multi-material from this scene.
  35144. * @param toRemove The multi-material to remove
  35145. * @returns The index of the removed multi-material
  35146. */
  35147. removeMultiMaterial(toRemove: MultiMaterial): number;
  35148. /**
  35149. * Removes the given material from this scene.
  35150. * @param toRemove The material to remove
  35151. * @returns The index of the removed material
  35152. */
  35153. removeMaterial(toRemove: Material): number;
  35154. /**
  35155. * Removes the given action manager from this scene.
  35156. * @param toRemove The action manager to remove
  35157. * @returns The index of the removed action manager
  35158. */
  35159. removeActionManager(toRemove: AbstractActionManager): number;
  35160. /**
  35161. * Removes the given texture from this scene.
  35162. * @param toRemove The texture to remove
  35163. * @returns The index of the removed texture
  35164. */
  35165. removeTexture(toRemove: BaseTexture): number;
  35166. /**
  35167. * Adds the given light to this scene
  35168. * @param newLight The light to add
  35169. */
  35170. addLight(newLight: Light): void;
  35171. /**
  35172. * Sorts the list list based on light priorities
  35173. */
  35174. sortLightsByPriority(): void;
  35175. /**
  35176. * Adds the given camera to this scene
  35177. * @param newCamera The camera to add
  35178. */
  35179. addCamera(newCamera: Camera): void;
  35180. /**
  35181. * Adds the given skeleton to this scene
  35182. * @param newSkeleton The skeleton to add
  35183. */
  35184. addSkeleton(newSkeleton: Skeleton): void;
  35185. /**
  35186. * Adds the given particle system to this scene
  35187. * @param newParticleSystem The particle system to add
  35188. */
  35189. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35190. /**
  35191. * Adds the given animation to this scene
  35192. * @param newAnimation The animation to add
  35193. */
  35194. addAnimation(newAnimation: Animation): void;
  35195. /**
  35196. * Adds the given animation group to this scene.
  35197. * @param newAnimationGroup The animation group to add
  35198. */
  35199. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35200. /**
  35201. * Adds the given multi-material to this scene
  35202. * @param newMultiMaterial The multi-material to add
  35203. */
  35204. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35205. /**
  35206. * Adds the given material to this scene
  35207. * @param newMaterial The material to add
  35208. */
  35209. addMaterial(newMaterial: Material): void;
  35210. /**
  35211. * Adds the given morph target to this scene
  35212. * @param newMorphTargetManager The morph target to add
  35213. */
  35214. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35215. /**
  35216. * Adds the given geometry to this scene
  35217. * @param newGeometry The geometry to add
  35218. */
  35219. addGeometry(newGeometry: Geometry): void;
  35220. /**
  35221. * Adds the given action manager to this scene
  35222. * @param newActionManager The action manager to add
  35223. */
  35224. addActionManager(newActionManager: AbstractActionManager): void;
  35225. /**
  35226. * Adds the given texture to this scene.
  35227. * @param newTexture The texture to add
  35228. */
  35229. addTexture(newTexture: BaseTexture): void;
  35230. /**
  35231. * Switch active camera
  35232. * @param newCamera defines the new active camera
  35233. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35234. */
  35235. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35236. /**
  35237. * sets the active camera of the scene using its ID
  35238. * @param id defines the camera's ID
  35239. * @return the new active camera or null if none found.
  35240. */
  35241. setActiveCameraByID(id: string): Nullable<Camera>;
  35242. /**
  35243. * sets the active camera of the scene using its name
  35244. * @param name defines the camera's name
  35245. * @returns the new active camera or null if none found.
  35246. */
  35247. setActiveCameraByName(name: string): Nullable<Camera>;
  35248. /**
  35249. * get an animation group using its name
  35250. * @param name defines the material's name
  35251. * @return the animation group or null if none found.
  35252. */
  35253. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35254. /**
  35255. * Get a material using its unique id
  35256. * @param uniqueId defines the material's unique id
  35257. * @return the material or null if none found.
  35258. */
  35259. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35260. /**
  35261. * get a material using its id
  35262. * @param id defines the material's ID
  35263. * @return the material or null if none found.
  35264. */
  35265. getMaterialByID(id: string): Nullable<Material>;
  35266. /**
  35267. * Gets a the last added material using a given id
  35268. * @param id defines the material's ID
  35269. * @return the last material with the given id or null if none found.
  35270. */
  35271. getLastMaterialByID(id: string): Nullable<Material>;
  35272. /**
  35273. * Gets a material using its name
  35274. * @param name defines the material's name
  35275. * @return the material or null if none found.
  35276. */
  35277. getMaterialByName(name: string): Nullable<Material>;
  35278. /**
  35279. * Get a texture using its unique id
  35280. * @param uniqueId defines the texture's unique id
  35281. * @return the texture or null if none found.
  35282. */
  35283. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35284. /**
  35285. * Gets a camera using its id
  35286. * @param id defines the id to look for
  35287. * @returns the camera or null if not found
  35288. */
  35289. getCameraByID(id: string): Nullable<Camera>;
  35290. /**
  35291. * Gets a camera using its unique id
  35292. * @param uniqueId defines the unique id to look for
  35293. * @returns the camera or null if not found
  35294. */
  35295. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35296. /**
  35297. * Gets a camera using its name
  35298. * @param name defines the camera's name
  35299. * @return the camera or null if none found.
  35300. */
  35301. getCameraByName(name: string): Nullable<Camera>;
  35302. /**
  35303. * Gets a bone using its id
  35304. * @param id defines the bone's id
  35305. * @return the bone or null if not found
  35306. */
  35307. getBoneByID(id: string): Nullable<Bone>;
  35308. /**
  35309. * Gets a bone using its id
  35310. * @param name defines the bone's name
  35311. * @return the bone or null if not found
  35312. */
  35313. getBoneByName(name: string): Nullable<Bone>;
  35314. /**
  35315. * Gets a light node using its name
  35316. * @param name defines the the light's name
  35317. * @return the light or null if none found.
  35318. */
  35319. getLightByName(name: string): Nullable<Light>;
  35320. /**
  35321. * Gets a light node using its id
  35322. * @param id defines the light's id
  35323. * @return the light or null if none found.
  35324. */
  35325. getLightByID(id: string): Nullable<Light>;
  35326. /**
  35327. * Gets a light node using its scene-generated unique ID
  35328. * @param uniqueId defines the light's unique id
  35329. * @return the light or null if none found.
  35330. */
  35331. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35332. /**
  35333. * Gets a particle system by id
  35334. * @param id defines the particle system id
  35335. * @return the corresponding system or null if none found
  35336. */
  35337. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35338. /**
  35339. * Gets a geometry using its ID
  35340. * @param id defines the geometry's id
  35341. * @return the geometry or null if none found.
  35342. */
  35343. getGeometryByID(id: string): Nullable<Geometry>;
  35344. private _getGeometryByUniqueID;
  35345. /**
  35346. * Add a new geometry to this scene
  35347. * @param geometry defines the geometry to be added to the scene.
  35348. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35349. * @return a boolean defining if the geometry was added or not
  35350. */
  35351. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35352. /**
  35353. * Removes an existing geometry
  35354. * @param geometry defines the geometry to be removed from the scene
  35355. * @return a boolean defining if the geometry was removed or not
  35356. */
  35357. removeGeometry(geometry: Geometry): boolean;
  35358. /**
  35359. * Gets the list of geometries attached to the scene
  35360. * @returns an array of Geometry
  35361. */
  35362. getGeometries(): Geometry[];
  35363. /**
  35364. * Gets the first added mesh found of a given ID
  35365. * @param id defines the id to search for
  35366. * @return the mesh found or null if not found at all
  35367. */
  35368. getMeshByID(id: string): Nullable<AbstractMesh>;
  35369. /**
  35370. * Gets a list of meshes using their id
  35371. * @param id defines the id to search for
  35372. * @returns a list of meshes
  35373. */
  35374. getMeshesByID(id: string): Array<AbstractMesh>;
  35375. /**
  35376. * Gets the first added transform node found of a given ID
  35377. * @param id defines the id to search for
  35378. * @return the found transform node or null if not found at all.
  35379. */
  35380. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35381. /**
  35382. * Gets a transform node with its auto-generated unique id
  35383. * @param uniqueId efines the unique id to search for
  35384. * @return the found transform node or null if not found at all.
  35385. */
  35386. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35387. /**
  35388. * Gets a list of transform nodes using their id
  35389. * @param id defines the id to search for
  35390. * @returns a list of transform nodes
  35391. */
  35392. getTransformNodesByID(id: string): Array<TransformNode>;
  35393. /**
  35394. * Gets a mesh with its auto-generated unique id
  35395. * @param uniqueId defines the unique id to search for
  35396. * @return the found mesh or null if not found at all.
  35397. */
  35398. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35399. /**
  35400. * Gets a the last added mesh using a given id
  35401. * @param id defines the id to search for
  35402. * @return the found mesh or null if not found at all.
  35403. */
  35404. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35405. /**
  35406. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35407. * @param id defines the id to search for
  35408. * @return the found node or null if not found at all
  35409. */
  35410. getLastEntryByID(id: string): Nullable<Node>;
  35411. /**
  35412. * Gets a node (Mesh, Camera, Light) using a given id
  35413. * @param id defines the id to search for
  35414. * @return the found node or null if not found at all
  35415. */
  35416. getNodeByID(id: string): Nullable<Node>;
  35417. /**
  35418. * Gets a node (Mesh, Camera, Light) using a given name
  35419. * @param name defines the name to search for
  35420. * @return the found node or null if not found at all.
  35421. */
  35422. getNodeByName(name: string): Nullable<Node>;
  35423. /**
  35424. * Gets a mesh using a given name
  35425. * @param name defines the name to search for
  35426. * @return the found mesh or null if not found at all.
  35427. */
  35428. getMeshByName(name: string): Nullable<AbstractMesh>;
  35429. /**
  35430. * Gets a transform node using a given name
  35431. * @param name defines the name to search for
  35432. * @return the found transform node or null if not found at all.
  35433. */
  35434. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35435. /**
  35436. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35437. * @param id defines the id to search for
  35438. * @return the found skeleton or null if not found at all.
  35439. */
  35440. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35441. /**
  35442. * Gets a skeleton using a given auto generated unique id
  35443. * @param uniqueId defines the unique id to search for
  35444. * @return the found skeleton or null if not found at all.
  35445. */
  35446. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35447. /**
  35448. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35449. * @param id defines the id to search for
  35450. * @return the found skeleton or null if not found at all.
  35451. */
  35452. getSkeletonById(id: string): Nullable<Skeleton>;
  35453. /**
  35454. * Gets a skeleton using a given name
  35455. * @param name defines the name to search for
  35456. * @return the found skeleton or null if not found at all.
  35457. */
  35458. getSkeletonByName(name: string): Nullable<Skeleton>;
  35459. /**
  35460. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35461. * @param id defines the id to search for
  35462. * @return the found morph target manager or null if not found at all.
  35463. */
  35464. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35465. /**
  35466. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35467. * @param id defines the id to search for
  35468. * @return the found morph target or null if not found at all.
  35469. */
  35470. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35471. /**
  35472. * Gets a boolean indicating if the given mesh is active
  35473. * @param mesh defines the mesh to look for
  35474. * @returns true if the mesh is in the active list
  35475. */
  35476. isActiveMesh(mesh: AbstractMesh): boolean;
  35477. /**
  35478. * Return a unique id as a string which can serve as an identifier for the scene
  35479. */
  35480. readonly uid: string;
  35481. /**
  35482. * Add an externaly attached data from its key.
  35483. * This method call will fail and return false, if such key already exists.
  35484. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35485. * @param key the unique key that identifies the data
  35486. * @param data the data object to associate to the key for this Engine instance
  35487. * @return true if no such key were already present and the data was added successfully, false otherwise
  35488. */
  35489. addExternalData<T>(key: string, data: T): boolean;
  35490. /**
  35491. * Get an externaly attached data from its key
  35492. * @param key the unique key that identifies the data
  35493. * @return the associated data, if present (can be null), or undefined if not present
  35494. */
  35495. getExternalData<T>(key: string): Nullable<T>;
  35496. /**
  35497. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35498. * @param key the unique key that identifies the data
  35499. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35500. * @return the associated data, can be null if the factory returned null.
  35501. */
  35502. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35503. /**
  35504. * Remove an externaly attached data from the Engine instance
  35505. * @param key the unique key that identifies the data
  35506. * @return true if the data was successfully removed, false if it doesn't exist
  35507. */
  35508. removeExternalData(key: string): boolean;
  35509. private _evaluateSubMesh;
  35510. /**
  35511. * Clear the processed materials smart array preventing retention point in material dispose.
  35512. */
  35513. freeProcessedMaterials(): void;
  35514. private _preventFreeActiveMeshesAndRenderingGroups;
  35515. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35516. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35517. * when disposing several meshes in a row or a hierarchy of meshes.
  35518. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35519. */
  35520. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35521. /**
  35522. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35523. */
  35524. freeActiveMeshes(): void;
  35525. /**
  35526. * Clear the info related to rendering groups preventing retention points during dispose.
  35527. */
  35528. freeRenderingGroups(): void;
  35529. /** @hidden */
  35530. _isInIntermediateRendering(): boolean;
  35531. /**
  35532. * Lambda returning the list of potentially active meshes.
  35533. */
  35534. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35535. /**
  35536. * Lambda returning the list of potentially active sub meshes.
  35537. */
  35538. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35539. /**
  35540. * Lambda returning the list of potentially intersecting sub meshes.
  35541. */
  35542. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35543. /**
  35544. * Lambda returning the list of potentially colliding sub meshes.
  35545. */
  35546. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35547. private _activeMeshesFrozen;
  35548. /**
  35549. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35550. * @returns the current scene
  35551. */
  35552. freezeActiveMeshes(): Scene;
  35553. /**
  35554. * Use this function to restart evaluating active meshes on every frame
  35555. * @returns the current scene
  35556. */
  35557. unfreezeActiveMeshes(): Scene;
  35558. private _evaluateActiveMeshes;
  35559. private _activeMesh;
  35560. /**
  35561. * Update the transform matrix to update from the current active camera
  35562. * @param force defines a boolean used to force the update even if cache is up to date
  35563. */
  35564. updateTransformMatrix(force?: boolean): void;
  35565. private _bindFrameBuffer;
  35566. /** @hidden */
  35567. _allowPostProcessClearColor: boolean;
  35568. /** @hidden */
  35569. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35570. private _processSubCameras;
  35571. private _checkIntersections;
  35572. /** @hidden */
  35573. _advancePhysicsEngineStep(step: number): void;
  35574. /**
  35575. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35576. */
  35577. getDeterministicFrameTime: () => number;
  35578. /** @hidden */
  35579. _animate(): void;
  35580. /** Execute all animations (for a frame) */
  35581. animate(): void;
  35582. /**
  35583. * Render the scene
  35584. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35585. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35586. */
  35587. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35588. /**
  35589. * Freeze all materials
  35590. * A frozen material will not be updatable but should be faster to render
  35591. */
  35592. freezeMaterials(): void;
  35593. /**
  35594. * Unfreeze all materials
  35595. * A frozen material will not be updatable but should be faster to render
  35596. */
  35597. unfreezeMaterials(): void;
  35598. /**
  35599. * Releases all held ressources
  35600. */
  35601. dispose(): void;
  35602. /**
  35603. * Gets if the scene is already disposed
  35604. */
  35605. readonly isDisposed: boolean;
  35606. /**
  35607. * Call this function to reduce memory footprint of the scene.
  35608. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35609. */
  35610. clearCachedVertexData(): void;
  35611. /**
  35612. * This function will remove the local cached buffer data from texture.
  35613. * It will save memory but will prevent the texture from being rebuilt
  35614. */
  35615. cleanCachedTextureBuffer(): void;
  35616. /**
  35617. * Get the world extend vectors with an optional filter
  35618. *
  35619. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35620. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35621. */
  35622. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35623. min: Vector3;
  35624. max: Vector3;
  35625. };
  35626. /**
  35627. * Creates a ray that can be used to pick in the scene
  35628. * @param x defines the x coordinate of the origin (on-screen)
  35629. * @param y defines the y coordinate of the origin (on-screen)
  35630. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35631. * @param camera defines the camera to use for the picking
  35632. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35633. * @returns a Ray
  35634. */
  35635. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35636. /**
  35637. * Creates a ray that can be used to pick in the scene
  35638. * @param x defines the x coordinate of the origin (on-screen)
  35639. * @param y defines the y coordinate of the origin (on-screen)
  35640. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35641. * @param result defines the ray where to store the picking ray
  35642. * @param camera defines the camera to use for the picking
  35643. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35644. * @returns the current scene
  35645. */
  35646. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35647. /**
  35648. * Creates a ray that can be used to pick in the scene
  35649. * @param x defines the x coordinate of the origin (on-screen)
  35650. * @param y defines the y coordinate of the origin (on-screen)
  35651. * @param camera defines the camera to use for the picking
  35652. * @returns a Ray
  35653. */
  35654. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35655. /**
  35656. * Creates a ray that can be used to pick in the scene
  35657. * @param x defines the x coordinate of the origin (on-screen)
  35658. * @param y defines the y coordinate of the origin (on-screen)
  35659. * @param result defines the ray where to store the picking ray
  35660. * @param camera defines the camera to use for the picking
  35661. * @returns the current scene
  35662. */
  35663. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35664. /** Launch a ray to try to pick a mesh in the scene
  35665. * @param x position on screen
  35666. * @param y position on screen
  35667. * @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
  35668. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35669. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35670. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35671. * @returns a PickingInfo
  35672. */
  35673. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35674. /** Use the given ray to pick a mesh in the scene
  35675. * @param ray The ray to use to pick meshes
  35676. * @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
  35677. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35678. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35679. * @returns a PickingInfo
  35680. */
  35681. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35682. /**
  35683. * Launch a ray to try to pick a mesh in the scene
  35684. * @param x X position on screen
  35685. * @param y Y position on screen
  35686. * @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
  35687. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35688. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35689. * @returns an array of PickingInfo
  35690. */
  35691. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35692. /**
  35693. * Launch a ray to try to pick a mesh in the scene
  35694. * @param ray Ray to use
  35695. * @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
  35696. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35697. * @returns an array of PickingInfo
  35698. */
  35699. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35700. /**
  35701. * Force the value of meshUnderPointer
  35702. * @param mesh defines the mesh to use
  35703. */
  35704. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35705. /**
  35706. * Gets the mesh under the pointer
  35707. * @returns a Mesh or null if no mesh is under the pointer
  35708. */
  35709. getPointerOverMesh(): Nullable<AbstractMesh>;
  35710. /** @hidden */
  35711. _rebuildGeometries(): void;
  35712. /** @hidden */
  35713. _rebuildTextures(): void;
  35714. private _getByTags;
  35715. /**
  35716. * Get a list of meshes by tags
  35717. * @param tagsQuery defines the tags query to use
  35718. * @param forEach defines a predicate used to filter results
  35719. * @returns an array of Mesh
  35720. */
  35721. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35722. /**
  35723. * Get a list of cameras by tags
  35724. * @param tagsQuery defines the tags query to use
  35725. * @param forEach defines a predicate used to filter results
  35726. * @returns an array of Camera
  35727. */
  35728. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35729. /**
  35730. * Get a list of lights by tags
  35731. * @param tagsQuery defines the tags query to use
  35732. * @param forEach defines a predicate used to filter results
  35733. * @returns an array of Light
  35734. */
  35735. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35736. /**
  35737. * Get a list of materials by tags
  35738. * @param tagsQuery defines the tags query to use
  35739. * @param forEach defines a predicate used to filter results
  35740. * @returns an array of Material
  35741. */
  35742. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35743. /**
  35744. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35745. * This allowed control for front to back rendering or reversly depending of the special needs.
  35746. *
  35747. * @param renderingGroupId The rendering group id corresponding to its index
  35748. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35749. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35750. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35751. */
  35752. 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;
  35753. /**
  35754. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35755. *
  35756. * @param renderingGroupId The rendering group id corresponding to its index
  35757. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35758. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35759. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35760. */
  35761. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35762. /**
  35763. * Gets the current auto clear configuration for one rendering group of the rendering
  35764. * manager.
  35765. * @param index the rendering group index to get the information for
  35766. * @returns The auto clear setup for the requested rendering group
  35767. */
  35768. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35769. private _blockMaterialDirtyMechanism;
  35770. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35771. blockMaterialDirtyMechanism: boolean;
  35772. /**
  35773. * Will flag all materials as dirty to trigger new shader compilation
  35774. * @param flag defines the flag used to specify which material part must be marked as dirty
  35775. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35776. */
  35777. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35778. /** @hidden */
  35779. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35780. /** @hidden */
  35781. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35782. }
  35783. }
  35784. declare module "babylonjs/assetContainer" {
  35785. import { AbstractScene } from "babylonjs/abstractScene";
  35786. import { Scene } from "babylonjs/scene";
  35787. import { Mesh } from "babylonjs/Meshes/mesh";
  35788. /**
  35789. * Set of assets to keep when moving a scene into an asset container.
  35790. */
  35791. export class KeepAssets extends AbstractScene {
  35792. }
  35793. /**
  35794. * Container with a set of assets that can be added or removed from a scene.
  35795. */
  35796. export class AssetContainer extends AbstractScene {
  35797. /**
  35798. * The scene the AssetContainer belongs to.
  35799. */
  35800. scene: Scene;
  35801. /**
  35802. * Instantiates an AssetContainer.
  35803. * @param scene The scene the AssetContainer belongs to.
  35804. */
  35805. constructor(scene: Scene);
  35806. /**
  35807. * Adds all the assets from the container to the scene.
  35808. */
  35809. addAllToScene(): void;
  35810. /**
  35811. * Removes all the assets in the container from the scene
  35812. */
  35813. removeAllFromScene(): void;
  35814. /**
  35815. * Disposes all the assets in the container
  35816. */
  35817. dispose(): void;
  35818. private _moveAssets;
  35819. /**
  35820. * Removes all the assets contained in the scene and adds them to the container.
  35821. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35822. */
  35823. moveAllFromScene(keepAssets?: KeepAssets): void;
  35824. /**
  35825. * 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.
  35826. * @returns the root mesh
  35827. */
  35828. createRootMesh(): Mesh;
  35829. }
  35830. }
  35831. declare module "babylonjs/abstractScene" {
  35832. import { Scene } from "babylonjs/scene";
  35833. import { Nullable } from "babylonjs/types";
  35834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35835. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35836. import { Geometry } from "babylonjs/Meshes/geometry";
  35837. import { Skeleton } from "babylonjs/Bones/skeleton";
  35838. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35839. import { AssetContainer } from "babylonjs/assetContainer";
  35840. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35841. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35843. import { Material } from "babylonjs/Materials/material";
  35844. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35845. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35846. import { Camera } from "babylonjs/Cameras/camera";
  35847. import { Light } from "babylonjs/Lights/light";
  35848. import { Node } from "babylonjs/node";
  35849. import { Animation } from "babylonjs/Animations/animation";
  35850. /**
  35851. * Defines how the parser contract is defined.
  35852. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35853. */
  35854. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35855. /**
  35856. * Defines how the individual parser contract is defined.
  35857. * These parser can parse an individual asset
  35858. */
  35859. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35860. /**
  35861. * Base class of the scene acting as a container for the different elements composing a scene.
  35862. * This class is dynamically extended by the different components of the scene increasing
  35863. * flexibility and reducing coupling
  35864. */
  35865. export abstract class AbstractScene {
  35866. /**
  35867. * Stores the list of available parsers in the application.
  35868. */
  35869. private static _BabylonFileParsers;
  35870. /**
  35871. * Stores the list of available individual parsers in the application.
  35872. */
  35873. private static _IndividualBabylonFileParsers;
  35874. /**
  35875. * Adds a parser in the list of available ones
  35876. * @param name Defines the name of the parser
  35877. * @param parser Defines the parser to add
  35878. */
  35879. static AddParser(name: string, parser: BabylonFileParser): void;
  35880. /**
  35881. * Gets a general parser from the list of avaialble ones
  35882. * @param name Defines the name of the parser
  35883. * @returns the requested parser or null
  35884. */
  35885. static GetParser(name: string): Nullable<BabylonFileParser>;
  35886. /**
  35887. * Adds n individual parser in the list of available ones
  35888. * @param name Defines the name of the parser
  35889. * @param parser Defines the parser to add
  35890. */
  35891. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35892. /**
  35893. * Gets an individual parser from the list of avaialble ones
  35894. * @param name Defines the name of the parser
  35895. * @returns the requested parser or null
  35896. */
  35897. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35898. /**
  35899. * Parser json data and populate both a scene and its associated container object
  35900. * @param jsonData Defines the data to parse
  35901. * @param scene Defines the scene to parse the data for
  35902. * @param container Defines the container attached to the parsing sequence
  35903. * @param rootUrl Defines the root url of the data
  35904. */
  35905. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35906. /**
  35907. * Gets the list of root nodes (ie. nodes with no parent)
  35908. */
  35909. rootNodes: Node[];
  35910. /** All of the cameras added to this scene
  35911. * @see http://doc.babylonjs.com/babylon101/cameras
  35912. */
  35913. cameras: Camera[];
  35914. /**
  35915. * All of the lights added to this scene
  35916. * @see http://doc.babylonjs.com/babylon101/lights
  35917. */
  35918. lights: Light[];
  35919. /**
  35920. * All of the (abstract) meshes added to this scene
  35921. */
  35922. meshes: AbstractMesh[];
  35923. /**
  35924. * The list of skeletons added to the scene
  35925. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35926. */
  35927. skeletons: Skeleton[];
  35928. /**
  35929. * All of the particle systems added to this scene
  35930. * @see http://doc.babylonjs.com/babylon101/particles
  35931. */
  35932. particleSystems: IParticleSystem[];
  35933. /**
  35934. * Gets a list of Animations associated with the scene
  35935. */
  35936. animations: Animation[];
  35937. /**
  35938. * All of the animation groups added to this scene
  35939. * @see http://doc.babylonjs.com/how_to/group
  35940. */
  35941. animationGroups: AnimationGroup[];
  35942. /**
  35943. * All of the multi-materials added to this scene
  35944. * @see http://doc.babylonjs.com/how_to/multi_materials
  35945. */
  35946. multiMaterials: MultiMaterial[];
  35947. /**
  35948. * All of the materials added to this scene
  35949. * In the context of a Scene, it is not supposed to be modified manually.
  35950. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35951. * Note also that the order of the Material wihin the array is not significant and might change.
  35952. * @see http://doc.babylonjs.com/babylon101/materials
  35953. */
  35954. materials: Material[];
  35955. /**
  35956. * The list of morph target managers added to the scene
  35957. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35958. */
  35959. morphTargetManagers: MorphTargetManager[];
  35960. /**
  35961. * The list of geometries used in the scene.
  35962. */
  35963. geometries: Geometry[];
  35964. /**
  35965. * All of the tranform nodes added to this scene
  35966. * In the context of a Scene, it is not supposed to be modified manually.
  35967. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35968. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35969. * @see http://doc.babylonjs.com/how_to/transformnode
  35970. */
  35971. transformNodes: TransformNode[];
  35972. /**
  35973. * ActionManagers available on the scene.
  35974. */
  35975. actionManagers: AbstractActionManager[];
  35976. /**
  35977. * Textures to keep.
  35978. */
  35979. textures: BaseTexture[];
  35980. /**
  35981. * Environment texture for the scene
  35982. */
  35983. environmentTexture: Nullable<BaseTexture>;
  35984. }
  35985. }
  35986. declare module "babylonjs/Audio/sound" {
  35987. import { Observable } from "babylonjs/Misc/observable";
  35988. import { Vector3 } from "babylonjs/Maths/math.vector";
  35989. import { Nullable } from "babylonjs/types";
  35990. import { Scene } from "babylonjs/scene";
  35991. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35992. /**
  35993. * Interface used to define options for Sound class
  35994. */
  35995. export interface ISoundOptions {
  35996. /**
  35997. * Does the sound autoplay once loaded.
  35998. */
  35999. autoplay?: boolean;
  36000. /**
  36001. * Does the sound loop after it finishes playing once.
  36002. */
  36003. loop?: boolean;
  36004. /**
  36005. * Sound's volume
  36006. */
  36007. volume?: number;
  36008. /**
  36009. * Is it a spatial sound?
  36010. */
  36011. spatialSound?: boolean;
  36012. /**
  36013. * Maximum distance to hear that sound
  36014. */
  36015. maxDistance?: number;
  36016. /**
  36017. * Uses user defined attenuation function
  36018. */
  36019. useCustomAttenuation?: boolean;
  36020. /**
  36021. * Define the roll off factor of spatial sounds.
  36022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36023. */
  36024. rolloffFactor?: number;
  36025. /**
  36026. * Define the reference distance the sound should be heard perfectly.
  36027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36028. */
  36029. refDistance?: number;
  36030. /**
  36031. * Define the distance attenuation model the sound will follow.
  36032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36033. */
  36034. distanceModel?: string;
  36035. /**
  36036. * Defines the playback speed (1 by default)
  36037. */
  36038. playbackRate?: number;
  36039. /**
  36040. * Defines if the sound is from a streaming source
  36041. */
  36042. streaming?: boolean;
  36043. /**
  36044. * Defines an optional length (in seconds) inside the sound file
  36045. */
  36046. length?: number;
  36047. /**
  36048. * Defines an optional offset (in seconds) inside the sound file
  36049. */
  36050. offset?: number;
  36051. /**
  36052. * If true, URLs will not be required to state the audio file codec to use.
  36053. */
  36054. skipCodecCheck?: boolean;
  36055. }
  36056. /**
  36057. * Defines a sound that can be played in the application.
  36058. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36060. */
  36061. export class Sound {
  36062. /**
  36063. * The name of the sound in the scene.
  36064. */
  36065. name: string;
  36066. /**
  36067. * Does the sound autoplay once loaded.
  36068. */
  36069. autoplay: boolean;
  36070. /**
  36071. * Does the sound loop after it finishes playing once.
  36072. */
  36073. loop: boolean;
  36074. /**
  36075. * Does the sound use a custom attenuation curve to simulate the falloff
  36076. * happening when the source gets further away from the camera.
  36077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36078. */
  36079. useCustomAttenuation: boolean;
  36080. /**
  36081. * The sound track id this sound belongs to.
  36082. */
  36083. soundTrackId: number;
  36084. /**
  36085. * Is this sound currently played.
  36086. */
  36087. isPlaying: boolean;
  36088. /**
  36089. * Is this sound currently paused.
  36090. */
  36091. isPaused: boolean;
  36092. /**
  36093. * Does this sound enables spatial sound.
  36094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36095. */
  36096. spatialSound: boolean;
  36097. /**
  36098. * Define the reference distance the sound should be heard perfectly.
  36099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36100. */
  36101. refDistance: number;
  36102. /**
  36103. * Define the roll off factor of spatial sounds.
  36104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36105. */
  36106. rolloffFactor: number;
  36107. /**
  36108. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36110. */
  36111. maxDistance: number;
  36112. /**
  36113. * Define the distance attenuation model the sound will follow.
  36114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36115. */
  36116. distanceModel: string;
  36117. /**
  36118. * @hidden
  36119. * Back Compat
  36120. **/
  36121. onended: () => any;
  36122. /**
  36123. * Observable event when the current playing sound finishes.
  36124. */
  36125. onEndedObservable: Observable<Sound>;
  36126. private _panningModel;
  36127. private _playbackRate;
  36128. private _streaming;
  36129. private _startTime;
  36130. private _startOffset;
  36131. private _position;
  36132. /** @hidden */
  36133. _positionInEmitterSpace: boolean;
  36134. private _localDirection;
  36135. private _volume;
  36136. private _isReadyToPlay;
  36137. private _isDirectional;
  36138. private _readyToPlayCallback;
  36139. private _audioBuffer;
  36140. private _soundSource;
  36141. private _streamingSource;
  36142. private _soundPanner;
  36143. private _soundGain;
  36144. private _inputAudioNode;
  36145. private _outputAudioNode;
  36146. private _coneInnerAngle;
  36147. private _coneOuterAngle;
  36148. private _coneOuterGain;
  36149. private _scene;
  36150. private _connectedTransformNode;
  36151. private _customAttenuationFunction;
  36152. private _registerFunc;
  36153. private _isOutputConnected;
  36154. private _htmlAudioElement;
  36155. private _urlType;
  36156. private _length?;
  36157. private _offset?;
  36158. /** @hidden */
  36159. static _SceneComponentInitialization: (scene: Scene) => void;
  36160. /**
  36161. * Create a sound and attach it to a scene
  36162. * @param name Name of your sound
  36163. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36164. * @param scene defines the scene the sound belongs to
  36165. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36166. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36167. */
  36168. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36169. /**
  36170. * Release the sound and its associated resources
  36171. */
  36172. dispose(): void;
  36173. /**
  36174. * Gets if the sounds is ready to be played or not.
  36175. * @returns true if ready, otherwise false
  36176. */
  36177. isReady(): boolean;
  36178. private _soundLoaded;
  36179. /**
  36180. * Sets the data of the sound from an audiobuffer
  36181. * @param audioBuffer The audioBuffer containing the data
  36182. */
  36183. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36184. /**
  36185. * Updates the current sounds options such as maxdistance, loop...
  36186. * @param options A JSON object containing values named as the object properties
  36187. */
  36188. updateOptions(options: ISoundOptions): void;
  36189. private _createSpatialParameters;
  36190. private _updateSpatialParameters;
  36191. /**
  36192. * Switch the panning model to HRTF:
  36193. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36195. */
  36196. switchPanningModelToHRTF(): void;
  36197. /**
  36198. * Switch the panning model to Equal Power:
  36199. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36201. */
  36202. switchPanningModelToEqualPower(): void;
  36203. private _switchPanningModel;
  36204. /**
  36205. * Connect this sound to a sound track audio node like gain...
  36206. * @param soundTrackAudioNode the sound track audio node to connect to
  36207. */
  36208. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36209. /**
  36210. * Transform this sound into a directional source
  36211. * @param coneInnerAngle Size of the inner cone in degree
  36212. * @param coneOuterAngle Size of the outer cone in degree
  36213. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36214. */
  36215. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36216. /**
  36217. * Gets or sets the inner angle for the directional cone.
  36218. */
  36219. /**
  36220. * Gets or sets the inner angle for the directional cone.
  36221. */
  36222. directionalConeInnerAngle: number;
  36223. /**
  36224. * Gets or sets the outer angle for the directional cone.
  36225. */
  36226. /**
  36227. * Gets or sets the outer angle for the directional cone.
  36228. */
  36229. directionalConeOuterAngle: number;
  36230. /**
  36231. * Sets the position of the emitter if spatial sound is enabled
  36232. * @param newPosition Defines the new posisiton
  36233. */
  36234. setPosition(newPosition: Vector3): void;
  36235. /**
  36236. * Sets the local direction of the emitter if spatial sound is enabled
  36237. * @param newLocalDirection Defines the new local direction
  36238. */
  36239. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36240. private _updateDirection;
  36241. /** @hidden */
  36242. updateDistanceFromListener(): void;
  36243. /**
  36244. * Sets a new custom attenuation function for the sound.
  36245. * @param callback Defines the function used for the attenuation
  36246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36247. */
  36248. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36249. /**
  36250. * Play the sound
  36251. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36252. * @param offset (optional) Start the sound at a specific time in seconds
  36253. * @param length (optional) Sound duration (in seconds)
  36254. */
  36255. play(time?: number, offset?: number, length?: number): void;
  36256. private _onended;
  36257. /**
  36258. * Stop the sound
  36259. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36260. */
  36261. stop(time?: number): void;
  36262. /**
  36263. * Put the sound in pause
  36264. */
  36265. pause(): void;
  36266. /**
  36267. * Sets a dedicated volume for this sounds
  36268. * @param newVolume Define the new volume of the sound
  36269. * @param time Define time for gradual change to new volume
  36270. */
  36271. setVolume(newVolume: number, time?: number): void;
  36272. /**
  36273. * Set the sound play back rate
  36274. * @param newPlaybackRate Define the playback rate the sound should be played at
  36275. */
  36276. setPlaybackRate(newPlaybackRate: number): void;
  36277. /**
  36278. * Gets the volume of the sound.
  36279. * @returns the volume of the sound
  36280. */
  36281. getVolume(): number;
  36282. /**
  36283. * Attach the sound to a dedicated mesh
  36284. * @param transformNode The transform node to connect the sound with
  36285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36286. */
  36287. attachToMesh(transformNode: TransformNode): void;
  36288. /**
  36289. * Detach the sound from the previously attached mesh
  36290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36291. */
  36292. detachFromMesh(): void;
  36293. private _onRegisterAfterWorldMatrixUpdate;
  36294. /**
  36295. * Clone the current sound in the scene.
  36296. * @returns the new sound clone
  36297. */
  36298. clone(): Nullable<Sound>;
  36299. /**
  36300. * Gets the current underlying audio buffer containing the data
  36301. * @returns the audio buffer
  36302. */
  36303. getAudioBuffer(): Nullable<AudioBuffer>;
  36304. /**
  36305. * Serializes the Sound in a JSON representation
  36306. * @returns the JSON representation of the sound
  36307. */
  36308. serialize(): any;
  36309. /**
  36310. * Parse a JSON representation of a sound to innstantiate in a given scene
  36311. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36312. * @param scene Define the scene the new parsed sound should be created in
  36313. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36314. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36315. * @returns the newly parsed sound
  36316. */
  36317. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36318. }
  36319. }
  36320. declare module "babylonjs/Actions/directAudioActions" {
  36321. import { Action } from "babylonjs/Actions/action";
  36322. import { Condition } from "babylonjs/Actions/condition";
  36323. import { Sound } from "babylonjs/Audio/sound";
  36324. /**
  36325. * This defines an action helpful to play a defined sound on a triggered action.
  36326. */
  36327. export class PlaySoundAction extends Action {
  36328. private _sound;
  36329. /**
  36330. * Instantiate the action
  36331. * @param triggerOptions defines the trigger options
  36332. * @param sound defines the sound to play
  36333. * @param condition defines the trigger related conditions
  36334. */
  36335. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36336. /** @hidden */
  36337. _prepare(): void;
  36338. /**
  36339. * Execute the action and play the sound.
  36340. */
  36341. execute(): void;
  36342. /**
  36343. * Serializes the actions and its related information.
  36344. * @param parent defines the object to serialize in
  36345. * @returns the serialized object
  36346. */
  36347. serialize(parent: any): any;
  36348. }
  36349. /**
  36350. * This defines an action helpful to stop a defined sound on a triggered action.
  36351. */
  36352. export class StopSoundAction extends Action {
  36353. private _sound;
  36354. /**
  36355. * Instantiate the action
  36356. * @param triggerOptions defines the trigger options
  36357. * @param sound defines the sound to stop
  36358. * @param condition defines the trigger related conditions
  36359. */
  36360. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36361. /** @hidden */
  36362. _prepare(): void;
  36363. /**
  36364. * Execute the action and stop the sound.
  36365. */
  36366. execute(): void;
  36367. /**
  36368. * Serializes the actions and its related information.
  36369. * @param parent defines the object to serialize in
  36370. * @returns the serialized object
  36371. */
  36372. serialize(parent: any): any;
  36373. }
  36374. }
  36375. declare module "babylonjs/Actions/interpolateValueAction" {
  36376. import { Action } from "babylonjs/Actions/action";
  36377. import { Condition } from "babylonjs/Actions/condition";
  36378. import { Observable } from "babylonjs/Misc/observable";
  36379. /**
  36380. * This defines an action responsible to change the value of a property
  36381. * by interpolating between its current value and the newly set one once triggered.
  36382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36383. */
  36384. export class InterpolateValueAction extends Action {
  36385. /**
  36386. * Defines the path of the property where the value should be interpolated
  36387. */
  36388. propertyPath: string;
  36389. /**
  36390. * Defines the target value at the end of the interpolation.
  36391. */
  36392. value: any;
  36393. /**
  36394. * Defines the time it will take for the property to interpolate to the value.
  36395. */
  36396. duration: number;
  36397. /**
  36398. * Defines if the other scene animations should be stopped when the action has been triggered
  36399. */
  36400. stopOtherAnimations?: boolean;
  36401. /**
  36402. * Defines a callback raised once the interpolation animation has been done.
  36403. */
  36404. onInterpolationDone?: () => void;
  36405. /**
  36406. * Observable triggered once the interpolation animation has been done.
  36407. */
  36408. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36409. private _target;
  36410. private _effectiveTarget;
  36411. private _property;
  36412. /**
  36413. * Instantiate the action
  36414. * @param triggerOptions defines the trigger options
  36415. * @param target defines the object containing the value to interpolate
  36416. * @param propertyPath defines the path to the property in the target object
  36417. * @param value defines the target value at the end of the interpolation
  36418. * @param duration deines the time it will take for the property to interpolate to the value.
  36419. * @param condition defines the trigger related conditions
  36420. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36421. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36422. */
  36423. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36424. /** @hidden */
  36425. _prepare(): void;
  36426. /**
  36427. * Execute the action starts the value interpolation.
  36428. */
  36429. execute(): void;
  36430. /**
  36431. * Serializes the actions and its related information.
  36432. * @param parent defines the object to serialize in
  36433. * @returns the serialized object
  36434. */
  36435. serialize(parent: any): any;
  36436. }
  36437. }
  36438. declare module "babylonjs/Actions/index" {
  36439. export * from "babylonjs/Actions/abstractActionManager";
  36440. export * from "babylonjs/Actions/action";
  36441. export * from "babylonjs/Actions/actionEvent";
  36442. export * from "babylonjs/Actions/actionManager";
  36443. export * from "babylonjs/Actions/condition";
  36444. export * from "babylonjs/Actions/directActions";
  36445. export * from "babylonjs/Actions/directAudioActions";
  36446. export * from "babylonjs/Actions/interpolateValueAction";
  36447. }
  36448. declare module "babylonjs/Animations/index" {
  36449. export * from "babylonjs/Animations/animatable";
  36450. export * from "babylonjs/Animations/animation";
  36451. export * from "babylonjs/Animations/animationGroup";
  36452. export * from "babylonjs/Animations/animationPropertiesOverride";
  36453. export * from "babylonjs/Animations/easing";
  36454. export * from "babylonjs/Animations/runtimeAnimation";
  36455. export * from "babylonjs/Animations/animationEvent";
  36456. export * from "babylonjs/Animations/animationGroup";
  36457. export * from "babylonjs/Animations/animationKey";
  36458. export * from "babylonjs/Animations/animationRange";
  36459. export * from "babylonjs/Animations/animatable.interface";
  36460. }
  36461. declare module "babylonjs/Audio/soundTrack" {
  36462. import { Sound } from "babylonjs/Audio/sound";
  36463. import { Analyser } from "babylonjs/Audio/analyser";
  36464. import { Scene } from "babylonjs/scene";
  36465. /**
  36466. * Options allowed during the creation of a sound track.
  36467. */
  36468. export interface ISoundTrackOptions {
  36469. /**
  36470. * The volume the sound track should take during creation
  36471. */
  36472. volume?: number;
  36473. /**
  36474. * Define if the sound track is the main sound track of the scene
  36475. */
  36476. mainTrack?: boolean;
  36477. }
  36478. /**
  36479. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36480. * It will be also used in a future release to apply effects on a specific track.
  36481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36482. */
  36483. export class SoundTrack {
  36484. /**
  36485. * The unique identifier of the sound track in the scene.
  36486. */
  36487. id: number;
  36488. /**
  36489. * The list of sounds included in the sound track.
  36490. */
  36491. soundCollection: Array<Sound>;
  36492. private _outputAudioNode;
  36493. private _scene;
  36494. private _isMainTrack;
  36495. private _connectedAnalyser;
  36496. private _options;
  36497. private _isInitialized;
  36498. /**
  36499. * Creates a new sound track.
  36500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36501. * @param scene Define the scene the sound track belongs to
  36502. * @param options
  36503. */
  36504. constructor(scene: Scene, options?: ISoundTrackOptions);
  36505. private _initializeSoundTrackAudioGraph;
  36506. /**
  36507. * Release the sound track and its associated resources
  36508. */
  36509. dispose(): void;
  36510. /**
  36511. * Adds a sound to this sound track
  36512. * @param sound define the cound to add
  36513. * @ignoreNaming
  36514. */
  36515. AddSound(sound: Sound): void;
  36516. /**
  36517. * Removes a sound to this sound track
  36518. * @param sound define the cound to remove
  36519. * @ignoreNaming
  36520. */
  36521. RemoveSound(sound: Sound): void;
  36522. /**
  36523. * Set a global volume for the full sound track.
  36524. * @param newVolume Define the new volume of the sound track
  36525. */
  36526. setVolume(newVolume: number): void;
  36527. /**
  36528. * Switch the panning model to HRTF:
  36529. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36531. */
  36532. switchPanningModelToHRTF(): void;
  36533. /**
  36534. * Switch the panning model to Equal Power:
  36535. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36537. */
  36538. switchPanningModelToEqualPower(): void;
  36539. /**
  36540. * Connect the sound track to an audio analyser allowing some amazing
  36541. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36543. * @param analyser The analyser to connect to the engine
  36544. */
  36545. connectToAnalyser(analyser: Analyser): void;
  36546. }
  36547. }
  36548. declare module "babylonjs/Audio/audioSceneComponent" {
  36549. import { Sound } from "babylonjs/Audio/sound";
  36550. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36551. import { Nullable } from "babylonjs/types";
  36552. import { Vector3 } from "babylonjs/Maths/math.vector";
  36553. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36554. import { Scene } from "babylonjs/scene";
  36555. import { AbstractScene } from "babylonjs/abstractScene";
  36556. import "babylonjs/Audio/audioEngine";
  36557. module "babylonjs/abstractScene" {
  36558. interface AbstractScene {
  36559. /**
  36560. * The list of sounds used in the scene.
  36561. */
  36562. sounds: Nullable<Array<Sound>>;
  36563. }
  36564. }
  36565. module "babylonjs/scene" {
  36566. interface Scene {
  36567. /**
  36568. * @hidden
  36569. * Backing field
  36570. */
  36571. _mainSoundTrack: SoundTrack;
  36572. /**
  36573. * The main sound track played by the scene.
  36574. * It cotains your primary collection of sounds.
  36575. */
  36576. mainSoundTrack: SoundTrack;
  36577. /**
  36578. * The list of sound tracks added to the scene
  36579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36580. */
  36581. soundTracks: Nullable<Array<SoundTrack>>;
  36582. /**
  36583. * Gets a sound using a given name
  36584. * @param name defines the name to search for
  36585. * @return the found sound or null if not found at all.
  36586. */
  36587. getSoundByName(name: string): Nullable<Sound>;
  36588. /**
  36589. * Gets or sets if audio support is enabled
  36590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36591. */
  36592. audioEnabled: boolean;
  36593. /**
  36594. * Gets or sets if audio will be output to headphones
  36595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36596. */
  36597. headphone: boolean;
  36598. /**
  36599. * Gets or sets custom audio listener position provider
  36600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36601. */
  36602. audioListenerPositionProvider: Nullable<() => Vector3>;
  36603. }
  36604. }
  36605. /**
  36606. * Defines the sound scene component responsible to manage any sounds
  36607. * in a given scene.
  36608. */
  36609. export class AudioSceneComponent implements ISceneSerializableComponent {
  36610. /**
  36611. * The component name helpfull to identify the component in the list of scene components.
  36612. */
  36613. readonly name: string;
  36614. /**
  36615. * The scene the component belongs to.
  36616. */
  36617. scene: Scene;
  36618. private _audioEnabled;
  36619. /**
  36620. * Gets whether audio is enabled or not.
  36621. * Please use related enable/disable method to switch state.
  36622. */
  36623. readonly audioEnabled: boolean;
  36624. private _headphone;
  36625. /**
  36626. * Gets whether audio is outputing to headphone or not.
  36627. * Please use the according Switch methods to change output.
  36628. */
  36629. readonly headphone: boolean;
  36630. private _audioListenerPositionProvider;
  36631. /**
  36632. * Gets the current audio listener position provider
  36633. */
  36634. /**
  36635. * Sets a custom listener position for all sounds in the scene
  36636. * By default, this is the position of the first active camera
  36637. */
  36638. audioListenerPositionProvider: Nullable<() => Vector3>;
  36639. /**
  36640. * Creates a new instance of the component for the given scene
  36641. * @param scene Defines the scene to register the component in
  36642. */
  36643. constructor(scene: Scene);
  36644. /**
  36645. * Registers the component in a given scene
  36646. */
  36647. register(): void;
  36648. /**
  36649. * Rebuilds the elements related to this component in case of
  36650. * context lost for instance.
  36651. */
  36652. rebuild(): void;
  36653. /**
  36654. * Serializes the component data to the specified json object
  36655. * @param serializationObject The object to serialize to
  36656. */
  36657. serialize(serializationObject: any): void;
  36658. /**
  36659. * Adds all the elements from the container to the scene
  36660. * @param container the container holding the elements
  36661. */
  36662. addFromContainer(container: AbstractScene): void;
  36663. /**
  36664. * Removes all the elements in the container from the scene
  36665. * @param container contains the elements to remove
  36666. * @param dispose if the removed element should be disposed (default: false)
  36667. */
  36668. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36669. /**
  36670. * Disposes the component and the associated ressources.
  36671. */
  36672. dispose(): void;
  36673. /**
  36674. * Disables audio in the associated scene.
  36675. */
  36676. disableAudio(): void;
  36677. /**
  36678. * Enables audio in the associated scene.
  36679. */
  36680. enableAudio(): void;
  36681. /**
  36682. * Switch audio to headphone output.
  36683. */
  36684. switchAudioModeForHeadphones(): void;
  36685. /**
  36686. * Switch audio to normal speakers.
  36687. */
  36688. switchAudioModeForNormalSpeakers(): void;
  36689. private _afterRender;
  36690. }
  36691. }
  36692. declare module "babylonjs/Audio/weightedsound" {
  36693. import { Sound } from "babylonjs/Audio/sound";
  36694. /**
  36695. * Wraps one or more Sound objects and selects one with random weight for playback.
  36696. */
  36697. export class WeightedSound {
  36698. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36699. loop: boolean;
  36700. private _coneInnerAngle;
  36701. private _coneOuterAngle;
  36702. private _volume;
  36703. /** A Sound is currently playing. */
  36704. isPlaying: boolean;
  36705. /** A Sound is currently paused. */
  36706. isPaused: boolean;
  36707. private _sounds;
  36708. private _weights;
  36709. private _currentIndex?;
  36710. /**
  36711. * Creates a new WeightedSound from the list of sounds given.
  36712. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36713. * @param sounds Array of Sounds that will be selected from.
  36714. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36715. */
  36716. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36717. /**
  36718. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36719. */
  36720. /**
  36721. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36722. */
  36723. directionalConeInnerAngle: number;
  36724. /**
  36725. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36726. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36727. */
  36728. /**
  36729. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36730. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36731. */
  36732. directionalConeOuterAngle: number;
  36733. /**
  36734. * Playback volume.
  36735. */
  36736. /**
  36737. * Playback volume.
  36738. */
  36739. volume: number;
  36740. private _onended;
  36741. /**
  36742. * Suspend playback
  36743. */
  36744. pause(): void;
  36745. /**
  36746. * Stop playback
  36747. */
  36748. stop(): void;
  36749. /**
  36750. * Start playback.
  36751. * @param startOffset Position the clip head at a specific time in seconds.
  36752. */
  36753. play(startOffset?: number): void;
  36754. }
  36755. }
  36756. declare module "babylonjs/Audio/index" {
  36757. export * from "babylonjs/Audio/analyser";
  36758. export * from "babylonjs/Audio/audioEngine";
  36759. export * from "babylonjs/Audio/audioSceneComponent";
  36760. export * from "babylonjs/Audio/sound";
  36761. export * from "babylonjs/Audio/soundTrack";
  36762. export * from "babylonjs/Audio/weightedsound";
  36763. }
  36764. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36765. import { Behavior } from "babylonjs/Behaviors/behavior";
  36766. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36767. import { BackEase } from "babylonjs/Animations/easing";
  36768. /**
  36769. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36770. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36771. */
  36772. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36773. /**
  36774. * Gets the name of the behavior.
  36775. */
  36776. readonly name: string;
  36777. /**
  36778. * The easing function used by animations
  36779. */
  36780. static EasingFunction: BackEase;
  36781. /**
  36782. * The easing mode used by animations
  36783. */
  36784. static EasingMode: number;
  36785. /**
  36786. * The duration of the animation, in milliseconds
  36787. */
  36788. transitionDuration: number;
  36789. /**
  36790. * Length of the distance animated by the transition when lower radius is reached
  36791. */
  36792. lowerRadiusTransitionRange: number;
  36793. /**
  36794. * Length of the distance animated by the transition when upper radius is reached
  36795. */
  36796. upperRadiusTransitionRange: number;
  36797. private _autoTransitionRange;
  36798. /**
  36799. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36800. */
  36801. /**
  36802. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36803. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36804. */
  36805. autoTransitionRange: boolean;
  36806. private _attachedCamera;
  36807. private _onAfterCheckInputsObserver;
  36808. private _onMeshTargetChangedObserver;
  36809. /**
  36810. * Initializes the behavior.
  36811. */
  36812. init(): void;
  36813. /**
  36814. * Attaches the behavior to its arc rotate camera.
  36815. * @param camera Defines the camera to attach the behavior to
  36816. */
  36817. attach(camera: ArcRotateCamera): void;
  36818. /**
  36819. * Detaches the behavior from its current arc rotate camera.
  36820. */
  36821. detach(): void;
  36822. private _radiusIsAnimating;
  36823. private _radiusBounceTransition;
  36824. private _animatables;
  36825. private _cachedWheelPrecision;
  36826. /**
  36827. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36828. * @param radiusLimit The limit to check against.
  36829. * @return Bool to indicate if at limit.
  36830. */
  36831. private _isRadiusAtLimit;
  36832. /**
  36833. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36834. * @param radiusDelta The delta by which to animate to. Can be negative.
  36835. */
  36836. private _applyBoundRadiusAnimation;
  36837. /**
  36838. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36839. */
  36840. protected _clearAnimationLocks(): void;
  36841. /**
  36842. * Stops and removes all animations that have been applied to the camera
  36843. */
  36844. stopAllAnimations(): void;
  36845. }
  36846. }
  36847. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36848. import { Behavior } from "babylonjs/Behaviors/behavior";
  36849. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36850. import { ExponentialEase } from "babylonjs/Animations/easing";
  36851. import { Nullable } from "babylonjs/types";
  36852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36853. import { Vector3 } from "babylonjs/Maths/math.vector";
  36854. /**
  36855. * 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.
  36856. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36857. */
  36858. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36859. /**
  36860. * Gets the name of the behavior.
  36861. */
  36862. readonly name: string;
  36863. private _mode;
  36864. private _radiusScale;
  36865. private _positionScale;
  36866. private _defaultElevation;
  36867. private _elevationReturnTime;
  36868. private _elevationReturnWaitTime;
  36869. private _zoomStopsAnimation;
  36870. private _framingTime;
  36871. /**
  36872. * The easing function used by animations
  36873. */
  36874. static EasingFunction: ExponentialEase;
  36875. /**
  36876. * The easing mode used by animations
  36877. */
  36878. static EasingMode: number;
  36879. /**
  36880. * Sets the current mode used by the behavior
  36881. */
  36882. /**
  36883. * Gets current mode used by the behavior.
  36884. */
  36885. mode: number;
  36886. /**
  36887. * Sets the scale applied to the radius (1 by default)
  36888. */
  36889. /**
  36890. * Gets the scale applied to the radius
  36891. */
  36892. radiusScale: number;
  36893. /**
  36894. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36895. */
  36896. /**
  36897. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36898. */
  36899. positionScale: number;
  36900. /**
  36901. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36902. * behaviour is triggered, in radians.
  36903. */
  36904. /**
  36905. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36906. * behaviour is triggered, in radians.
  36907. */
  36908. defaultElevation: number;
  36909. /**
  36910. * Sets the time (in milliseconds) taken to return to the default beta position.
  36911. * Negative value indicates camera should not return to default.
  36912. */
  36913. /**
  36914. * Gets the time (in milliseconds) taken to return to the default beta position.
  36915. * Negative value indicates camera should not return to default.
  36916. */
  36917. elevationReturnTime: number;
  36918. /**
  36919. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36920. */
  36921. /**
  36922. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36923. */
  36924. elevationReturnWaitTime: number;
  36925. /**
  36926. * Sets the flag that indicates if user zooming should stop animation.
  36927. */
  36928. /**
  36929. * Gets the flag that indicates if user zooming should stop animation.
  36930. */
  36931. zoomStopsAnimation: boolean;
  36932. /**
  36933. * Sets the transition time when framing the mesh, in milliseconds
  36934. */
  36935. /**
  36936. * Gets the transition time when framing the mesh, in milliseconds
  36937. */
  36938. framingTime: number;
  36939. /**
  36940. * Define if the behavior should automatically change the configured
  36941. * camera limits and sensibilities.
  36942. */
  36943. autoCorrectCameraLimitsAndSensibility: boolean;
  36944. private _onPrePointerObservableObserver;
  36945. private _onAfterCheckInputsObserver;
  36946. private _onMeshTargetChangedObserver;
  36947. private _attachedCamera;
  36948. private _isPointerDown;
  36949. private _lastInteractionTime;
  36950. /**
  36951. * Initializes the behavior.
  36952. */
  36953. init(): void;
  36954. /**
  36955. * Attaches the behavior to its arc rotate camera.
  36956. * @param camera Defines the camera to attach the behavior to
  36957. */
  36958. attach(camera: ArcRotateCamera): void;
  36959. /**
  36960. * Detaches the behavior from its current arc rotate camera.
  36961. */
  36962. detach(): void;
  36963. private _animatables;
  36964. private _betaIsAnimating;
  36965. private _betaTransition;
  36966. private _radiusTransition;
  36967. private _vectorTransition;
  36968. /**
  36969. * Targets the given mesh and updates zoom level accordingly.
  36970. * @param mesh The mesh to target.
  36971. * @param radius Optional. If a cached radius position already exists, overrides default.
  36972. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36973. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36974. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36975. */
  36976. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36977. /**
  36978. * Targets the given mesh with its children and updates zoom level accordingly.
  36979. * @param mesh The mesh to target.
  36980. * @param radius Optional. If a cached radius position already exists, overrides default.
  36981. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36982. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36983. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36984. */
  36985. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36986. /**
  36987. * Targets the given meshes with their children and updates zoom level accordingly.
  36988. * @param meshes The mesh to target.
  36989. * @param radius Optional. If a cached radius position already exists, overrides default.
  36990. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36991. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36992. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36993. */
  36994. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36995. /**
  36996. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36997. * @param minimumWorld Determines the smaller position of the bounding box extend
  36998. * @param maximumWorld Determines the bigger position of the bounding box extend
  36999. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37000. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37001. */
  37002. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37003. /**
  37004. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37005. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37006. * frustum width.
  37007. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37008. * to fully enclose the mesh in the viewing frustum.
  37009. */
  37010. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37011. /**
  37012. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37013. * is automatically returned to its default position (expected to be above ground plane).
  37014. */
  37015. private _maintainCameraAboveGround;
  37016. /**
  37017. * Returns the frustum slope based on the canvas ratio and camera FOV
  37018. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37019. */
  37020. private _getFrustumSlope;
  37021. /**
  37022. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37023. */
  37024. private _clearAnimationLocks;
  37025. /**
  37026. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37027. */
  37028. private _applyUserInteraction;
  37029. /**
  37030. * Stops and removes all animations that have been applied to the camera
  37031. */
  37032. stopAllAnimations(): void;
  37033. /**
  37034. * Gets a value indicating if the user is moving the camera
  37035. */
  37036. readonly isUserIsMoving: boolean;
  37037. /**
  37038. * The camera can move all the way towards the mesh.
  37039. */
  37040. static IgnoreBoundsSizeMode: number;
  37041. /**
  37042. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37043. */
  37044. static FitFrustumSidesMode: number;
  37045. }
  37046. }
  37047. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37048. import { Nullable } from "babylonjs/types";
  37049. import { Camera } from "babylonjs/Cameras/camera";
  37050. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37051. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37052. /**
  37053. * Base class for Camera Pointer Inputs.
  37054. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37055. * for example usage.
  37056. */
  37057. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37058. /**
  37059. * Defines the camera the input is attached to.
  37060. */
  37061. abstract camera: Camera;
  37062. /**
  37063. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37064. */
  37065. protected _altKey: boolean;
  37066. protected _ctrlKey: boolean;
  37067. protected _metaKey: boolean;
  37068. protected _shiftKey: boolean;
  37069. /**
  37070. * Which mouse buttons were pressed at time of last mouse event.
  37071. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37072. */
  37073. protected _buttonsPressed: number;
  37074. /**
  37075. * Defines the buttons associated with the input to handle camera move.
  37076. */
  37077. buttons: number[];
  37078. /**
  37079. * Attach the input controls to a specific dom element to get the input from.
  37080. * @param element Defines the element the controls should be listened from
  37081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37082. */
  37083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37084. /**
  37085. * Detach the current controls from the specified dom element.
  37086. * @param element Defines the element to stop listening the inputs from
  37087. */
  37088. detachControl(element: Nullable<HTMLElement>): void;
  37089. /**
  37090. * Gets the class name of the current input.
  37091. * @returns the class name
  37092. */
  37093. getClassName(): string;
  37094. /**
  37095. * Get the friendly name associated with the input class.
  37096. * @returns the input friendly name
  37097. */
  37098. getSimpleName(): string;
  37099. /**
  37100. * Called on pointer POINTERDOUBLETAP event.
  37101. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37102. */
  37103. protected onDoubleTap(type: string): void;
  37104. /**
  37105. * Called on pointer POINTERMOVE event if only a single touch is active.
  37106. * Override this method to provide functionality.
  37107. */
  37108. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37109. /**
  37110. * Called on pointer POINTERMOVE event if multiple touches are active.
  37111. * Override this method to provide functionality.
  37112. */
  37113. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37114. /**
  37115. * Called on JS contextmenu event.
  37116. * Override this method to provide functionality.
  37117. */
  37118. protected onContextMenu(evt: PointerEvent): void;
  37119. /**
  37120. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37121. * press.
  37122. * Override this method to provide functionality.
  37123. */
  37124. protected onButtonDown(evt: PointerEvent): void;
  37125. /**
  37126. * Called each time a new POINTERUP event occurs. Ie, for each button
  37127. * release.
  37128. * Override this method to provide functionality.
  37129. */
  37130. protected onButtonUp(evt: PointerEvent): void;
  37131. /**
  37132. * Called when window becomes inactive.
  37133. * Override this method to provide functionality.
  37134. */
  37135. protected onLostFocus(): void;
  37136. private _pointerInput;
  37137. private _observer;
  37138. private _onLostFocus;
  37139. private pointA;
  37140. private pointB;
  37141. }
  37142. }
  37143. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37144. import { Nullable } from "babylonjs/types";
  37145. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37146. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37147. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37148. /**
  37149. * Manage the pointers inputs to control an arc rotate camera.
  37150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37151. */
  37152. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37153. /**
  37154. * Defines the camera the input is attached to.
  37155. */
  37156. camera: ArcRotateCamera;
  37157. /**
  37158. * Gets the class name of the current input.
  37159. * @returns the class name
  37160. */
  37161. getClassName(): string;
  37162. /**
  37163. * Defines the buttons associated with the input to handle camera move.
  37164. */
  37165. buttons: number[];
  37166. /**
  37167. * Defines the pointer angular sensibility along the X axis or how fast is
  37168. * the camera rotating.
  37169. */
  37170. angularSensibilityX: number;
  37171. /**
  37172. * Defines the pointer angular sensibility along the Y axis or how fast is
  37173. * the camera rotating.
  37174. */
  37175. angularSensibilityY: number;
  37176. /**
  37177. * Defines the pointer pinch precision or how fast is the camera zooming.
  37178. */
  37179. pinchPrecision: number;
  37180. /**
  37181. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37182. * from 0.
  37183. * It defines the percentage of current camera.radius to use as delta when
  37184. * pinch zoom is used.
  37185. */
  37186. pinchDeltaPercentage: number;
  37187. /**
  37188. * Defines the pointer panning sensibility or how fast is the camera moving.
  37189. */
  37190. panningSensibility: number;
  37191. /**
  37192. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37193. */
  37194. multiTouchPanning: boolean;
  37195. /**
  37196. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37197. * zoom (pinch) through multitouch.
  37198. */
  37199. multiTouchPanAndZoom: boolean;
  37200. /**
  37201. * Revers pinch action direction.
  37202. */
  37203. pinchInwards: boolean;
  37204. private _isPanClick;
  37205. private _twoFingerActivityCount;
  37206. private _isPinching;
  37207. /**
  37208. * Called on pointer POINTERMOVE event if only a single touch is active.
  37209. */
  37210. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37211. /**
  37212. * Called on pointer POINTERDOUBLETAP event.
  37213. */
  37214. protected onDoubleTap(type: string): void;
  37215. /**
  37216. * Called on pointer POINTERMOVE event if multiple touches are active.
  37217. */
  37218. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37219. /**
  37220. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37221. * press.
  37222. */
  37223. protected onButtonDown(evt: PointerEvent): void;
  37224. /**
  37225. * Called each time a new POINTERUP event occurs. Ie, for each button
  37226. * release.
  37227. */
  37228. protected onButtonUp(evt: PointerEvent): void;
  37229. /**
  37230. * Called when window becomes inactive.
  37231. */
  37232. protected onLostFocus(): void;
  37233. }
  37234. }
  37235. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37236. import { Nullable } from "babylonjs/types";
  37237. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37238. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37239. /**
  37240. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37242. */
  37243. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37244. /**
  37245. * Defines the camera the input is attached to.
  37246. */
  37247. camera: ArcRotateCamera;
  37248. /**
  37249. * Defines the list of key codes associated with the up action (increase alpha)
  37250. */
  37251. keysUp: number[];
  37252. /**
  37253. * Defines the list of key codes associated with the down action (decrease alpha)
  37254. */
  37255. keysDown: number[];
  37256. /**
  37257. * Defines the list of key codes associated with the left action (increase beta)
  37258. */
  37259. keysLeft: number[];
  37260. /**
  37261. * Defines the list of key codes associated with the right action (decrease beta)
  37262. */
  37263. keysRight: number[];
  37264. /**
  37265. * Defines the list of key codes associated with the reset action.
  37266. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37267. */
  37268. keysReset: number[];
  37269. /**
  37270. * Defines the panning sensibility of the inputs.
  37271. * (How fast is the camera paning)
  37272. */
  37273. panningSensibility: number;
  37274. /**
  37275. * Defines the zooming sensibility of the inputs.
  37276. * (How fast is the camera zooming)
  37277. */
  37278. zoomingSensibility: number;
  37279. /**
  37280. * Defines wether maintaining the alt key down switch the movement mode from
  37281. * orientation to zoom.
  37282. */
  37283. useAltToZoom: boolean;
  37284. /**
  37285. * Rotation speed of the camera
  37286. */
  37287. angularSpeed: number;
  37288. private _keys;
  37289. private _ctrlPressed;
  37290. private _altPressed;
  37291. private _onCanvasBlurObserver;
  37292. private _onKeyboardObserver;
  37293. private _engine;
  37294. private _scene;
  37295. /**
  37296. * Attach the input controls to a specific dom element to get the input from.
  37297. * @param element Defines the element the controls should be listened from
  37298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37299. */
  37300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37301. /**
  37302. * Detach the current controls from the specified dom element.
  37303. * @param element Defines the element to stop listening the inputs from
  37304. */
  37305. detachControl(element: Nullable<HTMLElement>): void;
  37306. /**
  37307. * Update the current camera state depending on the inputs that have been used this frame.
  37308. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37309. */
  37310. checkInputs(): void;
  37311. /**
  37312. * Gets the class name of the current intput.
  37313. * @returns the class name
  37314. */
  37315. getClassName(): string;
  37316. /**
  37317. * Get the friendly name associated with the input class.
  37318. * @returns the input friendly name
  37319. */
  37320. getSimpleName(): string;
  37321. }
  37322. }
  37323. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37324. import { Nullable } from "babylonjs/types";
  37325. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37326. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37327. /**
  37328. * Manage the mouse wheel inputs to control an arc rotate camera.
  37329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37330. */
  37331. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37332. /**
  37333. * Defines the camera the input is attached to.
  37334. */
  37335. camera: ArcRotateCamera;
  37336. /**
  37337. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37338. */
  37339. wheelPrecision: number;
  37340. /**
  37341. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37342. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37343. */
  37344. wheelDeltaPercentage: number;
  37345. private _wheel;
  37346. private _observer;
  37347. private computeDeltaFromMouseWheelLegacyEvent;
  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. * Gets the class name of the current intput.
  37361. * @returns the class name
  37362. */
  37363. getClassName(): string;
  37364. /**
  37365. * Get the friendly name associated with the input class.
  37366. * @returns the input friendly name
  37367. */
  37368. getSimpleName(): string;
  37369. }
  37370. }
  37371. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37372. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37373. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37374. /**
  37375. * Default Inputs manager for the ArcRotateCamera.
  37376. * It groups all the default supported inputs for ease of use.
  37377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37378. */
  37379. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37380. /**
  37381. * Instantiates a new ArcRotateCameraInputsManager.
  37382. * @param camera Defines the camera the inputs belong to
  37383. */
  37384. constructor(camera: ArcRotateCamera);
  37385. /**
  37386. * Add mouse wheel input support to the input manager.
  37387. * @returns the current input manager
  37388. */
  37389. addMouseWheel(): ArcRotateCameraInputsManager;
  37390. /**
  37391. * Add pointers input support to the input manager.
  37392. * @returns the current input manager
  37393. */
  37394. addPointers(): ArcRotateCameraInputsManager;
  37395. /**
  37396. * Add keyboard input support to the input manager.
  37397. * @returns the current input manager
  37398. */
  37399. addKeyboard(): ArcRotateCameraInputsManager;
  37400. }
  37401. }
  37402. declare module "babylonjs/Cameras/arcRotateCamera" {
  37403. import { Observable } from "babylonjs/Misc/observable";
  37404. import { Nullable } from "babylonjs/types";
  37405. import { Scene } from "babylonjs/scene";
  37406. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37408. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37409. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37410. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37411. import { Camera } from "babylonjs/Cameras/camera";
  37412. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37413. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37414. import { Collider } from "babylonjs/Collisions/collider";
  37415. /**
  37416. * This represents an orbital type of camera.
  37417. *
  37418. * 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.
  37419. * 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.
  37420. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37421. */
  37422. export class ArcRotateCamera extends TargetCamera {
  37423. /**
  37424. * Defines the rotation angle of the camera along the longitudinal axis.
  37425. */
  37426. alpha: number;
  37427. /**
  37428. * Defines the rotation angle of the camera along the latitudinal axis.
  37429. */
  37430. beta: number;
  37431. /**
  37432. * Defines the radius of the camera from it s target point.
  37433. */
  37434. radius: number;
  37435. protected _target: Vector3;
  37436. protected _targetHost: Nullable<AbstractMesh>;
  37437. /**
  37438. * Defines the target point of the camera.
  37439. * The camera looks towards it form the radius distance.
  37440. */
  37441. target: Vector3;
  37442. /**
  37443. * Define the current local position of the camera in the scene
  37444. */
  37445. position: Vector3;
  37446. protected _upVector: Vector3;
  37447. protected _upToYMatrix: Matrix;
  37448. protected _YToUpMatrix: Matrix;
  37449. /**
  37450. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37451. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37452. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37453. */
  37454. upVector: Vector3;
  37455. /**
  37456. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37457. */
  37458. setMatUp(): void;
  37459. /**
  37460. * Current inertia value on the longitudinal axis.
  37461. * The bigger this number the longer it will take for the camera to stop.
  37462. */
  37463. inertialAlphaOffset: number;
  37464. /**
  37465. * Current inertia value on the latitudinal axis.
  37466. * The bigger this number the longer it will take for the camera to stop.
  37467. */
  37468. inertialBetaOffset: number;
  37469. /**
  37470. * Current inertia value on the radius axis.
  37471. * The bigger this number the longer it will take for the camera to stop.
  37472. */
  37473. inertialRadiusOffset: number;
  37474. /**
  37475. * Minimum allowed angle on the longitudinal axis.
  37476. * This can help limiting how the Camera is able to move in the scene.
  37477. */
  37478. lowerAlphaLimit: Nullable<number>;
  37479. /**
  37480. * Maximum allowed angle on the longitudinal axis.
  37481. * This can help limiting how the Camera is able to move in the scene.
  37482. */
  37483. upperAlphaLimit: Nullable<number>;
  37484. /**
  37485. * Minimum allowed angle on the latitudinal axis.
  37486. * This can help limiting how the Camera is able to move in the scene.
  37487. */
  37488. lowerBetaLimit: number;
  37489. /**
  37490. * Maximum allowed angle on the latitudinal axis.
  37491. * This can help limiting how the Camera is able to move in the scene.
  37492. */
  37493. upperBetaLimit: number;
  37494. /**
  37495. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37496. * This can help limiting how the Camera is able to move in the scene.
  37497. */
  37498. lowerRadiusLimit: Nullable<number>;
  37499. /**
  37500. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37501. * This can help limiting how the Camera is able to move in the scene.
  37502. */
  37503. upperRadiusLimit: Nullable<number>;
  37504. /**
  37505. * Defines the current inertia value used during panning of the camera along the X axis.
  37506. */
  37507. inertialPanningX: number;
  37508. /**
  37509. * Defines the current inertia value used during panning of the camera along the Y axis.
  37510. */
  37511. inertialPanningY: number;
  37512. /**
  37513. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37514. * Basically if your fingers moves away from more than this distance you will be considered
  37515. * in pinch mode.
  37516. */
  37517. pinchToPanMaxDistance: number;
  37518. /**
  37519. * Defines the maximum distance the camera can pan.
  37520. * This could help keeping the cammera always in your scene.
  37521. */
  37522. panningDistanceLimit: Nullable<number>;
  37523. /**
  37524. * Defines the target of the camera before paning.
  37525. */
  37526. panningOriginTarget: Vector3;
  37527. /**
  37528. * Defines the value of the inertia used during panning.
  37529. * 0 would mean stop inertia and one would mean no decelleration at all.
  37530. */
  37531. panningInertia: number;
  37532. /**
  37533. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37534. */
  37535. angularSensibilityX: number;
  37536. /**
  37537. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37538. */
  37539. angularSensibilityY: number;
  37540. /**
  37541. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37542. */
  37543. pinchPrecision: number;
  37544. /**
  37545. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37546. * It will be used instead of pinchDeltaPrecision if different from 0.
  37547. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37548. */
  37549. pinchDeltaPercentage: number;
  37550. /**
  37551. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37552. */
  37553. panningSensibility: number;
  37554. /**
  37555. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37556. */
  37557. keysUp: number[];
  37558. /**
  37559. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37560. */
  37561. keysDown: number[];
  37562. /**
  37563. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37564. */
  37565. keysLeft: number[];
  37566. /**
  37567. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37568. */
  37569. keysRight: number[];
  37570. /**
  37571. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37572. */
  37573. wheelPrecision: number;
  37574. /**
  37575. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37576. * It will be used instead of pinchDeltaPrecision if different from 0.
  37577. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37578. */
  37579. wheelDeltaPercentage: number;
  37580. /**
  37581. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37582. */
  37583. zoomOnFactor: number;
  37584. /**
  37585. * Defines a screen offset for the camera position.
  37586. */
  37587. targetScreenOffset: Vector2;
  37588. /**
  37589. * Allows the camera to be completely reversed.
  37590. * If false the camera can not arrive upside down.
  37591. */
  37592. allowUpsideDown: boolean;
  37593. /**
  37594. * Define if double tap/click is used to restore the previously saved state of the camera.
  37595. */
  37596. useInputToRestoreState: boolean;
  37597. /** @hidden */
  37598. _viewMatrix: Matrix;
  37599. /** @hidden */
  37600. _useCtrlForPanning: boolean;
  37601. /** @hidden */
  37602. _panningMouseButton: number;
  37603. /**
  37604. * Defines the input associated to the camera.
  37605. */
  37606. inputs: ArcRotateCameraInputsManager;
  37607. /** @hidden */
  37608. _reset: () => void;
  37609. /**
  37610. * Defines the allowed panning axis.
  37611. */
  37612. panningAxis: Vector3;
  37613. protected _localDirection: Vector3;
  37614. protected _transformedDirection: Vector3;
  37615. private _bouncingBehavior;
  37616. /**
  37617. * Gets the bouncing behavior of the camera if it has been enabled.
  37618. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37619. */
  37620. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37621. /**
  37622. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37623. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37624. */
  37625. useBouncingBehavior: boolean;
  37626. private _framingBehavior;
  37627. /**
  37628. * Gets the framing behavior of the camera if it has been enabled.
  37629. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37630. */
  37631. readonly framingBehavior: Nullable<FramingBehavior>;
  37632. /**
  37633. * Defines if the framing behavior of the camera is enabled on the camera.
  37634. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37635. */
  37636. useFramingBehavior: boolean;
  37637. private _autoRotationBehavior;
  37638. /**
  37639. * Gets the auto rotation behavior of the camera if it has been enabled.
  37640. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37641. */
  37642. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37643. /**
  37644. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37645. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37646. */
  37647. useAutoRotationBehavior: boolean;
  37648. /**
  37649. * Observable triggered when the mesh target has been changed on the camera.
  37650. */
  37651. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37652. /**
  37653. * Event raised when the camera is colliding with a mesh.
  37654. */
  37655. onCollide: (collidedMesh: AbstractMesh) => void;
  37656. /**
  37657. * Defines whether the camera should check collision with the objects oh the scene.
  37658. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37659. */
  37660. checkCollisions: boolean;
  37661. /**
  37662. * Defines the collision radius of the camera.
  37663. * This simulates a sphere around the camera.
  37664. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37665. */
  37666. collisionRadius: Vector3;
  37667. protected _collider: Collider;
  37668. protected _previousPosition: Vector3;
  37669. protected _collisionVelocity: Vector3;
  37670. protected _newPosition: Vector3;
  37671. protected _previousAlpha: number;
  37672. protected _previousBeta: number;
  37673. protected _previousRadius: number;
  37674. protected _collisionTriggered: boolean;
  37675. protected _targetBoundingCenter: Nullable<Vector3>;
  37676. private _computationVector;
  37677. /**
  37678. * Instantiates a new ArcRotateCamera in a given scene
  37679. * @param name Defines the name of the camera
  37680. * @param alpha Defines the camera rotation along the logitudinal axis
  37681. * @param beta Defines the camera rotation along the latitudinal axis
  37682. * @param radius Defines the camera distance from its target
  37683. * @param target Defines the camera target
  37684. * @param scene Defines the scene the camera belongs to
  37685. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37686. */
  37687. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37688. /** @hidden */
  37689. _initCache(): void;
  37690. /** @hidden */
  37691. _updateCache(ignoreParentClass?: boolean): void;
  37692. protected _getTargetPosition(): Vector3;
  37693. private _storedAlpha;
  37694. private _storedBeta;
  37695. private _storedRadius;
  37696. private _storedTarget;
  37697. private _storedTargetScreenOffset;
  37698. /**
  37699. * Stores the current state of the camera (alpha, beta, radius and target)
  37700. * @returns the camera itself
  37701. */
  37702. storeState(): Camera;
  37703. /**
  37704. * @hidden
  37705. * Restored camera state. You must call storeState() first
  37706. */
  37707. _restoreStateValues(): boolean;
  37708. /** @hidden */
  37709. _isSynchronizedViewMatrix(): boolean;
  37710. /**
  37711. * Attached controls to the current camera.
  37712. * @param element Defines the element the controls should be listened from
  37713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37714. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37715. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37716. */
  37717. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37718. /**
  37719. * Detach the current controls from the camera.
  37720. * The camera will stop reacting to inputs.
  37721. * @param element Defines the element to stop listening the inputs from
  37722. */
  37723. detachControl(element: HTMLElement): void;
  37724. /** @hidden */
  37725. _checkInputs(): void;
  37726. protected _checkLimits(): void;
  37727. /**
  37728. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37729. */
  37730. rebuildAnglesAndRadius(): void;
  37731. /**
  37732. * Use a position to define the current camera related information like aplha, beta and radius
  37733. * @param position Defines the position to set the camera at
  37734. */
  37735. setPosition(position: Vector3): void;
  37736. /**
  37737. * Defines the target the camera should look at.
  37738. * This will automatically adapt alpha beta and radius to fit within the new target.
  37739. * @param target Defines the new target as a Vector or a mesh
  37740. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37741. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37742. */
  37743. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37744. /** @hidden */
  37745. _getViewMatrix(): Matrix;
  37746. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37747. /**
  37748. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37749. * @param meshes Defines the mesh to zoom on
  37750. * @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)
  37751. */
  37752. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37753. /**
  37754. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37755. * The target will be changed but the radius
  37756. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37757. * @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)
  37758. */
  37759. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37760. min: Vector3;
  37761. max: Vector3;
  37762. distance: number;
  37763. }, doNotUpdateMaxZ?: boolean): void;
  37764. /**
  37765. * @override
  37766. * Override Camera.createRigCamera
  37767. */
  37768. createRigCamera(name: string, cameraIndex: number): Camera;
  37769. /**
  37770. * @hidden
  37771. * @override
  37772. * Override Camera._updateRigCameras
  37773. */
  37774. _updateRigCameras(): void;
  37775. /**
  37776. * Destroy the camera and release the current resources hold by it.
  37777. */
  37778. dispose(): void;
  37779. /**
  37780. * Gets the current object class name.
  37781. * @return the class name
  37782. */
  37783. getClassName(): string;
  37784. }
  37785. }
  37786. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37787. import { Behavior } from "babylonjs/Behaviors/behavior";
  37788. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37789. /**
  37790. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37792. */
  37793. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37794. /**
  37795. * Gets the name of the behavior.
  37796. */
  37797. readonly name: string;
  37798. private _zoomStopsAnimation;
  37799. private _idleRotationSpeed;
  37800. private _idleRotationWaitTime;
  37801. private _idleRotationSpinupTime;
  37802. /**
  37803. * Sets the flag that indicates if user zooming should stop animation.
  37804. */
  37805. /**
  37806. * Gets the flag that indicates if user zooming should stop animation.
  37807. */
  37808. zoomStopsAnimation: boolean;
  37809. /**
  37810. * Sets the default speed at which the camera rotates around the model.
  37811. */
  37812. /**
  37813. * Gets the default speed at which the camera rotates around the model.
  37814. */
  37815. idleRotationSpeed: number;
  37816. /**
  37817. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37818. */
  37819. /**
  37820. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37821. */
  37822. idleRotationWaitTime: number;
  37823. /**
  37824. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37825. */
  37826. /**
  37827. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37828. */
  37829. idleRotationSpinupTime: number;
  37830. /**
  37831. * Gets a value indicating if the camera is currently rotating because of this behavior
  37832. */
  37833. readonly rotationInProgress: boolean;
  37834. private _onPrePointerObservableObserver;
  37835. private _onAfterCheckInputsObserver;
  37836. private _attachedCamera;
  37837. private _isPointerDown;
  37838. private _lastFrameTime;
  37839. private _lastInteractionTime;
  37840. private _cameraRotationSpeed;
  37841. /**
  37842. * Initializes the behavior.
  37843. */
  37844. init(): void;
  37845. /**
  37846. * Attaches the behavior to its arc rotate camera.
  37847. * @param camera Defines the camera to attach the behavior to
  37848. */
  37849. attach(camera: ArcRotateCamera): void;
  37850. /**
  37851. * Detaches the behavior from its current arc rotate camera.
  37852. */
  37853. detach(): void;
  37854. /**
  37855. * Returns true if user is scrolling.
  37856. * @return true if user is scrolling.
  37857. */
  37858. private _userIsZooming;
  37859. private _lastFrameRadius;
  37860. private _shouldAnimationStopForInteraction;
  37861. /**
  37862. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37863. */
  37864. private _applyUserInteraction;
  37865. private _userIsMoving;
  37866. }
  37867. }
  37868. declare module "babylonjs/Behaviors/Cameras/index" {
  37869. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37870. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37871. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37872. }
  37873. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37874. import { Mesh } from "babylonjs/Meshes/mesh";
  37875. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37876. import { Behavior } from "babylonjs/Behaviors/behavior";
  37877. /**
  37878. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37879. */
  37880. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37881. private ui;
  37882. /**
  37883. * The name of the behavior
  37884. */
  37885. name: string;
  37886. /**
  37887. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37888. */
  37889. distanceAwayFromFace: number;
  37890. /**
  37891. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37892. */
  37893. distanceAwayFromBottomOfFace: number;
  37894. private _faceVectors;
  37895. private _target;
  37896. private _scene;
  37897. private _onRenderObserver;
  37898. private _tmpMatrix;
  37899. private _tmpVector;
  37900. /**
  37901. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37902. * @param ui The transform node that should be attched to the mesh
  37903. */
  37904. constructor(ui: TransformNode);
  37905. /**
  37906. * Initializes the behavior
  37907. */
  37908. init(): void;
  37909. private _closestFace;
  37910. private _zeroVector;
  37911. private _lookAtTmpMatrix;
  37912. private _lookAtToRef;
  37913. /**
  37914. * Attaches the AttachToBoxBehavior to the passed in mesh
  37915. * @param target The mesh that the specified node will be attached to
  37916. */
  37917. attach(target: Mesh): void;
  37918. /**
  37919. * Detaches the behavior from the mesh
  37920. */
  37921. detach(): void;
  37922. }
  37923. }
  37924. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37925. import { Behavior } from "babylonjs/Behaviors/behavior";
  37926. import { Mesh } from "babylonjs/Meshes/mesh";
  37927. /**
  37928. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37929. */
  37930. export class FadeInOutBehavior implements Behavior<Mesh> {
  37931. /**
  37932. * Time in milliseconds to delay before fading in (Default: 0)
  37933. */
  37934. delay: number;
  37935. /**
  37936. * Time in milliseconds for the mesh to fade in (Default: 300)
  37937. */
  37938. fadeInTime: number;
  37939. private _millisecondsPerFrame;
  37940. private _hovered;
  37941. private _hoverValue;
  37942. private _ownerNode;
  37943. /**
  37944. * Instatiates the FadeInOutBehavior
  37945. */
  37946. constructor();
  37947. /**
  37948. * The name of the behavior
  37949. */
  37950. readonly name: string;
  37951. /**
  37952. * Initializes the behavior
  37953. */
  37954. init(): void;
  37955. /**
  37956. * Attaches the fade behavior on the passed in mesh
  37957. * @param ownerNode The mesh that will be faded in/out once attached
  37958. */
  37959. attach(ownerNode: Mesh): void;
  37960. /**
  37961. * Detaches the behavior from the mesh
  37962. */
  37963. detach(): void;
  37964. /**
  37965. * Triggers the mesh to begin fading in or out
  37966. * @param value if the object should fade in or out (true to fade in)
  37967. */
  37968. fadeIn(value: boolean): void;
  37969. private _update;
  37970. private _setAllVisibility;
  37971. }
  37972. }
  37973. declare module "babylonjs/Misc/pivotTools" {
  37974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37975. /**
  37976. * Class containing a set of static utilities functions for managing Pivots
  37977. * @hidden
  37978. */
  37979. export class PivotTools {
  37980. private static _PivotCached;
  37981. private static _OldPivotPoint;
  37982. private static _PivotTranslation;
  37983. private static _PivotTmpVector;
  37984. /** @hidden */
  37985. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37986. /** @hidden */
  37987. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37988. }
  37989. }
  37990. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37991. import { Scene } from "babylonjs/scene";
  37992. import { Vector4 } from "babylonjs/Maths/math.vector";
  37993. import { Mesh } from "babylonjs/Meshes/mesh";
  37994. import { Nullable } from "babylonjs/types";
  37995. import { Plane } from "babylonjs/Maths/math.plane";
  37996. /**
  37997. * Class containing static functions to help procedurally build meshes
  37998. */
  37999. export class PlaneBuilder {
  38000. /**
  38001. * Creates a plane mesh
  38002. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38003. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38004. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38008. * @param name defines the name of the mesh
  38009. * @param options defines the options used to create the mesh
  38010. * @param scene defines the hosting scene
  38011. * @returns the plane mesh
  38012. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38013. */
  38014. static CreatePlane(name: string, options: {
  38015. size?: number;
  38016. width?: number;
  38017. height?: number;
  38018. sideOrientation?: number;
  38019. frontUVs?: Vector4;
  38020. backUVs?: Vector4;
  38021. updatable?: boolean;
  38022. sourcePlane?: Plane;
  38023. }, scene?: Nullable<Scene>): Mesh;
  38024. }
  38025. }
  38026. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38027. import { Behavior } from "babylonjs/Behaviors/behavior";
  38028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38029. import { Observable } from "babylonjs/Misc/observable";
  38030. import { Vector3 } from "babylonjs/Maths/math.vector";
  38031. import { Ray } from "babylonjs/Culling/ray";
  38032. import "babylonjs/Meshes/Builders/planeBuilder";
  38033. /**
  38034. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38035. */
  38036. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38037. private static _AnyMouseID;
  38038. /**
  38039. * Abstract mesh the behavior is set on
  38040. */
  38041. attachedNode: AbstractMesh;
  38042. private _dragPlane;
  38043. private _scene;
  38044. private _pointerObserver;
  38045. private _beforeRenderObserver;
  38046. private static _planeScene;
  38047. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38048. /**
  38049. * 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)
  38050. */
  38051. maxDragAngle: number;
  38052. /**
  38053. * @hidden
  38054. */
  38055. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38056. /**
  38057. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38058. */
  38059. currentDraggingPointerID: number;
  38060. /**
  38061. * The last position where the pointer hit the drag plane in world space
  38062. */
  38063. lastDragPosition: Vector3;
  38064. /**
  38065. * If the behavior is currently in a dragging state
  38066. */
  38067. dragging: boolean;
  38068. /**
  38069. * 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)
  38070. */
  38071. dragDeltaRatio: number;
  38072. /**
  38073. * If the drag plane orientation should be updated during the dragging (Default: true)
  38074. */
  38075. updateDragPlane: boolean;
  38076. private _debugMode;
  38077. private _moving;
  38078. /**
  38079. * Fires each time the attached mesh is dragged with the pointer
  38080. * * delta between last drag position and current drag position in world space
  38081. * * dragDistance along the drag axis
  38082. * * dragPlaneNormal normal of the current drag plane used during the drag
  38083. * * dragPlanePoint in world space where the drag intersects the drag plane
  38084. */
  38085. onDragObservable: Observable<{
  38086. delta: Vector3;
  38087. dragPlanePoint: Vector3;
  38088. dragPlaneNormal: Vector3;
  38089. dragDistance: number;
  38090. pointerId: number;
  38091. }>;
  38092. /**
  38093. * Fires each time a drag begins (eg. mouse down on mesh)
  38094. */
  38095. onDragStartObservable: Observable<{
  38096. dragPlanePoint: Vector3;
  38097. pointerId: number;
  38098. }>;
  38099. /**
  38100. * Fires each time a drag ends (eg. mouse release after drag)
  38101. */
  38102. onDragEndObservable: Observable<{
  38103. dragPlanePoint: Vector3;
  38104. pointerId: number;
  38105. }>;
  38106. /**
  38107. * If the attached mesh should be moved when dragged
  38108. */
  38109. moveAttached: boolean;
  38110. /**
  38111. * If the drag behavior will react to drag events (Default: true)
  38112. */
  38113. enabled: boolean;
  38114. /**
  38115. * If pointer events should start and release the drag (Default: true)
  38116. */
  38117. startAndReleaseDragOnPointerEvents: boolean;
  38118. /**
  38119. * If camera controls should be detached during the drag
  38120. */
  38121. detachCameraControls: boolean;
  38122. /**
  38123. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38124. */
  38125. useObjectOrienationForDragging: boolean;
  38126. private _options;
  38127. /**
  38128. * Creates a pointer drag behavior that can be attached to a mesh
  38129. * @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)
  38130. */
  38131. constructor(options?: {
  38132. dragAxis?: Vector3;
  38133. dragPlaneNormal?: Vector3;
  38134. });
  38135. /**
  38136. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38137. */
  38138. validateDrag: (targetPosition: Vector3) => boolean;
  38139. /**
  38140. * The name of the behavior
  38141. */
  38142. readonly name: string;
  38143. /**
  38144. * Initializes the behavior
  38145. */
  38146. init(): void;
  38147. private _tmpVector;
  38148. private _alternatePickedPoint;
  38149. private _worldDragAxis;
  38150. private _targetPosition;
  38151. private _attachedElement;
  38152. /**
  38153. * Attaches the drag behavior the passed in mesh
  38154. * @param ownerNode The mesh that will be dragged around once attached
  38155. * @param predicate Predicate to use for pick filtering
  38156. */
  38157. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38158. /**
  38159. * Force relase the drag action by code.
  38160. */
  38161. releaseDrag(): void;
  38162. private _startDragRay;
  38163. private _lastPointerRay;
  38164. /**
  38165. * Simulates the start of a pointer drag event on the behavior
  38166. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38167. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38168. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38169. */
  38170. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38171. private _startDrag;
  38172. private _dragDelta;
  38173. private _moveDrag;
  38174. private _pickWithRayOnDragPlane;
  38175. private _pointA;
  38176. private _pointB;
  38177. private _pointC;
  38178. private _lineA;
  38179. private _lineB;
  38180. private _localAxis;
  38181. private _lookAt;
  38182. private _updateDragPlanePosition;
  38183. /**
  38184. * Detaches the behavior from the mesh
  38185. */
  38186. detach(): void;
  38187. }
  38188. }
  38189. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38190. import { Mesh } from "babylonjs/Meshes/mesh";
  38191. import { Behavior } from "babylonjs/Behaviors/behavior";
  38192. /**
  38193. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38194. */
  38195. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38196. private _dragBehaviorA;
  38197. private _dragBehaviorB;
  38198. private _startDistance;
  38199. private _initialScale;
  38200. private _targetScale;
  38201. private _ownerNode;
  38202. private _sceneRenderObserver;
  38203. /**
  38204. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38205. */
  38206. constructor();
  38207. /**
  38208. * The name of the behavior
  38209. */
  38210. readonly name: string;
  38211. /**
  38212. * Initializes the behavior
  38213. */
  38214. init(): void;
  38215. private _getCurrentDistance;
  38216. /**
  38217. * Attaches the scale behavior the passed in mesh
  38218. * @param ownerNode The mesh that will be scaled around once attached
  38219. */
  38220. attach(ownerNode: Mesh): void;
  38221. /**
  38222. * Detaches the behavior from the mesh
  38223. */
  38224. detach(): void;
  38225. }
  38226. }
  38227. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38228. import { Behavior } from "babylonjs/Behaviors/behavior";
  38229. import { Mesh } from "babylonjs/Meshes/mesh";
  38230. import { Observable } from "babylonjs/Misc/observable";
  38231. /**
  38232. * 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
  38233. */
  38234. export class SixDofDragBehavior implements Behavior<Mesh> {
  38235. private static _virtualScene;
  38236. private _ownerNode;
  38237. private _sceneRenderObserver;
  38238. private _scene;
  38239. private _targetPosition;
  38240. private _virtualOriginMesh;
  38241. private _virtualDragMesh;
  38242. private _pointerObserver;
  38243. private _moving;
  38244. private _startingOrientation;
  38245. /**
  38246. * 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)
  38247. */
  38248. private zDragFactor;
  38249. /**
  38250. * If the object should rotate to face the drag origin
  38251. */
  38252. rotateDraggedObject: boolean;
  38253. /**
  38254. * If the behavior is currently in a dragging state
  38255. */
  38256. dragging: boolean;
  38257. /**
  38258. * 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)
  38259. */
  38260. dragDeltaRatio: number;
  38261. /**
  38262. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38263. */
  38264. currentDraggingPointerID: number;
  38265. /**
  38266. * If camera controls should be detached during the drag
  38267. */
  38268. detachCameraControls: boolean;
  38269. /**
  38270. * Fires each time a drag starts
  38271. */
  38272. onDragStartObservable: Observable<{}>;
  38273. /**
  38274. * Fires each time a drag ends (eg. mouse release after drag)
  38275. */
  38276. onDragEndObservable: Observable<{}>;
  38277. /**
  38278. * 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
  38279. */
  38280. constructor();
  38281. /**
  38282. * The name of the behavior
  38283. */
  38284. readonly name: string;
  38285. /**
  38286. * Initializes the behavior
  38287. */
  38288. init(): void;
  38289. /**
  38290. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38291. */
  38292. private readonly _pointerCamera;
  38293. /**
  38294. * Attaches the scale behavior the passed in mesh
  38295. * @param ownerNode The mesh that will be scaled around once attached
  38296. */
  38297. attach(ownerNode: Mesh): void;
  38298. /**
  38299. * Detaches the behavior from the mesh
  38300. */
  38301. detach(): void;
  38302. }
  38303. }
  38304. declare module "babylonjs/Behaviors/Meshes/index" {
  38305. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38306. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38307. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38308. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38309. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38310. }
  38311. declare module "babylonjs/Behaviors/index" {
  38312. export * from "babylonjs/Behaviors/behavior";
  38313. export * from "babylonjs/Behaviors/Cameras/index";
  38314. export * from "babylonjs/Behaviors/Meshes/index";
  38315. }
  38316. declare module "babylonjs/Bones/boneIKController" {
  38317. import { Bone } from "babylonjs/Bones/bone";
  38318. import { Vector3 } from "babylonjs/Maths/math.vector";
  38319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38320. import { Nullable } from "babylonjs/types";
  38321. /**
  38322. * Class used to apply inverse kinematics to bones
  38323. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38324. */
  38325. export class BoneIKController {
  38326. private static _tmpVecs;
  38327. private static _tmpQuat;
  38328. private static _tmpMats;
  38329. /**
  38330. * Gets or sets the target mesh
  38331. */
  38332. targetMesh: AbstractMesh;
  38333. /** Gets or sets the mesh used as pole */
  38334. poleTargetMesh: AbstractMesh;
  38335. /**
  38336. * Gets or sets the bone used as pole
  38337. */
  38338. poleTargetBone: Nullable<Bone>;
  38339. /**
  38340. * Gets or sets the target position
  38341. */
  38342. targetPosition: Vector3;
  38343. /**
  38344. * Gets or sets the pole target position
  38345. */
  38346. poleTargetPosition: Vector3;
  38347. /**
  38348. * Gets or sets the pole target local offset
  38349. */
  38350. poleTargetLocalOffset: Vector3;
  38351. /**
  38352. * Gets or sets the pole angle
  38353. */
  38354. poleAngle: number;
  38355. /**
  38356. * Gets or sets the mesh associated with the controller
  38357. */
  38358. mesh: AbstractMesh;
  38359. /**
  38360. * 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)
  38361. */
  38362. slerpAmount: number;
  38363. private _bone1Quat;
  38364. private _bone1Mat;
  38365. private _bone2Ang;
  38366. private _bone1;
  38367. private _bone2;
  38368. private _bone1Length;
  38369. private _bone2Length;
  38370. private _maxAngle;
  38371. private _maxReach;
  38372. private _rightHandedSystem;
  38373. private _bendAxis;
  38374. private _slerping;
  38375. private _adjustRoll;
  38376. /**
  38377. * Gets or sets maximum allowed angle
  38378. */
  38379. maxAngle: number;
  38380. /**
  38381. * Creates a new BoneIKController
  38382. * @param mesh defines the mesh to control
  38383. * @param bone defines the bone to control
  38384. * @param options defines options to set up the controller
  38385. */
  38386. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38387. targetMesh?: AbstractMesh;
  38388. poleTargetMesh?: AbstractMesh;
  38389. poleTargetBone?: Bone;
  38390. poleTargetLocalOffset?: Vector3;
  38391. poleAngle?: number;
  38392. bendAxis?: Vector3;
  38393. maxAngle?: number;
  38394. slerpAmount?: number;
  38395. });
  38396. private _setMaxAngle;
  38397. /**
  38398. * Force the controller to update the bones
  38399. */
  38400. update(): void;
  38401. }
  38402. }
  38403. declare module "babylonjs/Bones/boneLookController" {
  38404. import { Vector3 } from "babylonjs/Maths/math.vector";
  38405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38406. import { Bone } from "babylonjs/Bones/bone";
  38407. import { Space } from "babylonjs/Maths/math.axis";
  38408. /**
  38409. * Class used to make a bone look toward a point in space
  38410. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38411. */
  38412. export class BoneLookController {
  38413. private static _tmpVecs;
  38414. private static _tmpQuat;
  38415. private static _tmpMats;
  38416. /**
  38417. * The target Vector3 that the bone will look at
  38418. */
  38419. target: Vector3;
  38420. /**
  38421. * The mesh that the bone is attached to
  38422. */
  38423. mesh: AbstractMesh;
  38424. /**
  38425. * The bone that will be looking to the target
  38426. */
  38427. bone: Bone;
  38428. /**
  38429. * The up axis of the coordinate system that is used when the bone is rotated
  38430. */
  38431. upAxis: Vector3;
  38432. /**
  38433. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38434. */
  38435. upAxisSpace: Space;
  38436. /**
  38437. * Used to make an adjustment to the yaw of the bone
  38438. */
  38439. adjustYaw: number;
  38440. /**
  38441. * Used to make an adjustment to the pitch of the bone
  38442. */
  38443. adjustPitch: number;
  38444. /**
  38445. * Used to make an adjustment to the roll of the bone
  38446. */
  38447. adjustRoll: number;
  38448. /**
  38449. * 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)
  38450. */
  38451. slerpAmount: number;
  38452. private _minYaw;
  38453. private _maxYaw;
  38454. private _minPitch;
  38455. private _maxPitch;
  38456. private _minYawSin;
  38457. private _minYawCos;
  38458. private _maxYawSin;
  38459. private _maxYawCos;
  38460. private _midYawConstraint;
  38461. private _minPitchTan;
  38462. private _maxPitchTan;
  38463. private _boneQuat;
  38464. private _slerping;
  38465. private _transformYawPitch;
  38466. private _transformYawPitchInv;
  38467. private _firstFrameSkipped;
  38468. private _yawRange;
  38469. private _fowardAxis;
  38470. /**
  38471. * Gets or sets the minimum yaw angle that the bone can look to
  38472. */
  38473. minYaw: number;
  38474. /**
  38475. * Gets or sets the maximum yaw angle that the bone can look to
  38476. */
  38477. maxYaw: number;
  38478. /**
  38479. * Gets or sets the minimum pitch angle that the bone can look to
  38480. */
  38481. minPitch: number;
  38482. /**
  38483. * Gets or sets the maximum pitch angle that the bone can look to
  38484. */
  38485. maxPitch: number;
  38486. /**
  38487. * Create a BoneLookController
  38488. * @param mesh the mesh that the bone belongs to
  38489. * @param bone the bone that will be looking to the target
  38490. * @param target the target Vector3 to look at
  38491. * @param options optional settings:
  38492. * * maxYaw: the maximum angle the bone will yaw to
  38493. * * minYaw: the minimum angle the bone will yaw to
  38494. * * maxPitch: the maximum angle the bone will pitch to
  38495. * * minPitch: the minimum angle the bone will yaw to
  38496. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38497. * * upAxis: the up axis of the coordinate system
  38498. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38499. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38500. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38501. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38502. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38503. * * adjustRoll: used to make an adjustment to the roll of the bone
  38504. **/
  38505. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38506. maxYaw?: number;
  38507. minYaw?: number;
  38508. maxPitch?: number;
  38509. minPitch?: number;
  38510. slerpAmount?: number;
  38511. upAxis?: Vector3;
  38512. upAxisSpace?: Space;
  38513. yawAxis?: Vector3;
  38514. pitchAxis?: Vector3;
  38515. adjustYaw?: number;
  38516. adjustPitch?: number;
  38517. adjustRoll?: number;
  38518. });
  38519. /**
  38520. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38521. */
  38522. update(): void;
  38523. private _getAngleDiff;
  38524. private _getAngleBetween;
  38525. private _isAngleBetween;
  38526. }
  38527. }
  38528. declare module "babylonjs/Bones/index" {
  38529. export * from "babylonjs/Bones/bone";
  38530. export * from "babylonjs/Bones/boneIKController";
  38531. export * from "babylonjs/Bones/boneLookController";
  38532. export * from "babylonjs/Bones/skeleton";
  38533. }
  38534. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38535. import { Nullable } from "babylonjs/types";
  38536. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38537. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38538. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38539. /**
  38540. * Manage the gamepad inputs to control an arc rotate camera.
  38541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38542. */
  38543. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38544. /**
  38545. * Defines the camera the input is attached to.
  38546. */
  38547. camera: ArcRotateCamera;
  38548. /**
  38549. * Defines the gamepad the input is gathering event from.
  38550. */
  38551. gamepad: Nullable<Gamepad>;
  38552. /**
  38553. * Defines the gamepad rotation sensiblity.
  38554. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38555. */
  38556. gamepadRotationSensibility: number;
  38557. /**
  38558. * Defines the gamepad move sensiblity.
  38559. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38560. */
  38561. gamepadMoveSensibility: number;
  38562. private _onGamepadConnectedObserver;
  38563. private _onGamepadDisconnectedObserver;
  38564. /**
  38565. * Attach the input controls to a specific dom element to get the input from.
  38566. * @param element Defines the element the controls should be listened from
  38567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38568. */
  38569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38570. /**
  38571. * Detach the current controls from the specified dom element.
  38572. * @param element Defines the element to stop listening the inputs from
  38573. */
  38574. detachControl(element: Nullable<HTMLElement>): void;
  38575. /**
  38576. * Update the current camera state depending on the inputs that have been used this frame.
  38577. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38578. */
  38579. checkInputs(): void;
  38580. /**
  38581. * Gets the class name of the current intput.
  38582. * @returns the class name
  38583. */
  38584. getClassName(): string;
  38585. /**
  38586. * Get the friendly name associated with the input class.
  38587. * @returns the input friendly name
  38588. */
  38589. getSimpleName(): string;
  38590. }
  38591. }
  38592. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38593. import { Nullable } from "babylonjs/types";
  38594. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38595. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38596. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38597. interface ArcRotateCameraInputsManager {
  38598. /**
  38599. * Add orientation input support to the input manager.
  38600. * @returns the current input manager
  38601. */
  38602. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38603. }
  38604. }
  38605. /**
  38606. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38608. */
  38609. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38610. /**
  38611. * Defines the camera the input is attached to.
  38612. */
  38613. camera: ArcRotateCamera;
  38614. /**
  38615. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38616. */
  38617. alphaCorrection: number;
  38618. /**
  38619. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38620. */
  38621. gammaCorrection: number;
  38622. private _alpha;
  38623. private _gamma;
  38624. private _dirty;
  38625. private _deviceOrientationHandler;
  38626. /**
  38627. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38628. */
  38629. constructor();
  38630. /**
  38631. * Attach the input controls to a specific dom element to get the input from.
  38632. * @param element Defines the element the controls should be listened from
  38633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38634. */
  38635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38636. /** @hidden */
  38637. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38638. /**
  38639. * Update the current camera state depending on the inputs that have been used this frame.
  38640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38641. */
  38642. checkInputs(): void;
  38643. /**
  38644. * Detach the current controls from the specified dom element.
  38645. * @param element Defines the element to stop listening the inputs from
  38646. */
  38647. detachControl(element: Nullable<HTMLElement>): void;
  38648. /**
  38649. * Gets the class name of the current intput.
  38650. * @returns the class name
  38651. */
  38652. getClassName(): string;
  38653. /**
  38654. * Get the friendly name associated with the input class.
  38655. * @returns the input friendly name
  38656. */
  38657. getSimpleName(): string;
  38658. }
  38659. }
  38660. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38661. import { Nullable } from "babylonjs/types";
  38662. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38663. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38664. /**
  38665. * Listen to mouse events to control the camera.
  38666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38667. */
  38668. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38669. /**
  38670. * Defines the camera the input is attached to.
  38671. */
  38672. camera: FlyCamera;
  38673. /**
  38674. * Defines if touch is enabled. (Default is true.)
  38675. */
  38676. touchEnabled: boolean;
  38677. /**
  38678. * Defines the buttons associated with the input to handle camera rotation.
  38679. */
  38680. buttons: number[];
  38681. /**
  38682. * Assign buttons for Yaw control.
  38683. */
  38684. buttonsYaw: number[];
  38685. /**
  38686. * Assign buttons for Pitch control.
  38687. */
  38688. buttonsPitch: number[];
  38689. /**
  38690. * Assign buttons for Roll control.
  38691. */
  38692. buttonsRoll: number[];
  38693. /**
  38694. * Detect if any button is being pressed while mouse is moved.
  38695. * -1 = Mouse locked.
  38696. * 0 = Left button.
  38697. * 1 = Middle Button.
  38698. * 2 = Right Button.
  38699. */
  38700. activeButton: number;
  38701. /**
  38702. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38703. * Higher values reduce its sensitivity.
  38704. */
  38705. angularSensibility: number;
  38706. private _mousemoveCallback;
  38707. private _observer;
  38708. private _rollObserver;
  38709. private previousPosition;
  38710. private noPreventDefault;
  38711. private element;
  38712. /**
  38713. * Listen to mouse events to control the camera.
  38714. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38716. */
  38717. constructor(touchEnabled?: boolean);
  38718. /**
  38719. * Attach the mouse control to the HTML DOM element.
  38720. * @param element Defines the element that listens to the input events.
  38721. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38722. */
  38723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38724. /**
  38725. * Detach the current controls from the specified dom element.
  38726. * @param element Defines the element to stop listening the inputs from
  38727. */
  38728. detachControl(element: Nullable<HTMLElement>): void;
  38729. /**
  38730. * Gets the class name of the current input.
  38731. * @returns the class name.
  38732. */
  38733. getClassName(): string;
  38734. /**
  38735. * Get the friendly name associated with the input class.
  38736. * @returns the input's friendly name.
  38737. */
  38738. getSimpleName(): string;
  38739. private _pointerInput;
  38740. private _onMouseMove;
  38741. /**
  38742. * Rotate camera by mouse offset.
  38743. */
  38744. private rotateCamera;
  38745. }
  38746. }
  38747. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38748. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38749. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38750. /**
  38751. * Default Inputs manager for the FlyCamera.
  38752. * It groups all the default supported inputs for ease of use.
  38753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38754. */
  38755. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38756. /**
  38757. * Instantiates a new FlyCameraInputsManager.
  38758. * @param camera Defines the camera the inputs belong to.
  38759. */
  38760. constructor(camera: FlyCamera);
  38761. /**
  38762. * Add keyboard input support to the input manager.
  38763. * @returns the new FlyCameraKeyboardMoveInput().
  38764. */
  38765. addKeyboard(): FlyCameraInputsManager;
  38766. /**
  38767. * Add mouse input support to the input manager.
  38768. * @param touchEnabled Enable touch screen support.
  38769. * @returns the new FlyCameraMouseInput().
  38770. */
  38771. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38772. }
  38773. }
  38774. declare module "babylonjs/Cameras/flyCamera" {
  38775. import { Scene } from "babylonjs/scene";
  38776. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38778. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38779. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38780. /**
  38781. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38782. * such as in a 3D Space Shooter or a Flight Simulator.
  38783. */
  38784. export class FlyCamera extends TargetCamera {
  38785. /**
  38786. * Define the collision ellipsoid of the camera.
  38787. * This is helpful for simulating a camera body, like a player's body.
  38788. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38789. */
  38790. ellipsoid: Vector3;
  38791. /**
  38792. * Define an offset for the position of the ellipsoid around the camera.
  38793. * This can be helpful if the camera is attached away from the player's body center,
  38794. * such as at its head.
  38795. */
  38796. ellipsoidOffset: Vector3;
  38797. /**
  38798. * Enable or disable collisions of the camera with the rest of the scene objects.
  38799. */
  38800. checkCollisions: boolean;
  38801. /**
  38802. * Enable or disable gravity on the camera.
  38803. */
  38804. applyGravity: boolean;
  38805. /**
  38806. * Define the current direction the camera is moving to.
  38807. */
  38808. cameraDirection: Vector3;
  38809. /**
  38810. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38811. * This overrides and empties cameraRotation.
  38812. */
  38813. rotationQuaternion: Quaternion;
  38814. /**
  38815. * Track Roll to maintain the wanted Rolling when looking around.
  38816. */
  38817. _trackRoll: number;
  38818. /**
  38819. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38820. */
  38821. rollCorrect: number;
  38822. /**
  38823. * Mimic a banked turn, Rolling the camera when Yawing.
  38824. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38825. */
  38826. bankedTurn: boolean;
  38827. /**
  38828. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38829. */
  38830. bankedTurnLimit: number;
  38831. /**
  38832. * Value of 0 disables the banked Roll.
  38833. * Value of 1 is equal to the Yaw angle in radians.
  38834. */
  38835. bankedTurnMultiplier: number;
  38836. /**
  38837. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38838. */
  38839. inputs: FlyCameraInputsManager;
  38840. /**
  38841. * Gets the input sensibility for mouse input.
  38842. * Higher values reduce sensitivity.
  38843. */
  38844. /**
  38845. * Sets the input sensibility for a mouse input.
  38846. * Higher values reduce sensitivity.
  38847. */
  38848. angularSensibility: number;
  38849. /**
  38850. * Get the keys for camera movement forward.
  38851. */
  38852. /**
  38853. * Set the keys for camera movement forward.
  38854. */
  38855. keysForward: number[];
  38856. /**
  38857. * Get the keys for camera movement backward.
  38858. */
  38859. keysBackward: number[];
  38860. /**
  38861. * Get the keys for camera movement up.
  38862. */
  38863. /**
  38864. * Set the keys for camera movement up.
  38865. */
  38866. keysUp: number[];
  38867. /**
  38868. * Get the keys for camera movement down.
  38869. */
  38870. /**
  38871. * Set the keys for camera movement down.
  38872. */
  38873. keysDown: number[];
  38874. /**
  38875. * Get the keys for camera movement left.
  38876. */
  38877. /**
  38878. * Set the keys for camera movement left.
  38879. */
  38880. keysLeft: number[];
  38881. /**
  38882. * Set the keys for camera movement right.
  38883. */
  38884. /**
  38885. * Set the keys for camera movement right.
  38886. */
  38887. keysRight: number[];
  38888. /**
  38889. * Event raised when the camera collides with a mesh in the scene.
  38890. */
  38891. onCollide: (collidedMesh: AbstractMesh) => void;
  38892. private _collider;
  38893. private _needMoveForGravity;
  38894. private _oldPosition;
  38895. private _diffPosition;
  38896. private _newPosition;
  38897. /** @hidden */
  38898. _localDirection: Vector3;
  38899. /** @hidden */
  38900. _transformedDirection: Vector3;
  38901. /**
  38902. * Instantiates a FlyCamera.
  38903. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38904. * such as in a 3D Space Shooter or a Flight Simulator.
  38905. * @param name Define the name of the camera in the scene.
  38906. * @param position Define the starting position of the camera in the scene.
  38907. * @param scene Define the scene the camera belongs to.
  38908. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38909. */
  38910. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38911. /**
  38912. * Attach a control to the HTML DOM element.
  38913. * @param element Defines the element that listens to the input events.
  38914. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38915. */
  38916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38917. /**
  38918. * Detach a control from the HTML DOM element.
  38919. * The camera will stop reacting to that input.
  38920. * @param element Defines the element that listens to the input events.
  38921. */
  38922. detachControl(element: HTMLElement): void;
  38923. private _collisionMask;
  38924. /**
  38925. * Get the mask that the camera ignores in collision events.
  38926. */
  38927. /**
  38928. * Set the mask that the camera ignores in collision events.
  38929. */
  38930. collisionMask: number;
  38931. /** @hidden */
  38932. _collideWithWorld(displacement: Vector3): void;
  38933. /** @hidden */
  38934. private _onCollisionPositionChange;
  38935. /** @hidden */
  38936. _checkInputs(): void;
  38937. /** @hidden */
  38938. _decideIfNeedsToMove(): boolean;
  38939. /** @hidden */
  38940. _updatePosition(): void;
  38941. /**
  38942. * Restore the Roll to its target value at the rate specified.
  38943. * @param rate - Higher means slower restoring.
  38944. * @hidden
  38945. */
  38946. restoreRoll(rate: number): void;
  38947. /**
  38948. * Destroy the camera and release the current resources held by it.
  38949. */
  38950. dispose(): void;
  38951. /**
  38952. * Get the current object class name.
  38953. * @returns the class name.
  38954. */
  38955. getClassName(): string;
  38956. }
  38957. }
  38958. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38959. import { Nullable } from "babylonjs/types";
  38960. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38961. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38962. /**
  38963. * Listen to keyboard events to control the camera.
  38964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38965. */
  38966. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38967. /**
  38968. * Defines the camera the input is attached to.
  38969. */
  38970. camera: FlyCamera;
  38971. /**
  38972. * The list of keyboard keys used to control the forward move of the camera.
  38973. */
  38974. keysForward: number[];
  38975. /**
  38976. * The list of keyboard keys used to control the backward move of the camera.
  38977. */
  38978. keysBackward: number[];
  38979. /**
  38980. * The list of keyboard keys used to control the forward move of the camera.
  38981. */
  38982. keysUp: number[];
  38983. /**
  38984. * The list of keyboard keys used to control the backward move of the camera.
  38985. */
  38986. keysDown: number[];
  38987. /**
  38988. * The list of keyboard keys used to control the right strafe move of the camera.
  38989. */
  38990. keysRight: number[];
  38991. /**
  38992. * The list of keyboard keys used to control the left strafe move of the camera.
  38993. */
  38994. keysLeft: number[];
  38995. private _keys;
  38996. private _onCanvasBlurObserver;
  38997. private _onKeyboardObserver;
  38998. private _engine;
  38999. private _scene;
  39000. /**
  39001. * Attach the input controls to a specific dom element to get the input from.
  39002. * @param element Defines the element the controls should be listened from
  39003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39004. */
  39005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39006. /**
  39007. * Detach the current controls from the specified dom element.
  39008. * @param element Defines the element to stop listening the inputs from
  39009. */
  39010. detachControl(element: Nullable<HTMLElement>): void;
  39011. /**
  39012. * Gets the class name of the current intput.
  39013. * @returns the class name
  39014. */
  39015. getClassName(): string;
  39016. /** @hidden */
  39017. _onLostFocus(e: FocusEvent): void;
  39018. /**
  39019. * Get the friendly name associated with the input class.
  39020. * @returns the input friendly name
  39021. */
  39022. getSimpleName(): string;
  39023. /**
  39024. * Update the current camera state depending on the inputs that have been used this frame.
  39025. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39026. */
  39027. checkInputs(): void;
  39028. }
  39029. }
  39030. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39031. import { Nullable } from "babylonjs/types";
  39032. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39033. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39034. /**
  39035. * Manage the mouse wheel inputs to control a follow camera.
  39036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39037. */
  39038. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39039. /**
  39040. * Defines the camera the input is attached to.
  39041. */
  39042. camera: FollowCamera;
  39043. /**
  39044. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39045. */
  39046. axisControlRadius: boolean;
  39047. /**
  39048. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39049. */
  39050. axisControlHeight: boolean;
  39051. /**
  39052. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39053. */
  39054. axisControlRotation: boolean;
  39055. /**
  39056. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39057. * relation to mouseWheel events.
  39058. */
  39059. wheelPrecision: number;
  39060. /**
  39061. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39062. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39063. */
  39064. wheelDeltaPercentage: number;
  39065. private _wheel;
  39066. private _observer;
  39067. /**
  39068. * Attach the input controls to a specific dom element to get the input from.
  39069. * @param element Defines the element the controls should be listened from
  39070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39071. */
  39072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39073. /**
  39074. * Detach the current controls from the specified dom element.
  39075. * @param element Defines the element to stop listening the inputs from
  39076. */
  39077. detachControl(element: Nullable<HTMLElement>): void;
  39078. /**
  39079. * Gets the class name of the current intput.
  39080. * @returns the class name
  39081. */
  39082. getClassName(): string;
  39083. /**
  39084. * Get the friendly name associated with the input class.
  39085. * @returns the input friendly name
  39086. */
  39087. getSimpleName(): string;
  39088. }
  39089. }
  39090. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39091. import { Nullable } from "babylonjs/types";
  39092. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39093. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39094. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39095. /**
  39096. * Manage the pointers inputs to control an follow camera.
  39097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39098. */
  39099. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39100. /**
  39101. * Defines the camera the input is attached to.
  39102. */
  39103. camera: FollowCamera;
  39104. /**
  39105. * Gets the class name of the current input.
  39106. * @returns the class name
  39107. */
  39108. getClassName(): string;
  39109. /**
  39110. * Defines the pointer angular sensibility along the X axis or how fast is
  39111. * the camera rotating.
  39112. * A negative number will reverse the axis direction.
  39113. */
  39114. angularSensibilityX: number;
  39115. /**
  39116. * Defines the pointer angular sensibility along the Y axis or how fast is
  39117. * the camera rotating.
  39118. * A negative number will reverse the axis direction.
  39119. */
  39120. angularSensibilityY: number;
  39121. /**
  39122. * Defines the pointer pinch precision or how fast is the camera zooming.
  39123. * A negative number will reverse the axis direction.
  39124. */
  39125. pinchPrecision: number;
  39126. /**
  39127. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39128. * from 0.
  39129. * It defines the percentage of current camera.radius to use as delta when
  39130. * pinch zoom is used.
  39131. */
  39132. pinchDeltaPercentage: number;
  39133. /**
  39134. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39135. */
  39136. axisXControlRadius: boolean;
  39137. /**
  39138. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39139. */
  39140. axisXControlHeight: boolean;
  39141. /**
  39142. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39143. */
  39144. axisXControlRotation: boolean;
  39145. /**
  39146. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39147. */
  39148. axisYControlRadius: boolean;
  39149. /**
  39150. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39151. */
  39152. axisYControlHeight: boolean;
  39153. /**
  39154. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39155. */
  39156. axisYControlRotation: boolean;
  39157. /**
  39158. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39159. */
  39160. axisPinchControlRadius: boolean;
  39161. /**
  39162. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39163. */
  39164. axisPinchControlHeight: boolean;
  39165. /**
  39166. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39167. */
  39168. axisPinchControlRotation: boolean;
  39169. /**
  39170. * Log error messages if basic misconfiguration has occurred.
  39171. */
  39172. warningEnable: boolean;
  39173. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39174. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39175. private _warningCounter;
  39176. private _warning;
  39177. }
  39178. }
  39179. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39180. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39181. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39182. /**
  39183. * Default Inputs manager for the FollowCamera.
  39184. * It groups all the default supported inputs for ease of use.
  39185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39186. */
  39187. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39188. /**
  39189. * Instantiates a new FollowCameraInputsManager.
  39190. * @param camera Defines the camera the inputs belong to
  39191. */
  39192. constructor(camera: FollowCamera);
  39193. /**
  39194. * Add keyboard input support to the input manager.
  39195. * @returns the current input manager
  39196. */
  39197. addKeyboard(): FollowCameraInputsManager;
  39198. /**
  39199. * Add mouse wheel input support to the input manager.
  39200. * @returns the current input manager
  39201. */
  39202. addMouseWheel(): FollowCameraInputsManager;
  39203. /**
  39204. * Add pointers input support to the input manager.
  39205. * @returns the current input manager
  39206. */
  39207. addPointers(): FollowCameraInputsManager;
  39208. /**
  39209. * Add orientation input support to the input manager.
  39210. * @returns the current input manager
  39211. */
  39212. addVRDeviceOrientation(): FollowCameraInputsManager;
  39213. }
  39214. }
  39215. declare module "babylonjs/Cameras/followCamera" {
  39216. import { Nullable } from "babylonjs/types";
  39217. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39218. import { Scene } from "babylonjs/scene";
  39219. import { Vector3 } from "babylonjs/Maths/math.vector";
  39220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39221. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39222. /**
  39223. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39224. * an arc rotate version arcFollowCamera are available.
  39225. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39226. */
  39227. export class FollowCamera extends TargetCamera {
  39228. /**
  39229. * Distance the follow camera should follow an object at
  39230. */
  39231. radius: number;
  39232. /**
  39233. * Minimum allowed distance of the camera to the axis of rotation
  39234. * (The camera can not get closer).
  39235. * This can help limiting how the Camera is able to move in the scene.
  39236. */
  39237. lowerRadiusLimit: Nullable<number>;
  39238. /**
  39239. * Maximum allowed distance of the camera to the axis of rotation
  39240. * (The camera can not get further).
  39241. * This can help limiting how the Camera is able to move in the scene.
  39242. */
  39243. upperRadiusLimit: Nullable<number>;
  39244. /**
  39245. * Define a rotation offset between the camera and the object it follows
  39246. */
  39247. rotationOffset: number;
  39248. /**
  39249. * Minimum allowed angle to camera position relative to target object.
  39250. * This can help limiting how the Camera is able to move in the scene.
  39251. */
  39252. lowerRotationOffsetLimit: Nullable<number>;
  39253. /**
  39254. * Maximum allowed angle to camera position relative to target object.
  39255. * This can help limiting how the Camera is able to move in the scene.
  39256. */
  39257. upperRotationOffsetLimit: Nullable<number>;
  39258. /**
  39259. * Define a height offset between the camera and the object it follows.
  39260. * It can help following an object from the top (like a car chaing a plane)
  39261. */
  39262. heightOffset: number;
  39263. /**
  39264. * Minimum allowed height of camera position relative to target object.
  39265. * This can help limiting how the Camera is able to move in the scene.
  39266. */
  39267. lowerHeightOffsetLimit: Nullable<number>;
  39268. /**
  39269. * Maximum allowed height of camera position relative to target object.
  39270. * This can help limiting how the Camera is able to move in the scene.
  39271. */
  39272. upperHeightOffsetLimit: Nullable<number>;
  39273. /**
  39274. * Define how fast the camera can accelerate to follow it s target.
  39275. */
  39276. cameraAcceleration: number;
  39277. /**
  39278. * Define the speed limit of the camera following an object.
  39279. */
  39280. maxCameraSpeed: number;
  39281. /**
  39282. * Define the target of the camera.
  39283. */
  39284. lockedTarget: Nullable<AbstractMesh>;
  39285. /**
  39286. * Defines the input associated with the camera.
  39287. */
  39288. inputs: FollowCameraInputsManager;
  39289. /**
  39290. * Instantiates the follow camera.
  39291. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39292. * @param name Define the name of the camera in the scene
  39293. * @param position Define the position of the camera
  39294. * @param scene Define the scene the camera belong to
  39295. * @param lockedTarget Define the target of the camera
  39296. */
  39297. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39298. private _follow;
  39299. /**
  39300. * Attached controls to the current camera.
  39301. * @param element Defines the element the controls should be listened from
  39302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39303. */
  39304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39305. /**
  39306. * Detach the current controls from the camera.
  39307. * The camera will stop reacting to inputs.
  39308. * @param element Defines the element to stop listening the inputs from
  39309. */
  39310. detachControl(element: HTMLElement): void;
  39311. /** @hidden */
  39312. _checkInputs(): void;
  39313. private _checkLimits;
  39314. /**
  39315. * Gets the camera class name.
  39316. * @returns the class name
  39317. */
  39318. getClassName(): string;
  39319. }
  39320. /**
  39321. * Arc Rotate version of the follow camera.
  39322. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39323. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39324. */
  39325. export class ArcFollowCamera extends TargetCamera {
  39326. /** The longitudinal angle of the camera */
  39327. alpha: number;
  39328. /** The latitudinal angle of the camera */
  39329. beta: number;
  39330. /** The radius of the camera from its target */
  39331. radius: number;
  39332. /** Define the camera target (the messh it should follow) */
  39333. target: Nullable<AbstractMesh>;
  39334. private _cartesianCoordinates;
  39335. /**
  39336. * Instantiates a new ArcFollowCamera
  39337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39338. * @param name Define the name of the camera
  39339. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39340. * @param beta Define the rotation angle of the camera around the elevation axis
  39341. * @param radius Define the radius of the camera from its target point
  39342. * @param target Define the target of the camera
  39343. * @param scene Define the scene the camera belongs to
  39344. */
  39345. constructor(name: string,
  39346. /** The longitudinal angle of the camera */
  39347. alpha: number,
  39348. /** The latitudinal angle of the camera */
  39349. beta: number,
  39350. /** The radius of the camera from its target */
  39351. radius: number,
  39352. /** Define the camera target (the messh it should follow) */
  39353. target: Nullable<AbstractMesh>, scene: Scene);
  39354. private _follow;
  39355. /** @hidden */
  39356. _checkInputs(): void;
  39357. /**
  39358. * Returns the class name of the object.
  39359. * It is mostly used internally for serialization purposes.
  39360. */
  39361. getClassName(): string;
  39362. }
  39363. }
  39364. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39365. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39366. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39367. import { Nullable } from "babylonjs/types";
  39368. /**
  39369. * Manage the keyboard inputs to control the movement of a follow camera.
  39370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39371. */
  39372. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39373. /**
  39374. * Defines the camera the input is attached to.
  39375. */
  39376. camera: FollowCamera;
  39377. /**
  39378. * Defines the list of key codes associated with the up action (increase heightOffset)
  39379. */
  39380. keysHeightOffsetIncr: number[];
  39381. /**
  39382. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39383. */
  39384. keysHeightOffsetDecr: number[];
  39385. /**
  39386. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39387. */
  39388. keysHeightOffsetModifierAlt: boolean;
  39389. /**
  39390. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39391. */
  39392. keysHeightOffsetModifierCtrl: boolean;
  39393. /**
  39394. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39395. */
  39396. keysHeightOffsetModifierShift: boolean;
  39397. /**
  39398. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39399. */
  39400. keysRotationOffsetIncr: number[];
  39401. /**
  39402. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39403. */
  39404. keysRotationOffsetDecr: number[];
  39405. /**
  39406. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39407. */
  39408. keysRotationOffsetModifierAlt: boolean;
  39409. /**
  39410. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39411. */
  39412. keysRotationOffsetModifierCtrl: boolean;
  39413. /**
  39414. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39415. */
  39416. keysRotationOffsetModifierShift: boolean;
  39417. /**
  39418. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39419. */
  39420. keysRadiusIncr: number[];
  39421. /**
  39422. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39423. */
  39424. keysRadiusDecr: number[];
  39425. /**
  39426. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39427. */
  39428. keysRadiusModifierAlt: boolean;
  39429. /**
  39430. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39431. */
  39432. keysRadiusModifierCtrl: boolean;
  39433. /**
  39434. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39435. */
  39436. keysRadiusModifierShift: boolean;
  39437. /**
  39438. * Defines the rate of change of heightOffset.
  39439. */
  39440. heightSensibility: number;
  39441. /**
  39442. * Defines the rate of change of rotationOffset.
  39443. */
  39444. rotationSensibility: number;
  39445. /**
  39446. * Defines the rate of change of radius.
  39447. */
  39448. radiusSensibility: number;
  39449. private _keys;
  39450. private _ctrlPressed;
  39451. private _altPressed;
  39452. private _shiftPressed;
  39453. private _onCanvasBlurObserver;
  39454. private _onKeyboardObserver;
  39455. private _engine;
  39456. private _scene;
  39457. /**
  39458. * Attach the input controls to a specific dom element to get the input from.
  39459. * @param element Defines the element the controls should be listened from
  39460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39461. */
  39462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39463. /**
  39464. * Detach the current controls from the specified dom element.
  39465. * @param element Defines the element to stop listening the inputs from
  39466. */
  39467. detachControl(element: Nullable<HTMLElement>): void;
  39468. /**
  39469. * Update the current camera state depending on the inputs that have been used this frame.
  39470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39471. */
  39472. checkInputs(): void;
  39473. /**
  39474. * Gets the class name of the current input.
  39475. * @returns the class name
  39476. */
  39477. getClassName(): string;
  39478. /**
  39479. * Get the friendly name associated with the input class.
  39480. * @returns the input friendly name
  39481. */
  39482. getSimpleName(): string;
  39483. /**
  39484. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39485. * allow modification of the heightOffset value.
  39486. */
  39487. private _modifierHeightOffset;
  39488. /**
  39489. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39490. * allow modification of the rotationOffset value.
  39491. */
  39492. private _modifierRotationOffset;
  39493. /**
  39494. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39495. * allow modification of the radius value.
  39496. */
  39497. private _modifierRadius;
  39498. }
  39499. }
  39500. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39501. import { Nullable } from "babylonjs/types";
  39502. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39503. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39504. import { Observable } from "babylonjs/Misc/observable";
  39505. module "babylonjs/Cameras/freeCameraInputsManager" {
  39506. interface FreeCameraInputsManager {
  39507. /**
  39508. * @hidden
  39509. */
  39510. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39511. /**
  39512. * Add orientation input support to the input manager.
  39513. * @returns the current input manager
  39514. */
  39515. addDeviceOrientation(): FreeCameraInputsManager;
  39516. }
  39517. }
  39518. /**
  39519. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39520. * Screen rotation is taken into account.
  39521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39522. */
  39523. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39524. private _camera;
  39525. private _screenOrientationAngle;
  39526. private _constantTranform;
  39527. private _screenQuaternion;
  39528. private _alpha;
  39529. private _beta;
  39530. private _gamma;
  39531. /**
  39532. * Can be used to detect if a device orientation sensor is availible on a device
  39533. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39534. * @returns a promise that will resolve on orientation change
  39535. */
  39536. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39537. /**
  39538. * @hidden
  39539. */
  39540. _onDeviceOrientationChangedObservable: Observable<void>;
  39541. /**
  39542. * Instantiates a new input
  39543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39544. */
  39545. constructor();
  39546. /**
  39547. * Define the camera controlled by the input.
  39548. */
  39549. camera: FreeCamera;
  39550. /**
  39551. * Attach the input controls to a specific dom element to get the input from.
  39552. * @param element Defines the element the controls should be listened from
  39553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39554. */
  39555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39556. private _orientationChanged;
  39557. private _deviceOrientation;
  39558. /**
  39559. * Detach the current controls from the specified dom element.
  39560. * @param element Defines the element to stop listening the inputs from
  39561. */
  39562. detachControl(element: Nullable<HTMLElement>): void;
  39563. /**
  39564. * Update the current camera state depending on the inputs that have been used this frame.
  39565. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39566. */
  39567. checkInputs(): void;
  39568. /**
  39569. * Gets the class name of the current intput.
  39570. * @returns the class name
  39571. */
  39572. getClassName(): string;
  39573. /**
  39574. * Get the friendly name associated with the input class.
  39575. * @returns the input friendly name
  39576. */
  39577. getSimpleName(): string;
  39578. }
  39579. }
  39580. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39581. import { Nullable } from "babylonjs/types";
  39582. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39583. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39584. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39585. /**
  39586. * Manage the gamepad inputs to control a free camera.
  39587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39588. */
  39589. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39590. /**
  39591. * Define the camera the input is attached to.
  39592. */
  39593. camera: FreeCamera;
  39594. /**
  39595. * Define the Gamepad controlling the input
  39596. */
  39597. gamepad: Nullable<Gamepad>;
  39598. /**
  39599. * Defines the gamepad rotation sensiblity.
  39600. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39601. */
  39602. gamepadAngularSensibility: number;
  39603. /**
  39604. * Defines the gamepad move sensiblity.
  39605. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39606. */
  39607. gamepadMoveSensibility: number;
  39608. private _onGamepadConnectedObserver;
  39609. private _onGamepadDisconnectedObserver;
  39610. private _cameraTransform;
  39611. private _deltaTransform;
  39612. private _vector3;
  39613. private _vector2;
  39614. /**
  39615. * Attach the input controls to a specific dom element to get the input from.
  39616. * @param element Defines the element the controls should be listened from
  39617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39618. */
  39619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39620. /**
  39621. * Detach the current controls from the specified dom element.
  39622. * @param element Defines the element to stop listening the inputs from
  39623. */
  39624. detachControl(element: Nullable<HTMLElement>): void;
  39625. /**
  39626. * Update the current camera state depending on the inputs that have been used this frame.
  39627. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39628. */
  39629. checkInputs(): void;
  39630. /**
  39631. * Gets the class name of the current intput.
  39632. * @returns the class name
  39633. */
  39634. getClassName(): string;
  39635. /**
  39636. * Get the friendly name associated with the input class.
  39637. * @returns the input friendly name
  39638. */
  39639. getSimpleName(): string;
  39640. }
  39641. }
  39642. declare module "babylonjs/Misc/virtualJoystick" {
  39643. import { Nullable } from "babylonjs/types";
  39644. import { Vector3 } from "babylonjs/Maths/math.vector";
  39645. /**
  39646. * Defines the potential axis of a Joystick
  39647. */
  39648. export enum JoystickAxis {
  39649. /** X axis */
  39650. X = 0,
  39651. /** Y axis */
  39652. Y = 1,
  39653. /** Z axis */
  39654. Z = 2
  39655. }
  39656. /**
  39657. * Class used to define virtual joystick (used in touch mode)
  39658. */
  39659. export class VirtualJoystick {
  39660. /**
  39661. * Gets or sets a boolean indicating that left and right values must be inverted
  39662. */
  39663. reverseLeftRight: boolean;
  39664. /**
  39665. * Gets or sets a boolean indicating that up and down values must be inverted
  39666. */
  39667. reverseUpDown: boolean;
  39668. /**
  39669. * Gets the offset value for the position (ie. the change of the position value)
  39670. */
  39671. deltaPosition: Vector3;
  39672. /**
  39673. * Gets a boolean indicating if the virtual joystick was pressed
  39674. */
  39675. pressed: boolean;
  39676. /**
  39677. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39678. */
  39679. static Canvas: Nullable<HTMLCanvasElement>;
  39680. private static _globalJoystickIndex;
  39681. private static vjCanvasContext;
  39682. private static vjCanvasWidth;
  39683. private static vjCanvasHeight;
  39684. private static halfWidth;
  39685. private _action;
  39686. private _axisTargetedByLeftAndRight;
  39687. private _axisTargetedByUpAndDown;
  39688. private _joystickSensibility;
  39689. private _inversedSensibility;
  39690. private _joystickPointerID;
  39691. private _joystickColor;
  39692. private _joystickPointerPos;
  39693. private _joystickPreviousPointerPos;
  39694. private _joystickPointerStartPos;
  39695. private _deltaJoystickVector;
  39696. private _leftJoystick;
  39697. private _touches;
  39698. private _onPointerDownHandlerRef;
  39699. private _onPointerMoveHandlerRef;
  39700. private _onPointerUpHandlerRef;
  39701. private _onResize;
  39702. /**
  39703. * Creates a new virtual joystick
  39704. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39705. */
  39706. constructor(leftJoystick?: boolean);
  39707. /**
  39708. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39709. * @param newJoystickSensibility defines the new sensibility
  39710. */
  39711. setJoystickSensibility(newJoystickSensibility: number): void;
  39712. private _onPointerDown;
  39713. private _onPointerMove;
  39714. private _onPointerUp;
  39715. /**
  39716. * Change the color of the virtual joystick
  39717. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39718. */
  39719. setJoystickColor(newColor: string): void;
  39720. /**
  39721. * Defines a callback to call when the joystick is touched
  39722. * @param action defines the callback
  39723. */
  39724. setActionOnTouch(action: () => any): void;
  39725. /**
  39726. * Defines which axis you'd like to control for left & right
  39727. * @param axis defines the axis to use
  39728. */
  39729. setAxisForLeftRight(axis: JoystickAxis): void;
  39730. /**
  39731. * Defines which axis you'd like to control for up & down
  39732. * @param axis defines the axis to use
  39733. */
  39734. setAxisForUpDown(axis: JoystickAxis): void;
  39735. private _drawVirtualJoystick;
  39736. /**
  39737. * Release internal HTML canvas
  39738. */
  39739. releaseCanvas(): void;
  39740. }
  39741. }
  39742. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39743. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39744. import { Nullable } from "babylonjs/types";
  39745. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39746. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39747. module "babylonjs/Cameras/freeCameraInputsManager" {
  39748. interface FreeCameraInputsManager {
  39749. /**
  39750. * Add virtual joystick input support to the input manager.
  39751. * @returns the current input manager
  39752. */
  39753. addVirtualJoystick(): FreeCameraInputsManager;
  39754. }
  39755. }
  39756. /**
  39757. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39759. */
  39760. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39761. /**
  39762. * Defines the camera the input is attached to.
  39763. */
  39764. camera: FreeCamera;
  39765. private _leftjoystick;
  39766. private _rightjoystick;
  39767. /**
  39768. * Gets the left stick of the virtual joystick.
  39769. * @returns The virtual Joystick
  39770. */
  39771. getLeftJoystick(): VirtualJoystick;
  39772. /**
  39773. * Gets the right stick of the virtual joystick.
  39774. * @returns The virtual Joystick
  39775. */
  39776. getRightJoystick(): VirtualJoystick;
  39777. /**
  39778. * Update the current camera state depending on the inputs that have been used this frame.
  39779. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39780. */
  39781. checkInputs(): void;
  39782. /**
  39783. * Attach the input controls to a specific dom element to get the input from.
  39784. * @param element Defines the element the controls should be listened from
  39785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39786. */
  39787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39788. /**
  39789. * Detach the current controls from the specified dom element.
  39790. * @param element Defines the element to stop listening the inputs from
  39791. */
  39792. detachControl(element: Nullable<HTMLElement>): void;
  39793. /**
  39794. * Gets the class name of the current intput.
  39795. * @returns the class name
  39796. */
  39797. getClassName(): string;
  39798. /**
  39799. * Get the friendly name associated with the input class.
  39800. * @returns the input friendly name
  39801. */
  39802. getSimpleName(): string;
  39803. }
  39804. }
  39805. declare module "babylonjs/Cameras/Inputs/index" {
  39806. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39807. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39808. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39809. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39810. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39811. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39812. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39813. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39814. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39815. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39816. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39817. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39818. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39819. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39820. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39821. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39822. }
  39823. declare module "babylonjs/Cameras/touchCamera" {
  39824. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39825. import { Scene } from "babylonjs/scene";
  39826. import { Vector3 } from "babylonjs/Maths/math.vector";
  39827. /**
  39828. * This represents a FPS type of camera controlled by touch.
  39829. * This is like a universal camera minus the Gamepad controls.
  39830. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39831. */
  39832. export class TouchCamera extends FreeCamera {
  39833. /**
  39834. * Defines the touch sensibility for rotation.
  39835. * The higher the faster.
  39836. */
  39837. touchAngularSensibility: number;
  39838. /**
  39839. * Defines the touch sensibility for move.
  39840. * The higher the faster.
  39841. */
  39842. touchMoveSensibility: number;
  39843. /**
  39844. * Instantiates a new touch camera.
  39845. * This represents a FPS type of camera controlled by touch.
  39846. * This is like a universal camera minus the Gamepad controls.
  39847. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39848. * @param name Define the name of the camera in the scene
  39849. * @param position Define the start position of the camera in the scene
  39850. * @param scene Define the scene the camera belongs to
  39851. */
  39852. constructor(name: string, position: Vector3, scene: Scene);
  39853. /**
  39854. * Gets the current object class name.
  39855. * @return the class name
  39856. */
  39857. getClassName(): string;
  39858. /** @hidden */
  39859. _setupInputs(): void;
  39860. }
  39861. }
  39862. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39863. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39864. import { Scene } from "babylonjs/scene";
  39865. import { Vector3 } from "babylonjs/Maths/math.vector";
  39866. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39867. import { Axis } from "babylonjs/Maths/math.axis";
  39868. /**
  39869. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39870. * being tilted forward or back and left or right.
  39871. */
  39872. export class DeviceOrientationCamera extends FreeCamera {
  39873. private _initialQuaternion;
  39874. private _quaternionCache;
  39875. private _tmpDragQuaternion;
  39876. private _disablePointerInputWhenUsingDeviceOrientation;
  39877. /**
  39878. * Creates a new device orientation camera
  39879. * @param name The name of the camera
  39880. * @param position The start position camera
  39881. * @param scene The scene the camera belongs to
  39882. */
  39883. constructor(name: string, position: Vector3, scene: Scene);
  39884. /**
  39885. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39886. */
  39887. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39888. private _dragFactor;
  39889. /**
  39890. * Enabled turning on the y axis when the orientation sensor is active
  39891. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39892. */
  39893. enableHorizontalDragging(dragFactor?: number): void;
  39894. /**
  39895. * Gets the current instance class name ("DeviceOrientationCamera").
  39896. * This helps avoiding instanceof at run time.
  39897. * @returns the class name
  39898. */
  39899. getClassName(): string;
  39900. /**
  39901. * @hidden
  39902. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39903. */
  39904. _checkInputs(): void;
  39905. /**
  39906. * Reset the camera to its default orientation on the specified axis only.
  39907. * @param axis The axis to reset
  39908. */
  39909. resetToCurrentRotation(axis?: Axis): void;
  39910. }
  39911. }
  39912. declare module "babylonjs/Gamepads/xboxGamepad" {
  39913. import { Observable } from "babylonjs/Misc/observable";
  39914. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39915. /**
  39916. * Defines supported buttons for XBox360 compatible gamepads
  39917. */
  39918. export enum Xbox360Button {
  39919. /** A */
  39920. A = 0,
  39921. /** B */
  39922. B = 1,
  39923. /** X */
  39924. X = 2,
  39925. /** Y */
  39926. Y = 3,
  39927. /** Start */
  39928. Start = 4,
  39929. /** Back */
  39930. Back = 5,
  39931. /** Left button */
  39932. LB = 6,
  39933. /** Right button */
  39934. RB = 7,
  39935. /** Left stick */
  39936. LeftStick = 8,
  39937. /** Right stick */
  39938. RightStick = 9
  39939. }
  39940. /** Defines values for XBox360 DPad */
  39941. export enum Xbox360Dpad {
  39942. /** Up */
  39943. Up = 0,
  39944. /** Down */
  39945. Down = 1,
  39946. /** Left */
  39947. Left = 2,
  39948. /** Right */
  39949. Right = 3
  39950. }
  39951. /**
  39952. * Defines a XBox360 gamepad
  39953. */
  39954. export class Xbox360Pad extends Gamepad {
  39955. private _leftTrigger;
  39956. private _rightTrigger;
  39957. private _onlefttriggerchanged;
  39958. private _onrighttriggerchanged;
  39959. private _onbuttondown;
  39960. private _onbuttonup;
  39961. private _ondpaddown;
  39962. private _ondpadup;
  39963. /** Observable raised when a button is pressed */
  39964. onButtonDownObservable: Observable<Xbox360Button>;
  39965. /** Observable raised when a button is released */
  39966. onButtonUpObservable: Observable<Xbox360Button>;
  39967. /** Observable raised when a pad is pressed */
  39968. onPadDownObservable: Observable<Xbox360Dpad>;
  39969. /** Observable raised when a pad is released */
  39970. onPadUpObservable: Observable<Xbox360Dpad>;
  39971. private _buttonA;
  39972. private _buttonB;
  39973. private _buttonX;
  39974. private _buttonY;
  39975. private _buttonBack;
  39976. private _buttonStart;
  39977. private _buttonLB;
  39978. private _buttonRB;
  39979. private _buttonLeftStick;
  39980. private _buttonRightStick;
  39981. private _dPadUp;
  39982. private _dPadDown;
  39983. private _dPadLeft;
  39984. private _dPadRight;
  39985. private _isXboxOnePad;
  39986. /**
  39987. * Creates a new XBox360 gamepad object
  39988. * @param id defines the id of this gamepad
  39989. * @param index defines its index
  39990. * @param gamepad defines the internal HTML gamepad object
  39991. * @param xboxOne defines if it is a XBox One gamepad
  39992. */
  39993. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39994. /**
  39995. * Defines the callback to call when left trigger is pressed
  39996. * @param callback defines the callback to use
  39997. */
  39998. onlefttriggerchanged(callback: (value: number) => void): void;
  39999. /**
  40000. * Defines the callback to call when right trigger is pressed
  40001. * @param callback defines the callback to use
  40002. */
  40003. onrighttriggerchanged(callback: (value: number) => void): void;
  40004. /**
  40005. * Gets the left trigger value
  40006. */
  40007. /**
  40008. * Sets the left trigger value
  40009. */
  40010. leftTrigger: number;
  40011. /**
  40012. * Gets the right trigger value
  40013. */
  40014. /**
  40015. * Sets the right trigger value
  40016. */
  40017. rightTrigger: number;
  40018. /**
  40019. * Defines the callback to call when a button is pressed
  40020. * @param callback defines the callback to use
  40021. */
  40022. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40023. /**
  40024. * Defines the callback to call when a button is released
  40025. * @param callback defines the callback to use
  40026. */
  40027. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40028. /**
  40029. * Defines the callback to call when a pad is pressed
  40030. * @param callback defines the callback to use
  40031. */
  40032. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40033. /**
  40034. * Defines the callback to call when a pad is released
  40035. * @param callback defines the callback to use
  40036. */
  40037. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40038. private _setButtonValue;
  40039. private _setDPadValue;
  40040. /**
  40041. * Gets the value of the `A` button
  40042. */
  40043. /**
  40044. * Sets the value of the `A` button
  40045. */
  40046. buttonA: number;
  40047. /**
  40048. * Gets the value of the `B` button
  40049. */
  40050. /**
  40051. * Sets the value of the `B` button
  40052. */
  40053. buttonB: number;
  40054. /**
  40055. * Gets the value of the `X` button
  40056. */
  40057. /**
  40058. * Sets the value of the `X` button
  40059. */
  40060. buttonX: number;
  40061. /**
  40062. * Gets the value of the `Y` button
  40063. */
  40064. /**
  40065. * Sets the value of the `Y` button
  40066. */
  40067. buttonY: number;
  40068. /**
  40069. * Gets the value of the `Start` button
  40070. */
  40071. /**
  40072. * Sets the value of the `Start` button
  40073. */
  40074. buttonStart: number;
  40075. /**
  40076. * Gets the value of the `Back` button
  40077. */
  40078. /**
  40079. * Sets the value of the `Back` button
  40080. */
  40081. buttonBack: number;
  40082. /**
  40083. * Gets the value of the `Left` button
  40084. */
  40085. /**
  40086. * Sets the value of the `Left` button
  40087. */
  40088. buttonLB: number;
  40089. /**
  40090. * Gets the value of the `Right` button
  40091. */
  40092. /**
  40093. * Sets the value of the `Right` button
  40094. */
  40095. buttonRB: number;
  40096. /**
  40097. * Gets the value of the Left joystick
  40098. */
  40099. /**
  40100. * Sets the value of the Left joystick
  40101. */
  40102. buttonLeftStick: number;
  40103. /**
  40104. * Gets the value of the Right joystick
  40105. */
  40106. /**
  40107. * Sets the value of the Right joystick
  40108. */
  40109. buttonRightStick: number;
  40110. /**
  40111. * Gets the value of D-pad up
  40112. */
  40113. /**
  40114. * Sets the value of D-pad up
  40115. */
  40116. dPadUp: number;
  40117. /**
  40118. * Gets the value of D-pad down
  40119. */
  40120. /**
  40121. * Sets the value of D-pad down
  40122. */
  40123. dPadDown: number;
  40124. /**
  40125. * Gets the value of D-pad left
  40126. */
  40127. /**
  40128. * Sets the value of D-pad left
  40129. */
  40130. dPadLeft: number;
  40131. /**
  40132. * Gets the value of D-pad right
  40133. */
  40134. /**
  40135. * Sets the value of D-pad right
  40136. */
  40137. dPadRight: number;
  40138. /**
  40139. * Force the gamepad to synchronize with device values
  40140. */
  40141. update(): void;
  40142. /**
  40143. * Disposes the gamepad
  40144. */
  40145. dispose(): void;
  40146. }
  40147. }
  40148. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40149. import { Observable } from "babylonjs/Misc/observable";
  40150. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40151. /**
  40152. * Defines supported buttons for DualShock compatible gamepads
  40153. */
  40154. export enum DualShockButton {
  40155. /** Cross */
  40156. Cross = 0,
  40157. /** Circle */
  40158. Circle = 1,
  40159. /** Square */
  40160. Square = 2,
  40161. /** Triangle */
  40162. Triangle = 3,
  40163. /** Options */
  40164. Options = 4,
  40165. /** Share */
  40166. Share = 5,
  40167. /** L1 */
  40168. L1 = 6,
  40169. /** R1 */
  40170. R1 = 7,
  40171. /** Left stick */
  40172. LeftStick = 8,
  40173. /** Right stick */
  40174. RightStick = 9
  40175. }
  40176. /** Defines values for DualShock DPad */
  40177. export enum DualShockDpad {
  40178. /** Up */
  40179. Up = 0,
  40180. /** Down */
  40181. Down = 1,
  40182. /** Left */
  40183. Left = 2,
  40184. /** Right */
  40185. Right = 3
  40186. }
  40187. /**
  40188. * Defines a DualShock gamepad
  40189. */
  40190. export class DualShockPad extends Gamepad {
  40191. private _leftTrigger;
  40192. private _rightTrigger;
  40193. private _onlefttriggerchanged;
  40194. private _onrighttriggerchanged;
  40195. private _onbuttondown;
  40196. private _onbuttonup;
  40197. private _ondpaddown;
  40198. private _ondpadup;
  40199. /** Observable raised when a button is pressed */
  40200. onButtonDownObservable: Observable<DualShockButton>;
  40201. /** Observable raised when a button is released */
  40202. onButtonUpObservable: Observable<DualShockButton>;
  40203. /** Observable raised when a pad is pressed */
  40204. onPadDownObservable: Observable<DualShockDpad>;
  40205. /** Observable raised when a pad is released */
  40206. onPadUpObservable: Observable<DualShockDpad>;
  40207. private _buttonCross;
  40208. private _buttonCircle;
  40209. private _buttonSquare;
  40210. private _buttonTriangle;
  40211. private _buttonShare;
  40212. private _buttonOptions;
  40213. private _buttonL1;
  40214. private _buttonR1;
  40215. private _buttonLeftStick;
  40216. private _buttonRightStick;
  40217. private _dPadUp;
  40218. private _dPadDown;
  40219. private _dPadLeft;
  40220. private _dPadRight;
  40221. /**
  40222. * Creates a new DualShock gamepad object
  40223. * @param id defines the id of this gamepad
  40224. * @param index defines its index
  40225. * @param gamepad defines the internal HTML gamepad object
  40226. */
  40227. constructor(id: string, index: number, gamepad: any);
  40228. /**
  40229. * Defines the callback to call when left trigger is pressed
  40230. * @param callback defines the callback to use
  40231. */
  40232. onlefttriggerchanged(callback: (value: number) => void): void;
  40233. /**
  40234. * Defines the callback to call when right trigger is pressed
  40235. * @param callback defines the callback to use
  40236. */
  40237. onrighttriggerchanged(callback: (value: number) => void): void;
  40238. /**
  40239. * Gets the left trigger value
  40240. */
  40241. /**
  40242. * Sets the left trigger value
  40243. */
  40244. leftTrigger: number;
  40245. /**
  40246. * Gets the right trigger value
  40247. */
  40248. /**
  40249. * Sets the right trigger value
  40250. */
  40251. rightTrigger: number;
  40252. /**
  40253. * Defines the callback to call when a button is pressed
  40254. * @param callback defines the callback to use
  40255. */
  40256. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40257. /**
  40258. * Defines the callback to call when a button is released
  40259. * @param callback defines the callback to use
  40260. */
  40261. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40262. /**
  40263. * Defines the callback to call when a pad is pressed
  40264. * @param callback defines the callback to use
  40265. */
  40266. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40267. /**
  40268. * Defines the callback to call when a pad is released
  40269. * @param callback defines the callback to use
  40270. */
  40271. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40272. private _setButtonValue;
  40273. private _setDPadValue;
  40274. /**
  40275. * Gets the value of the `Cross` button
  40276. */
  40277. /**
  40278. * Sets the value of the `Cross` button
  40279. */
  40280. buttonCross: number;
  40281. /**
  40282. * Gets the value of the `Circle` button
  40283. */
  40284. /**
  40285. * Sets the value of the `Circle` button
  40286. */
  40287. buttonCircle: number;
  40288. /**
  40289. * Gets the value of the `Square` button
  40290. */
  40291. /**
  40292. * Sets the value of the `Square` button
  40293. */
  40294. buttonSquare: number;
  40295. /**
  40296. * Gets the value of the `Triangle` button
  40297. */
  40298. /**
  40299. * Sets the value of the `Triangle` button
  40300. */
  40301. buttonTriangle: number;
  40302. /**
  40303. * Gets the value of the `Options` button
  40304. */
  40305. /**
  40306. * Sets the value of the `Options` button
  40307. */
  40308. buttonOptions: number;
  40309. /**
  40310. * Gets the value of the `Share` button
  40311. */
  40312. /**
  40313. * Sets the value of the `Share` button
  40314. */
  40315. buttonShare: number;
  40316. /**
  40317. * Gets the value of the `L1` button
  40318. */
  40319. /**
  40320. * Sets the value of the `L1` button
  40321. */
  40322. buttonL1: number;
  40323. /**
  40324. * Gets the value of the `R1` button
  40325. */
  40326. /**
  40327. * Sets the value of the `R1` button
  40328. */
  40329. buttonR1: number;
  40330. /**
  40331. * Gets the value of the Left joystick
  40332. */
  40333. /**
  40334. * Sets the value of the Left joystick
  40335. */
  40336. buttonLeftStick: number;
  40337. /**
  40338. * Gets the value of the Right joystick
  40339. */
  40340. /**
  40341. * Sets the value of the Right joystick
  40342. */
  40343. buttonRightStick: number;
  40344. /**
  40345. * Gets the value of D-pad up
  40346. */
  40347. /**
  40348. * Sets the value of D-pad up
  40349. */
  40350. dPadUp: number;
  40351. /**
  40352. * Gets the value of D-pad down
  40353. */
  40354. /**
  40355. * Sets the value of D-pad down
  40356. */
  40357. dPadDown: number;
  40358. /**
  40359. * Gets the value of D-pad left
  40360. */
  40361. /**
  40362. * Sets the value of D-pad left
  40363. */
  40364. dPadLeft: number;
  40365. /**
  40366. * Gets the value of D-pad right
  40367. */
  40368. /**
  40369. * Sets the value of D-pad right
  40370. */
  40371. dPadRight: number;
  40372. /**
  40373. * Force the gamepad to synchronize with device values
  40374. */
  40375. update(): void;
  40376. /**
  40377. * Disposes the gamepad
  40378. */
  40379. dispose(): void;
  40380. }
  40381. }
  40382. declare module "babylonjs/Gamepads/gamepadManager" {
  40383. import { Observable } from "babylonjs/Misc/observable";
  40384. import { Nullable } from "babylonjs/types";
  40385. import { Scene } from "babylonjs/scene";
  40386. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40387. /**
  40388. * Manager for handling gamepads
  40389. */
  40390. export class GamepadManager {
  40391. private _scene?;
  40392. private _babylonGamepads;
  40393. private _oneGamepadConnected;
  40394. /** @hidden */
  40395. _isMonitoring: boolean;
  40396. private _gamepadEventSupported;
  40397. private _gamepadSupport;
  40398. /**
  40399. * observable to be triggered when the gamepad controller has been connected
  40400. */
  40401. onGamepadConnectedObservable: Observable<Gamepad>;
  40402. /**
  40403. * observable to be triggered when the gamepad controller has been disconnected
  40404. */
  40405. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40406. private _onGamepadConnectedEvent;
  40407. private _onGamepadDisconnectedEvent;
  40408. /**
  40409. * Initializes the gamepad manager
  40410. * @param _scene BabylonJS scene
  40411. */
  40412. constructor(_scene?: Scene | undefined);
  40413. /**
  40414. * The gamepads in the game pad manager
  40415. */
  40416. readonly gamepads: Gamepad[];
  40417. /**
  40418. * Get the gamepad controllers based on type
  40419. * @param type The type of gamepad controller
  40420. * @returns Nullable gamepad
  40421. */
  40422. getGamepadByType(type?: number): Nullable<Gamepad>;
  40423. /**
  40424. * Disposes the gamepad manager
  40425. */
  40426. dispose(): void;
  40427. private _addNewGamepad;
  40428. private _startMonitoringGamepads;
  40429. private _stopMonitoringGamepads;
  40430. /** @hidden */
  40431. _checkGamepadsStatus(): void;
  40432. private _updateGamepadObjects;
  40433. }
  40434. }
  40435. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40436. import { Nullable } from "babylonjs/types";
  40437. import { Scene } from "babylonjs/scene";
  40438. import { ISceneComponent } from "babylonjs/sceneComponent";
  40439. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40440. module "babylonjs/scene" {
  40441. interface Scene {
  40442. /** @hidden */
  40443. _gamepadManager: Nullable<GamepadManager>;
  40444. /**
  40445. * Gets the gamepad manager associated with the scene
  40446. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40447. */
  40448. gamepadManager: GamepadManager;
  40449. }
  40450. }
  40451. module "babylonjs/Cameras/freeCameraInputsManager" {
  40452. /**
  40453. * Interface representing a free camera inputs manager
  40454. */
  40455. interface FreeCameraInputsManager {
  40456. /**
  40457. * Adds gamepad input support to the FreeCameraInputsManager.
  40458. * @returns the FreeCameraInputsManager
  40459. */
  40460. addGamepad(): FreeCameraInputsManager;
  40461. }
  40462. }
  40463. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40464. /**
  40465. * Interface representing an arc rotate camera inputs manager
  40466. */
  40467. interface ArcRotateCameraInputsManager {
  40468. /**
  40469. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40470. * @returns the camera inputs manager
  40471. */
  40472. addGamepad(): ArcRotateCameraInputsManager;
  40473. }
  40474. }
  40475. /**
  40476. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40477. */
  40478. export class GamepadSystemSceneComponent implements ISceneComponent {
  40479. /**
  40480. * The component name helpfull to identify the component in the list of scene components.
  40481. */
  40482. readonly name: string;
  40483. /**
  40484. * The scene the component belongs to.
  40485. */
  40486. scene: Scene;
  40487. /**
  40488. * Creates a new instance of the component for the given scene
  40489. * @param scene Defines the scene to register the component in
  40490. */
  40491. constructor(scene: Scene);
  40492. /**
  40493. * Registers the component in a given scene
  40494. */
  40495. register(): void;
  40496. /**
  40497. * Rebuilds the elements related to this component in case of
  40498. * context lost for instance.
  40499. */
  40500. rebuild(): void;
  40501. /**
  40502. * Disposes the component and the associated ressources
  40503. */
  40504. dispose(): void;
  40505. private _beforeCameraUpdate;
  40506. }
  40507. }
  40508. declare module "babylonjs/Cameras/universalCamera" {
  40509. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40510. import { Scene } from "babylonjs/scene";
  40511. import { Vector3 } from "babylonjs/Maths/math.vector";
  40512. import "babylonjs/Gamepads/gamepadSceneComponent";
  40513. /**
  40514. * 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,
  40515. * which still works and will still be found in many Playgrounds.
  40516. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40517. */
  40518. export class UniversalCamera extends TouchCamera {
  40519. /**
  40520. * Defines the gamepad rotation sensiblity.
  40521. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40522. */
  40523. gamepadAngularSensibility: number;
  40524. /**
  40525. * Defines the gamepad move sensiblity.
  40526. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40527. */
  40528. gamepadMoveSensibility: number;
  40529. /**
  40530. * 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,
  40531. * which still works and will still be found in many Playgrounds.
  40532. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40533. * @param name Define the name of the camera in the scene
  40534. * @param position Define the start position of the camera in the scene
  40535. * @param scene Define the scene the camera belongs to
  40536. */
  40537. constructor(name: string, position: Vector3, scene: Scene);
  40538. /**
  40539. * Gets the current object class name.
  40540. * @return the class name
  40541. */
  40542. getClassName(): string;
  40543. }
  40544. }
  40545. declare module "babylonjs/Cameras/gamepadCamera" {
  40546. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40547. import { Scene } from "babylonjs/scene";
  40548. import { Vector3 } from "babylonjs/Maths/math.vector";
  40549. /**
  40550. * This represents a FPS type of camera. This is only here for back compat purpose.
  40551. * Please use the UniversalCamera instead as both are identical.
  40552. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40553. */
  40554. export class GamepadCamera extends UniversalCamera {
  40555. /**
  40556. * Instantiates a new Gamepad Camera
  40557. * This represents a FPS type of camera. This is only here for back compat purpose.
  40558. * Please use the UniversalCamera instead as both are identical.
  40559. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40560. * @param name Define the name of the camera in the scene
  40561. * @param position Define the start position of the camera in the scene
  40562. * @param scene Define the scene the camera belongs to
  40563. */
  40564. constructor(name: string, position: Vector3, scene: Scene);
  40565. /**
  40566. * Gets the current object class name.
  40567. * @return the class name
  40568. */
  40569. getClassName(): string;
  40570. }
  40571. }
  40572. declare module "babylonjs/Shaders/pass.fragment" {
  40573. /** @hidden */
  40574. export var passPixelShader: {
  40575. name: string;
  40576. shader: string;
  40577. };
  40578. }
  40579. declare module "babylonjs/Shaders/passCube.fragment" {
  40580. /** @hidden */
  40581. export var passCubePixelShader: {
  40582. name: string;
  40583. shader: string;
  40584. };
  40585. }
  40586. declare module "babylonjs/PostProcesses/passPostProcess" {
  40587. import { Nullable } from "babylonjs/types";
  40588. import { Camera } from "babylonjs/Cameras/camera";
  40589. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40590. import { Engine } from "babylonjs/Engines/engine";
  40591. import "babylonjs/Shaders/pass.fragment";
  40592. import "babylonjs/Shaders/passCube.fragment";
  40593. /**
  40594. * PassPostProcess which produces an output the same as it's input
  40595. */
  40596. export class PassPostProcess extends PostProcess {
  40597. /**
  40598. * Creates the PassPostProcess
  40599. * @param name The name of the effect.
  40600. * @param options The required width/height ratio to downsize to before computing the render pass.
  40601. * @param camera The camera to apply the render pass to.
  40602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40603. * @param engine The engine which the post process will be applied. (default: current engine)
  40604. * @param reusable If the post process can be reused on the same frame. (default: false)
  40605. * @param textureType The type of texture to be used when performing the post processing.
  40606. * @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)
  40607. */
  40608. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40609. }
  40610. /**
  40611. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40612. */
  40613. export class PassCubePostProcess extends PostProcess {
  40614. private _face;
  40615. /**
  40616. * Gets or sets the cube face to display.
  40617. * * 0 is +X
  40618. * * 1 is -X
  40619. * * 2 is +Y
  40620. * * 3 is -Y
  40621. * * 4 is +Z
  40622. * * 5 is -Z
  40623. */
  40624. face: number;
  40625. /**
  40626. * Creates the PassCubePostProcess
  40627. * @param name The name of the effect.
  40628. * @param options The required width/height ratio to downsize to before computing the render pass.
  40629. * @param camera The camera to apply the render pass to.
  40630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40631. * @param engine The engine which the post process will be applied. (default: current engine)
  40632. * @param reusable If the post process can be reused on the same frame. (default: false)
  40633. * @param textureType The type of texture to be used when performing the post processing.
  40634. * @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)
  40635. */
  40636. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40637. }
  40638. }
  40639. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40640. /** @hidden */
  40641. export var anaglyphPixelShader: {
  40642. name: string;
  40643. shader: string;
  40644. };
  40645. }
  40646. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40647. import { Engine } from "babylonjs/Engines/engine";
  40648. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40649. import { Camera } from "babylonjs/Cameras/camera";
  40650. import "babylonjs/Shaders/anaglyph.fragment";
  40651. /**
  40652. * Postprocess used to generate anaglyphic rendering
  40653. */
  40654. export class AnaglyphPostProcess extends PostProcess {
  40655. private _passedProcess;
  40656. /**
  40657. * Creates a new AnaglyphPostProcess
  40658. * @param name defines postprocess name
  40659. * @param options defines creation options or target ratio scale
  40660. * @param rigCameras defines cameras using this postprocess
  40661. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40662. * @param engine defines hosting engine
  40663. * @param reusable defines if the postprocess will be reused multiple times per frame
  40664. */
  40665. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40666. }
  40667. }
  40668. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40669. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40670. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40671. import { Scene } from "babylonjs/scene";
  40672. import { Vector3 } from "babylonjs/Maths/math.vector";
  40673. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40674. /**
  40675. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40676. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40677. */
  40678. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40679. /**
  40680. * Creates a new AnaglyphArcRotateCamera
  40681. * @param name defines camera name
  40682. * @param alpha defines alpha angle (in radians)
  40683. * @param beta defines beta angle (in radians)
  40684. * @param radius defines radius
  40685. * @param target defines camera target
  40686. * @param interaxialDistance defines distance between each color axis
  40687. * @param scene defines the hosting scene
  40688. */
  40689. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40690. /**
  40691. * Gets camera class name
  40692. * @returns AnaglyphArcRotateCamera
  40693. */
  40694. getClassName(): string;
  40695. }
  40696. }
  40697. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40698. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40699. import { Scene } from "babylonjs/scene";
  40700. import { Vector3 } from "babylonjs/Maths/math.vector";
  40701. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40702. /**
  40703. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40704. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40705. */
  40706. export class AnaglyphFreeCamera extends FreeCamera {
  40707. /**
  40708. * Creates a new AnaglyphFreeCamera
  40709. * @param name defines camera name
  40710. * @param position defines initial position
  40711. * @param interaxialDistance defines distance between each color axis
  40712. * @param scene defines the hosting scene
  40713. */
  40714. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40715. /**
  40716. * Gets camera class name
  40717. * @returns AnaglyphFreeCamera
  40718. */
  40719. getClassName(): string;
  40720. }
  40721. }
  40722. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40723. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40724. import { Scene } from "babylonjs/scene";
  40725. import { Vector3 } from "babylonjs/Maths/math.vector";
  40726. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40727. /**
  40728. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40729. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40730. */
  40731. export class AnaglyphGamepadCamera extends GamepadCamera {
  40732. /**
  40733. * Creates a new AnaglyphGamepadCamera
  40734. * @param name defines camera name
  40735. * @param position defines initial position
  40736. * @param interaxialDistance defines distance between each color axis
  40737. * @param scene defines the hosting scene
  40738. */
  40739. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40740. /**
  40741. * Gets camera class name
  40742. * @returns AnaglyphGamepadCamera
  40743. */
  40744. getClassName(): string;
  40745. }
  40746. }
  40747. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40748. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40749. import { Scene } from "babylonjs/scene";
  40750. import { Vector3 } from "babylonjs/Maths/math.vector";
  40751. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40752. /**
  40753. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40754. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40755. */
  40756. export class AnaglyphUniversalCamera extends UniversalCamera {
  40757. /**
  40758. * Creates a new AnaglyphUniversalCamera
  40759. * @param name defines camera name
  40760. * @param position defines initial position
  40761. * @param interaxialDistance defines distance between each color axis
  40762. * @param scene defines the hosting scene
  40763. */
  40764. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40765. /**
  40766. * Gets camera class name
  40767. * @returns AnaglyphUniversalCamera
  40768. */
  40769. getClassName(): string;
  40770. }
  40771. }
  40772. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40773. /** @hidden */
  40774. export var stereoscopicInterlacePixelShader: {
  40775. name: string;
  40776. shader: string;
  40777. };
  40778. }
  40779. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40780. import { Camera } from "babylonjs/Cameras/camera";
  40781. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40782. import { Engine } from "babylonjs/Engines/engine";
  40783. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40784. /**
  40785. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40786. */
  40787. export class StereoscopicInterlacePostProcess extends PostProcess {
  40788. private _stepSize;
  40789. private _passedProcess;
  40790. /**
  40791. * Initializes a StereoscopicInterlacePostProcess
  40792. * @param name The name of the effect.
  40793. * @param rigCameras The rig cameras to be appled to the post process
  40794. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40796. * @param engine The engine which the post process will be applied. (default: current engine)
  40797. * @param reusable If the post process can be reused on the same frame. (default: false)
  40798. */
  40799. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40800. }
  40801. }
  40802. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40803. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40804. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40805. import { Scene } from "babylonjs/scene";
  40806. import { Vector3 } from "babylonjs/Maths/math.vector";
  40807. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40808. /**
  40809. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40810. * @see http://doc.babylonjs.com/features/cameras
  40811. */
  40812. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40813. /**
  40814. * Creates a new StereoscopicArcRotateCamera
  40815. * @param name defines camera name
  40816. * @param alpha defines alpha angle (in radians)
  40817. * @param beta defines beta angle (in radians)
  40818. * @param radius defines radius
  40819. * @param target defines camera target
  40820. * @param interaxialDistance defines distance between each color axis
  40821. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40822. * @param scene defines the hosting scene
  40823. */
  40824. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40825. /**
  40826. * Gets camera class name
  40827. * @returns StereoscopicArcRotateCamera
  40828. */
  40829. getClassName(): string;
  40830. }
  40831. }
  40832. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40833. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40834. import { Scene } from "babylonjs/scene";
  40835. import { Vector3 } from "babylonjs/Maths/math.vector";
  40836. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40837. /**
  40838. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40839. * @see http://doc.babylonjs.com/features/cameras
  40840. */
  40841. export class StereoscopicFreeCamera extends FreeCamera {
  40842. /**
  40843. * Creates a new StereoscopicFreeCamera
  40844. * @param name defines camera name
  40845. * @param position defines initial position
  40846. * @param interaxialDistance defines distance between each color axis
  40847. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40848. * @param scene defines the hosting scene
  40849. */
  40850. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40851. /**
  40852. * Gets camera class name
  40853. * @returns StereoscopicFreeCamera
  40854. */
  40855. getClassName(): string;
  40856. }
  40857. }
  40858. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40859. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40860. import { Scene } from "babylonjs/scene";
  40861. import { Vector3 } from "babylonjs/Maths/math.vector";
  40862. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40863. /**
  40864. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40865. * @see http://doc.babylonjs.com/features/cameras
  40866. */
  40867. export class StereoscopicGamepadCamera extends GamepadCamera {
  40868. /**
  40869. * Creates a new StereoscopicGamepadCamera
  40870. * @param name defines camera name
  40871. * @param position defines initial position
  40872. * @param interaxialDistance defines distance between each color axis
  40873. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40874. * @param scene defines the hosting scene
  40875. */
  40876. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40877. /**
  40878. * Gets camera class name
  40879. * @returns StereoscopicGamepadCamera
  40880. */
  40881. getClassName(): string;
  40882. }
  40883. }
  40884. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40885. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40886. import { Scene } from "babylonjs/scene";
  40887. import { Vector3 } from "babylonjs/Maths/math.vector";
  40888. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40889. /**
  40890. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40891. * @see http://doc.babylonjs.com/features/cameras
  40892. */
  40893. export class StereoscopicUniversalCamera extends UniversalCamera {
  40894. /**
  40895. * Creates a new StereoscopicUniversalCamera
  40896. * @param name defines camera name
  40897. * @param position defines initial position
  40898. * @param interaxialDistance defines distance between each color axis
  40899. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40900. * @param scene defines the hosting scene
  40901. */
  40902. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40903. /**
  40904. * Gets camera class name
  40905. * @returns StereoscopicUniversalCamera
  40906. */
  40907. getClassName(): string;
  40908. }
  40909. }
  40910. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40911. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40912. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40913. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40914. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40915. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40916. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40917. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40918. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40919. }
  40920. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40921. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40922. import { Scene } from "babylonjs/scene";
  40923. import { Vector3 } from "babylonjs/Maths/math.vector";
  40924. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40925. /**
  40926. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40927. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40928. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40929. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40930. */
  40931. export class VirtualJoysticksCamera extends FreeCamera {
  40932. /**
  40933. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40934. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40935. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40936. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40937. * @param name Define the name of the camera in the scene
  40938. * @param position Define the start position of the camera in the scene
  40939. * @param scene Define the scene the camera belongs to
  40940. */
  40941. constructor(name: string, position: Vector3, scene: Scene);
  40942. /**
  40943. * Gets the current object class name.
  40944. * @return the class name
  40945. */
  40946. getClassName(): string;
  40947. }
  40948. }
  40949. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40950. import { Matrix } from "babylonjs/Maths/math.vector";
  40951. /**
  40952. * This represents all the required metrics to create a VR camera.
  40953. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40954. */
  40955. export class VRCameraMetrics {
  40956. /**
  40957. * Define the horizontal resolution off the screen.
  40958. */
  40959. hResolution: number;
  40960. /**
  40961. * Define the vertical resolution off the screen.
  40962. */
  40963. vResolution: number;
  40964. /**
  40965. * Define the horizontal screen size.
  40966. */
  40967. hScreenSize: number;
  40968. /**
  40969. * Define the vertical screen size.
  40970. */
  40971. vScreenSize: number;
  40972. /**
  40973. * Define the vertical screen center position.
  40974. */
  40975. vScreenCenter: number;
  40976. /**
  40977. * Define the distance of the eyes to the screen.
  40978. */
  40979. eyeToScreenDistance: number;
  40980. /**
  40981. * Define the distance between both lenses
  40982. */
  40983. lensSeparationDistance: number;
  40984. /**
  40985. * Define the distance between both viewer's eyes.
  40986. */
  40987. interpupillaryDistance: number;
  40988. /**
  40989. * Define the distortion factor of the VR postprocess.
  40990. * Please, touch with care.
  40991. */
  40992. distortionK: number[];
  40993. /**
  40994. * Define the chromatic aberration correction factors for the VR post process.
  40995. */
  40996. chromaAbCorrection: number[];
  40997. /**
  40998. * Define the scale factor of the post process.
  40999. * The smaller the better but the slower.
  41000. */
  41001. postProcessScaleFactor: number;
  41002. /**
  41003. * Define an offset for the lens center.
  41004. */
  41005. lensCenterOffset: number;
  41006. /**
  41007. * Define if the current vr camera should compensate the distortion of the lense or not.
  41008. */
  41009. compensateDistortion: boolean;
  41010. /**
  41011. * Defines if multiview should be enabled when rendering (Default: false)
  41012. */
  41013. multiviewEnabled: boolean;
  41014. /**
  41015. * Gets the rendering aspect ratio based on the provided resolutions.
  41016. */
  41017. readonly aspectRatio: number;
  41018. /**
  41019. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41020. */
  41021. readonly aspectRatioFov: number;
  41022. /**
  41023. * @hidden
  41024. */
  41025. readonly leftHMatrix: Matrix;
  41026. /**
  41027. * @hidden
  41028. */
  41029. readonly rightHMatrix: Matrix;
  41030. /**
  41031. * @hidden
  41032. */
  41033. readonly leftPreViewMatrix: Matrix;
  41034. /**
  41035. * @hidden
  41036. */
  41037. readonly rightPreViewMatrix: Matrix;
  41038. /**
  41039. * Get the default VRMetrics based on the most generic setup.
  41040. * @returns the default vr metrics
  41041. */
  41042. static GetDefault(): VRCameraMetrics;
  41043. }
  41044. }
  41045. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41046. /** @hidden */
  41047. export var vrDistortionCorrectionPixelShader: {
  41048. name: string;
  41049. shader: string;
  41050. };
  41051. }
  41052. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41053. import { Camera } from "babylonjs/Cameras/camera";
  41054. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41055. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41056. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41057. /**
  41058. * VRDistortionCorrectionPostProcess used for mobile VR
  41059. */
  41060. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41061. private _isRightEye;
  41062. private _distortionFactors;
  41063. private _postProcessScaleFactor;
  41064. private _lensCenterOffset;
  41065. private _scaleIn;
  41066. private _scaleFactor;
  41067. private _lensCenter;
  41068. /**
  41069. * Initializes the VRDistortionCorrectionPostProcess
  41070. * @param name The name of the effect.
  41071. * @param camera The camera to apply the render pass to.
  41072. * @param isRightEye If this is for the right eye distortion
  41073. * @param vrMetrics All the required metrics for the VR camera
  41074. */
  41075. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41076. }
  41077. }
  41078. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41079. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41080. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41081. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41082. import { Scene } from "babylonjs/scene";
  41083. import { Vector3 } from "babylonjs/Maths/math.vector";
  41084. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41085. import "babylonjs/Cameras/RigModes/vrRigMode";
  41086. /**
  41087. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41088. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41089. */
  41090. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41091. /**
  41092. * Creates a new VRDeviceOrientationArcRotateCamera
  41093. * @param name defines camera name
  41094. * @param alpha defines the camera rotation along the logitudinal axis
  41095. * @param beta defines the camera rotation along the latitudinal axis
  41096. * @param radius defines the camera distance from its target
  41097. * @param target defines the camera target
  41098. * @param scene defines the scene the camera belongs to
  41099. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41100. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41101. */
  41102. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41103. /**
  41104. * Gets camera class name
  41105. * @returns VRDeviceOrientationArcRotateCamera
  41106. */
  41107. getClassName(): string;
  41108. }
  41109. }
  41110. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41111. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41112. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41113. import { Scene } from "babylonjs/scene";
  41114. import { Vector3 } from "babylonjs/Maths/math.vector";
  41115. import "babylonjs/Cameras/RigModes/vrRigMode";
  41116. /**
  41117. * Camera used to simulate VR rendering (based on FreeCamera)
  41118. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41119. */
  41120. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41121. /**
  41122. * Creates a new VRDeviceOrientationFreeCamera
  41123. * @param name defines camera name
  41124. * @param position defines the start position of the camera
  41125. * @param scene defines the scene the camera belongs to
  41126. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41127. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41128. */
  41129. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41130. /**
  41131. * Gets camera class name
  41132. * @returns VRDeviceOrientationFreeCamera
  41133. */
  41134. getClassName(): string;
  41135. }
  41136. }
  41137. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41138. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41139. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41140. import { Scene } from "babylonjs/scene";
  41141. import { Vector3 } from "babylonjs/Maths/math.vector";
  41142. import "babylonjs/Gamepads/gamepadSceneComponent";
  41143. /**
  41144. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41145. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41146. */
  41147. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41148. /**
  41149. * Creates a new VRDeviceOrientationGamepadCamera
  41150. * @param name defines camera name
  41151. * @param position defines the start position of the camera
  41152. * @param scene defines the scene the camera belongs to
  41153. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41154. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41155. */
  41156. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41157. /**
  41158. * Gets camera class name
  41159. * @returns VRDeviceOrientationGamepadCamera
  41160. */
  41161. getClassName(): string;
  41162. }
  41163. }
  41164. declare module "babylonjs/Materials/pushMaterial" {
  41165. import { Nullable } from "babylonjs/types";
  41166. import { Scene } from "babylonjs/scene";
  41167. import { Matrix } from "babylonjs/Maths/math.vector";
  41168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41169. import { Mesh } from "babylonjs/Meshes/mesh";
  41170. import { Material } from "babylonjs/Materials/material";
  41171. import { Effect } from "babylonjs/Materials/effect";
  41172. /**
  41173. * Base class of materials working in push mode in babylon JS
  41174. * @hidden
  41175. */
  41176. export class PushMaterial extends Material {
  41177. protected _activeEffect: Effect;
  41178. protected _normalMatrix: Matrix;
  41179. /**
  41180. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41181. * This means that the material can keep using a previous shader while a new one is being compiled.
  41182. * This is mostly used when shader parallel compilation is supported (true by default)
  41183. */
  41184. allowShaderHotSwapping: boolean;
  41185. constructor(name: string, scene: Scene);
  41186. getEffect(): Effect;
  41187. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41188. /**
  41189. * Binds the given world matrix to the active effect
  41190. *
  41191. * @param world the matrix to bind
  41192. */
  41193. bindOnlyWorldMatrix(world: Matrix): void;
  41194. /**
  41195. * Binds the given normal matrix to the active effect
  41196. *
  41197. * @param normalMatrix the matrix to bind
  41198. */
  41199. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41200. bind(world: Matrix, mesh?: Mesh): void;
  41201. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41202. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41203. }
  41204. }
  41205. declare module "babylonjs/Materials/materialFlags" {
  41206. /**
  41207. * This groups all the flags used to control the materials channel.
  41208. */
  41209. export class MaterialFlags {
  41210. private static _DiffuseTextureEnabled;
  41211. /**
  41212. * Are diffuse textures enabled in the application.
  41213. */
  41214. static DiffuseTextureEnabled: boolean;
  41215. private static _AmbientTextureEnabled;
  41216. /**
  41217. * Are ambient textures enabled in the application.
  41218. */
  41219. static AmbientTextureEnabled: boolean;
  41220. private static _OpacityTextureEnabled;
  41221. /**
  41222. * Are opacity textures enabled in the application.
  41223. */
  41224. static OpacityTextureEnabled: boolean;
  41225. private static _ReflectionTextureEnabled;
  41226. /**
  41227. * Are reflection textures enabled in the application.
  41228. */
  41229. static ReflectionTextureEnabled: boolean;
  41230. private static _EmissiveTextureEnabled;
  41231. /**
  41232. * Are emissive textures enabled in the application.
  41233. */
  41234. static EmissiveTextureEnabled: boolean;
  41235. private static _SpecularTextureEnabled;
  41236. /**
  41237. * Are specular textures enabled in the application.
  41238. */
  41239. static SpecularTextureEnabled: boolean;
  41240. private static _BumpTextureEnabled;
  41241. /**
  41242. * Are bump textures enabled in the application.
  41243. */
  41244. static BumpTextureEnabled: boolean;
  41245. private static _LightmapTextureEnabled;
  41246. /**
  41247. * Are lightmap textures enabled in the application.
  41248. */
  41249. static LightmapTextureEnabled: boolean;
  41250. private static _RefractionTextureEnabled;
  41251. /**
  41252. * Are refraction textures enabled in the application.
  41253. */
  41254. static RefractionTextureEnabled: boolean;
  41255. private static _ColorGradingTextureEnabled;
  41256. /**
  41257. * Are color grading textures enabled in the application.
  41258. */
  41259. static ColorGradingTextureEnabled: boolean;
  41260. private static _FresnelEnabled;
  41261. /**
  41262. * Are fresnels enabled in the application.
  41263. */
  41264. static FresnelEnabled: boolean;
  41265. private static _ClearCoatTextureEnabled;
  41266. /**
  41267. * Are clear coat textures enabled in the application.
  41268. */
  41269. static ClearCoatTextureEnabled: boolean;
  41270. private static _ClearCoatBumpTextureEnabled;
  41271. /**
  41272. * Are clear coat bump textures enabled in the application.
  41273. */
  41274. static ClearCoatBumpTextureEnabled: boolean;
  41275. private static _ClearCoatTintTextureEnabled;
  41276. /**
  41277. * Are clear coat tint textures enabled in the application.
  41278. */
  41279. static ClearCoatTintTextureEnabled: boolean;
  41280. private static _SheenTextureEnabled;
  41281. /**
  41282. * Are sheen textures enabled in the application.
  41283. */
  41284. static SheenTextureEnabled: boolean;
  41285. private static _AnisotropicTextureEnabled;
  41286. /**
  41287. * Are anisotropic textures enabled in the application.
  41288. */
  41289. static AnisotropicTextureEnabled: boolean;
  41290. private static _ThicknessTextureEnabled;
  41291. /**
  41292. * Are thickness textures enabled in the application.
  41293. */
  41294. static ThicknessTextureEnabled: boolean;
  41295. }
  41296. }
  41297. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41298. /** @hidden */
  41299. export var defaultFragmentDeclaration: {
  41300. name: string;
  41301. shader: string;
  41302. };
  41303. }
  41304. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41305. /** @hidden */
  41306. export var defaultUboDeclaration: {
  41307. name: string;
  41308. shader: string;
  41309. };
  41310. }
  41311. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41312. /** @hidden */
  41313. export var lightFragmentDeclaration: {
  41314. name: string;
  41315. shader: string;
  41316. };
  41317. }
  41318. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41319. /** @hidden */
  41320. export var lightUboDeclaration: {
  41321. name: string;
  41322. shader: string;
  41323. };
  41324. }
  41325. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41326. /** @hidden */
  41327. export var lightsFragmentFunctions: {
  41328. name: string;
  41329. shader: string;
  41330. };
  41331. }
  41332. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41333. /** @hidden */
  41334. export var shadowsFragmentFunctions: {
  41335. name: string;
  41336. shader: string;
  41337. };
  41338. }
  41339. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41340. /** @hidden */
  41341. export var fresnelFunction: {
  41342. name: string;
  41343. shader: string;
  41344. };
  41345. }
  41346. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41347. /** @hidden */
  41348. export var reflectionFunction: {
  41349. name: string;
  41350. shader: string;
  41351. };
  41352. }
  41353. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41354. /** @hidden */
  41355. export var bumpFragmentFunctions: {
  41356. name: string;
  41357. shader: string;
  41358. };
  41359. }
  41360. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41361. /** @hidden */
  41362. export var logDepthDeclaration: {
  41363. name: string;
  41364. shader: string;
  41365. };
  41366. }
  41367. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41368. /** @hidden */
  41369. export var bumpFragment: {
  41370. name: string;
  41371. shader: string;
  41372. };
  41373. }
  41374. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41375. /** @hidden */
  41376. export var depthPrePass: {
  41377. name: string;
  41378. shader: string;
  41379. };
  41380. }
  41381. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41382. /** @hidden */
  41383. export var lightFragment: {
  41384. name: string;
  41385. shader: string;
  41386. };
  41387. }
  41388. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41389. /** @hidden */
  41390. export var logDepthFragment: {
  41391. name: string;
  41392. shader: string;
  41393. };
  41394. }
  41395. declare module "babylonjs/Shaders/default.fragment" {
  41396. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41397. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41398. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41399. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41400. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41401. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41402. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41403. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41404. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41405. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41406. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41407. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41408. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41409. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41410. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41411. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41412. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41413. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41414. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41415. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41416. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41417. /** @hidden */
  41418. export var defaultPixelShader: {
  41419. name: string;
  41420. shader: string;
  41421. };
  41422. }
  41423. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41424. /** @hidden */
  41425. export var defaultVertexDeclaration: {
  41426. name: string;
  41427. shader: string;
  41428. };
  41429. }
  41430. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41431. /** @hidden */
  41432. export var bumpVertexDeclaration: {
  41433. name: string;
  41434. shader: string;
  41435. };
  41436. }
  41437. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41438. /** @hidden */
  41439. export var bumpVertex: {
  41440. name: string;
  41441. shader: string;
  41442. };
  41443. }
  41444. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41445. /** @hidden */
  41446. export var fogVertex: {
  41447. name: string;
  41448. shader: string;
  41449. };
  41450. }
  41451. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41452. /** @hidden */
  41453. export var shadowsVertex: {
  41454. name: string;
  41455. shader: string;
  41456. };
  41457. }
  41458. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41459. /** @hidden */
  41460. export var pointCloudVertex: {
  41461. name: string;
  41462. shader: string;
  41463. };
  41464. }
  41465. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41466. /** @hidden */
  41467. export var logDepthVertex: {
  41468. name: string;
  41469. shader: string;
  41470. };
  41471. }
  41472. declare module "babylonjs/Shaders/default.vertex" {
  41473. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41474. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41475. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41476. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41477. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41478. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41479. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41480. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41481. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41482. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41483. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41484. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41485. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41486. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41487. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41488. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41489. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41490. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41491. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41492. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41493. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41494. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41495. /** @hidden */
  41496. export var defaultVertexShader: {
  41497. name: string;
  41498. shader: string;
  41499. };
  41500. }
  41501. declare module "babylonjs/Materials/standardMaterial" {
  41502. import { SmartArray } from "babylonjs/Misc/smartArray";
  41503. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41504. import { Nullable } from "babylonjs/types";
  41505. import { Scene } from "babylonjs/scene";
  41506. import { Matrix } from "babylonjs/Maths/math.vector";
  41507. import { Color3 } from "babylonjs/Maths/math.color";
  41508. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41510. import { Mesh } from "babylonjs/Meshes/mesh";
  41511. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41512. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41513. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41514. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41515. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41516. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41517. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41518. import "babylonjs/Shaders/default.fragment";
  41519. import "babylonjs/Shaders/default.vertex";
  41520. /** @hidden */
  41521. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41522. MAINUV1: boolean;
  41523. MAINUV2: boolean;
  41524. DIFFUSE: boolean;
  41525. DIFFUSEDIRECTUV: number;
  41526. AMBIENT: boolean;
  41527. AMBIENTDIRECTUV: number;
  41528. OPACITY: boolean;
  41529. OPACITYDIRECTUV: number;
  41530. OPACITYRGB: boolean;
  41531. REFLECTION: boolean;
  41532. EMISSIVE: boolean;
  41533. EMISSIVEDIRECTUV: number;
  41534. SPECULAR: boolean;
  41535. SPECULARDIRECTUV: number;
  41536. BUMP: boolean;
  41537. BUMPDIRECTUV: number;
  41538. PARALLAX: boolean;
  41539. PARALLAXOCCLUSION: boolean;
  41540. SPECULAROVERALPHA: boolean;
  41541. CLIPPLANE: boolean;
  41542. CLIPPLANE2: boolean;
  41543. CLIPPLANE3: boolean;
  41544. CLIPPLANE4: boolean;
  41545. ALPHATEST: boolean;
  41546. DEPTHPREPASS: boolean;
  41547. ALPHAFROMDIFFUSE: boolean;
  41548. POINTSIZE: boolean;
  41549. FOG: boolean;
  41550. SPECULARTERM: boolean;
  41551. DIFFUSEFRESNEL: boolean;
  41552. OPACITYFRESNEL: boolean;
  41553. REFLECTIONFRESNEL: boolean;
  41554. REFRACTIONFRESNEL: boolean;
  41555. EMISSIVEFRESNEL: boolean;
  41556. FRESNEL: boolean;
  41557. NORMAL: boolean;
  41558. UV1: boolean;
  41559. UV2: boolean;
  41560. VERTEXCOLOR: boolean;
  41561. VERTEXALPHA: boolean;
  41562. NUM_BONE_INFLUENCERS: number;
  41563. BonesPerMesh: number;
  41564. BONETEXTURE: boolean;
  41565. INSTANCES: boolean;
  41566. GLOSSINESS: boolean;
  41567. ROUGHNESS: boolean;
  41568. EMISSIVEASILLUMINATION: boolean;
  41569. LINKEMISSIVEWITHDIFFUSE: boolean;
  41570. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41571. LIGHTMAP: boolean;
  41572. LIGHTMAPDIRECTUV: number;
  41573. OBJECTSPACE_NORMALMAP: boolean;
  41574. USELIGHTMAPASSHADOWMAP: boolean;
  41575. REFLECTIONMAP_3D: boolean;
  41576. REFLECTIONMAP_SPHERICAL: boolean;
  41577. REFLECTIONMAP_PLANAR: boolean;
  41578. REFLECTIONMAP_CUBIC: boolean;
  41579. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41580. REFLECTIONMAP_PROJECTION: boolean;
  41581. REFLECTIONMAP_SKYBOX: boolean;
  41582. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41583. REFLECTIONMAP_EXPLICIT: boolean;
  41584. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41585. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41586. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41587. INVERTCUBICMAP: boolean;
  41588. LOGARITHMICDEPTH: boolean;
  41589. REFRACTION: boolean;
  41590. REFRACTIONMAP_3D: boolean;
  41591. REFLECTIONOVERALPHA: boolean;
  41592. TWOSIDEDLIGHTING: boolean;
  41593. SHADOWFLOAT: boolean;
  41594. MORPHTARGETS: boolean;
  41595. MORPHTARGETS_NORMAL: boolean;
  41596. MORPHTARGETS_TANGENT: boolean;
  41597. MORPHTARGETS_UV: boolean;
  41598. NUM_MORPH_INFLUENCERS: number;
  41599. NONUNIFORMSCALING: boolean;
  41600. PREMULTIPLYALPHA: boolean;
  41601. IMAGEPROCESSING: boolean;
  41602. VIGNETTE: boolean;
  41603. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41604. VIGNETTEBLENDMODEOPAQUE: boolean;
  41605. TONEMAPPING: boolean;
  41606. TONEMAPPING_ACES: boolean;
  41607. CONTRAST: boolean;
  41608. COLORCURVES: boolean;
  41609. COLORGRADING: boolean;
  41610. COLORGRADING3D: boolean;
  41611. SAMPLER3DGREENDEPTH: boolean;
  41612. SAMPLER3DBGRMAP: boolean;
  41613. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41614. MULTIVIEW: boolean;
  41615. /**
  41616. * If the reflection texture on this material is in linear color space
  41617. * @hidden
  41618. */
  41619. IS_REFLECTION_LINEAR: boolean;
  41620. /**
  41621. * If the refraction texture on this material is in linear color space
  41622. * @hidden
  41623. */
  41624. IS_REFRACTION_LINEAR: boolean;
  41625. EXPOSURE: boolean;
  41626. constructor();
  41627. setReflectionMode(modeToEnable: string): void;
  41628. }
  41629. /**
  41630. * This is the default material used in Babylon. It is the best trade off between quality
  41631. * and performances.
  41632. * @see http://doc.babylonjs.com/babylon101/materials
  41633. */
  41634. export class StandardMaterial extends PushMaterial {
  41635. private _diffuseTexture;
  41636. /**
  41637. * The basic texture of the material as viewed under a light.
  41638. */
  41639. diffuseTexture: Nullable<BaseTexture>;
  41640. private _ambientTexture;
  41641. /**
  41642. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41643. */
  41644. ambientTexture: Nullable<BaseTexture>;
  41645. private _opacityTexture;
  41646. /**
  41647. * Define the transparency of the material from a texture.
  41648. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41649. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41650. */
  41651. opacityTexture: Nullable<BaseTexture>;
  41652. private _reflectionTexture;
  41653. /**
  41654. * Define the texture used to display the reflection.
  41655. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41656. */
  41657. reflectionTexture: Nullable<BaseTexture>;
  41658. private _emissiveTexture;
  41659. /**
  41660. * Define texture of the material as if self lit.
  41661. * This will be mixed in the final result even in the absence of light.
  41662. */
  41663. emissiveTexture: Nullable<BaseTexture>;
  41664. private _specularTexture;
  41665. /**
  41666. * Define how the color and intensity of the highlight given by the light in the material.
  41667. */
  41668. specularTexture: Nullable<BaseTexture>;
  41669. private _bumpTexture;
  41670. /**
  41671. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41672. * 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.
  41673. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41674. */
  41675. bumpTexture: Nullable<BaseTexture>;
  41676. private _lightmapTexture;
  41677. /**
  41678. * Complex lighting can be computationally expensive to compute at runtime.
  41679. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41680. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41681. */
  41682. lightmapTexture: Nullable<BaseTexture>;
  41683. private _refractionTexture;
  41684. /**
  41685. * Define the texture used to display the refraction.
  41686. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41687. */
  41688. refractionTexture: Nullable<BaseTexture>;
  41689. /**
  41690. * The color of the material lit by the environmental background lighting.
  41691. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41692. */
  41693. ambientColor: Color3;
  41694. /**
  41695. * The basic color of the material as viewed under a light.
  41696. */
  41697. diffuseColor: Color3;
  41698. /**
  41699. * Define how the color and intensity of the highlight given by the light in the material.
  41700. */
  41701. specularColor: Color3;
  41702. /**
  41703. * Define the color of the material as if self lit.
  41704. * This will be mixed in the final result even in the absence of light.
  41705. */
  41706. emissiveColor: Color3;
  41707. /**
  41708. * Defines how sharp are the highlights in the material.
  41709. * The bigger the value the sharper giving a more glossy feeling to the result.
  41710. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41711. */
  41712. specularPower: number;
  41713. private _useAlphaFromDiffuseTexture;
  41714. /**
  41715. * Does the transparency come from the diffuse texture alpha channel.
  41716. */
  41717. useAlphaFromDiffuseTexture: boolean;
  41718. private _useEmissiveAsIllumination;
  41719. /**
  41720. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41721. */
  41722. useEmissiveAsIllumination: boolean;
  41723. private _linkEmissiveWithDiffuse;
  41724. /**
  41725. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41726. * the emissive level when the final color is close to one.
  41727. */
  41728. linkEmissiveWithDiffuse: boolean;
  41729. private _useSpecularOverAlpha;
  41730. /**
  41731. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41732. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41733. */
  41734. useSpecularOverAlpha: boolean;
  41735. private _useReflectionOverAlpha;
  41736. /**
  41737. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41738. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41739. */
  41740. useReflectionOverAlpha: boolean;
  41741. private _disableLighting;
  41742. /**
  41743. * Does lights from the scene impacts this material.
  41744. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41745. */
  41746. disableLighting: boolean;
  41747. private _useObjectSpaceNormalMap;
  41748. /**
  41749. * Allows using an object space normal map (instead of tangent space).
  41750. */
  41751. useObjectSpaceNormalMap: boolean;
  41752. private _useParallax;
  41753. /**
  41754. * Is parallax enabled or not.
  41755. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41756. */
  41757. useParallax: boolean;
  41758. private _useParallaxOcclusion;
  41759. /**
  41760. * Is parallax occlusion enabled or not.
  41761. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41762. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41763. */
  41764. useParallaxOcclusion: boolean;
  41765. /**
  41766. * 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.
  41767. */
  41768. parallaxScaleBias: number;
  41769. private _roughness;
  41770. /**
  41771. * Helps to define how blurry the reflections should appears in the material.
  41772. */
  41773. roughness: number;
  41774. /**
  41775. * In case of refraction, define the value of the index of refraction.
  41776. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41777. */
  41778. indexOfRefraction: number;
  41779. /**
  41780. * Invert the refraction texture alongside the y axis.
  41781. * It can be useful with procedural textures or probe for instance.
  41782. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41783. */
  41784. invertRefractionY: boolean;
  41785. /**
  41786. * Defines the alpha limits in alpha test mode.
  41787. */
  41788. alphaCutOff: number;
  41789. private _useLightmapAsShadowmap;
  41790. /**
  41791. * In case of light mapping, define whether the map contains light or shadow informations.
  41792. */
  41793. useLightmapAsShadowmap: boolean;
  41794. private _diffuseFresnelParameters;
  41795. /**
  41796. * Define the diffuse fresnel parameters of the material.
  41797. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41798. */
  41799. diffuseFresnelParameters: FresnelParameters;
  41800. private _opacityFresnelParameters;
  41801. /**
  41802. * Define the opacity fresnel parameters of the material.
  41803. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41804. */
  41805. opacityFresnelParameters: FresnelParameters;
  41806. private _reflectionFresnelParameters;
  41807. /**
  41808. * Define the reflection fresnel parameters of the material.
  41809. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41810. */
  41811. reflectionFresnelParameters: FresnelParameters;
  41812. private _refractionFresnelParameters;
  41813. /**
  41814. * Define the refraction fresnel parameters of the material.
  41815. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41816. */
  41817. refractionFresnelParameters: FresnelParameters;
  41818. private _emissiveFresnelParameters;
  41819. /**
  41820. * Define the emissive fresnel parameters of the material.
  41821. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41822. */
  41823. emissiveFresnelParameters: FresnelParameters;
  41824. private _useReflectionFresnelFromSpecular;
  41825. /**
  41826. * If true automatically deducts the fresnels values from the material specularity.
  41827. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41828. */
  41829. useReflectionFresnelFromSpecular: boolean;
  41830. private _useGlossinessFromSpecularMapAlpha;
  41831. /**
  41832. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41833. */
  41834. useGlossinessFromSpecularMapAlpha: boolean;
  41835. private _maxSimultaneousLights;
  41836. /**
  41837. * Defines the maximum number of lights that can be used in the material
  41838. */
  41839. maxSimultaneousLights: number;
  41840. private _invertNormalMapX;
  41841. /**
  41842. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41843. */
  41844. invertNormalMapX: boolean;
  41845. private _invertNormalMapY;
  41846. /**
  41847. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41848. */
  41849. invertNormalMapY: boolean;
  41850. private _twoSidedLighting;
  41851. /**
  41852. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41853. */
  41854. twoSidedLighting: boolean;
  41855. /**
  41856. * Default configuration related to image processing available in the standard Material.
  41857. */
  41858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41859. /**
  41860. * Gets the image processing configuration used either in this material.
  41861. */
  41862. /**
  41863. * Sets the Default image processing configuration used either in the this material.
  41864. *
  41865. * If sets to null, the scene one is in use.
  41866. */
  41867. imageProcessingConfiguration: ImageProcessingConfiguration;
  41868. /**
  41869. * Keep track of the image processing observer to allow dispose and replace.
  41870. */
  41871. private _imageProcessingObserver;
  41872. /**
  41873. * Attaches a new image processing configuration to the Standard Material.
  41874. * @param configuration
  41875. */
  41876. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41877. /**
  41878. * Gets wether the color curves effect is enabled.
  41879. */
  41880. /**
  41881. * Sets wether the color curves effect is enabled.
  41882. */
  41883. cameraColorCurvesEnabled: boolean;
  41884. /**
  41885. * Gets wether the color grading effect is enabled.
  41886. */
  41887. /**
  41888. * Gets wether the color grading effect is enabled.
  41889. */
  41890. cameraColorGradingEnabled: boolean;
  41891. /**
  41892. * Gets wether tonemapping is enabled or not.
  41893. */
  41894. /**
  41895. * Sets wether tonemapping is enabled or not
  41896. */
  41897. cameraToneMappingEnabled: boolean;
  41898. /**
  41899. * The camera exposure used on this material.
  41900. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41901. * This corresponds to a photographic exposure.
  41902. */
  41903. /**
  41904. * The camera exposure used on this material.
  41905. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41906. * This corresponds to a photographic exposure.
  41907. */
  41908. cameraExposure: number;
  41909. /**
  41910. * Gets The camera contrast used on this material.
  41911. */
  41912. /**
  41913. * Sets The camera contrast used on this material.
  41914. */
  41915. cameraContrast: number;
  41916. /**
  41917. * Gets the Color Grading 2D Lookup Texture.
  41918. */
  41919. /**
  41920. * Sets the Color Grading 2D Lookup Texture.
  41921. */
  41922. cameraColorGradingTexture: Nullable<BaseTexture>;
  41923. /**
  41924. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41925. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41926. * 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;
  41927. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41928. */
  41929. /**
  41930. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41931. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41932. * 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;
  41933. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41934. */
  41935. cameraColorCurves: Nullable<ColorCurves>;
  41936. /**
  41937. * Custom callback helping to override the default shader used in the material.
  41938. */
  41939. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41940. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41941. protected _worldViewProjectionMatrix: Matrix;
  41942. protected _globalAmbientColor: Color3;
  41943. protected _useLogarithmicDepth: boolean;
  41944. protected _rebuildInParallel: boolean;
  41945. /**
  41946. * Instantiates a new standard material.
  41947. * This is the default material used in Babylon. It is the best trade off between quality
  41948. * and performances.
  41949. * @see http://doc.babylonjs.com/babylon101/materials
  41950. * @param name Define the name of the material in the scene
  41951. * @param scene Define the scene the material belong to
  41952. */
  41953. constructor(name: string, scene: Scene);
  41954. /**
  41955. * Gets a boolean indicating that current material needs to register RTT
  41956. */
  41957. readonly hasRenderTargetTextures: boolean;
  41958. /**
  41959. * Gets the current class name of the material e.g. "StandardMaterial"
  41960. * Mainly use in serialization.
  41961. * @returns the class name
  41962. */
  41963. getClassName(): string;
  41964. /**
  41965. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41966. * You can try switching to logarithmic depth.
  41967. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41968. */
  41969. useLogarithmicDepth: boolean;
  41970. /**
  41971. * Specifies if the material will require alpha blending
  41972. * @returns a boolean specifying if alpha blending is needed
  41973. */
  41974. needAlphaBlending(): boolean;
  41975. /**
  41976. * Specifies if this material should be rendered in alpha test mode
  41977. * @returns a boolean specifying if an alpha test is needed.
  41978. */
  41979. needAlphaTesting(): boolean;
  41980. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41981. /**
  41982. * Get the texture used for alpha test purpose.
  41983. * @returns the diffuse texture in case of the standard material.
  41984. */
  41985. getAlphaTestTexture(): Nullable<BaseTexture>;
  41986. /**
  41987. * Get if the submesh is ready to be used and all its information available.
  41988. * Child classes can use it to update shaders
  41989. * @param mesh defines the mesh to check
  41990. * @param subMesh defines which submesh to check
  41991. * @param useInstances specifies that instances should be used
  41992. * @returns a boolean indicating that the submesh is ready or not
  41993. */
  41994. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41995. /**
  41996. * Builds the material UBO layouts.
  41997. * Used internally during the effect preparation.
  41998. */
  41999. buildUniformLayout(): void;
  42000. /**
  42001. * Unbinds the material from the mesh
  42002. */
  42003. unbind(): void;
  42004. /**
  42005. * Binds the submesh to this material by preparing the effect and shader to draw
  42006. * @param world defines the world transformation matrix
  42007. * @param mesh defines the mesh containing the submesh
  42008. * @param subMesh defines the submesh to bind the material to
  42009. */
  42010. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42011. /**
  42012. * Get the list of animatables in the material.
  42013. * @returns the list of animatables object used in the material
  42014. */
  42015. getAnimatables(): IAnimatable[];
  42016. /**
  42017. * Gets the active textures from the material
  42018. * @returns an array of textures
  42019. */
  42020. getActiveTextures(): BaseTexture[];
  42021. /**
  42022. * Specifies if the material uses a texture
  42023. * @param texture defines the texture to check against the material
  42024. * @returns a boolean specifying if the material uses the texture
  42025. */
  42026. hasTexture(texture: BaseTexture): boolean;
  42027. /**
  42028. * Disposes the material
  42029. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42030. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42031. */
  42032. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42033. /**
  42034. * Makes a duplicate of the material, and gives it a new name
  42035. * @param name defines the new name for the duplicated material
  42036. * @returns the cloned material
  42037. */
  42038. clone(name: string): StandardMaterial;
  42039. /**
  42040. * Serializes this material in a JSON representation
  42041. * @returns the serialized material object
  42042. */
  42043. serialize(): any;
  42044. /**
  42045. * Creates a standard material from parsed material data
  42046. * @param source defines the JSON representation of the material
  42047. * @param scene defines the hosting scene
  42048. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42049. * @returns a new standard material
  42050. */
  42051. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42052. /**
  42053. * Are diffuse textures enabled in the application.
  42054. */
  42055. static DiffuseTextureEnabled: boolean;
  42056. /**
  42057. * Are ambient textures enabled in the application.
  42058. */
  42059. static AmbientTextureEnabled: boolean;
  42060. /**
  42061. * Are opacity textures enabled in the application.
  42062. */
  42063. static OpacityTextureEnabled: boolean;
  42064. /**
  42065. * Are reflection textures enabled in the application.
  42066. */
  42067. static ReflectionTextureEnabled: boolean;
  42068. /**
  42069. * Are emissive textures enabled in the application.
  42070. */
  42071. static EmissiveTextureEnabled: boolean;
  42072. /**
  42073. * Are specular textures enabled in the application.
  42074. */
  42075. static SpecularTextureEnabled: boolean;
  42076. /**
  42077. * Are bump textures enabled in the application.
  42078. */
  42079. static BumpTextureEnabled: boolean;
  42080. /**
  42081. * Are lightmap textures enabled in the application.
  42082. */
  42083. static LightmapTextureEnabled: boolean;
  42084. /**
  42085. * Are refraction textures enabled in the application.
  42086. */
  42087. static RefractionTextureEnabled: boolean;
  42088. /**
  42089. * Are color grading textures enabled in the application.
  42090. */
  42091. static ColorGradingTextureEnabled: boolean;
  42092. /**
  42093. * Are fresnels enabled in the application.
  42094. */
  42095. static FresnelEnabled: boolean;
  42096. }
  42097. }
  42098. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42099. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42100. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42101. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42102. /** @hidden */
  42103. export var imageProcessingPixelShader: {
  42104. name: string;
  42105. shader: string;
  42106. };
  42107. }
  42108. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42109. import { Nullable } from "babylonjs/types";
  42110. import { Color4 } from "babylonjs/Maths/math.color";
  42111. import { Camera } from "babylonjs/Cameras/camera";
  42112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42113. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42114. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42116. import { Engine } from "babylonjs/Engines/engine";
  42117. import "babylonjs/Shaders/imageProcessing.fragment";
  42118. import "babylonjs/Shaders/postprocess.vertex";
  42119. /**
  42120. * ImageProcessingPostProcess
  42121. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42122. */
  42123. export class ImageProcessingPostProcess extends PostProcess {
  42124. /**
  42125. * Default configuration related to image processing available in the PBR Material.
  42126. */
  42127. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42128. /**
  42129. * Gets the image processing configuration used either in this material.
  42130. */
  42131. /**
  42132. * Sets the Default image processing configuration used either in the this material.
  42133. *
  42134. * If sets to null, the scene one is in use.
  42135. */
  42136. imageProcessingConfiguration: ImageProcessingConfiguration;
  42137. /**
  42138. * Keep track of the image processing observer to allow dispose and replace.
  42139. */
  42140. private _imageProcessingObserver;
  42141. /**
  42142. * Attaches a new image processing configuration to the PBR Material.
  42143. * @param configuration
  42144. */
  42145. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42146. /**
  42147. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42148. */
  42149. /**
  42150. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42151. */
  42152. colorCurves: Nullable<ColorCurves>;
  42153. /**
  42154. * Gets wether the color curves effect is enabled.
  42155. */
  42156. /**
  42157. * Sets wether the color curves effect is enabled.
  42158. */
  42159. colorCurvesEnabled: boolean;
  42160. /**
  42161. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42162. */
  42163. /**
  42164. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42165. */
  42166. colorGradingTexture: Nullable<BaseTexture>;
  42167. /**
  42168. * Gets wether the color grading effect is enabled.
  42169. */
  42170. /**
  42171. * Gets wether the color grading effect is enabled.
  42172. */
  42173. colorGradingEnabled: boolean;
  42174. /**
  42175. * Gets exposure used in the effect.
  42176. */
  42177. /**
  42178. * Sets exposure used in the effect.
  42179. */
  42180. exposure: number;
  42181. /**
  42182. * Gets wether tonemapping is enabled or not.
  42183. */
  42184. /**
  42185. * Sets wether tonemapping is enabled or not
  42186. */
  42187. toneMappingEnabled: boolean;
  42188. /**
  42189. * Gets the type of tone mapping effect.
  42190. */
  42191. /**
  42192. * Sets the type of tone mapping effect.
  42193. */
  42194. toneMappingType: number;
  42195. /**
  42196. * Gets contrast used in the effect.
  42197. */
  42198. /**
  42199. * Sets contrast used in the effect.
  42200. */
  42201. contrast: number;
  42202. /**
  42203. * Gets Vignette stretch size.
  42204. */
  42205. /**
  42206. * Sets Vignette stretch size.
  42207. */
  42208. vignetteStretch: number;
  42209. /**
  42210. * Gets Vignette centre X Offset.
  42211. */
  42212. /**
  42213. * Sets Vignette centre X Offset.
  42214. */
  42215. vignetteCentreX: number;
  42216. /**
  42217. * Gets Vignette centre Y Offset.
  42218. */
  42219. /**
  42220. * Sets Vignette centre Y Offset.
  42221. */
  42222. vignetteCentreY: number;
  42223. /**
  42224. * Gets Vignette weight or intensity of the vignette effect.
  42225. */
  42226. /**
  42227. * Sets Vignette weight or intensity of the vignette effect.
  42228. */
  42229. vignetteWeight: number;
  42230. /**
  42231. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42232. * if vignetteEnabled is set to true.
  42233. */
  42234. /**
  42235. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42236. * if vignetteEnabled is set to true.
  42237. */
  42238. vignetteColor: Color4;
  42239. /**
  42240. * Gets Camera field of view used by the Vignette effect.
  42241. */
  42242. /**
  42243. * Sets Camera field of view used by the Vignette effect.
  42244. */
  42245. vignetteCameraFov: number;
  42246. /**
  42247. * Gets the vignette blend mode allowing different kind of effect.
  42248. */
  42249. /**
  42250. * Sets the vignette blend mode allowing different kind of effect.
  42251. */
  42252. vignetteBlendMode: number;
  42253. /**
  42254. * Gets wether the vignette effect is enabled.
  42255. */
  42256. /**
  42257. * Sets wether the vignette effect is enabled.
  42258. */
  42259. vignetteEnabled: boolean;
  42260. private _fromLinearSpace;
  42261. /**
  42262. * Gets wether the input of the processing is in Gamma or Linear Space.
  42263. */
  42264. /**
  42265. * Sets wether the input of the processing is in Gamma or Linear Space.
  42266. */
  42267. fromLinearSpace: boolean;
  42268. /**
  42269. * Defines cache preventing GC.
  42270. */
  42271. private _defines;
  42272. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42273. /**
  42274. * "ImageProcessingPostProcess"
  42275. * @returns "ImageProcessingPostProcess"
  42276. */
  42277. getClassName(): string;
  42278. protected _updateParameters(): void;
  42279. dispose(camera?: Camera): void;
  42280. }
  42281. }
  42282. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42283. import { Scene } from "babylonjs/scene";
  42284. import { Color3 } from "babylonjs/Maths/math.color";
  42285. import { Mesh } from "babylonjs/Meshes/mesh";
  42286. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42287. import { Nullable } from "babylonjs/types";
  42288. /**
  42289. * Class containing static functions to help procedurally build meshes
  42290. */
  42291. export class GroundBuilder {
  42292. /**
  42293. * Creates a ground mesh
  42294. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42295. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42297. * @param name defines the name of the mesh
  42298. * @param options defines the options used to create the mesh
  42299. * @param scene defines the hosting scene
  42300. * @returns the ground mesh
  42301. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42302. */
  42303. static CreateGround(name: string, options: {
  42304. width?: number;
  42305. height?: number;
  42306. subdivisions?: number;
  42307. subdivisionsX?: number;
  42308. subdivisionsY?: number;
  42309. updatable?: boolean;
  42310. }, scene: any): Mesh;
  42311. /**
  42312. * Creates a tiled ground mesh
  42313. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42314. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42315. * * 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
  42316. * * 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
  42317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42318. * @param name defines the name of the mesh
  42319. * @param options defines the options used to create the mesh
  42320. * @param scene defines the hosting scene
  42321. * @returns the tiled ground mesh
  42322. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42323. */
  42324. static CreateTiledGround(name: string, options: {
  42325. xmin: number;
  42326. zmin: number;
  42327. xmax: number;
  42328. zmax: number;
  42329. subdivisions?: {
  42330. w: number;
  42331. h: number;
  42332. };
  42333. precision?: {
  42334. w: number;
  42335. h: number;
  42336. };
  42337. updatable?: boolean;
  42338. }, scene?: Nullable<Scene>): Mesh;
  42339. /**
  42340. * Creates a ground mesh from a height map
  42341. * * The parameter `url` sets the URL of the height map image resource.
  42342. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42343. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42344. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42345. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42346. * * 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.
  42347. * * 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).
  42348. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42350. * @param name defines the name of the mesh
  42351. * @param url defines the url to the height map
  42352. * @param options defines the options used to create the mesh
  42353. * @param scene defines the hosting scene
  42354. * @returns the ground mesh
  42355. * @see https://doc.babylonjs.com/babylon101/height_map
  42356. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42357. */
  42358. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42359. width?: number;
  42360. height?: number;
  42361. subdivisions?: number;
  42362. minHeight?: number;
  42363. maxHeight?: number;
  42364. colorFilter?: Color3;
  42365. alphaFilter?: number;
  42366. updatable?: boolean;
  42367. onReady?: (mesh: GroundMesh) => void;
  42368. }, scene?: Nullable<Scene>): GroundMesh;
  42369. }
  42370. }
  42371. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42372. import { Vector4 } from "babylonjs/Maths/math.vector";
  42373. import { Mesh } from "babylonjs/Meshes/mesh";
  42374. /**
  42375. * Class containing static functions to help procedurally build meshes
  42376. */
  42377. export class TorusBuilder {
  42378. /**
  42379. * Creates a torus mesh
  42380. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42381. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42382. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42386. * @param name defines the name of the mesh
  42387. * @param options defines the options used to create the mesh
  42388. * @param scene defines the hosting scene
  42389. * @returns the torus mesh
  42390. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42391. */
  42392. static CreateTorus(name: string, options: {
  42393. diameter?: number;
  42394. thickness?: number;
  42395. tessellation?: number;
  42396. updatable?: boolean;
  42397. sideOrientation?: number;
  42398. frontUVs?: Vector4;
  42399. backUVs?: Vector4;
  42400. }, scene: any): Mesh;
  42401. }
  42402. }
  42403. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42404. import { Vector4 } from "babylonjs/Maths/math.vector";
  42405. import { Color4 } from "babylonjs/Maths/math.color";
  42406. import { Mesh } from "babylonjs/Meshes/mesh";
  42407. /**
  42408. * Class containing static functions to help procedurally build meshes
  42409. */
  42410. export class CylinderBuilder {
  42411. /**
  42412. * Creates a cylinder or a cone mesh
  42413. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42414. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42415. * * 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.
  42416. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42417. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42418. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42419. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42420. * * 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).
  42421. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42422. * * 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).
  42423. * * 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
  42424. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42425. * * 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
  42426. * * 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.
  42427. * * If `enclose` is false, a ring surface is one element.
  42428. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42429. * * 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
  42430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42433. * @param name defines the name of the mesh
  42434. * @param options defines the options used to create the mesh
  42435. * @param scene defines the hosting scene
  42436. * @returns the cylinder mesh
  42437. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42438. */
  42439. static CreateCylinder(name: string, options: {
  42440. height?: number;
  42441. diameterTop?: number;
  42442. diameterBottom?: number;
  42443. diameter?: number;
  42444. tessellation?: number;
  42445. subdivisions?: number;
  42446. arc?: number;
  42447. faceColors?: Color4[];
  42448. faceUV?: Vector4[];
  42449. updatable?: boolean;
  42450. hasRings?: boolean;
  42451. enclose?: boolean;
  42452. cap?: number;
  42453. sideOrientation?: number;
  42454. frontUVs?: Vector4;
  42455. backUVs?: Vector4;
  42456. }, scene: any): Mesh;
  42457. }
  42458. }
  42459. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42460. import { Observable } from "babylonjs/Misc/observable";
  42461. import { Nullable } from "babylonjs/types";
  42462. import { Camera } from "babylonjs/Cameras/camera";
  42463. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42464. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42465. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42466. import { Scene } from "babylonjs/scene";
  42467. import { Vector3 } from "babylonjs/Maths/math.vector";
  42468. import { Color3 } from "babylonjs/Maths/math.color";
  42469. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42471. import { Mesh } from "babylonjs/Meshes/mesh";
  42472. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42473. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42474. import "babylonjs/Meshes/Builders/groundBuilder";
  42475. import "babylonjs/Meshes/Builders/torusBuilder";
  42476. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42477. import "babylonjs/Gamepads/gamepadSceneComponent";
  42478. import "babylonjs/Animations/animatable";
  42479. /**
  42480. * Options to modify the vr teleportation behavior.
  42481. */
  42482. export interface VRTeleportationOptions {
  42483. /**
  42484. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42485. */
  42486. floorMeshName?: string;
  42487. /**
  42488. * A list of meshes to be used as the teleportation floor. (default: empty)
  42489. */
  42490. floorMeshes?: Mesh[];
  42491. }
  42492. /**
  42493. * Options to modify the vr experience helper's behavior.
  42494. */
  42495. export interface VRExperienceHelperOptions extends WebVROptions {
  42496. /**
  42497. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42498. */
  42499. createDeviceOrientationCamera?: boolean;
  42500. /**
  42501. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42502. */
  42503. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42504. /**
  42505. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42506. */
  42507. laserToggle?: boolean;
  42508. /**
  42509. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42510. */
  42511. floorMeshes?: Mesh[];
  42512. /**
  42513. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42514. */
  42515. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42516. }
  42517. /**
  42518. * Event containing information after VR has been entered
  42519. */
  42520. export class OnAfterEnteringVRObservableEvent {
  42521. /**
  42522. * If entering vr was successful
  42523. */
  42524. success: boolean;
  42525. }
  42526. /**
  42527. * Helps to quickly add VR support to an existing scene.
  42528. * See http://doc.babylonjs.com/how_to/webvr_helper
  42529. */
  42530. export class VRExperienceHelper {
  42531. /** Options to modify the vr experience helper's behavior. */
  42532. webVROptions: VRExperienceHelperOptions;
  42533. private _scene;
  42534. private _position;
  42535. private _btnVR;
  42536. private _btnVRDisplayed;
  42537. private _webVRsupported;
  42538. private _webVRready;
  42539. private _webVRrequesting;
  42540. private _webVRpresenting;
  42541. private _hasEnteredVR;
  42542. private _fullscreenVRpresenting;
  42543. private _canvas;
  42544. private _webVRCamera;
  42545. private _vrDeviceOrientationCamera;
  42546. private _deviceOrientationCamera;
  42547. private _existingCamera;
  42548. private _onKeyDown;
  42549. private _onVrDisplayPresentChange;
  42550. private _onVRDisplayChanged;
  42551. private _onVRRequestPresentStart;
  42552. private _onVRRequestPresentComplete;
  42553. /**
  42554. * 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)
  42555. */
  42556. enableGazeEvenWhenNoPointerLock: boolean;
  42557. /**
  42558. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42559. */
  42560. exitVROnDoubleTap: boolean;
  42561. /**
  42562. * Observable raised right before entering VR.
  42563. */
  42564. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42565. /**
  42566. * Observable raised when entering VR has completed.
  42567. */
  42568. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42569. /**
  42570. * Observable raised when exiting VR.
  42571. */
  42572. onExitingVRObservable: Observable<VRExperienceHelper>;
  42573. /**
  42574. * Observable raised when controller mesh is loaded.
  42575. */
  42576. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42577. /** Return this.onEnteringVRObservable
  42578. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42579. */
  42580. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42581. /** Return this.onExitingVRObservable
  42582. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42583. */
  42584. readonly onExitingVR: Observable<VRExperienceHelper>;
  42585. /** Return this.onControllerMeshLoadedObservable
  42586. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42587. */
  42588. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42589. private _rayLength;
  42590. private _useCustomVRButton;
  42591. private _teleportationRequested;
  42592. private _teleportActive;
  42593. private _floorMeshName;
  42594. private _floorMeshesCollection;
  42595. private _rotationAllowed;
  42596. private _teleportBackwardsVector;
  42597. private _teleportationTarget;
  42598. private _isDefaultTeleportationTarget;
  42599. private _postProcessMove;
  42600. private _teleportationFillColor;
  42601. private _teleportationBorderColor;
  42602. private _rotationAngle;
  42603. private _haloCenter;
  42604. private _cameraGazer;
  42605. private _padSensibilityUp;
  42606. private _padSensibilityDown;
  42607. private _leftController;
  42608. private _rightController;
  42609. /**
  42610. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42611. */
  42612. onNewMeshSelected: Observable<AbstractMesh>;
  42613. /**
  42614. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42615. * This observable will provide the mesh and the controller used to select the mesh
  42616. */
  42617. onMeshSelectedWithController: Observable<{
  42618. mesh: AbstractMesh;
  42619. controller: WebVRController;
  42620. }>;
  42621. /**
  42622. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42623. */
  42624. onNewMeshPicked: Observable<PickingInfo>;
  42625. private _circleEase;
  42626. /**
  42627. * Observable raised before camera teleportation
  42628. */
  42629. onBeforeCameraTeleport: Observable<Vector3>;
  42630. /**
  42631. * Observable raised after camera teleportation
  42632. */
  42633. onAfterCameraTeleport: Observable<Vector3>;
  42634. /**
  42635. * Observable raised when current selected mesh gets unselected
  42636. */
  42637. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42638. private _raySelectionPredicate;
  42639. /**
  42640. * To be optionaly changed by user to define custom ray selection
  42641. */
  42642. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42643. /**
  42644. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42645. */
  42646. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42647. /**
  42648. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42649. */
  42650. teleportationEnabled: boolean;
  42651. private _defaultHeight;
  42652. private _teleportationInitialized;
  42653. private _interactionsEnabled;
  42654. private _interactionsRequested;
  42655. private _displayGaze;
  42656. private _displayLaserPointer;
  42657. /**
  42658. * The mesh used to display where the user is going to teleport.
  42659. */
  42660. /**
  42661. * Sets the mesh to be used to display where the user is going to teleport.
  42662. */
  42663. teleportationTarget: Mesh;
  42664. /**
  42665. * 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
  42666. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42667. * See http://doc.babylonjs.com/resources/baking_transformations
  42668. */
  42669. gazeTrackerMesh: Mesh;
  42670. /**
  42671. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42672. */
  42673. updateGazeTrackerScale: boolean;
  42674. /**
  42675. * If the gaze trackers color should be updated when selecting meshes
  42676. */
  42677. updateGazeTrackerColor: boolean;
  42678. /**
  42679. * If the controller laser color should be updated when selecting meshes
  42680. */
  42681. updateControllerLaserColor: boolean;
  42682. /**
  42683. * The gaze tracking mesh corresponding to the left controller
  42684. */
  42685. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42686. /**
  42687. * The gaze tracking mesh corresponding to the right controller
  42688. */
  42689. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42690. /**
  42691. * If the ray of the gaze should be displayed.
  42692. */
  42693. /**
  42694. * Sets if the ray of the gaze should be displayed.
  42695. */
  42696. displayGaze: boolean;
  42697. /**
  42698. * If the ray of the LaserPointer should be displayed.
  42699. */
  42700. /**
  42701. * Sets if the ray of the LaserPointer should be displayed.
  42702. */
  42703. displayLaserPointer: boolean;
  42704. /**
  42705. * The deviceOrientationCamera used as the camera when not in VR.
  42706. */
  42707. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42708. /**
  42709. * Based on the current WebVR support, returns the current VR camera used.
  42710. */
  42711. readonly currentVRCamera: Nullable<Camera>;
  42712. /**
  42713. * The webVRCamera which is used when in VR.
  42714. */
  42715. readonly webVRCamera: WebVRFreeCamera;
  42716. /**
  42717. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42718. */
  42719. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42720. /**
  42721. * The html button that is used to trigger entering into VR.
  42722. */
  42723. readonly vrButton: Nullable<HTMLButtonElement>;
  42724. private readonly _teleportationRequestInitiated;
  42725. /**
  42726. * Defines wether or not Pointer lock should be requested when switching to
  42727. * full screen.
  42728. */
  42729. requestPointerLockOnFullScreen: boolean;
  42730. /**
  42731. * Instantiates a VRExperienceHelper.
  42732. * Helps to quickly add VR support to an existing scene.
  42733. * @param scene The scene the VRExperienceHelper belongs to.
  42734. * @param webVROptions Options to modify the vr experience helper's behavior.
  42735. */
  42736. constructor(scene: Scene,
  42737. /** Options to modify the vr experience helper's behavior. */
  42738. webVROptions?: VRExperienceHelperOptions);
  42739. private _onDefaultMeshLoaded;
  42740. private _onResize;
  42741. private _onFullscreenChange;
  42742. /**
  42743. * Gets a value indicating if we are currently in VR mode.
  42744. */
  42745. readonly isInVRMode: boolean;
  42746. private onVrDisplayPresentChange;
  42747. private onVRDisplayChanged;
  42748. private moveButtonToBottomRight;
  42749. private displayVRButton;
  42750. private updateButtonVisibility;
  42751. private _cachedAngularSensibility;
  42752. /**
  42753. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42754. * Otherwise, will use the fullscreen API.
  42755. */
  42756. enterVR(): void;
  42757. /**
  42758. * Attempt to exit VR, or fullscreen.
  42759. */
  42760. exitVR(): void;
  42761. /**
  42762. * The position of the vr experience helper.
  42763. */
  42764. /**
  42765. * Sets the position of the vr experience helper.
  42766. */
  42767. position: Vector3;
  42768. /**
  42769. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42770. */
  42771. enableInteractions(): void;
  42772. private readonly _noControllerIsActive;
  42773. private beforeRender;
  42774. private _isTeleportationFloor;
  42775. /**
  42776. * Adds a floor mesh to be used for teleportation.
  42777. * @param floorMesh the mesh to be used for teleportation.
  42778. */
  42779. addFloorMesh(floorMesh: Mesh): void;
  42780. /**
  42781. * Removes a floor mesh from being used for teleportation.
  42782. * @param floorMesh the mesh to be removed.
  42783. */
  42784. removeFloorMesh(floorMesh: Mesh): void;
  42785. /**
  42786. * Enables interactions and teleportation using the VR controllers and gaze.
  42787. * @param vrTeleportationOptions options to modify teleportation behavior.
  42788. */
  42789. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42790. private _onNewGamepadConnected;
  42791. private _tryEnableInteractionOnController;
  42792. private _onNewGamepadDisconnected;
  42793. private _enableInteractionOnController;
  42794. private _checkTeleportWithRay;
  42795. private _checkRotate;
  42796. private _checkTeleportBackwards;
  42797. private _enableTeleportationOnController;
  42798. private _createTeleportationCircles;
  42799. private _displayTeleportationTarget;
  42800. private _hideTeleportationTarget;
  42801. private _rotateCamera;
  42802. private _moveTeleportationSelectorTo;
  42803. private _workingVector;
  42804. private _workingQuaternion;
  42805. private _workingMatrix;
  42806. /**
  42807. * Teleports the users feet to the desired location
  42808. * @param location The location where the user's feet should be placed
  42809. */
  42810. teleportCamera(location: Vector3): void;
  42811. private _convertNormalToDirectionOfRay;
  42812. private _castRayAndSelectObject;
  42813. private _notifySelectedMeshUnselected;
  42814. /**
  42815. * Sets the color of the laser ray from the vr controllers.
  42816. * @param color new color for the ray.
  42817. */
  42818. changeLaserColor(color: Color3): void;
  42819. /**
  42820. * Sets the color of the ray from the vr headsets gaze.
  42821. * @param color new color for the ray.
  42822. */
  42823. changeGazeColor(color: Color3): void;
  42824. /**
  42825. * Exits VR and disposes of the vr experience helper
  42826. */
  42827. dispose(): void;
  42828. /**
  42829. * Gets the name of the VRExperienceHelper class
  42830. * @returns "VRExperienceHelper"
  42831. */
  42832. getClassName(): string;
  42833. }
  42834. }
  42835. declare module "babylonjs/Cameras/VR/index" {
  42836. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42837. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42838. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42839. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42840. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42841. export * from "babylonjs/Cameras/VR/webVRCamera";
  42842. }
  42843. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42844. import { Observable } from "babylonjs/Misc/observable";
  42845. import { Nullable } from "babylonjs/types";
  42846. import { IDisposable, Scene } from "babylonjs/scene";
  42847. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42848. /**
  42849. * Manages an XRSession to work with Babylon's engine
  42850. * @see https://doc.babylonjs.com/how_to/webxr
  42851. */
  42852. export class WebXRSessionManager implements IDisposable {
  42853. private scene;
  42854. /**
  42855. * Fires every time a new xrFrame arrives which can be used to update the camera
  42856. */
  42857. onXRFrameObservable: Observable<any>;
  42858. /**
  42859. * Fires when the xr session is ended either by the device or manually done
  42860. */
  42861. onXRSessionEnded: Observable<any>;
  42862. /**
  42863. * Underlying xr session
  42864. */
  42865. session: XRSession;
  42866. /**
  42867. * Type of reference space used when creating the session
  42868. */
  42869. referenceSpace: XRReferenceSpace;
  42870. /** @hidden */
  42871. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42872. /**
  42873. * Current XR frame
  42874. */
  42875. currentFrame: Nullable<XRFrame>;
  42876. private _xrNavigator;
  42877. private baseLayer;
  42878. /**
  42879. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42880. * @param scene The scene which the session should be created for
  42881. */
  42882. constructor(scene: Scene);
  42883. /**
  42884. * Initializes the manager
  42885. * After initialization enterXR can be called to start an XR session
  42886. * @returns Promise which resolves after it is initialized
  42887. */
  42888. initializeAsync(): Promise<void>;
  42889. /**
  42890. * Initializes an xr session
  42891. * @param xrSessionMode mode to initialize
  42892. * @returns a promise which will resolve once the session has been initialized
  42893. */
  42894. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42895. /**
  42896. * Sets the reference space on the xr session
  42897. * @param referenceSpace space to set
  42898. * @returns a promise that will resolve once the reference space has been set
  42899. */
  42900. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42901. /**
  42902. * Updates the render state of the session
  42903. * @param state state to set
  42904. * @returns a promise that resolves once the render state has been updated
  42905. */
  42906. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42907. /**
  42908. * Starts rendering to the xr layer
  42909. * @returns a promise that will resolve once rendering has started
  42910. */
  42911. startRenderingToXRAsync(): Promise<void>;
  42912. /**
  42913. * Stops the xrSession and restores the renderloop
  42914. * @returns Promise which resolves after it exits XR
  42915. */
  42916. exitXRAsync(): Promise<unknown>;
  42917. /**
  42918. * Checks if a session would be supported for the creation options specified
  42919. * @param sessionMode session mode to check if supported eg. immersive-vr
  42920. * @returns true if supported
  42921. */
  42922. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42923. /**
  42924. * @hidden
  42925. * Converts the render layer of xrSession to a render target
  42926. * @param session session to create render target for
  42927. * @param scene scene the new render target should be created for
  42928. */
  42929. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42930. /**
  42931. * Disposes of the session manager
  42932. */
  42933. dispose(): void;
  42934. }
  42935. }
  42936. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42937. import { Scene } from "babylonjs/scene";
  42938. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42939. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42940. /**
  42941. * WebXR Camera which holds the views for the xrSession
  42942. * @see https://doc.babylonjs.com/how_to/webxr
  42943. */
  42944. export class WebXRCamera extends FreeCamera {
  42945. private static _TmpMatrix;
  42946. /**
  42947. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42948. * @param name the name of the camera
  42949. * @param scene the scene to add the camera to
  42950. */
  42951. constructor(name: string, scene: Scene);
  42952. private _updateNumberOfRigCameras;
  42953. /** @hidden */
  42954. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42955. /**
  42956. * Updates the cameras position from the current pose information of the XR session
  42957. * @param xrSessionManager the session containing pose information
  42958. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42959. */
  42960. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42961. }
  42962. }
  42963. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42964. import { Nullable } from "babylonjs/types";
  42965. import { IDisposable } from "babylonjs/scene";
  42966. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42967. /**
  42968. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42969. */
  42970. export class WebXRManagedOutputCanvas implements IDisposable {
  42971. private helper;
  42972. private _canvas;
  42973. /**
  42974. * xrpresent context of the canvas which can be used to display/mirror xr content
  42975. */
  42976. canvasContext: WebGLRenderingContext;
  42977. /**
  42978. * xr layer for the canvas
  42979. */
  42980. xrLayer: Nullable<XRWebGLLayer>;
  42981. /**
  42982. * Initializes the xr layer for the session
  42983. * @param xrSession xr session
  42984. * @returns a promise that will resolve once the XR Layer has been created
  42985. */
  42986. initializeXRLayerAsync(xrSession: any): any;
  42987. /**
  42988. * Initializes the canvas to be added/removed upon entering/exiting xr
  42989. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42990. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42991. */
  42992. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42993. /**
  42994. * Disposes of the object
  42995. */
  42996. dispose(): void;
  42997. private _setManagedOutputCanvas;
  42998. private _addCanvas;
  42999. private _removeCanvas;
  43000. }
  43001. }
  43002. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43003. import { Observable } from "babylonjs/Misc/observable";
  43004. import { IDisposable, Scene } from "babylonjs/scene";
  43005. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43007. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43008. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43009. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43010. /**
  43011. * States of the webXR experience
  43012. */
  43013. export enum WebXRState {
  43014. /**
  43015. * Transitioning to being in XR mode
  43016. */
  43017. ENTERING_XR = 0,
  43018. /**
  43019. * Transitioning to non XR mode
  43020. */
  43021. EXITING_XR = 1,
  43022. /**
  43023. * In XR mode and presenting
  43024. */
  43025. IN_XR = 2,
  43026. /**
  43027. * Not entered XR mode
  43028. */
  43029. NOT_IN_XR = 3
  43030. }
  43031. /**
  43032. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43033. * @see https://doc.babylonjs.com/how_to/webxr
  43034. */
  43035. export class WebXRExperienceHelper implements IDisposable {
  43036. private scene;
  43037. /**
  43038. * 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
  43039. */
  43040. container: AbstractMesh;
  43041. /**
  43042. * Camera used to render xr content
  43043. */
  43044. camera: WebXRCamera;
  43045. /**
  43046. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43047. */
  43048. state: WebXRState;
  43049. private _setState;
  43050. private static _TmpVector;
  43051. /**
  43052. * Fires when the state of the experience helper has changed
  43053. */
  43054. onStateChangedObservable: Observable<WebXRState>;
  43055. /** Session manager used to keep track of xr session */
  43056. sessionManager: WebXRSessionManager;
  43057. private _nonVRCamera;
  43058. private _originalSceneAutoClear;
  43059. private _supported;
  43060. /**
  43061. * Creates the experience helper
  43062. * @param scene the scene to attach the experience helper to
  43063. * @returns a promise for the experience helper
  43064. */
  43065. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43066. /**
  43067. * Creates a WebXRExperienceHelper
  43068. * @param scene The scene the helper should be created in
  43069. */
  43070. private constructor();
  43071. /**
  43072. * Exits XR mode and returns the scene to its original state
  43073. * @returns promise that resolves after xr mode has exited
  43074. */
  43075. exitXRAsync(): Promise<unknown>;
  43076. /**
  43077. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43078. * @param sessionCreationOptions options for the XR session
  43079. * @param referenceSpaceType frame of reference of the XR session
  43080. * @param outputCanvas the output canvas that will be used to enter XR mode
  43081. * @returns promise that resolves after xr mode has entered
  43082. */
  43083. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43084. /**
  43085. * Updates the global position of the camera by moving the camera's container
  43086. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43087. * @param position The desired global position of the camera
  43088. */
  43089. setPositionOfCameraUsingContainer(position: Vector3): void;
  43090. /**
  43091. * Rotates the xr camera by rotating the camera's container around the camera's position
  43092. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43093. * @param rotation the desired quaternion rotation to apply to the camera
  43094. */
  43095. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43096. /**
  43097. * Disposes of the experience helper
  43098. */
  43099. dispose(): void;
  43100. }
  43101. }
  43102. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43103. import { Nullable } from "babylonjs/types";
  43104. import { Observable } from "babylonjs/Misc/observable";
  43105. import { IDisposable, Scene } from "babylonjs/scene";
  43106. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43107. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43108. /**
  43109. * Button which can be used to enter a different mode of XR
  43110. */
  43111. export class WebXREnterExitUIButton {
  43112. /** button element */
  43113. element: HTMLElement;
  43114. /** XR initialization options for the button */
  43115. sessionMode: XRSessionMode;
  43116. /** Reference space type */
  43117. referenceSpaceType: XRReferenceSpaceType;
  43118. /**
  43119. * Creates a WebXREnterExitUIButton
  43120. * @param element button element
  43121. * @param sessionMode XR initialization session mode
  43122. * @param referenceSpaceType the type of reference space to be used
  43123. */
  43124. constructor(
  43125. /** button element */
  43126. element: HTMLElement,
  43127. /** XR initialization options for the button */
  43128. sessionMode: XRSessionMode,
  43129. /** Reference space type */
  43130. referenceSpaceType: XRReferenceSpaceType);
  43131. /**
  43132. * Overwritable function which can be used to update the button's visuals when the state changes
  43133. * @param activeButton the current active button in the UI
  43134. */
  43135. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43136. }
  43137. /**
  43138. * Options to create the webXR UI
  43139. */
  43140. export class WebXREnterExitUIOptions {
  43141. /**
  43142. * Context to enter xr with
  43143. */
  43144. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43145. /**
  43146. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43147. */
  43148. customButtons?: Array<WebXREnterExitUIButton>;
  43149. }
  43150. /**
  43151. * UI to allow the user to enter/exit XR mode
  43152. */
  43153. export class WebXREnterExitUI implements IDisposable {
  43154. private scene;
  43155. private _overlay;
  43156. private _buttons;
  43157. private _activeButton;
  43158. /**
  43159. * Fired every time the active button is changed.
  43160. *
  43161. * When xr is entered via a button that launches xr that button will be the callback parameter
  43162. *
  43163. * When exiting xr the callback parameter will be null)
  43164. */
  43165. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43166. /**
  43167. * Creates UI to allow the user to enter/exit XR mode
  43168. * @param scene the scene to add the ui to
  43169. * @param helper the xr experience helper to enter/exit xr with
  43170. * @param options options to configure the UI
  43171. * @returns the created ui
  43172. */
  43173. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43174. private constructor();
  43175. private _updateButtons;
  43176. /**
  43177. * Disposes of the object
  43178. */
  43179. dispose(): void;
  43180. }
  43181. }
  43182. declare module "babylonjs/Cameras/XR/webXRController" {
  43183. import { Nullable } from "babylonjs/types";
  43184. import { Observable } from "babylonjs/Misc/observable";
  43185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43186. import { Ray } from "babylonjs/Culling/ray";
  43187. import { Scene } from "babylonjs/scene";
  43188. /**
  43189. * Represents an XR input
  43190. */
  43191. export class WebXRController {
  43192. private scene;
  43193. /** The underlying input source for the controller */
  43194. inputSource: XRInputSource;
  43195. private parentContainer;
  43196. /**
  43197. * 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
  43198. */
  43199. grip?: AbstractMesh;
  43200. /**
  43201. * Pointer which can be used to select objects or attach a visible laser to
  43202. */
  43203. pointer: AbstractMesh;
  43204. /**
  43205. * Event that fires when the controller is removed/disposed
  43206. */
  43207. onDisposeObservable: Observable<{}>;
  43208. private _tmpMatrix;
  43209. private _tmpQuaternion;
  43210. private _tmpVector;
  43211. /**
  43212. * Creates the controller
  43213. * @see https://doc.babylonjs.com/how_to/webxr
  43214. * @param scene the scene which the controller should be associated to
  43215. * @param inputSource the underlying input source for the controller
  43216. * @param parentContainer parent that the controller meshes should be children of
  43217. */
  43218. constructor(scene: Scene,
  43219. /** The underlying input source for the controller */
  43220. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43221. /**
  43222. * Updates the controller pose based on the given XRFrame
  43223. * @param xrFrame xr frame to update the pose with
  43224. * @param referenceSpace reference space to use
  43225. */
  43226. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43227. /**
  43228. * Gets a world space ray coming from the controller
  43229. * @param result the resulting ray
  43230. */
  43231. getWorldPointerRayToRef(result: Ray): void;
  43232. /**
  43233. * Disposes of the object
  43234. */
  43235. dispose(): void;
  43236. }
  43237. }
  43238. declare module "babylonjs/Cameras/XR/webXRInput" {
  43239. import { Observable } from "babylonjs/Misc/observable";
  43240. import { IDisposable } from "babylonjs/scene";
  43241. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43242. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43243. /**
  43244. * XR input used to track XR inputs such as controllers/rays
  43245. */
  43246. export class WebXRInput implements IDisposable {
  43247. /**
  43248. * Base experience the input listens to
  43249. */
  43250. baseExperience: WebXRExperienceHelper;
  43251. /**
  43252. * XR controllers being tracked
  43253. */
  43254. controllers: Array<WebXRController>;
  43255. private _frameObserver;
  43256. private _stateObserver;
  43257. /**
  43258. * Event when a controller has been connected/added
  43259. */
  43260. onControllerAddedObservable: Observable<WebXRController>;
  43261. /**
  43262. * Event when a controller has been removed/disconnected
  43263. */
  43264. onControllerRemovedObservable: Observable<WebXRController>;
  43265. /**
  43266. * Initializes the WebXRInput
  43267. * @param baseExperience experience helper which the input should be created for
  43268. */
  43269. constructor(
  43270. /**
  43271. * Base experience the input listens to
  43272. */
  43273. baseExperience: WebXRExperienceHelper);
  43274. private _onInputSourcesChange;
  43275. private _addAndRemoveControllers;
  43276. /**
  43277. * Disposes of the object
  43278. */
  43279. dispose(): void;
  43280. }
  43281. }
  43282. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43284. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43285. /**
  43286. * Enables teleportation
  43287. */
  43288. export class WebXRControllerTeleportation {
  43289. private _teleportationFillColor;
  43290. private _teleportationBorderColor;
  43291. private _tmpRay;
  43292. private _tmpVector;
  43293. /**
  43294. * Creates a WebXRControllerTeleportation
  43295. * @param input input manager to add teleportation to
  43296. * @param floorMeshes floormeshes which can be teleported to
  43297. */
  43298. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43299. }
  43300. }
  43301. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43302. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43303. /**
  43304. * Handles pointer input automatically for the pointer of XR controllers
  43305. */
  43306. export class WebXRControllerPointerSelection {
  43307. private static _idCounter;
  43308. private _tmpRay;
  43309. /**
  43310. * Creates a WebXRControllerPointerSelection
  43311. * @param input input manager to setup pointer selection
  43312. */
  43313. constructor(input: WebXRInput);
  43314. private _convertNormalToDirectionOfRay;
  43315. private _updatePointerDistance;
  43316. }
  43317. }
  43318. declare module "babylonjs/Loading/sceneLoader" {
  43319. import { Observable } from "babylonjs/Misc/observable";
  43320. import { Nullable } from "babylonjs/types";
  43321. import { Scene } from "babylonjs/scene";
  43322. import { Engine } from "babylonjs/Engines/engine";
  43323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43324. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43325. import { AssetContainer } from "babylonjs/assetContainer";
  43326. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43327. import { Skeleton } from "babylonjs/Bones/skeleton";
  43328. /**
  43329. * Class used to represent data loading progression
  43330. */
  43331. export class SceneLoaderProgressEvent {
  43332. /** defines if data length to load can be evaluated */
  43333. readonly lengthComputable: boolean;
  43334. /** defines the loaded data length */
  43335. readonly loaded: number;
  43336. /** defines the data length to load */
  43337. readonly total: number;
  43338. /**
  43339. * Create a new progress event
  43340. * @param lengthComputable defines if data length to load can be evaluated
  43341. * @param loaded defines the loaded data length
  43342. * @param total defines the data length to load
  43343. */
  43344. constructor(
  43345. /** defines if data length to load can be evaluated */
  43346. lengthComputable: boolean,
  43347. /** defines the loaded data length */
  43348. loaded: number,
  43349. /** defines the data length to load */
  43350. total: number);
  43351. /**
  43352. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43353. * @param event defines the source event
  43354. * @returns a new SceneLoaderProgressEvent
  43355. */
  43356. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43357. }
  43358. /**
  43359. * Interface used by SceneLoader plugins to define supported file extensions
  43360. */
  43361. export interface ISceneLoaderPluginExtensions {
  43362. /**
  43363. * Defines the list of supported extensions
  43364. */
  43365. [extension: string]: {
  43366. isBinary: boolean;
  43367. };
  43368. }
  43369. /**
  43370. * Interface used by SceneLoader plugin factory
  43371. */
  43372. export interface ISceneLoaderPluginFactory {
  43373. /**
  43374. * Defines the name of the factory
  43375. */
  43376. name: string;
  43377. /**
  43378. * Function called to create a new plugin
  43379. * @return the new plugin
  43380. */
  43381. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43382. /**
  43383. * Boolean indicating if the plugin can direct load specific data
  43384. */
  43385. canDirectLoad?: (data: string) => boolean;
  43386. }
  43387. /**
  43388. * Interface used to define a SceneLoader plugin
  43389. */
  43390. export interface ISceneLoaderPlugin {
  43391. /**
  43392. * The friendly name of this plugin.
  43393. */
  43394. name: string;
  43395. /**
  43396. * The file extensions supported by this plugin.
  43397. */
  43398. extensions: string | ISceneLoaderPluginExtensions;
  43399. /**
  43400. * Import meshes into a scene.
  43401. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43402. * @param scene The scene to import into
  43403. * @param data The data to import
  43404. * @param rootUrl The root url for scene and resources
  43405. * @param meshes The meshes array to import into
  43406. * @param particleSystems The particle systems array to import into
  43407. * @param skeletons The skeletons array to import into
  43408. * @param onError The callback when import fails
  43409. * @returns True if successful or false otherwise
  43410. */
  43411. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43412. /**
  43413. * Load into a scene.
  43414. * @param scene The scene to load into
  43415. * @param data The data to import
  43416. * @param rootUrl The root url for scene and resources
  43417. * @param onError The callback when import fails
  43418. * @returns true if successful or false otherwise
  43419. */
  43420. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43421. /**
  43422. * The callback that returns true if the data can be directly loaded.
  43423. */
  43424. canDirectLoad?: (data: string) => boolean;
  43425. /**
  43426. * The callback that allows custom handling of the root url based on the response url.
  43427. */
  43428. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43429. /**
  43430. * Load into an asset container.
  43431. * @param scene The scene to load into
  43432. * @param data The data to import
  43433. * @param rootUrl The root url for scene and resources
  43434. * @param onError The callback when import fails
  43435. * @returns The loaded asset container
  43436. */
  43437. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43438. }
  43439. /**
  43440. * Interface used to define an async SceneLoader plugin
  43441. */
  43442. export interface ISceneLoaderPluginAsync {
  43443. /**
  43444. * The friendly name of this plugin.
  43445. */
  43446. name: string;
  43447. /**
  43448. * The file extensions supported by this plugin.
  43449. */
  43450. extensions: string | ISceneLoaderPluginExtensions;
  43451. /**
  43452. * Import meshes into a scene.
  43453. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43454. * @param scene The scene to import into
  43455. * @param data The data to import
  43456. * @param rootUrl The root url for scene and resources
  43457. * @param onProgress The callback when the load progresses
  43458. * @param fileName Defines the name of the file to load
  43459. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43460. */
  43461. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43462. meshes: AbstractMesh[];
  43463. particleSystems: IParticleSystem[];
  43464. skeletons: Skeleton[];
  43465. animationGroups: AnimationGroup[];
  43466. }>;
  43467. /**
  43468. * Load into a scene.
  43469. * @param scene The scene to load into
  43470. * @param data The data to import
  43471. * @param rootUrl The root url for scene and resources
  43472. * @param onProgress The callback when the load progresses
  43473. * @param fileName Defines the name of the file to load
  43474. * @returns Nothing
  43475. */
  43476. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43477. /**
  43478. * The callback that returns true if the data can be directly loaded.
  43479. */
  43480. canDirectLoad?: (data: string) => boolean;
  43481. /**
  43482. * The callback that allows custom handling of the root url based on the response url.
  43483. */
  43484. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43485. /**
  43486. * Load into an asset container.
  43487. * @param scene The scene to load into
  43488. * @param data The data to import
  43489. * @param rootUrl The root url for scene and resources
  43490. * @param onProgress The callback when the load progresses
  43491. * @param fileName Defines the name of the file to load
  43492. * @returns The loaded asset container
  43493. */
  43494. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43495. }
  43496. /**
  43497. * Class used to load scene from various file formats using registered plugins
  43498. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43499. */
  43500. export class SceneLoader {
  43501. /**
  43502. * No logging while loading
  43503. */
  43504. static readonly NO_LOGGING: number;
  43505. /**
  43506. * Minimal logging while loading
  43507. */
  43508. static readonly MINIMAL_LOGGING: number;
  43509. /**
  43510. * Summary logging while loading
  43511. */
  43512. static readonly SUMMARY_LOGGING: number;
  43513. /**
  43514. * Detailled logging while loading
  43515. */
  43516. static readonly DETAILED_LOGGING: number;
  43517. /**
  43518. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43519. */
  43520. static ForceFullSceneLoadingForIncremental: boolean;
  43521. /**
  43522. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43523. */
  43524. static ShowLoadingScreen: boolean;
  43525. /**
  43526. * Defines the current logging level (while loading the scene)
  43527. * @ignorenaming
  43528. */
  43529. static loggingLevel: number;
  43530. /**
  43531. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43532. */
  43533. static CleanBoneMatrixWeights: boolean;
  43534. /**
  43535. * Event raised when a plugin is used to load a scene
  43536. */
  43537. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43538. private static _registeredPlugins;
  43539. private static _getDefaultPlugin;
  43540. private static _getPluginForExtension;
  43541. private static _getPluginForDirectLoad;
  43542. private static _getPluginForFilename;
  43543. private static _getDirectLoad;
  43544. private static _loadData;
  43545. private static _getFileInfo;
  43546. /**
  43547. * Gets a plugin that can load the given extension
  43548. * @param extension defines the extension to load
  43549. * @returns a plugin or null if none works
  43550. */
  43551. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43552. /**
  43553. * Gets a boolean indicating that the given extension can be loaded
  43554. * @param extension defines the extension to load
  43555. * @returns true if the extension is supported
  43556. */
  43557. static IsPluginForExtensionAvailable(extension: string): boolean;
  43558. /**
  43559. * Adds a new plugin to the list of registered plugins
  43560. * @param plugin defines the plugin to add
  43561. */
  43562. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43563. /**
  43564. * Import meshes into a scene
  43565. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43566. * @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)
  43567. * @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)
  43568. * @param scene the instance of BABYLON.Scene to append to
  43569. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43570. * @param onProgress a callback with a progress event for each file being loaded
  43571. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43572. * @param pluginExtension the extension used to determine the plugin
  43573. * @returns The loaded plugin
  43574. */
  43575. 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>;
  43576. /**
  43577. * Import meshes into a scene
  43578. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43579. * @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)
  43580. * @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)
  43581. * @param scene the instance of BABYLON.Scene to append to
  43582. * @param onProgress a callback with a progress event for each file being loaded
  43583. * @param pluginExtension the extension used to determine the plugin
  43584. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43585. */
  43586. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43587. meshes: AbstractMesh[];
  43588. particleSystems: IParticleSystem[];
  43589. skeletons: Skeleton[];
  43590. animationGroups: AnimationGroup[];
  43591. }>;
  43592. /**
  43593. * Load a scene
  43594. * @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)
  43595. * @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)
  43596. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43597. * @param onSuccess a callback with the scene when import succeeds
  43598. * @param onProgress a callback with a progress event for each file being loaded
  43599. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43600. * @param pluginExtension the extension used to determine the plugin
  43601. * @returns The loaded plugin
  43602. */
  43603. 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>;
  43604. /**
  43605. * Load a scene
  43606. * @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)
  43607. * @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)
  43608. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43609. * @param onProgress a callback with a progress event for each file being loaded
  43610. * @param pluginExtension the extension used to determine the plugin
  43611. * @returns The loaded scene
  43612. */
  43613. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43614. /**
  43615. * Append a scene
  43616. * @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)
  43617. * @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)
  43618. * @param scene is the instance of BABYLON.Scene to append to
  43619. * @param onSuccess a callback with the scene when import succeeds
  43620. * @param onProgress a callback with a progress event for each file being loaded
  43621. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43622. * @param pluginExtension the extension used to determine the plugin
  43623. * @returns The loaded plugin
  43624. */
  43625. 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>;
  43626. /**
  43627. * Append a scene
  43628. * @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)
  43629. * @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)
  43630. * @param scene is the instance of BABYLON.Scene to append to
  43631. * @param onProgress a callback with a progress event for each file being loaded
  43632. * @param pluginExtension the extension used to determine the plugin
  43633. * @returns The given scene
  43634. */
  43635. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43636. /**
  43637. * Load a scene into an asset container
  43638. * @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)
  43639. * @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)
  43640. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43641. * @param onSuccess a callback with the scene when import succeeds
  43642. * @param onProgress a callback with a progress event for each file being loaded
  43643. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43644. * @param pluginExtension the extension used to determine the plugin
  43645. * @returns The loaded plugin
  43646. */
  43647. 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>;
  43648. /**
  43649. * Load a scene into an asset container
  43650. * @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)
  43651. * @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)
  43652. * @param scene is the instance of Scene to append to
  43653. * @param onProgress a callback with a progress event for each file being loaded
  43654. * @param pluginExtension the extension used to determine the plugin
  43655. * @returns The loaded asset container
  43656. */
  43657. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43658. }
  43659. }
  43660. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43661. import { Scene } from "babylonjs/scene";
  43662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43663. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43664. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43665. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43666. /**
  43667. * Generic Controller
  43668. */
  43669. export class GenericController extends WebVRController {
  43670. /**
  43671. * Base Url for the controller model.
  43672. */
  43673. static readonly MODEL_BASE_URL: string;
  43674. /**
  43675. * File name for the controller model.
  43676. */
  43677. static readonly MODEL_FILENAME: string;
  43678. /**
  43679. * Creates a new GenericController from a gamepad
  43680. * @param vrGamepad the gamepad that the controller should be created from
  43681. */
  43682. constructor(vrGamepad: any);
  43683. /**
  43684. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43685. * @param scene scene in which to add meshes
  43686. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43687. */
  43688. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43689. /**
  43690. * Called once for each button that changed state since the last frame
  43691. * @param buttonIdx Which button index changed
  43692. * @param state New state of the button
  43693. * @param changes Which properties on the state changed since last frame
  43694. */
  43695. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43696. }
  43697. }
  43698. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43699. import { Observable } from "babylonjs/Misc/observable";
  43700. import { Scene } from "babylonjs/scene";
  43701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43702. import { Ray } from "babylonjs/Culling/ray";
  43703. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43704. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43705. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43706. /**
  43707. * Defines the WindowsMotionController object that the state of the windows motion controller
  43708. */
  43709. export class WindowsMotionController extends WebVRController {
  43710. /**
  43711. * The base url used to load the left and right controller models
  43712. */
  43713. static MODEL_BASE_URL: string;
  43714. /**
  43715. * The name of the left controller model file
  43716. */
  43717. static MODEL_LEFT_FILENAME: string;
  43718. /**
  43719. * The name of the right controller model file
  43720. */
  43721. static MODEL_RIGHT_FILENAME: string;
  43722. /**
  43723. * The controller name prefix for this controller type
  43724. */
  43725. static readonly GAMEPAD_ID_PREFIX: string;
  43726. /**
  43727. * The controller id pattern for this controller type
  43728. */
  43729. private static readonly GAMEPAD_ID_PATTERN;
  43730. private _loadedMeshInfo;
  43731. private readonly _mapping;
  43732. /**
  43733. * Fired when the trackpad on this controller is clicked
  43734. */
  43735. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43736. /**
  43737. * Fired when the trackpad on this controller is modified
  43738. */
  43739. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43740. /**
  43741. * The current x and y values of this controller's trackpad
  43742. */
  43743. trackpad: StickValues;
  43744. /**
  43745. * Creates a new WindowsMotionController from a gamepad
  43746. * @param vrGamepad the gamepad that the controller should be created from
  43747. */
  43748. constructor(vrGamepad: any);
  43749. /**
  43750. * Fired when the trigger on this controller is modified
  43751. */
  43752. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43753. /**
  43754. * Fired when the menu button on this controller is modified
  43755. */
  43756. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43757. /**
  43758. * Fired when the grip button on this controller is modified
  43759. */
  43760. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43761. /**
  43762. * Fired when the thumbstick button on this controller is modified
  43763. */
  43764. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43765. /**
  43766. * Fired when the touchpad button on this controller is modified
  43767. */
  43768. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43769. /**
  43770. * Fired when the touchpad values on this controller are modified
  43771. */
  43772. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43773. private _updateTrackpad;
  43774. /**
  43775. * Called once per frame by the engine.
  43776. */
  43777. update(): void;
  43778. /**
  43779. * Called once for each button that changed state since the last frame
  43780. * @param buttonIdx Which button index changed
  43781. * @param state New state of the button
  43782. * @param changes Which properties on the state changed since last frame
  43783. */
  43784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43785. /**
  43786. * Moves the buttons on the controller mesh based on their current state
  43787. * @param buttonName the name of the button to move
  43788. * @param buttonValue the value of the button which determines the buttons new position
  43789. */
  43790. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43791. /**
  43792. * Moves the axis on the controller mesh based on its current state
  43793. * @param axis the index of the axis
  43794. * @param axisValue the value of the axis which determines the meshes new position
  43795. * @hidden
  43796. */
  43797. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43798. /**
  43799. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43800. * @param scene scene in which to add meshes
  43801. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43802. */
  43803. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43804. /**
  43805. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43806. * can be transformed by button presses and axes values, based on this._mapping.
  43807. *
  43808. * @param scene scene in which the meshes exist
  43809. * @param meshes list of meshes that make up the controller model to process
  43810. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43811. */
  43812. private processModel;
  43813. private createMeshInfo;
  43814. /**
  43815. * Gets the ray of the controller in the direction the controller is pointing
  43816. * @param length the length the resulting ray should be
  43817. * @returns a ray in the direction the controller is pointing
  43818. */
  43819. getForwardRay(length?: number): Ray;
  43820. /**
  43821. * Disposes of the controller
  43822. */
  43823. dispose(): void;
  43824. }
  43825. }
  43826. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43827. import { Observable } from "babylonjs/Misc/observable";
  43828. import { Scene } from "babylonjs/scene";
  43829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43830. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43831. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43832. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43833. /**
  43834. * Oculus Touch Controller
  43835. */
  43836. export class OculusTouchController extends WebVRController {
  43837. /**
  43838. * Base Url for the controller model.
  43839. */
  43840. static MODEL_BASE_URL: string;
  43841. /**
  43842. * File name for the left controller model.
  43843. */
  43844. static MODEL_LEFT_FILENAME: string;
  43845. /**
  43846. * File name for the right controller model.
  43847. */
  43848. static MODEL_RIGHT_FILENAME: string;
  43849. /**
  43850. * Base Url for the Quest controller model.
  43851. */
  43852. static QUEST_MODEL_BASE_URL: string;
  43853. /**
  43854. * @hidden
  43855. * If the controllers are running on a device that needs the updated Quest controller models
  43856. */
  43857. static _IsQuest: boolean;
  43858. /**
  43859. * Fired when the secondary trigger on this controller is modified
  43860. */
  43861. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43862. /**
  43863. * Fired when the thumb rest on this controller is modified
  43864. */
  43865. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43866. /**
  43867. * Creates a new OculusTouchController from a gamepad
  43868. * @param vrGamepad the gamepad that the controller should be created from
  43869. */
  43870. constructor(vrGamepad: any);
  43871. /**
  43872. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43873. * @param scene scene in which to add meshes
  43874. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43875. */
  43876. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43877. /**
  43878. * Fired when the A button on this controller is modified
  43879. */
  43880. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43881. /**
  43882. * Fired when the B button on this controller is modified
  43883. */
  43884. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43885. /**
  43886. * Fired when the X button on this controller is modified
  43887. */
  43888. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43889. /**
  43890. * Fired when the Y button on this controller is modified
  43891. */
  43892. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43893. /**
  43894. * Called once for each button that changed state since the last frame
  43895. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43896. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43897. * 2) secondary trigger (same)
  43898. * 3) A (right) X (left), touch, pressed = value
  43899. * 4) B / Y
  43900. * 5) thumb rest
  43901. * @param buttonIdx Which button index changed
  43902. * @param state New state of the button
  43903. * @param changes Which properties on the state changed since last frame
  43904. */
  43905. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43906. }
  43907. }
  43908. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43909. import { Scene } from "babylonjs/scene";
  43910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43911. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43912. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43913. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43914. import { Observable } from "babylonjs/Misc/observable";
  43915. /**
  43916. * Vive Controller
  43917. */
  43918. export class ViveController extends WebVRController {
  43919. /**
  43920. * Base Url for the controller model.
  43921. */
  43922. static MODEL_BASE_URL: string;
  43923. /**
  43924. * File name for the controller model.
  43925. */
  43926. static MODEL_FILENAME: string;
  43927. /**
  43928. * Creates a new ViveController from a gamepad
  43929. * @param vrGamepad the gamepad that the controller should be created from
  43930. */
  43931. constructor(vrGamepad: any);
  43932. /**
  43933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43934. * @param scene scene in which to add meshes
  43935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43936. */
  43937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43938. /**
  43939. * Fired when the left button on this controller is modified
  43940. */
  43941. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43942. /**
  43943. * Fired when the right button on this controller is modified
  43944. */
  43945. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43946. /**
  43947. * Fired when the menu button on this controller is modified
  43948. */
  43949. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43950. /**
  43951. * Called once for each button that changed state since the last frame
  43952. * Vive mapping:
  43953. * 0: touchpad
  43954. * 1: trigger
  43955. * 2: left AND right buttons
  43956. * 3: menu button
  43957. * @param buttonIdx Which button index changed
  43958. * @param state New state of the button
  43959. * @param changes Which properties on the state changed since last frame
  43960. */
  43961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43962. }
  43963. }
  43964. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43965. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43966. /**
  43967. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43968. */
  43969. export class WebXRControllerModelLoader {
  43970. /**
  43971. * Creates the WebXRControllerModelLoader
  43972. * @param input xr input that creates the controllers
  43973. */
  43974. constructor(input: WebXRInput);
  43975. }
  43976. }
  43977. declare module "babylonjs/Cameras/XR/index" {
  43978. export * from "babylonjs/Cameras/XR/webXRCamera";
  43979. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43980. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43981. export * from "babylonjs/Cameras/XR/webXRInput";
  43982. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43983. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43984. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43985. export * from "babylonjs/Cameras/XR/webXRController";
  43986. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43987. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43988. }
  43989. declare module "babylonjs/Cameras/RigModes/index" {
  43990. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43991. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43992. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43993. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43994. }
  43995. declare module "babylonjs/Cameras/index" {
  43996. export * from "babylonjs/Cameras/Inputs/index";
  43997. export * from "babylonjs/Cameras/cameraInputsManager";
  43998. export * from "babylonjs/Cameras/camera";
  43999. export * from "babylonjs/Cameras/targetCamera";
  44000. export * from "babylonjs/Cameras/freeCamera";
  44001. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44002. export * from "babylonjs/Cameras/touchCamera";
  44003. export * from "babylonjs/Cameras/arcRotateCamera";
  44004. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44005. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44006. export * from "babylonjs/Cameras/flyCamera";
  44007. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44008. export * from "babylonjs/Cameras/followCamera";
  44009. export * from "babylonjs/Cameras/followCameraInputsManager";
  44010. export * from "babylonjs/Cameras/gamepadCamera";
  44011. export * from "babylonjs/Cameras/Stereoscopic/index";
  44012. export * from "babylonjs/Cameras/universalCamera";
  44013. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44014. export * from "babylonjs/Cameras/VR/index";
  44015. export * from "babylonjs/Cameras/XR/index";
  44016. export * from "babylonjs/Cameras/RigModes/index";
  44017. }
  44018. declare module "babylonjs/Collisions/index" {
  44019. export * from "babylonjs/Collisions/collider";
  44020. export * from "babylonjs/Collisions/collisionCoordinator";
  44021. export * from "babylonjs/Collisions/pickingInfo";
  44022. export * from "babylonjs/Collisions/intersectionInfo";
  44023. export * from "babylonjs/Collisions/meshCollisionData";
  44024. }
  44025. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44026. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44027. import { Vector3 } from "babylonjs/Maths/math.vector";
  44028. import { Ray } from "babylonjs/Culling/ray";
  44029. import { Plane } from "babylonjs/Maths/math.plane";
  44030. /**
  44031. * Contains an array of blocks representing the octree
  44032. */
  44033. export interface IOctreeContainer<T> {
  44034. /**
  44035. * Blocks within the octree
  44036. */
  44037. blocks: Array<OctreeBlock<T>>;
  44038. }
  44039. /**
  44040. * Class used to store a cell in an octree
  44041. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44042. */
  44043. export class OctreeBlock<T> {
  44044. /**
  44045. * Gets the content of the current block
  44046. */
  44047. entries: T[];
  44048. /**
  44049. * Gets the list of block children
  44050. */
  44051. blocks: Array<OctreeBlock<T>>;
  44052. private _depth;
  44053. private _maxDepth;
  44054. private _capacity;
  44055. private _minPoint;
  44056. private _maxPoint;
  44057. private _boundingVectors;
  44058. private _creationFunc;
  44059. /**
  44060. * Creates a new block
  44061. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44062. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44063. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44064. * @param depth defines the current depth of this block in the octree
  44065. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44066. * @param creationFunc defines a callback to call when an element is added to the block
  44067. */
  44068. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44069. /**
  44070. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44071. */
  44072. readonly capacity: number;
  44073. /**
  44074. * Gets the minimum vector (in world space) of the block's bounding box
  44075. */
  44076. readonly minPoint: Vector3;
  44077. /**
  44078. * Gets the maximum vector (in world space) of the block's bounding box
  44079. */
  44080. readonly maxPoint: Vector3;
  44081. /**
  44082. * Add a new element to this block
  44083. * @param entry defines the element to add
  44084. */
  44085. addEntry(entry: T): void;
  44086. /**
  44087. * Remove an element from this block
  44088. * @param entry defines the element to remove
  44089. */
  44090. removeEntry(entry: T): void;
  44091. /**
  44092. * Add an array of elements to this block
  44093. * @param entries defines the array of elements to add
  44094. */
  44095. addEntries(entries: T[]): void;
  44096. /**
  44097. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44098. * @param frustumPlanes defines the frustum planes to test
  44099. * @param selection defines the array to store current content if selection is positive
  44100. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44101. */
  44102. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44103. /**
  44104. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44105. * @param sphereCenter defines the bounding sphere center
  44106. * @param sphereRadius defines the bounding sphere radius
  44107. * @param selection defines the array to store current content if selection is positive
  44108. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44109. */
  44110. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44111. /**
  44112. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44113. * @param ray defines the ray to test with
  44114. * @param selection defines the array to store current content if selection is positive
  44115. */
  44116. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44117. /**
  44118. * Subdivide the content into child blocks (this block will then be empty)
  44119. */
  44120. createInnerBlocks(): void;
  44121. /**
  44122. * @hidden
  44123. */
  44124. 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;
  44125. }
  44126. }
  44127. declare module "babylonjs/Culling/Octrees/octree" {
  44128. import { SmartArray } from "babylonjs/Misc/smartArray";
  44129. import { Vector3 } from "babylonjs/Maths/math.vector";
  44130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44132. import { Ray } from "babylonjs/Culling/ray";
  44133. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44134. import { Plane } from "babylonjs/Maths/math.plane";
  44135. /**
  44136. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44137. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44138. */
  44139. export class Octree<T> {
  44140. /** 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.) */
  44141. maxDepth: number;
  44142. /**
  44143. * Blocks within the octree containing objects
  44144. */
  44145. blocks: Array<OctreeBlock<T>>;
  44146. /**
  44147. * Content stored in the octree
  44148. */
  44149. dynamicContent: T[];
  44150. private _maxBlockCapacity;
  44151. private _selectionContent;
  44152. private _creationFunc;
  44153. /**
  44154. * Creates a octree
  44155. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44156. * @param creationFunc function to be used to instatiate the octree
  44157. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44158. * @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.)
  44159. */
  44160. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44161. /** 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.) */
  44162. maxDepth?: number);
  44163. /**
  44164. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44165. * @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);
  44166. * @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);
  44167. * @param entries meshes to be added to the octree blocks
  44168. */
  44169. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44170. /**
  44171. * Adds a mesh to the octree
  44172. * @param entry Mesh to add to the octree
  44173. */
  44174. addMesh(entry: T): void;
  44175. /**
  44176. * Remove an element from the octree
  44177. * @param entry defines the element to remove
  44178. */
  44179. removeMesh(entry: T): void;
  44180. /**
  44181. * Selects an array of meshes within the frustum
  44182. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44183. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44184. * @returns array of meshes within the frustum
  44185. */
  44186. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44187. /**
  44188. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44189. * @param sphereCenter defines the bounding sphere center
  44190. * @param sphereRadius defines the bounding sphere radius
  44191. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44192. * @returns an array of objects that intersect the sphere
  44193. */
  44194. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44195. /**
  44196. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44197. * @param ray defines the ray to test with
  44198. * @returns array of intersected objects
  44199. */
  44200. intersectsRay(ray: Ray): SmartArray<T>;
  44201. /**
  44202. * Adds a mesh into the octree block if it intersects the block
  44203. */
  44204. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44205. /**
  44206. * Adds a submesh into the octree block if it intersects the block
  44207. */
  44208. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44209. }
  44210. }
  44211. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44212. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44213. import { Scene } from "babylonjs/scene";
  44214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44216. import { Ray } from "babylonjs/Culling/ray";
  44217. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44218. import { Collider } from "babylonjs/Collisions/collider";
  44219. module "babylonjs/scene" {
  44220. interface Scene {
  44221. /**
  44222. * @hidden
  44223. * Backing Filed
  44224. */
  44225. _selectionOctree: Octree<AbstractMesh>;
  44226. /**
  44227. * Gets the octree used to boost mesh selection (picking)
  44228. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44229. */
  44230. selectionOctree: Octree<AbstractMesh>;
  44231. /**
  44232. * Creates or updates the octree used to boost selection (picking)
  44233. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44234. * @param maxCapacity defines the maximum capacity per leaf
  44235. * @param maxDepth defines the maximum depth of the octree
  44236. * @returns an octree of AbstractMesh
  44237. */
  44238. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44239. }
  44240. }
  44241. module "babylonjs/Meshes/abstractMesh" {
  44242. interface AbstractMesh {
  44243. /**
  44244. * @hidden
  44245. * Backing Field
  44246. */
  44247. _submeshesOctree: Octree<SubMesh>;
  44248. /**
  44249. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44250. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44251. * @param maxCapacity defines the maximum size of each block (64 by default)
  44252. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44253. * @returns the new octree
  44254. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44256. */
  44257. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44258. }
  44259. }
  44260. /**
  44261. * Defines the octree scene component responsible to manage any octrees
  44262. * in a given scene.
  44263. */
  44264. export class OctreeSceneComponent {
  44265. /**
  44266. * The component name help to identify the component in the list of scene components.
  44267. */
  44268. readonly name: string;
  44269. /**
  44270. * The scene the component belongs to.
  44271. */
  44272. scene: Scene;
  44273. /**
  44274. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44275. */
  44276. readonly checksIsEnabled: boolean;
  44277. /**
  44278. * Creates a new instance of the component for the given scene
  44279. * @param scene Defines the scene to register the component in
  44280. */
  44281. constructor(scene: Scene);
  44282. /**
  44283. * Registers the component in a given scene
  44284. */
  44285. register(): void;
  44286. /**
  44287. * Return the list of active meshes
  44288. * @returns the list of active meshes
  44289. */
  44290. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44291. /**
  44292. * Return the list of active sub meshes
  44293. * @param mesh The mesh to get the candidates sub meshes from
  44294. * @returns the list of active sub meshes
  44295. */
  44296. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44297. private _tempRay;
  44298. /**
  44299. * Return the list of sub meshes intersecting with a given local ray
  44300. * @param mesh defines the mesh to find the submesh for
  44301. * @param localRay defines the ray in local space
  44302. * @returns the list of intersecting sub meshes
  44303. */
  44304. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44305. /**
  44306. * Return the list of sub meshes colliding with a collider
  44307. * @param mesh defines the mesh to find the submesh for
  44308. * @param collider defines the collider to evaluate the collision against
  44309. * @returns the list of colliding sub meshes
  44310. */
  44311. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44312. /**
  44313. * Rebuilds the elements related to this component in case of
  44314. * context lost for instance.
  44315. */
  44316. rebuild(): void;
  44317. /**
  44318. * Disposes the component and the associated ressources.
  44319. */
  44320. dispose(): void;
  44321. }
  44322. }
  44323. declare module "babylonjs/Culling/Octrees/index" {
  44324. export * from "babylonjs/Culling/Octrees/octree";
  44325. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44326. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44327. }
  44328. declare module "babylonjs/Culling/index" {
  44329. export * from "babylonjs/Culling/boundingBox";
  44330. export * from "babylonjs/Culling/boundingInfo";
  44331. export * from "babylonjs/Culling/boundingSphere";
  44332. export * from "babylonjs/Culling/Octrees/index";
  44333. export * from "babylonjs/Culling/ray";
  44334. }
  44335. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44336. import { IDisposable, Scene } from "babylonjs/scene";
  44337. import { Nullable } from "babylonjs/types";
  44338. import { Observable } from "babylonjs/Misc/observable";
  44339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44340. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44341. import { Camera } from "babylonjs/Cameras/camera";
  44342. /**
  44343. * Renders a layer on top of an existing scene
  44344. */
  44345. export class UtilityLayerRenderer implements IDisposable {
  44346. /** the original scene that will be rendered on top of */
  44347. originalScene: Scene;
  44348. private _pointerCaptures;
  44349. private _lastPointerEvents;
  44350. private static _DefaultUtilityLayer;
  44351. private static _DefaultKeepDepthUtilityLayer;
  44352. private _sharedGizmoLight;
  44353. private _renderCamera;
  44354. /**
  44355. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44356. * @returns the camera that is used when rendering the utility layer
  44357. */
  44358. getRenderCamera(): Nullable<Camera>;
  44359. /**
  44360. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44361. * @param cam the camera that should be used when rendering the utility layer
  44362. */
  44363. setRenderCamera(cam: Nullable<Camera>): void;
  44364. /**
  44365. * @hidden
  44366. * Light which used by gizmos to get light shading
  44367. */
  44368. _getSharedGizmoLight(): HemisphericLight;
  44369. /**
  44370. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44371. */
  44372. pickUtilitySceneFirst: boolean;
  44373. /**
  44374. * 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)
  44375. */
  44376. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44377. /**
  44378. * 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)
  44379. */
  44380. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44381. /**
  44382. * The scene that is rendered on top of the original scene
  44383. */
  44384. utilityLayerScene: Scene;
  44385. /**
  44386. * If the utility layer should automatically be rendered on top of existing scene
  44387. */
  44388. shouldRender: boolean;
  44389. /**
  44390. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44391. */
  44392. onlyCheckPointerDownEvents: boolean;
  44393. /**
  44394. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44395. */
  44396. processAllEvents: boolean;
  44397. /**
  44398. * Observable raised when the pointer move from the utility layer scene to the main scene
  44399. */
  44400. onPointerOutObservable: Observable<number>;
  44401. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44402. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44403. private _afterRenderObserver;
  44404. private _sceneDisposeObserver;
  44405. private _originalPointerObserver;
  44406. /**
  44407. * Instantiates a UtilityLayerRenderer
  44408. * @param originalScene the original scene that will be rendered on top of
  44409. * @param handleEvents boolean indicating if the utility layer should handle events
  44410. */
  44411. constructor(
  44412. /** the original scene that will be rendered on top of */
  44413. originalScene: Scene, handleEvents?: boolean);
  44414. private _notifyObservers;
  44415. /**
  44416. * Renders the utility layers scene on top of the original scene
  44417. */
  44418. render(): void;
  44419. /**
  44420. * Disposes of the renderer
  44421. */
  44422. dispose(): void;
  44423. private _updateCamera;
  44424. }
  44425. }
  44426. declare module "babylonjs/Gizmos/gizmo" {
  44427. import { Nullable } from "babylonjs/types";
  44428. import { IDisposable } from "babylonjs/scene";
  44429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44430. import { Mesh } from "babylonjs/Meshes/mesh";
  44431. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44432. /**
  44433. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44434. */
  44435. export class Gizmo implements IDisposable {
  44436. /** The utility layer the gizmo will be added to */
  44437. gizmoLayer: UtilityLayerRenderer;
  44438. /**
  44439. * The root mesh of the gizmo
  44440. */
  44441. _rootMesh: Mesh;
  44442. private _attachedMesh;
  44443. /**
  44444. * Ratio for the scale of the gizmo (Default: 1)
  44445. */
  44446. scaleRatio: number;
  44447. /**
  44448. * If a custom mesh has been set (Default: false)
  44449. */
  44450. protected _customMeshSet: boolean;
  44451. /**
  44452. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44453. * * When set, interactions will be enabled
  44454. */
  44455. attachedMesh: Nullable<AbstractMesh>;
  44456. /**
  44457. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44458. * @param mesh The mesh to replace the default mesh of the gizmo
  44459. */
  44460. setCustomMesh(mesh: Mesh): void;
  44461. /**
  44462. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44463. */
  44464. updateGizmoRotationToMatchAttachedMesh: boolean;
  44465. /**
  44466. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44467. */
  44468. updateGizmoPositionToMatchAttachedMesh: boolean;
  44469. /**
  44470. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44471. */
  44472. updateScale: boolean;
  44473. protected _interactionsEnabled: boolean;
  44474. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44475. private _beforeRenderObserver;
  44476. private _tempVector;
  44477. /**
  44478. * Creates a gizmo
  44479. * @param gizmoLayer The utility layer the gizmo will be added to
  44480. */
  44481. constructor(
  44482. /** The utility layer the gizmo will be added to */
  44483. gizmoLayer?: UtilityLayerRenderer);
  44484. /**
  44485. * Updates the gizmo to match the attached mesh's position/rotation
  44486. */
  44487. protected _update(): void;
  44488. /**
  44489. * Disposes of the gizmo
  44490. */
  44491. dispose(): void;
  44492. }
  44493. }
  44494. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44495. import { Observable } from "babylonjs/Misc/observable";
  44496. import { Nullable } from "babylonjs/types";
  44497. import { Vector3 } from "babylonjs/Maths/math.vector";
  44498. import { Color3 } from "babylonjs/Maths/math.color";
  44499. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44501. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44502. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44503. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44504. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44505. import { Scene } from "babylonjs/scene";
  44506. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44507. /**
  44508. * Single plane drag gizmo
  44509. */
  44510. export class PlaneDragGizmo extends Gizmo {
  44511. /**
  44512. * Drag behavior responsible for the gizmos dragging interactions
  44513. */
  44514. dragBehavior: PointerDragBehavior;
  44515. private _pointerObserver;
  44516. /**
  44517. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44518. */
  44519. snapDistance: number;
  44520. /**
  44521. * Event that fires each time the gizmo snaps to a new location.
  44522. * * snapDistance is the the change in distance
  44523. */
  44524. onSnapObservable: Observable<{
  44525. snapDistance: number;
  44526. }>;
  44527. private _plane;
  44528. private _coloredMaterial;
  44529. private _hoverMaterial;
  44530. private _isEnabled;
  44531. private _parent;
  44532. /** @hidden */
  44533. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44534. /** @hidden */
  44535. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44536. /**
  44537. * Creates a PlaneDragGizmo
  44538. * @param gizmoLayer The utility layer the gizmo will be added to
  44539. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44540. * @param color The color of the gizmo
  44541. */
  44542. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44543. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44544. /**
  44545. * If the gizmo is enabled
  44546. */
  44547. isEnabled: boolean;
  44548. /**
  44549. * Disposes of the gizmo
  44550. */
  44551. dispose(): void;
  44552. }
  44553. }
  44554. declare module "babylonjs/Gizmos/positionGizmo" {
  44555. import { Observable } from "babylonjs/Misc/observable";
  44556. import { Nullable } from "babylonjs/types";
  44557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44558. import { Mesh } from "babylonjs/Meshes/mesh";
  44559. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44560. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44561. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44562. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44563. /**
  44564. * Gizmo that enables dragging a mesh along 3 axis
  44565. */
  44566. export class PositionGizmo extends Gizmo {
  44567. /**
  44568. * Internal gizmo used for interactions on the x axis
  44569. */
  44570. xGizmo: AxisDragGizmo;
  44571. /**
  44572. * Internal gizmo used for interactions on the y axis
  44573. */
  44574. yGizmo: AxisDragGizmo;
  44575. /**
  44576. * Internal gizmo used for interactions on the z axis
  44577. */
  44578. zGizmo: AxisDragGizmo;
  44579. /**
  44580. * Internal gizmo used for interactions on the yz plane
  44581. */
  44582. xPlaneGizmo: PlaneDragGizmo;
  44583. /**
  44584. * Internal gizmo used for interactions on the xz plane
  44585. */
  44586. yPlaneGizmo: PlaneDragGizmo;
  44587. /**
  44588. * Internal gizmo used for interactions on the xy plane
  44589. */
  44590. zPlaneGizmo: PlaneDragGizmo;
  44591. /**
  44592. * private variables
  44593. */
  44594. private _meshAttached;
  44595. private _updateGizmoRotationToMatchAttachedMesh;
  44596. private _snapDistance;
  44597. private _scaleRatio;
  44598. /** Fires an event when any of it's sub gizmos are dragged */
  44599. onDragStartObservable: Observable<unknown>;
  44600. /** Fires an event when any of it's sub gizmos are released from dragging */
  44601. onDragEndObservable: Observable<unknown>;
  44602. /**
  44603. * If set to true, planar drag is enabled
  44604. */
  44605. private _planarGizmoEnabled;
  44606. attachedMesh: Nullable<AbstractMesh>;
  44607. /**
  44608. * Creates a PositionGizmo
  44609. * @param gizmoLayer The utility layer the gizmo will be added to
  44610. */
  44611. constructor(gizmoLayer?: UtilityLayerRenderer);
  44612. /**
  44613. * If the planar drag gizmo is enabled
  44614. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44615. */
  44616. planarGizmoEnabled: boolean;
  44617. updateGizmoRotationToMatchAttachedMesh: boolean;
  44618. /**
  44619. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44620. */
  44621. snapDistance: number;
  44622. /**
  44623. * Ratio for the scale of the gizmo (Default: 1)
  44624. */
  44625. scaleRatio: number;
  44626. /**
  44627. * Disposes of the gizmo
  44628. */
  44629. dispose(): void;
  44630. /**
  44631. * CustomMeshes are not supported by this gizmo
  44632. * @param mesh The mesh to replace the default mesh of the gizmo
  44633. */
  44634. setCustomMesh(mesh: Mesh): void;
  44635. }
  44636. }
  44637. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44638. import { Observable } from "babylonjs/Misc/observable";
  44639. import { Nullable } from "babylonjs/types";
  44640. import { Vector3 } from "babylonjs/Maths/math.vector";
  44641. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44643. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44644. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44645. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44646. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44647. import { Scene } from "babylonjs/scene";
  44648. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44649. import { Color3 } from "babylonjs/Maths/math.color";
  44650. /**
  44651. * Single axis drag gizmo
  44652. */
  44653. export class AxisDragGizmo extends Gizmo {
  44654. /**
  44655. * Drag behavior responsible for the gizmos dragging interactions
  44656. */
  44657. dragBehavior: PointerDragBehavior;
  44658. private _pointerObserver;
  44659. /**
  44660. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44661. */
  44662. snapDistance: number;
  44663. /**
  44664. * Event that fires each time the gizmo snaps to a new location.
  44665. * * snapDistance is the the change in distance
  44666. */
  44667. onSnapObservable: Observable<{
  44668. snapDistance: number;
  44669. }>;
  44670. private _isEnabled;
  44671. private _parent;
  44672. private _arrow;
  44673. private _coloredMaterial;
  44674. private _hoverMaterial;
  44675. /** @hidden */
  44676. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44677. /** @hidden */
  44678. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44679. /**
  44680. * Creates an AxisDragGizmo
  44681. * @param gizmoLayer The utility layer the gizmo will be added to
  44682. * @param dragAxis The axis which the gizmo will be able to drag on
  44683. * @param color The color of the gizmo
  44684. */
  44685. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44686. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44687. /**
  44688. * If the gizmo is enabled
  44689. */
  44690. isEnabled: boolean;
  44691. /**
  44692. * Disposes of the gizmo
  44693. */
  44694. dispose(): void;
  44695. }
  44696. }
  44697. declare module "babylonjs/Debug/axesViewer" {
  44698. import { Vector3 } from "babylonjs/Maths/math.vector";
  44699. import { Nullable } from "babylonjs/types";
  44700. import { Scene } from "babylonjs/scene";
  44701. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44702. /**
  44703. * The Axes viewer will show 3 axes in a specific point in space
  44704. */
  44705. export class AxesViewer {
  44706. private _xAxis;
  44707. private _yAxis;
  44708. private _zAxis;
  44709. private _scaleLinesFactor;
  44710. private _instanced;
  44711. /**
  44712. * Gets the hosting scene
  44713. */
  44714. scene: Scene;
  44715. /**
  44716. * Gets or sets a number used to scale line length
  44717. */
  44718. scaleLines: number;
  44719. /** Gets the node hierarchy used to render x-axis */
  44720. readonly xAxis: TransformNode;
  44721. /** Gets the node hierarchy used to render y-axis */
  44722. readonly yAxis: TransformNode;
  44723. /** Gets the node hierarchy used to render z-axis */
  44724. readonly zAxis: TransformNode;
  44725. /**
  44726. * Creates a new AxesViewer
  44727. * @param scene defines the hosting scene
  44728. * @param scaleLines defines a number used to scale line length (1 by default)
  44729. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44730. * @param xAxis defines the node hierarchy used to render the x-axis
  44731. * @param yAxis defines the node hierarchy used to render the y-axis
  44732. * @param zAxis defines the node hierarchy used to render the z-axis
  44733. */
  44734. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44735. /**
  44736. * Force the viewer to update
  44737. * @param position defines the position of the viewer
  44738. * @param xaxis defines the x axis of the viewer
  44739. * @param yaxis defines the y axis of the viewer
  44740. * @param zaxis defines the z axis of the viewer
  44741. */
  44742. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44743. /**
  44744. * Creates an instance of this axes viewer.
  44745. * @returns a new axes viewer with instanced meshes
  44746. */
  44747. createInstance(): AxesViewer;
  44748. /** Releases resources */
  44749. dispose(): void;
  44750. private static _SetRenderingGroupId;
  44751. }
  44752. }
  44753. declare module "babylonjs/Debug/boneAxesViewer" {
  44754. import { Nullable } from "babylonjs/types";
  44755. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44756. import { Vector3 } from "babylonjs/Maths/math.vector";
  44757. import { Mesh } from "babylonjs/Meshes/mesh";
  44758. import { Bone } from "babylonjs/Bones/bone";
  44759. import { Scene } from "babylonjs/scene";
  44760. /**
  44761. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44762. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44763. */
  44764. export class BoneAxesViewer extends AxesViewer {
  44765. /**
  44766. * Gets or sets the target mesh where to display the axes viewer
  44767. */
  44768. mesh: Nullable<Mesh>;
  44769. /**
  44770. * Gets or sets the target bone where to display the axes viewer
  44771. */
  44772. bone: Nullable<Bone>;
  44773. /** Gets current position */
  44774. pos: Vector3;
  44775. /** Gets direction of X axis */
  44776. xaxis: Vector3;
  44777. /** Gets direction of Y axis */
  44778. yaxis: Vector3;
  44779. /** Gets direction of Z axis */
  44780. zaxis: Vector3;
  44781. /**
  44782. * Creates a new BoneAxesViewer
  44783. * @param scene defines the hosting scene
  44784. * @param bone defines the target bone
  44785. * @param mesh defines the target mesh
  44786. * @param scaleLines defines a scaling factor for line length (1 by default)
  44787. */
  44788. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44789. /**
  44790. * Force the viewer to update
  44791. */
  44792. update(): void;
  44793. /** Releases resources */
  44794. dispose(): void;
  44795. }
  44796. }
  44797. declare module "babylonjs/Debug/debugLayer" {
  44798. import { Scene } from "babylonjs/scene";
  44799. /**
  44800. * Interface used to define scene explorer extensibility option
  44801. */
  44802. export interface IExplorerExtensibilityOption {
  44803. /**
  44804. * Define the option label
  44805. */
  44806. label: string;
  44807. /**
  44808. * Defines the action to execute on click
  44809. */
  44810. action: (entity: any) => void;
  44811. }
  44812. /**
  44813. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44814. */
  44815. export interface IExplorerExtensibilityGroup {
  44816. /**
  44817. * Defines a predicate to test if a given type mut be extended
  44818. */
  44819. predicate: (entity: any) => boolean;
  44820. /**
  44821. * Gets the list of options added to a type
  44822. */
  44823. entries: IExplorerExtensibilityOption[];
  44824. }
  44825. /**
  44826. * Interface used to define the options to use to create the Inspector
  44827. */
  44828. export interface IInspectorOptions {
  44829. /**
  44830. * Display in overlay mode (default: false)
  44831. */
  44832. overlay?: boolean;
  44833. /**
  44834. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44835. */
  44836. globalRoot?: HTMLElement;
  44837. /**
  44838. * Display the Scene explorer
  44839. */
  44840. showExplorer?: boolean;
  44841. /**
  44842. * Display the property inspector
  44843. */
  44844. showInspector?: boolean;
  44845. /**
  44846. * Display in embed mode (both panes on the right)
  44847. */
  44848. embedMode?: boolean;
  44849. /**
  44850. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44851. */
  44852. handleResize?: boolean;
  44853. /**
  44854. * Allow the panes to popup (default: true)
  44855. */
  44856. enablePopup?: boolean;
  44857. /**
  44858. * Allow the panes to be closed by users (default: true)
  44859. */
  44860. enableClose?: boolean;
  44861. /**
  44862. * Optional list of extensibility entries
  44863. */
  44864. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44865. /**
  44866. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44867. */
  44868. inspectorURL?: string;
  44869. }
  44870. module "babylonjs/scene" {
  44871. interface Scene {
  44872. /**
  44873. * @hidden
  44874. * Backing field
  44875. */
  44876. _debugLayer: DebugLayer;
  44877. /**
  44878. * Gets the debug layer (aka Inspector) associated with the scene
  44879. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44880. */
  44881. debugLayer: DebugLayer;
  44882. }
  44883. }
  44884. /**
  44885. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44886. * what is happening in your scene
  44887. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44888. */
  44889. export class DebugLayer {
  44890. /**
  44891. * Define the url to get the inspector script from.
  44892. * By default it uses the babylonjs CDN.
  44893. * @ignoreNaming
  44894. */
  44895. static InspectorURL: string;
  44896. private _scene;
  44897. private BJSINSPECTOR;
  44898. private _onPropertyChangedObservable?;
  44899. /**
  44900. * Observable triggered when a property is changed through the inspector.
  44901. */
  44902. readonly onPropertyChangedObservable: any;
  44903. /**
  44904. * Instantiates a new debug layer.
  44905. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44906. * what is happening in your scene
  44907. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44908. * @param scene Defines the scene to inspect
  44909. */
  44910. constructor(scene: Scene);
  44911. /** Creates the inspector window. */
  44912. private _createInspector;
  44913. /**
  44914. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44915. * @param entity defines the entity to select
  44916. * @param lineContainerTitle defines the specific block to highlight
  44917. */
  44918. select(entity: any, lineContainerTitle?: string): void;
  44919. /** Get the inspector from bundle or global */
  44920. private _getGlobalInspector;
  44921. /**
  44922. * Get if the inspector is visible or not.
  44923. * @returns true if visible otherwise, false
  44924. */
  44925. isVisible(): boolean;
  44926. /**
  44927. * Hide the inspector and close its window.
  44928. */
  44929. hide(): void;
  44930. /**
  44931. * Launch the debugLayer.
  44932. * @param config Define the configuration of the inspector
  44933. * @return a promise fulfilled when the debug layer is visible
  44934. */
  44935. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44936. }
  44937. }
  44938. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44939. import { Nullable } from "babylonjs/types";
  44940. import { Scene } from "babylonjs/scene";
  44941. import { Vector4 } from "babylonjs/Maths/math.vector";
  44942. import { Color4 } from "babylonjs/Maths/math.color";
  44943. import { Mesh } from "babylonjs/Meshes/mesh";
  44944. /**
  44945. * Class containing static functions to help procedurally build meshes
  44946. */
  44947. export class BoxBuilder {
  44948. /**
  44949. * Creates a box mesh
  44950. * * The parameter `size` sets the size (float) of each box side (default 1)
  44951. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44952. * * 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)
  44953. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44957. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44958. * @param name defines the name of the mesh
  44959. * @param options defines the options used to create the mesh
  44960. * @param scene defines the hosting scene
  44961. * @returns the box mesh
  44962. */
  44963. static CreateBox(name: string, options: {
  44964. size?: number;
  44965. width?: number;
  44966. height?: number;
  44967. depth?: number;
  44968. faceUV?: Vector4[];
  44969. faceColors?: Color4[];
  44970. sideOrientation?: number;
  44971. frontUVs?: Vector4;
  44972. backUVs?: Vector4;
  44973. wrap?: boolean;
  44974. topBaseAt?: number;
  44975. bottomBaseAt?: number;
  44976. updatable?: boolean;
  44977. }, scene?: Nullable<Scene>): Mesh;
  44978. }
  44979. }
  44980. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44981. import { Vector4 } from "babylonjs/Maths/math.vector";
  44982. import { Mesh } from "babylonjs/Meshes/mesh";
  44983. import { Scene } from "babylonjs/scene";
  44984. import { Nullable } from "babylonjs/types";
  44985. /**
  44986. * Class containing static functions to help procedurally build meshes
  44987. */
  44988. export class SphereBuilder {
  44989. /**
  44990. * Creates a sphere mesh
  44991. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44992. * * 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`)
  44993. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44994. * * 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
  44995. * * 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)
  44996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44999. * @param name defines the name of the mesh
  45000. * @param options defines the options used to create the mesh
  45001. * @param scene defines the hosting scene
  45002. * @returns the sphere mesh
  45003. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45004. */
  45005. static CreateSphere(name: string, options: {
  45006. segments?: number;
  45007. diameter?: number;
  45008. diameterX?: number;
  45009. diameterY?: number;
  45010. diameterZ?: number;
  45011. arc?: number;
  45012. slice?: number;
  45013. sideOrientation?: number;
  45014. frontUVs?: Vector4;
  45015. backUVs?: Vector4;
  45016. updatable?: boolean;
  45017. }, scene?: Nullable<Scene>): Mesh;
  45018. }
  45019. }
  45020. declare module "babylonjs/Debug/physicsViewer" {
  45021. import { Nullable } from "babylonjs/types";
  45022. import { Scene } from "babylonjs/scene";
  45023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45024. import { Mesh } from "babylonjs/Meshes/mesh";
  45025. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45026. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45027. /**
  45028. * Used to show the physics impostor around the specific mesh
  45029. */
  45030. export class PhysicsViewer {
  45031. /** @hidden */
  45032. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45033. /** @hidden */
  45034. protected _meshes: Array<Nullable<AbstractMesh>>;
  45035. /** @hidden */
  45036. protected _scene: Nullable<Scene>;
  45037. /** @hidden */
  45038. protected _numMeshes: number;
  45039. /** @hidden */
  45040. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45041. private _renderFunction;
  45042. private _utilityLayer;
  45043. private _debugBoxMesh;
  45044. private _debugSphereMesh;
  45045. private _debugCylinderMesh;
  45046. private _debugMaterial;
  45047. private _debugMeshMeshes;
  45048. /**
  45049. * Creates a new PhysicsViewer
  45050. * @param scene defines the hosting scene
  45051. */
  45052. constructor(scene: Scene);
  45053. /** @hidden */
  45054. protected _updateDebugMeshes(): void;
  45055. /**
  45056. * Renders a specified physic impostor
  45057. * @param impostor defines the impostor to render
  45058. * @param targetMesh defines the mesh represented by the impostor
  45059. * @returns the new debug mesh used to render the impostor
  45060. */
  45061. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45062. /**
  45063. * Hides a specified physic impostor
  45064. * @param impostor defines the impostor to hide
  45065. */
  45066. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45067. private _getDebugMaterial;
  45068. private _getDebugBoxMesh;
  45069. private _getDebugSphereMesh;
  45070. private _getDebugCylinderMesh;
  45071. private _getDebugMeshMesh;
  45072. private _getDebugMesh;
  45073. /** Releases all resources */
  45074. dispose(): void;
  45075. }
  45076. }
  45077. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45078. import { Vector3 } from "babylonjs/Maths/math.vector";
  45079. import { Color4 } from "babylonjs/Maths/math.color";
  45080. import { Nullable } from "babylonjs/types";
  45081. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45082. import { Scene } from "babylonjs/scene";
  45083. /**
  45084. * Class containing static functions to help procedurally build meshes
  45085. */
  45086. export class LinesBuilder {
  45087. /**
  45088. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45089. * * 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
  45090. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45091. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45092. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45093. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45094. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45095. * * 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
  45096. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45099. * @param name defines the name of the new line system
  45100. * @param options defines the options used to create the line system
  45101. * @param scene defines the hosting scene
  45102. * @returns a new line system mesh
  45103. */
  45104. static CreateLineSystem(name: string, options: {
  45105. lines: Vector3[][];
  45106. updatable?: boolean;
  45107. instance?: Nullable<LinesMesh>;
  45108. colors?: Nullable<Color4[][]>;
  45109. useVertexAlpha?: boolean;
  45110. }, scene: Nullable<Scene>): LinesMesh;
  45111. /**
  45112. * Creates a line mesh
  45113. * 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
  45114. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45115. * * The parameter `points` is an array successive Vector3
  45116. * * 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
  45117. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45118. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45119. * * When updating an instance, remember that only point positions can change, not the number of points
  45120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45122. * @param name defines the name of the new line system
  45123. * @param options defines the options used to create the line system
  45124. * @param scene defines the hosting scene
  45125. * @returns a new line mesh
  45126. */
  45127. static CreateLines(name: string, options: {
  45128. points: Vector3[];
  45129. updatable?: boolean;
  45130. instance?: Nullable<LinesMesh>;
  45131. colors?: Color4[];
  45132. useVertexAlpha?: boolean;
  45133. }, scene?: Nullable<Scene>): LinesMesh;
  45134. /**
  45135. * Creates a dashed line mesh
  45136. * * 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
  45137. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45138. * * The parameter `points` is an array successive Vector3
  45139. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45140. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45141. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45142. * * 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
  45143. * * When updating an instance, remember that only point positions can change, not the number of points
  45144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45145. * @param name defines the name of the mesh
  45146. * @param options defines the options used to create the mesh
  45147. * @param scene defines the hosting scene
  45148. * @returns the dashed line mesh
  45149. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45150. */
  45151. static CreateDashedLines(name: string, options: {
  45152. points: Vector3[];
  45153. dashSize?: number;
  45154. gapSize?: number;
  45155. dashNb?: number;
  45156. updatable?: boolean;
  45157. instance?: LinesMesh;
  45158. }, scene?: Nullable<Scene>): LinesMesh;
  45159. }
  45160. }
  45161. declare module "babylonjs/Debug/rayHelper" {
  45162. import { Nullable } from "babylonjs/types";
  45163. import { Ray } from "babylonjs/Culling/ray";
  45164. import { Vector3 } from "babylonjs/Maths/math.vector";
  45165. import { Color3 } from "babylonjs/Maths/math.color";
  45166. import { Scene } from "babylonjs/scene";
  45167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45168. import "babylonjs/Meshes/Builders/linesBuilder";
  45169. /**
  45170. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45171. * in order to better appreciate the issue one might have.
  45172. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45173. */
  45174. export class RayHelper {
  45175. /**
  45176. * Defines the ray we are currently tryin to visualize.
  45177. */
  45178. ray: Nullable<Ray>;
  45179. private _renderPoints;
  45180. private _renderLine;
  45181. private _renderFunction;
  45182. private _scene;
  45183. private _updateToMeshFunction;
  45184. private _attachedToMesh;
  45185. private _meshSpaceDirection;
  45186. private _meshSpaceOrigin;
  45187. /**
  45188. * Helper function to create a colored helper in a scene in one line.
  45189. * @param ray Defines the ray we are currently tryin to visualize
  45190. * @param scene Defines the scene the ray is used in
  45191. * @param color Defines the color we want to see the ray in
  45192. * @returns The newly created ray helper.
  45193. */
  45194. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45195. /**
  45196. * Instantiate a new ray helper.
  45197. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45198. * in order to better appreciate the issue one might have.
  45199. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45200. * @param ray Defines the ray we are currently tryin to visualize
  45201. */
  45202. constructor(ray: Ray);
  45203. /**
  45204. * Shows the ray we are willing to debug.
  45205. * @param scene Defines the scene the ray needs to be rendered in
  45206. * @param color Defines the color the ray needs to be rendered in
  45207. */
  45208. show(scene: Scene, color?: Color3): void;
  45209. /**
  45210. * Hides the ray we are debugging.
  45211. */
  45212. hide(): void;
  45213. private _render;
  45214. /**
  45215. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45216. * @param mesh Defines the mesh we want the helper attached to
  45217. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45218. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45219. * @param length Defines the length of the ray
  45220. */
  45221. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45222. /**
  45223. * Detach the ray helper from the mesh it has previously been attached to.
  45224. */
  45225. detachFromMesh(): void;
  45226. private _updateToMesh;
  45227. /**
  45228. * Dispose the helper and release its associated resources.
  45229. */
  45230. dispose(): void;
  45231. }
  45232. }
  45233. declare module "babylonjs/Debug/skeletonViewer" {
  45234. import { Color3 } from "babylonjs/Maths/math.color";
  45235. import { Scene } from "babylonjs/scene";
  45236. import { Nullable } from "babylonjs/types";
  45237. import { Skeleton } from "babylonjs/Bones/skeleton";
  45238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45239. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45240. /**
  45241. * Class used to render a debug view of a given skeleton
  45242. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45243. */
  45244. export class SkeletonViewer {
  45245. /** defines the skeleton to render */
  45246. skeleton: Skeleton;
  45247. /** defines the mesh attached to the skeleton */
  45248. mesh: AbstractMesh;
  45249. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45250. autoUpdateBonesMatrices: boolean;
  45251. /** defines the rendering group id to use with the viewer */
  45252. renderingGroupId: number;
  45253. /** Gets or sets the color used to render the skeleton */
  45254. color: Color3;
  45255. private _scene;
  45256. private _debugLines;
  45257. private _debugMesh;
  45258. private _isEnabled;
  45259. private _renderFunction;
  45260. private _utilityLayer;
  45261. /**
  45262. * Returns the mesh used to render the bones
  45263. */
  45264. readonly debugMesh: Nullable<LinesMesh>;
  45265. /**
  45266. * Creates a new SkeletonViewer
  45267. * @param skeleton defines the skeleton to render
  45268. * @param mesh defines the mesh attached to the skeleton
  45269. * @param scene defines the hosting scene
  45270. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45271. * @param renderingGroupId defines the rendering group id to use with the viewer
  45272. */
  45273. constructor(
  45274. /** defines the skeleton to render */
  45275. skeleton: Skeleton,
  45276. /** defines the mesh attached to the skeleton */
  45277. mesh: AbstractMesh, scene: Scene,
  45278. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45279. autoUpdateBonesMatrices?: boolean,
  45280. /** defines the rendering group id to use with the viewer */
  45281. renderingGroupId?: number);
  45282. /** Gets or sets a boolean indicating if the viewer is enabled */
  45283. isEnabled: boolean;
  45284. private _getBonePosition;
  45285. private _getLinesForBonesWithLength;
  45286. private _getLinesForBonesNoLength;
  45287. /** Update the viewer to sync with current skeleton state */
  45288. update(): void;
  45289. /** Release associated resources */
  45290. dispose(): void;
  45291. }
  45292. }
  45293. declare module "babylonjs/Debug/index" {
  45294. export * from "babylonjs/Debug/axesViewer";
  45295. export * from "babylonjs/Debug/boneAxesViewer";
  45296. export * from "babylonjs/Debug/debugLayer";
  45297. export * from "babylonjs/Debug/physicsViewer";
  45298. export * from "babylonjs/Debug/rayHelper";
  45299. export * from "babylonjs/Debug/skeletonViewer";
  45300. }
  45301. declare module "babylonjs/Engines/nullEngine" {
  45302. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45303. import { Scene } from "babylonjs/scene";
  45304. import { Engine } from "babylonjs/Engines/engine";
  45305. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45306. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45307. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45308. import { Effect } from "babylonjs/Materials/effect";
  45309. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45310. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45311. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45312. /**
  45313. * Options to create the null engine
  45314. */
  45315. export class NullEngineOptions {
  45316. /**
  45317. * Render width (Default: 512)
  45318. */
  45319. renderWidth: number;
  45320. /**
  45321. * Render height (Default: 256)
  45322. */
  45323. renderHeight: number;
  45324. /**
  45325. * Texture size (Default: 512)
  45326. */
  45327. textureSize: number;
  45328. /**
  45329. * If delta time between frames should be constant
  45330. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45331. */
  45332. deterministicLockstep: boolean;
  45333. /**
  45334. * Maximum about of steps between frames (Default: 4)
  45335. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45336. */
  45337. lockstepMaxSteps: number;
  45338. }
  45339. /**
  45340. * The null engine class provides support for headless version of babylon.js.
  45341. * This can be used in server side scenario or for testing purposes
  45342. */
  45343. export class NullEngine extends Engine {
  45344. private _options;
  45345. /**
  45346. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45347. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45348. * @returns true if engine is in deterministic lock step mode
  45349. */
  45350. isDeterministicLockStep(): boolean;
  45351. /**
  45352. * Gets the max steps when engine is running in deterministic lock step
  45353. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45354. * @returns the max steps
  45355. */
  45356. getLockstepMaxSteps(): number;
  45357. /**
  45358. * Gets the current hardware scaling level.
  45359. * By default the hardware scaling level is computed from the window device ratio.
  45360. * 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.
  45361. * @returns a number indicating the current hardware scaling level
  45362. */
  45363. getHardwareScalingLevel(): number;
  45364. constructor(options?: NullEngineOptions);
  45365. /**
  45366. * Creates a vertex buffer
  45367. * @param vertices the data for the vertex buffer
  45368. * @returns the new WebGL static buffer
  45369. */
  45370. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45371. /**
  45372. * Creates a new index buffer
  45373. * @param indices defines the content of the index buffer
  45374. * @param updatable defines if the index buffer must be updatable
  45375. * @returns a new webGL buffer
  45376. */
  45377. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45378. /**
  45379. * Clear the current render buffer or the current render target (if any is set up)
  45380. * @param color defines the color to use
  45381. * @param backBuffer defines if the back buffer must be cleared
  45382. * @param depth defines if the depth buffer must be cleared
  45383. * @param stencil defines if the stencil buffer must be cleared
  45384. */
  45385. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45386. /**
  45387. * Gets the current render width
  45388. * @param useScreen defines if screen size must be used (or the current render target if any)
  45389. * @returns a number defining the current render width
  45390. */
  45391. getRenderWidth(useScreen?: boolean): number;
  45392. /**
  45393. * Gets the current render height
  45394. * @param useScreen defines if screen size must be used (or the current render target if any)
  45395. * @returns a number defining the current render height
  45396. */
  45397. getRenderHeight(useScreen?: boolean): number;
  45398. /**
  45399. * Set the WebGL's viewport
  45400. * @param viewport defines the viewport element to be used
  45401. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45402. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45403. */
  45404. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45405. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45406. /**
  45407. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45408. * @param pipelineContext defines the pipeline context to use
  45409. * @param uniformsNames defines the list of uniform names
  45410. * @returns an array of webGL uniform locations
  45411. */
  45412. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45413. /**
  45414. * Gets the lsit of active attributes for a given webGL program
  45415. * @param pipelineContext defines the pipeline context to use
  45416. * @param attributesNames defines the list of attribute names to get
  45417. * @returns an array of indices indicating the offset of each attribute
  45418. */
  45419. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45420. /**
  45421. * Binds an effect to the webGL context
  45422. * @param effect defines the effect to bind
  45423. */
  45424. bindSamplers(effect: Effect): void;
  45425. /**
  45426. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45427. * @param effect defines the effect to activate
  45428. */
  45429. enableEffect(effect: Effect): void;
  45430. /**
  45431. * Set various states to the webGL context
  45432. * @param culling defines backface culling state
  45433. * @param zOffset defines the value to apply to zOffset (0 by default)
  45434. * @param force defines if states must be applied even if cache is up to date
  45435. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45436. */
  45437. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45438. /**
  45439. * Set the value of an uniform to an array of int32
  45440. * @param uniform defines the webGL uniform location where to store the value
  45441. * @param array defines the array of int32 to store
  45442. */
  45443. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45444. /**
  45445. * Set the value of an uniform to an array of int32 (stored as vec2)
  45446. * @param uniform defines the webGL uniform location where to store the value
  45447. * @param array defines the array of int32 to store
  45448. */
  45449. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45450. /**
  45451. * Set the value of an uniform to an array of int32 (stored as vec3)
  45452. * @param uniform defines the webGL uniform location where to store the value
  45453. * @param array defines the array of int32 to store
  45454. */
  45455. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45456. /**
  45457. * Set the value of an uniform to an array of int32 (stored as vec4)
  45458. * @param uniform defines the webGL uniform location where to store the value
  45459. * @param array defines the array of int32 to store
  45460. */
  45461. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45462. /**
  45463. * Set the value of an uniform to an array of float32
  45464. * @param uniform defines the webGL uniform location where to store the value
  45465. * @param array defines the array of float32 to store
  45466. */
  45467. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45468. /**
  45469. * Set the value of an uniform to an array of float32 (stored as vec2)
  45470. * @param uniform defines the webGL uniform location where to store the value
  45471. * @param array defines the array of float32 to store
  45472. */
  45473. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45474. /**
  45475. * Set the value of an uniform to an array of float32 (stored as vec3)
  45476. * @param uniform defines the webGL uniform location where to store the value
  45477. * @param array defines the array of float32 to store
  45478. */
  45479. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45480. /**
  45481. * Set the value of an uniform to an array of float32 (stored as vec4)
  45482. * @param uniform defines the webGL uniform location where to store the value
  45483. * @param array defines the array of float32 to store
  45484. */
  45485. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45486. /**
  45487. * Set the value of an uniform to an array of number
  45488. * @param uniform defines the webGL uniform location where to store the value
  45489. * @param array defines the array of number to store
  45490. */
  45491. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45492. /**
  45493. * Set the value of an uniform to an array of number (stored as vec2)
  45494. * @param uniform defines the webGL uniform location where to store the value
  45495. * @param array defines the array of number to store
  45496. */
  45497. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45498. /**
  45499. * Set the value of an uniform to an array of number (stored as vec3)
  45500. * @param uniform defines the webGL uniform location where to store the value
  45501. * @param array defines the array of number to store
  45502. */
  45503. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45504. /**
  45505. * Set the value of an uniform to an array of number (stored as vec4)
  45506. * @param uniform defines the webGL uniform location where to store the value
  45507. * @param array defines the array of number to store
  45508. */
  45509. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45510. /**
  45511. * Set the value of an uniform to an array of float32 (stored as matrices)
  45512. * @param uniform defines the webGL uniform location where to store the value
  45513. * @param matrices defines the array of float32 to store
  45514. */
  45515. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45516. /**
  45517. * Set the value of an uniform to a matrix (3x3)
  45518. * @param uniform defines the webGL uniform location where to store the value
  45519. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45520. */
  45521. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45522. /**
  45523. * Set the value of an uniform to a matrix (2x2)
  45524. * @param uniform defines the webGL uniform location where to store the value
  45525. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45526. */
  45527. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45528. /**
  45529. * Set the value of an uniform to a number (float)
  45530. * @param uniform defines the webGL uniform location where to store the value
  45531. * @param value defines the float number to store
  45532. */
  45533. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45534. /**
  45535. * Set the value of an uniform to a vec2
  45536. * @param uniform defines the webGL uniform location where to store the value
  45537. * @param x defines the 1st component of the value
  45538. * @param y defines the 2nd component of the value
  45539. */
  45540. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45541. /**
  45542. * Set the value of an uniform to a vec3
  45543. * @param uniform defines the webGL uniform location where to store the value
  45544. * @param x defines the 1st component of the value
  45545. * @param y defines the 2nd component of the value
  45546. * @param z defines the 3rd component of the value
  45547. */
  45548. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45549. /**
  45550. * Set the value of an uniform to a boolean
  45551. * @param uniform defines the webGL uniform location where to store the value
  45552. * @param bool defines the boolean to store
  45553. */
  45554. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45555. /**
  45556. * Set the value of an uniform to a vec4
  45557. * @param uniform defines the webGL uniform location where to store the value
  45558. * @param x defines the 1st component of the value
  45559. * @param y defines the 2nd component of the value
  45560. * @param z defines the 3rd component of the value
  45561. * @param w defines the 4th component of the value
  45562. */
  45563. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45564. /**
  45565. * Sets the current alpha mode
  45566. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45567. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45568. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45569. */
  45570. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45571. /**
  45572. * Bind webGl buffers directly to the webGL context
  45573. * @param vertexBuffers defines the vertex buffer to bind
  45574. * @param indexBuffer defines the index buffer to bind
  45575. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45576. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45577. * @param effect defines the effect associated with the vertex buffer
  45578. */
  45579. bindBuffers(vertexBuffers: {
  45580. [key: string]: VertexBuffer;
  45581. }, indexBuffer: DataBuffer, effect: Effect): void;
  45582. /**
  45583. * Force the entire cache to be cleared
  45584. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45585. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45586. */
  45587. wipeCaches(bruteForce?: boolean): void;
  45588. /**
  45589. * Send a draw order
  45590. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45591. * @param indexStart defines the starting index
  45592. * @param indexCount defines the number of index to draw
  45593. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45594. */
  45595. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45596. /**
  45597. * Draw a list of indexed primitives
  45598. * @param fillMode defines the primitive to use
  45599. * @param indexStart defines the starting index
  45600. * @param indexCount defines the number of index to draw
  45601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45602. */
  45603. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45604. /**
  45605. * Draw a list of unindexed primitives
  45606. * @param fillMode defines the primitive to use
  45607. * @param verticesStart defines the index of first vertex to draw
  45608. * @param verticesCount defines the count of vertices to draw
  45609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45610. */
  45611. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45612. /** @hidden */
  45613. _createTexture(): WebGLTexture;
  45614. /** @hidden */
  45615. _releaseTexture(texture: InternalTexture): void;
  45616. /**
  45617. * Usually called from Texture.ts.
  45618. * Passed information to create a WebGLTexture
  45619. * @param urlArg defines a value which contains one of the following:
  45620. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45621. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45622. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45623. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45624. * @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)
  45625. * @param scene needed for loading to the correct scene
  45626. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45627. * @param onLoad optional callback to be called upon successful completion
  45628. * @param onError optional callback to be called upon failure
  45629. * @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
  45630. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45631. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45632. * @param forcedExtension defines the extension to use to pick the right loader
  45633. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45634. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45635. */
  45636. 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;
  45637. /**
  45638. * Creates a new render target texture
  45639. * @param size defines the size of the texture
  45640. * @param options defines the options used to create the texture
  45641. * @returns a new render target texture stored in an InternalTexture
  45642. */
  45643. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45644. /**
  45645. * Update the sampling mode of a given texture
  45646. * @param samplingMode defines the required sampling mode
  45647. * @param texture defines the texture to update
  45648. */
  45649. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45650. /**
  45651. * Binds the frame buffer to the specified texture.
  45652. * @param texture The texture to render to or null for the default canvas
  45653. * @param faceIndex The face of the texture to render to in case of cube texture
  45654. * @param requiredWidth The width of the target to render to
  45655. * @param requiredHeight The height of the target to render to
  45656. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45657. * @param depthStencilTexture The depth stencil texture to use to render
  45658. * @param lodLevel defines le lod level to bind to the frame buffer
  45659. */
  45660. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45661. /**
  45662. * Unbind the current render target texture from the webGL context
  45663. * @param texture defines the render target texture to unbind
  45664. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45665. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45666. */
  45667. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45668. /**
  45669. * Creates a dynamic vertex buffer
  45670. * @param vertices the data for the dynamic vertex buffer
  45671. * @returns the new WebGL dynamic buffer
  45672. */
  45673. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45674. /**
  45675. * Update the content of a dynamic texture
  45676. * @param texture defines the texture to update
  45677. * @param canvas defines the canvas containing the source
  45678. * @param invertY defines if data must be stored with Y axis inverted
  45679. * @param premulAlpha defines if alpha is stored as premultiplied
  45680. * @param format defines the format of the data
  45681. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45682. */
  45683. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45684. /**
  45685. * Gets a boolean indicating if all created effects are ready
  45686. * @returns true if all effects are ready
  45687. */
  45688. areAllEffectsReady(): boolean;
  45689. /**
  45690. * @hidden
  45691. * Get the current error code of the webGL context
  45692. * @returns the error code
  45693. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45694. */
  45695. getError(): number;
  45696. /** @hidden */
  45697. _getUnpackAlignement(): number;
  45698. /** @hidden */
  45699. _unpackFlipY(value: boolean): void;
  45700. /**
  45701. * Update a dynamic index buffer
  45702. * @param indexBuffer defines the target index buffer
  45703. * @param indices defines the data to update
  45704. * @param offset defines the offset in the target index buffer where update should start
  45705. */
  45706. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45707. /**
  45708. * Updates a dynamic vertex buffer.
  45709. * @param vertexBuffer the vertex buffer to update
  45710. * @param vertices the data used to update the vertex buffer
  45711. * @param byteOffset the byte offset of the data (optional)
  45712. * @param byteLength the byte length of the data (optional)
  45713. */
  45714. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45715. /** @hidden */
  45716. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45717. /** @hidden */
  45718. _bindTexture(channel: number, texture: InternalTexture): void;
  45719. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45720. /**
  45721. * 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
  45722. */
  45723. releaseEffects(): void;
  45724. displayLoadingUI(): void;
  45725. hideLoadingUI(): void;
  45726. /** @hidden */
  45727. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45728. /** @hidden */
  45729. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45730. /** @hidden */
  45731. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45732. /** @hidden */
  45733. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45734. }
  45735. }
  45736. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45737. import { Nullable, int } from "babylonjs/types";
  45738. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45739. /** @hidden */
  45740. export class _OcclusionDataStorage {
  45741. /** @hidden */
  45742. occlusionInternalRetryCounter: number;
  45743. /** @hidden */
  45744. isOcclusionQueryInProgress: boolean;
  45745. /** @hidden */
  45746. isOccluded: boolean;
  45747. /** @hidden */
  45748. occlusionRetryCount: number;
  45749. /** @hidden */
  45750. occlusionType: number;
  45751. /** @hidden */
  45752. occlusionQueryAlgorithmType: number;
  45753. }
  45754. module "babylonjs/Engines/engine" {
  45755. interface Engine {
  45756. /**
  45757. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45758. * @return the new query
  45759. */
  45760. createQuery(): WebGLQuery;
  45761. /**
  45762. * Delete and release a webGL query
  45763. * @param query defines the query to delete
  45764. * @return the current engine
  45765. */
  45766. deleteQuery(query: WebGLQuery): Engine;
  45767. /**
  45768. * Check if a given query has resolved and got its value
  45769. * @param query defines the query to check
  45770. * @returns true if the query got its value
  45771. */
  45772. isQueryResultAvailable(query: WebGLQuery): boolean;
  45773. /**
  45774. * Gets the value of a given query
  45775. * @param query defines the query to check
  45776. * @returns the value of the query
  45777. */
  45778. getQueryResult(query: WebGLQuery): number;
  45779. /**
  45780. * Initiates an occlusion query
  45781. * @param algorithmType defines the algorithm to use
  45782. * @param query defines the query to use
  45783. * @returns the current engine
  45784. * @see http://doc.babylonjs.com/features/occlusionquery
  45785. */
  45786. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45787. /**
  45788. * Ends an occlusion query
  45789. * @see http://doc.babylonjs.com/features/occlusionquery
  45790. * @param algorithmType defines the algorithm to use
  45791. * @returns the current engine
  45792. */
  45793. endOcclusionQuery(algorithmType: number): Engine;
  45794. /**
  45795. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45796. * Please note that only one query can be issued at a time
  45797. * @returns a time token used to track the time span
  45798. */
  45799. startTimeQuery(): Nullable<_TimeToken>;
  45800. /**
  45801. * Ends a time query
  45802. * @param token defines the token used to measure the time span
  45803. * @returns the time spent (in ns)
  45804. */
  45805. endTimeQuery(token: _TimeToken): int;
  45806. /** @hidden */
  45807. _currentNonTimestampToken: Nullable<_TimeToken>;
  45808. /** @hidden */
  45809. _createTimeQuery(): WebGLQuery;
  45810. /** @hidden */
  45811. _deleteTimeQuery(query: WebGLQuery): void;
  45812. /** @hidden */
  45813. _getGlAlgorithmType(algorithmType: number): number;
  45814. /** @hidden */
  45815. _getTimeQueryResult(query: WebGLQuery): any;
  45816. /** @hidden */
  45817. _getTimeQueryAvailability(query: WebGLQuery): any;
  45818. }
  45819. }
  45820. module "babylonjs/Meshes/abstractMesh" {
  45821. interface AbstractMesh {
  45822. /**
  45823. * Backing filed
  45824. * @hidden
  45825. */
  45826. __occlusionDataStorage: _OcclusionDataStorage;
  45827. /**
  45828. * Access property
  45829. * @hidden
  45830. */
  45831. _occlusionDataStorage: _OcclusionDataStorage;
  45832. /**
  45833. * 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.
  45834. * The default value is -1 which means don't break the query and wait till the result
  45835. * @see http://doc.babylonjs.com/features/occlusionquery
  45836. */
  45837. occlusionRetryCount: number;
  45838. /**
  45839. * 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:
  45840. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45841. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45842. * * 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.
  45843. * @see http://doc.babylonjs.com/features/occlusionquery
  45844. */
  45845. occlusionType: number;
  45846. /**
  45847. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45848. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45849. * * 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.
  45850. * @see http://doc.babylonjs.com/features/occlusionquery
  45851. */
  45852. occlusionQueryAlgorithmType: number;
  45853. /**
  45854. * 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
  45855. * @see http://doc.babylonjs.com/features/occlusionquery
  45856. */
  45857. isOccluded: boolean;
  45858. /**
  45859. * Flag to check the progress status of the query
  45860. * @see http://doc.babylonjs.com/features/occlusionquery
  45861. */
  45862. isOcclusionQueryInProgress: boolean;
  45863. }
  45864. }
  45865. }
  45866. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45867. import { Nullable } from "babylonjs/types";
  45868. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45869. /** @hidden */
  45870. export var _forceTransformFeedbackToBundle: boolean;
  45871. module "babylonjs/Engines/engine" {
  45872. interface Engine {
  45873. /**
  45874. * Creates a webGL transform feedback object
  45875. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45876. * @returns the webGL transform feedback object
  45877. */
  45878. createTransformFeedback(): WebGLTransformFeedback;
  45879. /**
  45880. * Delete a webGL transform feedback object
  45881. * @param value defines the webGL transform feedback object to delete
  45882. */
  45883. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45884. /**
  45885. * Bind a webGL transform feedback object to the webgl context
  45886. * @param value defines the webGL transform feedback object to bind
  45887. */
  45888. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45889. /**
  45890. * Begins a transform feedback operation
  45891. * @param usePoints defines if points or triangles must be used
  45892. */
  45893. beginTransformFeedback(usePoints: boolean): void;
  45894. /**
  45895. * Ends a transform feedback operation
  45896. */
  45897. endTransformFeedback(): void;
  45898. /**
  45899. * Specify the varyings to use with transform feedback
  45900. * @param program defines the associated webGL program
  45901. * @param value defines the list of strings representing the varying names
  45902. */
  45903. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45904. /**
  45905. * Bind a webGL buffer for a transform feedback operation
  45906. * @param value defines the webGL buffer to bind
  45907. */
  45908. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45909. }
  45910. }
  45911. }
  45912. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45913. import { Scene } from "babylonjs/scene";
  45914. import { Engine } from "babylonjs/Engines/engine";
  45915. import { Texture } from "babylonjs/Materials/Textures/texture";
  45916. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45917. import "babylonjs/Engines/Extensions/engine.multiRender";
  45918. /**
  45919. * Creation options of the multi render target texture.
  45920. */
  45921. export interface IMultiRenderTargetOptions {
  45922. /**
  45923. * Define if the texture needs to create mip maps after render.
  45924. */
  45925. generateMipMaps?: boolean;
  45926. /**
  45927. * Define the types of all the draw buffers we want to create
  45928. */
  45929. types?: number[];
  45930. /**
  45931. * Define the sampling modes of all the draw buffers we want to create
  45932. */
  45933. samplingModes?: number[];
  45934. /**
  45935. * Define if a depth buffer is required
  45936. */
  45937. generateDepthBuffer?: boolean;
  45938. /**
  45939. * Define if a stencil buffer is required
  45940. */
  45941. generateStencilBuffer?: boolean;
  45942. /**
  45943. * Define if a depth texture is required instead of a depth buffer
  45944. */
  45945. generateDepthTexture?: boolean;
  45946. /**
  45947. * Define the number of desired draw buffers
  45948. */
  45949. textureCount?: number;
  45950. /**
  45951. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45952. */
  45953. doNotChangeAspectRatio?: boolean;
  45954. /**
  45955. * Define the default type of the buffers we are creating
  45956. */
  45957. defaultType?: number;
  45958. }
  45959. /**
  45960. * A multi render target, like a render target provides the ability to render to a texture.
  45961. * Unlike the render target, it can render to several draw buffers in one draw.
  45962. * This is specially interesting in deferred rendering or for any effects requiring more than
  45963. * just one color from a single pass.
  45964. */
  45965. export class MultiRenderTarget extends RenderTargetTexture {
  45966. private _internalTextures;
  45967. private _textures;
  45968. private _multiRenderTargetOptions;
  45969. /**
  45970. * Get if draw buffers are currently supported by the used hardware and browser.
  45971. */
  45972. readonly isSupported: boolean;
  45973. /**
  45974. * Get the list of textures generated by the multi render target.
  45975. */
  45976. readonly textures: Texture[];
  45977. /**
  45978. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45979. */
  45980. readonly depthTexture: Texture;
  45981. /**
  45982. * Set the wrapping mode on U of all the textures we are rendering to.
  45983. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45984. */
  45985. wrapU: number;
  45986. /**
  45987. * Set the wrapping mode on V of all the textures we are rendering to.
  45988. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45989. */
  45990. wrapV: number;
  45991. /**
  45992. * Instantiate a new multi render target texture.
  45993. * A multi render target, like a render target provides the ability to render to a texture.
  45994. * Unlike the render target, it can render to several draw buffers in one draw.
  45995. * This is specially interesting in deferred rendering or for any effects requiring more than
  45996. * just one color from a single pass.
  45997. * @param name Define the name of the texture
  45998. * @param size Define the size of the buffers to render to
  45999. * @param count Define the number of target we are rendering into
  46000. * @param scene Define the scene the texture belongs to
  46001. * @param options Define the options used to create the multi render target
  46002. */
  46003. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46004. /** @hidden */
  46005. _rebuild(): void;
  46006. private _createInternalTextures;
  46007. private _createTextures;
  46008. /**
  46009. * Define the number of samples used if MSAA is enabled.
  46010. */
  46011. samples: number;
  46012. /**
  46013. * Resize all the textures in the multi render target.
  46014. * Be carrefull as it will recreate all the data in the new texture.
  46015. * @param size Define the new size
  46016. */
  46017. resize(size: any): void;
  46018. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46019. /**
  46020. * Dispose the render targets and their associated resources
  46021. */
  46022. dispose(): void;
  46023. /**
  46024. * Release all the underlying texture used as draw buffers.
  46025. */
  46026. releaseInternalTextures(): void;
  46027. }
  46028. }
  46029. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46030. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46031. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46032. import { Nullable } from "babylonjs/types";
  46033. module "babylonjs/Engines/thinEngine" {
  46034. interface ThinEngine {
  46035. /**
  46036. * Unbind a list of render target textures from the webGL context
  46037. * This is used only when drawBuffer extension or webGL2 are active
  46038. * @param textures defines the render target textures to unbind
  46039. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46040. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46041. */
  46042. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46043. /**
  46044. * Create a multi render target texture
  46045. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46046. * @param size defines the size of the texture
  46047. * @param options defines the creation options
  46048. * @returns the cube texture as an InternalTexture
  46049. */
  46050. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46051. /**
  46052. * Update the sample count for a given multiple render target texture
  46053. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46054. * @param textures defines the textures to update
  46055. * @param samples defines the sample count to set
  46056. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46057. */
  46058. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46059. }
  46060. }
  46061. }
  46062. declare module "babylonjs/Engines/Extensions/index" {
  46063. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46064. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46065. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46066. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46067. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46068. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46069. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46070. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46071. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46072. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46073. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46074. }
  46075. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46076. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46077. /** @hidden */
  46078. export var rgbdEncodePixelShader: {
  46079. name: string;
  46080. shader: string;
  46081. };
  46082. }
  46083. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46085. /** @hidden */
  46086. export var rgbdDecodePixelShader: {
  46087. name: string;
  46088. shader: string;
  46089. };
  46090. }
  46091. declare module "babylonjs/Misc/environmentTextureTools" {
  46092. import { Nullable } from "babylonjs/types";
  46093. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46094. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46095. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46096. import "babylonjs/Engines/Extensions/engine.renderTarget";
  46097. import "babylonjs/Shaders/rgbdEncode.fragment";
  46098. import "babylonjs/Shaders/rgbdDecode.fragment";
  46099. /**
  46100. * Raw texture data and descriptor sufficient for WebGL texture upload
  46101. */
  46102. export interface EnvironmentTextureInfo {
  46103. /**
  46104. * Version of the environment map
  46105. */
  46106. version: number;
  46107. /**
  46108. * Width of image
  46109. */
  46110. width: number;
  46111. /**
  46112. * Irradiance information stored in the file.
  46113. */
  46114. irradiance: any;
  46115. /**
  46116. * Specular information stored in the file.
  46117. */
  46118. specular: any;
  46119. }
  46120. /**
  46121. * Defines One Image in the file. It requires only the position in the file
  46122. * as well as the length.
  46123. */
  46124. interface BufferImageData {
  46125. /**
  46126. * Length of the image data.
  46127. */
  46128. length: number;
  46129. /**
  46130. * Position of the data from the null terminator delimiting the end of the JSON.
  46131. */
  46132. position: number;
  46133. }
  46134. /**
  46135. * Defines the specular data enclosed in the file.
  46136. * This corresponds to the version 1 of the data.
  46137. */
  46138. export interface EnvironmentTextureSpecularInfoV1 {
  46139. /**
  46140. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46141. */
  46142. specularDataPosition?: number;
  46143. /**
  46144. * This contains all the images data needed to reconstruct the cubemap.
  46145. */
  46146. mipmaps: Array<BufferImageData>;
  46147. /**
  46148. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46149. */
  46150. lodGenerationScale: number;
  46151. }
  46152. /**
  46153. * Sets of helpers addressing the serialization and deserialization of environment texture
  46154. * stored in a BabylonJS env file.
  46155. * Those files are usually stored as .env files.
  46156. */
  46157. export class EnvironmentTextureTools {
  46158. /**
  46159. * Magic number identifying the env file.
  46160. */
  46161. private static _MagicBytes;
  46162. /**
  46163. * Gets the environment info from an env file.
  46164. * @param data The array buffer containing the .env bytes.
  46165. * @returns the environment file info (the json header) if successfully parsed.
  46166. */
  46167. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46168. /**
  46169. * Creates an environment texture from a loaded cube texture.
  46170. * @param texture defines the cube texture to convert in env file
  46171. * @return a promise containing the environment data if succesfull.
  46172. */
  46173. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46174. /**
  46175. * Creates a JSON representation of the spherical data.
  46176. * @param texture defines the texture containing the polynomials
  46177. * @return the JSON representation of the spherical info
  46178. */
  46179. private static _CreateEnvTextureIrradiance;
  46180. /**
  46181. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46182. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46183. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46184. * @return the views described by info providing access to the underlying buffer
  46185. */
  46186. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46187. /**
  46188. * Uploads the texture info contained in the env file to the GPU.
  46189. * @param texture defines the internal texture to upload to
  46190. * @param arrayBuffer defines the buffer cotaining the data to load
  46191. * @param info defines the texture info retrieved through the GetEnvInfo method
  46192. * @returns a promise
  46193. */
  46194. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46195. /**
  46196. * Uploads the levels of image data to the GPU.
  46197. * @param texture defines the internal texture to upload to
  46198. * @param imageData defines the array buffer views of image data [mipmap][face]
  46199. * @returns a promise
  46200. */
  46201. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46202. /**
  46203. * Uploads spherical polynomials information to the texture.
  46204. * @param texture defines the texture we are trying to upload the information to
  46205. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46206. */
  46207. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46208. /** @hidden */
  46209. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46210. }
  46211. }
  46212. declare module "babylonjs/Maths/math.vertexFormat" {
  46213. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46214. /**
  46215. * Contains position and normal vectors for a vertex
  46216. */
  46217. export class PositionNormalVertex {
  46218. /** the position of the vertex (defaut: 0,0,0) */
  46219. position: Vector3;
  46220. /** the normal of the vertex (defaut: 0,1,0) */
  46221. normal: Vector3;
  46222. /**
  46223. * Creates a PositionNormalVertex
  46224. * @param position the position of the vertex (defaut: 0,0,0)
  46225. * @param normal the normal of the vertex (defaut: 0,1,0)
  46226. */
  46227. constructor(
  46228. /** the position of the vertex (defaut: 0,0,0) */
  46229. position?: Vector3,
  46230. /** the normal of the vertex (defaut: 0,1,0) */
  46231. normal?: Vector3);
  46232. /**
  46233. * Clones the PositionNormalVertex
  46234. * @returns the cloned PositionNormalVertex
  46235. */
  46236. clone(): PositionNormalVertex;
  46237. }
  46238. /**
  46239. * Contains position, normal and uv vectors for a vertex
  46240. */
  46241. export class PositionNormalTextureVertex {
  46242. /** the position of the vertex (defaut: 0,0,0) */
  46243. position: Vector3;
  46244. /** the normal of the vertex (defaut: 0,1,0) */
  46245. normal: Vector3;
  46246. /** the uv of the vertex (default: 0,0) */
  46247. uv: Vector2;
  46248. /**
  46249. * Creates a PositionNormalTextureVertex
  46250. * @param position the position of the vertex (defaut: 0,0,0)
  46251. * @param normal the normal of the vertex (defaut: 0,1,0)
  46252. * @param uv the uv of the vertex (default: 0,0)
  46253. */
  46254. constructor(
  46255. /** the position of the vertex (defaut: 0,0,0) */
  46256. position?: Vector3,
  46257. /** the normal of the vertex (defaut: 0,1,0) */
  46258. normal?: Vector3,
  46259. /** the uv of the vertex (default: 0,0) */
  46260. uv?: Vector2);
  46261. /**
  46262. * Clones the PositionNormalTextureVertex
  46263. * @returns the cloned PositionNormalTextureVertex
  46264. */
  46265. clone(): PositionNormalTextureVertex;
  46266. }
  46267. }
  46268. declare module "babylonjs/Maths/math" {
  46269. export * from "babylonjs/Maths/math.axis";
  46270. export * from "babylonjs/Maths/math.color";
  46271. export * from "babylonjs/Maths/math.constants";
  46272. export * from "babylonjs/Maths/math.frustum";
  46273. export * from "babylonjs/Maths/math.path";
  46274. export * from "babylonjs/Maths/math.plane";
  46275. export * from "babylonjs/Maths/math.size";
  46276. export * from "babylonjs/Maths/math.vector";
  46277. export * from "babylonjs/Maths/math.vertexFormat";
  46278. export * from "babylonjs/Maths/math.viewport";
  46279. }
  46280. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46281. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46282. /** @hidden */
  46283. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46284. private _genericAttributeLocation;
  46285. private _varyingLocationCount;
  46286. private _varyingLocationMap;
  46287. private _replacements;
  46288. private _textureCount;
  46289. private _uniforms;
  46290. lineProcessor(line: string): string;
  46291. attributeProcessor(attribute: string): string;
  46292. varyingProcessor(varying: string, isFragment: boolean): string;
  46293. uniformProcessor(uniform: string): string;
  46294. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46295. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46296. }
  46297. }
  46298. declare module "babylonjs/Engines/nativeEngine" {
  46299. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46300. import { Engine } from "babylonjs/Engines/engine";
  46301. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46302. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46304. import { Effect } from "babylonjs/Materials/effect";
  46305. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46306. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46307. import { Scene } from "babylonjs/scene";
  46308. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46309. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46310. /**
  46311. * Container for accessors for natively-stored mesh data buffers.
  46312. */
  46313. class NativeDataBuffer extends DataBuffer {
  46314. /**
  46315. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46316. */
  46317. nativeIndexBuffer?: any;
  46318. /**
  46319. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46320. */
  46321. nativeVertexBuffer?: any;
  46322. }
  46323. /** @hidden */
  46324. export class NativeEngine extends Engine {
  46325. private readonly _native;
  46326. getHardwareScalingLevel(): number;
  46327. constructor();
  46328. /**
  46329. * Can be used to override the current requestAnimationFrame requester.
  46330. * @hidden
  46331. */
  46332. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46333. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46334. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46335. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46336. recordVertexArrayObject(vertexBuffers: {
  46337. [key: string]: VertexBuffer;
  46338. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46339. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46340. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46341. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46342. /**
  46343. * Draw a list of indexed primitives
  46344. * @param fillMode defines the primitive to use
  46345. * @param indexStart defines the starting index
  46346. * @param indexCount defines the number of index to draw
  46347. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46348. */
  46349. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46350. /**
  46351. * Draw a list of unindexed primitives
  46352. * @param fillMode defines the primitive to use
  46353. * @param verticesStart defines the index of first vertex to draw
  46354. * @param verticesCount defines the count of vertices to draw
  46355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46356. */
  46357. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46358. createPipelineContext(): IPipelineContext;
  46359. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46360. /** @hidden */
  46361. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46362. /** @hidden */
  46363. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46364. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46365. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46366. protected _setProgram(program: WebGLProgram): void;
  46367. _releaseEffect(effect: Effect): void;
  46368. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46369. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46370. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46371. bindSamplers(effect: Effect): void;
  46372. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46373. getRenderWidth(useScreen?: boolean): number;
  46374. getRenderHeight(useScreen?: boolean): number;
  46375. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46376. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46377. /**
  46378. * Set the z offset to apply to current rendering
  46379. * @param value defines the offset to apply
  46380. */
  46381. setZOffset(value: number): void;
  46382. /**
  46383. * Gets the current value of the zOffset
  46384. * @returns the current zOffset state
  46385. */
  46386. getZOffset(): number;
  46387. /**
  46388. * Enable or disable depth buffering
  46389. * @param enable defines the state to set
  46390. */
  46391. setDepthBuffer(enable: boolean): void;
  46392. /**
  46393. * Gets a boolean indicating if depth writing is enabled
  46394. * @returns the current depth writing state
  46395. */
  46396. getDepthWrite(): boolean;
  46397. /**
  46398. * Enable or disable depth writing
  46399. * @param enable defines the state to set
  46400. */
  46401. setDepthWrite(enable: boolean): void;
  46402. /**
  46403. * Enable or disable color writing
  46404. * @param enable defines the state to set
  46405. */
  46406. setColorWrite(enable: boolean): void;
  46407. /**
  46408. * Gets a boolean indicating if color writing is enabled
  46409. * @returns the current color writing state
  46410. */
  46411. getColorWrite(): boolean;
  46412. /**
  46413. * Sets alpha constants used by some alpha blending modes
  46414. * @param r defines the red component
  46415. * @param g defines the green component
  46416. * @param b defines the blue component
  46417. * @param a defines the alpha component
  46418. */
  46419. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46420. /**
  46421. * Sets the current alpha mode
  46422. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46423. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46424. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46425. */
  46426. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46427. /**
  46428. * Gets the current alpha mode
  46429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46430. * @returns the current alpha mode
  46431. */
  46432. getAlphaMode(): number;
  46433. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46434. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46435. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46436. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46437. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46438. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46439. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46440. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46441. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46442. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46443. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46444. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46445. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46446. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46447. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46448. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46449. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46450. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46451. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46452. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46453. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46454. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46455. wipeCaches(bruteForce?: boolean): void;
  46456. _createTexture(): WebGLTexture;
  46457. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46458. /**
  46459. * Usually called from BABYLON.Texture.ts.
  46460. * Passed information to create a WebGLTexture
  46461. * @param urlArg defines a value which contains one of the following:
  46462. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46463. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46464. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46465. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46466. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46467. * @param scene needed for loading to the correct scene
  46468. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46469. * @param onLoad optional callback to be called upon successful completion
  46470. * @param onError optional callback to be called upon failure
  46471. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46472. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46473. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46474. * @param forcedExtension defines the extension to use to pick the right loader
  46475. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46476. */
  46477. 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;
  46478. /**
  46479. * Creates a cube texture
  46480. * @param rootUrl defines the url where the files to load is located
  46481. * @param scene defines the current scene
  46482. * @param files defines the list of files to load (1 per face)
  46483. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46484. * @param onLoad defines an optional callback raised when the texture is loaded
  46485. * @param onError defines an optional callback raised if there is an issue to load the texture
  46486. * @param format defines the format of the data
  46487. * @param forcedExtension defines the extension to use to pick the right loader
  46488. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46489. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46490. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46491. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46492. * @returns the cube texture as an InternalTexture
  46493. */
  46494. 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;
  46495. private _getSamplingFilter;
  46496. private static _GetNativeTextureFormat;
  46497. createRenderTargetTexture(size: number | {
  46498. width: number;
  46499. height: number;
  46500. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46501. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46502. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46503. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46504. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46505. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46506. /**
  46507. * Updates a dynamic vertex buffer.
  46508. * @param vertexBuffer the vertex buffer to update
  46509. * @param data the data used to update the vertex buffer
  46510. * @param byteOffset the byte offset of the data (optional)
  46511. * @param byteLength the byte length of the data (optional)
  46512. */
  46513. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46514. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46515. private _updateAnisotropicLevel;
  46516. private _getAddressMode;
  46517. /** @hidden */
  46518. _bindTexture(channel: number, texture: InternalTexture): void;
  46519. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46520. releaseEffects(): void;
  46521. /** @hidden */
  46522. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46523. /** @hidden */
  46524. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46525. /** @hidden */
  46526. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46527. /** @hidden */
  46528. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46529. }
  46530. }
  46531. declare module "babylonjs/Engines/index" {
  46532. export * from "babylonjs/Engines/constants";
  46533. export * from "babylonjs/Engines/engineCapabilities";
  46534. export * from "babylonjs/Engines/instancingAttributeInfo";
  46535. export * from "babylonjs/Engines/thinEngine";
  46536. export * from "babylonjs/Engines/engine";
  46537. export * from "babylonjs/Engines/engineStore";
  46538. export * from "babylonjs/Engines/nullEngine";
  46539. export * from "babylonjs/Engines/Extensions/index";
  46540. export * from "babylonjs/Engines/IPipelineContext";
  46541. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46542. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46543. export * from "babylonjs/Engines/nativeEngine";
  46544. }
  46545. declare module "babylonjs/Events/clipboardEvents" {
  46546. /**
  46547. * Gather the list of clipboard event types as constants.
  46548. */
  46549. export class ClipboardEventTypes {
  46550. /**
  46551. * The clipboard event is fired when a copy command is active (pressed).
  46552. */
  46553. static readonly COPY: number;
  46554. /**
  46555. * The clipboard event is fired when a cut command is active (pressed).
  46556. */
  46557. static readonly CUT: number;
  46558. /**
  46559. * The clipboard event is fired when a paste command is active (pressed).
  46560. */
  46561. static readonly PASTE: number;
  46562. }
  46563. /**
  46564. * This class is used to store clipboard related info for the onClipboardObservable event.
  46565. */
  46566. export class ClipboardInfo {
  46567. /**
  46568. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46569. */
  46570. type: number;
  46571. /**
  46572. * Defines the related dom event
  46573. */
  46574. event: ClipboardEvent;
  46575. /**
  46576. *Creates an instance of ClipboardInfo.
  46577. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46578. * @param event Defines the related dom event
  46579. */
  46580. constructor(
  46581. /**
  46582. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46583. */
  46584. type: number,
  46585. /**
  46586. * Defines the related dom event
  46587. */
  46588. event: ClipboardEvent);
  46589. /**
  46590. * Get the clipboard event's type from the keycode.
  46591. * @param keyCode Defines the keyCode for the current keyboard event.
  46592. * @return {number}
  46593. */
  46594. static GetTypeFromCharacter(keyCode: number): number;
  46595. }
  46596. }
  46597. declare module "babylonjs/Events/index" {
  46598. export * from "babylonjs/Events/keyboardEvents";
  46599. export * from "babylonjs/Events/pointerEvents";
  46600. export * from "babylonjs/Events/clipboardEvents";
  46601. }
  46602. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46603. import { Scene } from "babylonjs/scene";
  46604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46605. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46606. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46607. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46608. /**
  46609. * Google Daydream controller
  46610. */
  46611. export class DaydreamController extends WebVRController {
  46612. /**
  46613. * Base Url for the controller model.
  46614. */
  46615. static MODEL_BASE_URL: string;
  46616. /**
  46617. * File name for the controller model.
  46618. */
  46619. static MODEL_FILENAME: string;
  46620. /**
  46621. * Gamepad Id prefix used to identify Daydream Controller.
  46622. */
  46623. static readonly GAMEPAD_ID_PREFIX: string;
  46624. /**
  46625. * Creates a new DaydreamController from a gamepad
  46626. * @param vrGamepad the gamepad that the controller should be created from
  46627. */
  46628. constructor(vrGamepad: any);
  46629. /**
  46630. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46631. * @param scene scene in which to add meshes
  46632. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46633. */
  46634. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46635. /**
  46636. * Called once for each button that changed state since the last frame
  46637. * @param buttonIdx Which button index changed
  46638. * @param state New state of the button
  46639. * @param changes Which properties on the state changed since last frame
  46640. */
  46641. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46642. }
  46643. }
  46644. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46645. import { Scene } from "babylonjs/scene";
  46646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46647. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46648. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46649. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46650. /**
  46651. * Gear VR Controller
  46652. */
  46653. export class GearVRController extends WebVRController {
  46654. /**
  46655. * Base Url for the controller model.
  46656. */
  46657. static MODEL_BASE_URL: string;
  46658. /**
  46659. * File name for the controller model.
  46660. */
  46661. static MODEL_FILENAME: string;
  46662. /**
  46663. * Gamepad Id prefix used to identify this controller.
  46664. */
  46665. static readonly GAMEPAD_ID_PREFIX: string;
  46666. private readonly _buttonIndexToObservableNameMap;
  46667. /**
  46668. * Creates a new GearVRController from a gamepad
  46669. * @param vrGamepad the gamepad that the controller should be created from
  46670. */
  46671. constructor(vrGamepad: any);
  46672. /**
  46673. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46674. * @param scene scene in which to add meshes
  46675. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46676. */
  46677. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46678. /**
  46679. * Called once for each button that changed state since the last frame
  46680. * @param buttonIdx Which button index changed
  46681. * @param state New state of the button
  46682. * @param changes Which properties on the state changed since last frame
  46683. */
  46684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46685. }
  46686. }
  46687. declare module "babylonjs/Gamepads/Controllers/index" {
  46688. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46689. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46690. export * from "babylonjs/Gamepads/Controllers/genericController";
  46691. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46692. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46693. export * from "babylonjs/Gamepads/Controllers/viveController";
  46694. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46695. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46696. }
  46697. declare module "babylonjs/Gamepads/index" {
  46698. export * from "babylonjs/Gamepads/Controllers/index";
  46699. export * from "babylonjs/Gamepads/gamepad";
  46700. export * from "babylonjs/Gamepads/gamepadManager";
  46701. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46702. export * from "babylonjs/Gamepads/xboxGamepad";
  46703. export * from "babylonjs/Gamepads/dualShockGamepad";
  46704. }
  46705. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46706. import { Scene } from "babylonjs/scene";
  46707. import { Vector4 } from "babylonjs/Maths/math.vector";
  46708. import { Color4 } from "babylonjs/Maths/math.color";
  46709. import { Mesh } from "babylonjs/Meshes/mesh";
  46710. import { Nullable } from "babylonjs/types";
  46711. /**
  46712. * Class containing static functions to help procedurally build meshes
  46713. */
  46714. export class PolyhedronBuilder {
  46715. /**
  46716. * Creates a polyhedron mesh
  46717. * * 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
  46718. * * The parameter `size` (positive float, default 1) sets the polygon size
  46719. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46720. * * 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`
  46721. * * 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
  46722. * * 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)`)
  46723. * * 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
  46724. * * 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
  46725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46728. * @param name defines the name of the mesh
  46729. * @param options defines the options used to create the mesh
  46730. * @param scene defines the hosting scene
  46731. * @returns the polyhedron mesh
  46732. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46733. */
  46734. static CreatePolyhedron(name: string, options: {
  46735. type?: number;
  46736. size?: number;
  46737. sizeX?: number;
  46738. sizeY?: number;
  46739. sizeZ?: number;
  46740. custom?: any;
  46741. faceUV?: Vector4[];
  46742. faceColors?: Color4[];
  46743. flat?: boolean;
  46744. updatable?: boolean;
  46745. sideOrientation?: number;
  46746. frontUVs?: Vector4;
  46747. backUVs?: Vector4;
  46748. }, scene?: Nullable<Scene>): Mesh;
  46749. }
  46750. }
  46751. declare module "babylonjs/Gizmos/scaleGizmo" {
  46752. import { Observable } from "babylonjs/Misc/observable";
  46753. import { Nullable } from "babylonjs/types";
  46754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46755. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46756. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46757. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46758. /**
  46759. * Gizmo that enables scaling a mesh along 3 axis
  46760. */
  46761. export class ScaleGizmo extends Gizmo {
  46762. /**
  46763. * Internal gizmo used for interactions on the x axis
  46764. */
  46765. xGizmo: AxisScaleGizmo;
  46766. /**
  46767. * Internal gizmo used for interactions on the y axis
  46768. */
  46769. yGizmo: AxisScaleGizmo;
  46770. /**
  46771. * Internal gizmo used for interactions on the z axis
  46772. */
  46773. zGizmo: AxisScaleGizmo;
  46774. /**
  46775. * Internal gizmo used to scale all axis equally
  46776. */
  46777. uniformScaleGizmo: AxisScaleGizmo;
  46778. private _meshAttached;
  46779. private _updateGizmoRotationToMatchAttachedMesh;
  46780. private _snapDistance;
  46781. private _scaleRatio;
  46782. private _uniformScalingMesh;
  46783. private _octahedron;
  46784. /** Fires an event when any of it's sub gizmos are dragged */
  46785. onDragStartObservable: Observable<unknown>;
  46786. /** Fires an event when any of it's sub gizmos are released from dragging */
  46787. onDragEndObservable: Observable<unknown>;
  46788. attachedMesh: Nullable<AbstractMesh>;
  46789. /**
  46790. * Creates a ScaleGizmo
  46791. * @param gizmoLayer The utility layer the gizmo will be added to
  46792. */
  46793. constructor(gizmoLayer?: UtilityLayerRenderer);
  46794. updateGizmoRotationToMatchAttachedMesh: boolean;
  46795. /**
  46796. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46797. */
  46798. snapDistance: number;
  46799. /**
  46800. * Ratio for the scale of the gizmo (Default: 1)
  46801. */
  46802. scaleRatio: number;
  46803. /**
  46804. * Disposes of the gizmo
  46805. */
  46806. dispose(): void;
  46807. }
  46808. }
  46809. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46810. import { Observable } from "babylonjs/Misc/observable";
  46811. import { Nullable } from "babylonjs/types";
  46812. import { Vector3 } from "babylonjs/Maths/math.vector";
  46813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46814. import { Mesh } from "babylonjs/Meshes/mesh";
  46815. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46816. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46817. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46818. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46819. import { Color3 } from "babylonjs/Maths/math.color";
  46820. /**
  46821. * Single axis scale gizmo
  46822. */
  46823. export class AxisScaleGizmo extends Gizmo {
  46824. /**
  46825. * Drag behavior responsible for the gizmos dragging interactions
  46826. */
  46827. dragBehavior: PointerDragBehavior;
  46828. private _pointerObserver;
  46829. /**
  46830. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46831. */
  46832. snapDistance: number;
  46833. /**
  46834. * Event that fires each time the gizmo snaps to a new location.
  46835. * * snapDistance is the the change in distance
  46836. */
  46837. onSnapObservable: Observable<{
  46838. snapDistance: number;
  46839. }>;
  46840. /**
  46841. * If the scaling operation should be done on all axis (default: false)
  46842. */
  46843. uniformScaling: boolean;
  46844. private _isEnabled;
  46845. private _parent;
  46846. private _arrow;
  46847. private _coloredMaterial;
  46848. private _hoverMaterial;
  46849. /**
  46850. * Creates an AxisScaleGizmo
  46851. * @param gizmoLayer The utility layer the gizmo will be added to
  46852. * @param dragAxis The axis which the gizmo will be able to scale on
  46853. * @param color The color of the gizmo
  46854. */
  46855. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46856. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46857. /**
  46858. * If the gizmo is enabled
  46859. */
  46860. isEnabled: boolean;
  46861. /**
  46862. * Disposes of the gizmo
  46863. */
  46864. dispose(): void;
  46865. /**
  46866. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46867. * @param mesh The mesh to replace the default mesh of the gizmo
  46868. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46869. */
  46870. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46871. }
  46872. }
  46873. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46874. import { Observable } from "babylonjs/Misc/observable";
  46875. import { Nullable } from "babylonjs/types";
  46876. import { Vector3 } from "babylonjs/Maths/math.vector";
  46877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46878. import { Mesh } from "babylonjs/Meshes/mesh";
  46879. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46880. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46881. import { Color3 } from "babylonjs/Maths/math.color";
  46882. import "babylonjs/Meshes/Builders/boxBuilder";
  46883. /**
  46884. * Bounding box gizmo
  46885. */
  46886. export class BoundingBoxGizmo extends Gizmo {
  46887. private _lineBoundingBox;
  46888. private _rotateSpheresParent;
  46889. private _scaleBoxesParent;
  46890. private _boundingDimensions;
  46891. private _renderObserver;
  46892. private _pointerObserver;
  46893. private _scaleDragSpeed;
  46894. private _tmpQuaternion;
  46895. private _tmpVector;
  46896. private _tmpRotationMatrix;
  46897. /**
  46898. * 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)
  46899. */
  46900. ignoreChildren: boolean;
  46901. /**
  46902. * 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)
  46903. */
  46904. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46905. /**
  46906. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46907. */
  46908. rotationSphereSize: number;
  46909. /**
  46910. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46911. */
  46912. scaleBoxSize: number;
  46913. /**
  46914. * 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)
  46915. */
  46916. fixedDragMeshScreenSize: boolean;
  46917. /**
  46918. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46919. */
  46920. fixedDragMeshScreenSizeDistanceFactor: number;
  46921. /**
  46922. * Fired when a rotation sphere or scale box is dragged
  46923. */
  46924. onDragStartObservable: Observable<{}>;
  46925. /**
  46926. * Fired when a scale box is dragged
  46927. */
  46928. onScaleBoxDragObservable: Observable<{}>;
  46929. /**
  46930. * Fired when a scale box drag is ended
  46931. */
  46932. onScaleBoxDragEndObservable: Observable<{}>;
  46933. /**
  46934. * Fired when a rotation sphere is dragged
  46935. */
  46936. onRotationSphereDragObservable: Observable<{}>;
  46937. /**
  46938. * Fired when a rotation sphere drag is ended
  46939. */
  46940. onRotationSphereDragEndObservable: Observable<{}>;
  46941. /**
  46942. * 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)
  46943. */
  46944. scalePivot: Nullable<Vector3>;
  46945. /**
  46946. * Mesh used as a pivot to rotate the attached mesh
  46947. */
  46948. private _anchorMesh;
  46949. private _existingMeshScale;
  46950. private _dragMesh;
  46951. private pointerDragBehavior;
  46952. private coloredMaterial;
  46953. private hoverColoredMaterial;
  46954. /**
  46955. * Sets the color of the bounding box gizmo
  46956. * @param color the color to set
  46957. */
  46958. setColor(color: Color3): void;
  46959. /**
  46960. * Creates an BoundingBoxGizmo
  46961. * @param gizmoLayer The utility layer the gizmo will be added to
  46962. * @param color The color of the gizmo
  46963. */
  46964. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46965. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46966. private _selectNode;
  46967. /**
  46968. * Updates the bounding box information for the Gizmo
  46969. */
  46970. updateBoundingBox(): void;
  46971. private _updateRotationSpheres;
  46972. private _updateScaleBoxes;
  46973. /**
  46974. * Enables rotation on the specified axis and disables rotation on the others
  46975. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46976. */
  46977. setEnabledRotationAxis(axis: string): void;
  46978. /**
  46979. * Enables/disables scaling
  46980. * @param enable if scaling should be enabled
  46981. */
  46982. setEnabledScaling(enable: boolean): void;
  46983. private _updateDummy;
  46984. /**
  46985. * Enables a pointer drag behavior on the bounding box of the gizmo
  46986. */
  46987. enableDragBehavior(): void;
  46988. /**
  46989. * Disposes of the gizmo
  46990. */
  46991. dispose(): void;
  46992. /**
  46993. * 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)
  46994. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46995. * @returns the bounding box mesh with the passed in mesh as a child
  46996. */
  46997. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46998. /**
  46999. * CustomMeshes are not supported by this gizmo
  47000. * @param mesh The mesh to replace the default mesh of the gizmo
  47001. */
  47002. setCustomMesh(mesh: Mesh): void;
  47003. }
  47004. }
  47005. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47006. import { Observable } from "babylonjs/Misc/observable";
  47007. import { Nullable } from "babylonjs/types";
  47008. import { Vector3 } from "babylonjs/Maths/math.vector";
  47009. import { Color3 } from "babylonjs/Maths/math.color";
  47010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47011. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47012. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47013. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47014. import "babylonjs/Meshes/Builders/linesBuilder";
  47015. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47016. /**
  47017. * Single plane rotation gizmo
  47018. */
  47019. export class PlaneRotationGizmo extends Gizmo {
  47020. /**
  47021. * Drag behavior responsible for the gizmos dragging interactions
  47022. */
  47023. dragBehavior: PointerDragBehavior;
  47024. private _pointerObserver;
  47025. /**
  47026. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47027. */
  47028. snapDistance: number;
  47029. /**
  47030. * Event that fires each time the gizmo snaps to a new location.
  47031. * * snapDistance is the the change in distance
  47032. */
  47033. onSnapObservable: Observable<{
  47034. snapDistance: number;
  47035. }>;
  47036. private _isEnabled;
  47037. private _parent;
  47038. /**
  47039. * Creates a PlaneRotationGizmo
  47040. * @param gizmoLayer The utility layer the gizmo will be added to
  47041. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47042. * @param color The color of the gizmo
  47043. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47044. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47045. */
  47046. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47047. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47048. /**
  47049. * If the gizmo is enabled
  47050. */
  47051. isEnabled: boolean;
  47052. /**
  47053. * Disposes of the gizmo
  47054. */
  47055. dispose(): void;
  47056. }
  47057. }
  47058. declare module "babylonjs/Gizmos/rotationGizmo" {
  47059. import { Observable } from "babylonjs/Misc/observable";
  47060. import { Nullable } from "babylonjs/types";
  47061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47062. import { Mesh } from "babylonjs/Meshes/mesh";
  47063. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47064. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47065. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47066. /**
  47067. * Gizmo that enables rotating a mesh along 3 axis
  47068. */
  47069. export class RotationGizmo extends Gizmo {
  47070. /**
  47071. * Internal gizmo used for interactions on the x axis
  47072. */
  47073. xGizmo: PlaneRotationGizmo;
  47074. /**
  47075. * Internal gizmo used for interactions on the y axis
  47076. */
  47077. yGizmo: PlaneRotationGizmo;
  47078. /**
  47079. * Internal gizmo used for interactions on the z axis
  47080. */
  47081. zGizmo: PlaneRotationGizmo;
  47082. /** Fires an event when any of it's sub gizmos are dragged */
  47083. onDragStartObservable: Observable<unknown>;
  47084. /** Fires an event when any of it's sub gizmos are released from dragging */
  47085. onDragEndObservable: Observable<unknown>;
  47086. private _meshAttached;
  47087. attachedMesh: Nullable<AbstractMesh>;
  47088. /**
  47089. * Creates a RotationGizmo
  47090. * @param gizmoLayer The utility layer the gizmo will be added to
  47091. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47092. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47093. */
  47094. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47095. updateGizmoRotationToMatchAttachedMesh: boolean;
  47096. /**
  47097. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47098. */
  47099. snapDistance: number;
  47100. /**
  47101. * Ratio for the scale of the gizmo (Default: 1)
  47102. */
  47103. scaleRatio: number;
  47104. /**
  47105. * Disposes of the gizmo
  47106. */
  47107. dispose(): void;
  47108. /**
  47109. * CustomMeshes are not supported by this gizmo
  47110. * @param mesh The mesh to replace the default mesh of the gizmo
  47111. */
  47112. setCustomMesh(mesh: Mesh): void;
  47113. }
  47114. }
  47115. declare module "babylonjs/Gizmos/gizmoManager" {
  47116. import { Observable } from "babylonjs/Misc/observable";
  47117. import { Nullable } from "babylonjs/types";
  47118. import { Scene, IDisposable } from "babylonjs/scene";
  47119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47120. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47121. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47122. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47123. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47124. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47125. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47126. /**
  47127. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47128. */
  47129. export class GizmoManager implements IDisposable {
  47130. private scene;
  47131. /**
  47132. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47133. */
  47134. gizmos: {
  47135. positionGizmo: Nullable<PositionGizmo>;
  47136. rotationGizmo: Nullable<RotationGizmo>;
  47137. scaleGizmo: Nullable<ScaleGizmo>;
  47138. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47139. };
  47140. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47141. clearGizmoOnEmptyPointerEvent: boolean;
  47142. /** Fires an event when the manager is attached to a mesh */
  47143. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47144. private _gizmosEnabled;
  47145. private _pointerObserver;
  47146. private _attachedMesh;
  47147. private _boundingBoxColor;
  47148. private _defaultUtilityLayer;
  47149. private _defaultKeepDepthUtilityLayer;
  47150. /**
  47151. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47152. */
  47153. boundingBoxDragBehavior: SixDofDragBehavior;
  47154. /**
  47155. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47156. */
  47157. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47158. /**
  47159. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47160. */
  47161. usePointerToAttachGizmos: boolean;
  47162. /**
  47163. * Utility layer that the bounding box gizmo belongs to
  47164. */
  47165. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47166. /**
  47167. * Utility layer that all gizmos besides bounding box belong to
  47168. */
  47169. readonly utilityLayer: UtilityLayerRenderer;
  47170. /**
  47171. * Instatiates a gizmo manager
  47172. * @param scene the scene to overlay the gizmos on top of
  47173. */
  47174. constructor(scene: Scene);
  47175. /**
  47176. * Attaches a set of gizmos to the specified mesh
  47177. * @param mesh The mesh the gizmo's should be attached to
  47178. */
  47179. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47180. /**
  47181. * If the position gizmo is enabled
  47182. */
  47183. positionGizmoEnabled: boolean;
  47184. /**
  47185. * If the rotation gizmo is enabled
  47186. */
  47187. rotationGizmoEnabled: boolean;
  47188. /**
  47189. * If the scale gizmo is enabled
  47190. */
  47191. scaleGizmoEnabled: boolean;
  47192. /**
  47193. * If the boundingBox gizmo is enabled
  47194. */
  47195. boundingBoxGizmoEnabled: boolean;
  47196. /**
  47197. * Disposes of the gizmo manager
  47198. */
  47199. dispose(): void;
  47200. }
  47201. }
  47202. declare module "babylonjs/Lights/directionalLight" {
  47203. import { Camera } from "babylonjs/Cameras/camera";
  47204. import { Scene } from "babylonjs/scene";
  47205. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47207. import { Light } from "babylonjs/Lights/light";
  47208. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47209. import { Effect } from "babylonjs/Materials/effect";
  47210. /**
  47211. * A directional light is defined by a direction (what a surprise!).
  47212. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47213. * 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.
  47214. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47215. */
  47216. export class DirectionalLight extends ShadowLight {
  47217. private _shadowFrustumSize;
  47218. /**
  47219. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47220. */
  47221. /**
  47222. * Specifies a fix frustum size for the shadow generation.
  47223. */
  47224. shadowFrustumSize: number;
  47225. private _shadowOrthoScale;
  47226. /**
  47227. * Gets the shadow projection scale against the optimal computed one.
  47228. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47229. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47230. */
  47231. /**
  47232. * Sets the shadow projection scale against the optimal computed one.
  47233. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47234. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47235. */
  47236. shadowOrthoScale: number;
  47237. /**
  47238. * Automatically compute the projection matrix to best fit (including all the casters)
  47239. * on each frame.
  47240. */
  47241. autoUpdateExtends: boolean;
  47242. private _orthoLeft;
  47243. private _orthoRight;
  47244. private _orthoTop;
  47245. private _orthoBottom;
  47246. /**
  47247. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47248. * The directional light is emitted from everywhere in the given direction.
  47249. * It can cast shadows.
  47250. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47251. * @param name The friendly name of the light
  47252. * @param direction The direction of the light
  47253. * @param scene The scene the light belongs to
  47254. */
  47255. constructor(name: string, direction: Vector3, scene: Scene);
  47256. /**
  47257. * Returns the string "DirectionalLight".
  47258. * @return The class name
  47259. */
  47260. getClassName(): string;
  47261. /**
  47262. * Returns the integer 1.
  47263. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47264. */
  47265. getTypeID(): number;
  47266. /**
  47267. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47268. * Returns the DirectionalLight Shadow projection matrix.
  47269. */
  47270. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47271. /**
  47272. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47273. * Returns the DirectionalLight Shadow projection matrix.
  47274. */
  47275. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47276. /**
  47277. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47278. * Returns the DirectionalLight Shadow projection matrix.
  47279. */
  47280. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47281. protected _buildUniformLayout(): void;
  47282. /**
  47283. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47284. * @param effect The effect to update
  47285. * @param lightIndex The index of the light in the effect to update
  47286. * @returns The directional light
  47287. */
  47288. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47289. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47290. /**
  47291. * Gets the minZ used for shadow according to both the scene and the light.
  47292. *
  47293. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47294. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47295. * @param activeCamera The camera we are returning the min for
  47296. * @returns the depth min z
  47297. */
  47298. getDepthMinZ(activeCamera: Camera): number;
  47299. /**
  47300. * Gets the maxZ used for shadow according to both the scene and the light.
  47301. *
  47302. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47303. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47304. * @param activeCamera The camera we are returning the max for
  47305. * @returns the depth max z
  47306. */
  47307. getDepthMaxZ(activeCamera: Camera): number;
  47308. /**
  47309. * Prepares the list of defines specific to the light type.
  47310. * @param defines the list of defines
  47311. * @param lightIndex defines the index of the light for the effect
  47312. */
  47313. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47314. }
  47315. }
  47316. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47317. import { Mesh } from "babylonjs/Meshes/mesh";
  47318. /**
  47319. * Class containing static functions to help procedurally build meshes
  47320. */
  47321. export class HemisphereBuilder {
  47322. /**
  47323. * Creates a hemisphere mesh
  47324. * @param name defines the name of the mesh
  47325. * @param options defines the options used to create the mesh
  47326. * @param scene defines the hosting scene
  47327. * @returns the hemisphere mesh
  47328. */
  47329. static CreateHemisphere(name: string, options: {
  47330. segments?: number;
  47331. diameter?: number;
  47332. sideOrientation?: number;
  47333. }, scene: any): Mesh;
  47334. }
  47335. }
  47336. declare module "babylonjs/Lights/spotLight" {
  47337. import { Nullable } from "babylonjs/types";
  47338. import { Scene } from "babylonjs/scene";
  47339. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47341. import { Effect } from "babylonjs/Materials/effect";
  47342. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47343. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47344. /**
  47345. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47346. * These values define a cone of light starting from the position, emitting toward the direction.
  47347. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47348. * and the exponent defines the speed of the decay of the light with distance (reach).
  47349. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47350. */
  47351. export class SpotLight extends ShadowLight {
  47352. private _angle;
  47353. private _innerAngle;
  47354. private _cosHalfAngle;
  47355. private _lightAngleScale;
  47356. private _lightAngleOffset;
  47357. /**
  47358. * Gets the cone angle of the spot light in Radians.
  47359. */
  47360. /**
  47361. * Sets the cone angle of the spot light in Radians.
  47362. */
  47363. angle: number;
  47364. /**
  47365. * Only used in gltf falloff mode, this defines the angle where
  47366. * the directional falloff will start before cutting at angle which could be seen
  47367. * as outer angle.
  47368. */
  47369. /**
  47370. * Only used in gltf falloff mode, this defines the angle where
  47371. * the directional falloff will start before cutting at angle which could be seen
  47372. * as outer angle.
  47373. */
  47374. innerAngle: number;
  47375. private _shadowAngleScale;
  47376. /**
  47377. * Allows scaling the angle of the light for shadow generation only.
  47378. */
  47379. /**
  47380. * Allows scaling the angle of the light for shadow generation only.
  47381. */
  47382. shadowAngleScale: number;
  47383. /**
  47384. * The light decay speed with the distance from the emission spot.
  47385. */
  47386. exponent: number;
  47387. private _projectionTextureMatrix;
  47388. /**
  47389. * Allows reading the projecton texture
  47390. */
  47391. readonly projectionTextureMatrix: Matrix;
  47392. protected _projectionTextureLightNear: number;
  47393. /**
  47394. * Gets the near clip of the Spotlight for texture projection.
  47395. */
  47396. /**
  47397. * Sets the near clip of the Spotlight for texture projection.
  47398. */
  47399. projectionTextureLightNear: number;
  47400. protected _projectionTextureLightFar: number;
  47401. /**
  47402. * Gets the far clip of the Spotlight for texture projection.
  47403. */
  47404. /**
  47405. * Sets the far clip of the Spotlight for texture projection.
  47406. */
  47407. projectionTextureLightFar: number;
  47408. protected _projectionTextureUpDirection: Vector3;
  47409. /**
  47410. * Gets the Up vector of the Spotlight for texture projection.
  47411. */
  47412. /**
  47413. * Sets the Up vector of the Spotlight for texture projection.
  47414. */
  47415. projectionTextureUpDirection: Vector3;
  47416. private _projectionTexture;
  47417. /**
  47418. * Gets the projection texture of the light.
  47419. */
  47420. /**
  47421. * Sets the projection texture of the light.
  47422. */
  47423. projectionTexture: Nullable<BaseTexture>;
  47424. private _projectionTextureViewLightDirty;
  47425. private _projectionTextureProjectionLightDirty;
  47426. private _projectionTextureDirty;
  47427. private _projectionTextureViewTargetVector;
  47428. private _projectionTextureViewLightMatrix;
  47429. private _projectionTextureProjectionLightMatrix;
  47430. private _projectionTextureScalingMatrix;
  47431. /**
  47432. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47433. * It can cast shadows.
  47434. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47435. * @param name The light friendly name
  47436. * @param position The position of the spot light in the scene
  47437. * @param direction The direction of the light in the scene
  47438. * @param angle The cone angle of the light in Radians
  47439. * @param exponent The light decay speed with the distance from the emission spot
  47440. * @param scene The scene the lights belongs to
  47441. */
  47442. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47443. /**
  47444. * Returns the string "SpotLight".
  47445. * @returns the class name
  47446. */
  47447. getClassName(): string;
  47448. /**
  47449. * Returns the integer 2.
  47450. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47451. */
  47452. getTypeID(): number;
  47453. /**
  47454. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47455. */
  47456. protected _setDirection(value: Vector3): void;
  47457. /**
  47458. * Overrides the position setter to recompute the projection texture view light Matrix.
  47459. */
  47460. protected _setPosition(value: Vector3): void;
  47461. /**
  47462. * 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.
  47463. * Returns the SpotLight.
  47464. */
  47465. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47466. protected _computeProjectionTextureViewLightMatrix(): void;
  47467. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47468. /**
  47469. * Main function for light texture projection matrix computing.
  47470. */
  47471. protected _computeProjectionTextureMatrix(): void;
  47472. protected _buildUniformLayout(): void;
  47473. private _computeAngleValues;
  47474. /**
  47475. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47476. * @param effect The effect to update
  47477. * @param lightIndex The index of the light in the effect to update
  47478. * @returns The spot light
  47479. */
  47480. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47481. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47482. /**
  47483. * Disposes the light and the associated resources.
  47484. */
  47485. dispose(): void;
  47486. /**
  47487. * Prepares the list of defines specific to the light type.
  47488. * @param defines the list of defines
  47489. * @param lightIndex defines the index of the light for the effect
  47490. */
  47491. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47492. }
  47493. }
  47494. declare module "babylonjs/Gizmos/lightGizmo" {
  47495. import { Nullable } from "babylonjs/types";
  47496. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47497. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47498. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47499. import { Light } from "babylonjs/Lights/light";
  47500. /**
  47501. * Gizmo that enables viewing a light
  47502. */
  47503. export class LightGizmo extends Gizmo {
  47504. private _lightMesh;
  47505. private _material;
  47506. private cachedPosition;
  47507. private cachedForward;
  47508. /**
  47509. * Creates a LightGizmo
  47510. * @param gizmoLayer The utility layer the gizmo will be added to
  47511. */
  47512. constructor(gizmoLayer?: UtilityLayerRenderer);
  47513. private _light;
  47514. /**
  47515. * The light that the gizmo is attached to
  47516. */
  47517. light: Nullable<Light>;
  47518. /**
  47519. * Gets the material used to render the light gizmo
  47520. */
  47521. readonly material: StandardMaterial;
  47522. /**
  47523. * @hidden
  47524. * Updates the gizmo to match the attached mesh's position/rotation
  47525. */
  47526. protected _update(): void;
  47527. private static _Scale;
  47528. /**
  47529. * Creates the lines for a light mesh
  47530. */
  47531. private static _createLightLines;
  47532. /**
  47533. * Disposes of the light gizmo
  47534. */
  47535. dispose(): void;
  47536. private static _CreateHemisphericLightMesh;
  47537. private static _CreatePointLightMesh;
  47538. private static _CreateSpotLightMesh;
  47539. private static _CreateDirectionalLightMesh;
  47540. }
  47541. }
  47542. declare module "babylonjs/Gizmos/index" {
  47543. export * from "babylonjs/Gizmos/axisDragGizmo";
  47544. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47545. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47546. export * from "babylonjs/Gizmos/gizmo";
  47547. export * from "babylonjs/Gizmos/gizmoManager";
  47548. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47549. export * from "babylonjs/Gizmos/positionGizmo";
  47550. export * from "babylonjs/Gizmos/rotationGizmo";
  47551. export * from "babylonjs/Gizmos/scaleGizmo";
  47552. export * from "babylonjs/Gizmos/lightGizmo";
  47553. export * from "babylonjs/Gizmos/planeDragGizmo";
  47554. }
  47555. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47556. /** @hidden */
  47557. export var backgroundFragmentDeclaration: {
  47558. name: string;
  47559. shader: string;
  47560. };
  47561. }
  47562. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47563. /** @hidden */
  47564. export var backgroundUboDeclaration: {
  47565. name: string;
  47566. shader: string;
  47567. };
  47568. }
  47569. declare module "babylonjs/Shaders/background.fragment" {
  47570. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47571. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47572. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47573. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47574. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47575. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47577. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47578. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47579. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47580. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47581. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47582. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47583. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47584. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47585. /** @hidden */
  47586. export var backgroundPixelShader: {
  47587. name: string;
  47588. shader: string;
  47589. };
  47590. }
  47591. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47592. /** @hidden */
  47593. export var backgroundVertexDeclaration: {
  47594. name: string;
  47595. shader: string;
  47596. };
  47597. }
  47598. declare module "babylonjs/Shaders/background.vertex" {
  47599. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47600. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47601. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47602. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47603. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47604. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47605. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47606. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47607. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47608. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47609. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47610. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47611. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47612. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47613. /** @hidden */
  47614. export var backgroundVertexShader: {
  47615. name: string;
  47616. shader: string;
  47617. };
  47618. }
  47619. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47620. import { Nullable, int, float } from "babylonjs/types";
  47621. import { Scene } from "babylonjs/scene";
  47622. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47623. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47625. import { Mesh } from "babylonjs/Meshes/mesh";
  47626. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47627. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47628. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47629. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47630. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47631. import { Color3 } from "babylonjs/Maths/math.color";
  47632. import "babylonjs/Shaders/background.fragment";
  47633. import "babylonjs/Shaders/background.vertex";
  47634. /**
  47635. * Background material used to create an efficient environement around your scene.
  47636. */
  47637. export class BackgroundMaterial extends PushMaterial {
  47638. /**
  47639. * Standard reflectance value at parallel view angle.
  47640. */
  47641. static StandardReflectance0: number;
  47642. /**
  47643. * Standard reflectance value at grazing angle.
  47644. */
  47645. static StandardReflectance90: number;
  47646. protected _primaryColor: Color3;
  47647. /**
  47648. * Key light Color (multiply against the environement texture)
  47649. */
  47650. primaryColor: Color3;
  47651. protected __perceptualColor: Nullable<Color3>;
  47652. /**
  47653. * Experimental Internal Use Only.
  47654. *
  47655. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47656. * This acts as a helper to set the primary color to a more "human friendly" value.
  47657. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47658. * output color as close as possible from the chosen value.
  47659. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47660. * part of lighting setup.)
  47661. */
  47662. _perceptualColor: Nullable<Color3>;
  47663. protected _primaryColorShadowLevel: float;
  47664. /**
  47665. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47666. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47667. */
  47668. primaryColorShadowLevel: float;
  47669. protected _primaryColorHighlightLevel: float;
  47670. /**
  47671. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47672. * The primary color is used at the level chosen to define what the white area would look.
  47673. */
  47674. primaryColorHighlightLevel: float;
  47675. protected _reflectionTexture: Nullable<BaseTexture>;
  47676. /**
  47677. * Reflection Texture used in the material.
  47678. * Should be author in a specific way for the best result (refer to the documentation).
  47679. */
  47680. reflectionTexture: Nullable<BaseTexture>;
  47681. protected _reflectionBlur: float;
  47682. /**
  47683. * Reflection Texture level of blur.
  47684. *
  47685. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47686. * texture twice.
  47687. */
  47688. reflectionBlur: float;
  47689. protected _diffuseTexture: Nullable<BaseTexture>;
  47690. /**
  47691. * Diffuse Texture used in the material.
  47692. * Should be author in a specific way for the best result (refer to the documentation).
  47693. */
  47694. diffuseTexture: Nullable<BaseTexture>;
  47695. protected _shadowLights: Nullable<IShadowLight[]>;
  47696. /**
  47697. * Specify the list of lights casting shadow on the material.
  47698. * All scene shadow lights will be included if null.
  47699. */
  47700. shadowLights: Nullable<IShadowLight[]>;
  47701. protected _shadowLevel: float;
  47702. /**
  47703. * Helps adjusting the shadow to a softer level if required.
  47704. * 0 means black shadows and 1 means no shadows.
  47705. */
  47706. shadowLevel: float;
  47707. protected _sceneCenter: Vector3;
  47708. /**
  47709. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47710. * It is usually zero but might be interesting to modify according to your setup.
  47711. */
  47712. sceneCenter: Vector3;
  47713. protected _opacityFresnel: boolean;
  47714. /**
  47715. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47716. * This helps ensuring a nice transition when the camera goes under the ground.
  47717. */
  47718. opacityFresnel: boolean;
  47719. protected _reflectionFresnel: boolean;
  47720. /**
  47721. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47722. * This helps adding a mirror texture on the ground.
  47723. */
  47724. reflectionFresnel: boolean;
  47725. protected _reflectionFalloffDistance: number;
  47726. /**
  47727. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47728. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47729. */
  47730. reflectionFalloffDistance: number;
  47731. protected _reflectionAmount: number;
  47732. /**
  47733. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47734. */
  47735. reflectionAmount: number;
  47736. protected _reflectionReflectance0: number;
  47737. /**
  47738. * This specifies the weight of the reflection at grazing angle.
  47739. */
  47740. reflectionReflectance0: number;
  47741. protected _reflectionReflectance90: number;
  47742. /**
  47743. * This specifies the weight of the reflection at a perpendicular point of view.
  47744. */
  47745. reflectionReflectance90: number;
  47746. /**
  47747. * Sets the reflection reflectance fresnel values according to the default standard
  47748. * empirically know to work well :-)
  47749. */
  47750. reflectionStandardFresnelWeight: number;
  47751. protected _useRGBColor: boolean;
  47752. /**
  47753. * Helps to directly use the maps channels instead of their level.
  47754. */
  47755. useRGBColor: boolean;
  47756. protected _enableNoise: boolean;
  47757. /**
  47758. * This helps reducing the banding effect that could occur on the background.
  47759. */
  47760. enableNoise: boolean;
  47761. /**
  47762. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47763. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47764. * Recommended to be keep at 1.0 except for special cases.
  47765. */
  47766. fovMultiplier: number;
  47767. private _fovMultiplier;
  47768. /**
  47769. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47770. */
  47771. useEquirectangularFOV: boolean;
  47772. private _maxSimultaneousLights;
  47773. /**
  47774. * Number of Simultaneous lights allowed on the material.
  47775. */
  47776. maxSimultaneousLights: int;
  47777. /**
  47778. * Default configuration related to image processing available in the Background Material.
  47779. */
  47780. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47781. /**
  47782. * Keep track of the image processing observer to allow dispose and replace.
  47783. */
  47784. private _imageProcessingObserver;
  47785. /**
  47786. * Attaches a new image processing configuration to the PBR Material.
  47787. * @param configuration (if null the scene configuration will be use)
  47788. */
  47789. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47790. /**
  47791. * Gets the image processing configuration used either in this material.
  47792. */
  47793. /**
  47794. * Sets the Default image processing configuration used either in the this material.
  47795. *
  47796. * If sets to null, the scene one is in use.
  47797. */
  47798. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47799. /**
  47800. * Gets wether the color curves effect is enabled.
  47801. */
  47802. /**
  47803. * Sets wether the color curves effect is enabled.
  47804. */
  47805. cameraColorCurvesEnabled: boolean;
  47806. /**
  47807. * Gets wether the color grading effect is enabled.
  47808. */
  47809. /**
  47810. * Gets wether the color grading effect is enabled.
  47811. */
  47812. cameraColorGradingEnabled: boolean;
  47813. /**
  47814. * Gets wether tonemapping is enabled or not.
  47815. */
  47816. /**
  47817. * Sets wether tonemapping is enabled or not
  47818. */
  47819. cameraToneMappingEnabled: boolean;
  47820. /**
  47821. * The camera exposure used on this material.
  47822. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47823. * This corresponds to a photographic exposure.
  47824. */
  47825. /**
  47826. * The camera exposure used on this material.
  47827. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47828. * This corresponds to a photographic exposure.
  47829. */
  47830. cameraExposure: float;
  47831. /**
  47832. * Gets The camera contrast used on this material.
  47833. */
  47834. /**
  47835. * Sets The camera contrast used on this material.
  47836. */
  47837. cameraContrast: float;
  47838. /**
  47839. * Gets the Color Grading 2D Lookup Texture.
  47840. */
  47841. /**
  47842. * Sets the Color Grading 2D Lookup Texture.
  47843. */
  47844. cameraColorGradingTexture: Nullable<BaseTexture>;
  47845. /**
  47846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47848. * 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;
  47849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47850. */
  47851. /**
  47852. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47854. * 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;
  47855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47856. */
  47857. cameraColorCurves: Nullable<ColorCurves>;
  47858. /**
  47859. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47860. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47861. */
  47862. switchToBGR: boolean;
  47863. private _renderTargets;
  47864. private _reflectionControls;
  47865. private _white;
  47866. private _primaryShadowColor;
  47867. private _primaryHighlightColor;
  47868. /**
  47869. * Instantiates a Background Material in the given scene
  47870. * @param name The friendly name of the material
  47871. * @param scene The scene to add the material to
  47872. */
  47873. constructor(name: string, scene: Scene);
  47874. /**
  47875. * Gets a boolean indicating that current material needs to register RTT
  47876. */
  47877. readonly hasRenderTargetTextures: boolean;
  47878. /**
  47879. * The entire material has been created in order to prevent overdraw.
  47880. * @returns false
  47881. */
  47882. needAlphaTesting(): boolean;
  47883. /**
  47884. * The entire material has been created in order to prevent overdraw.
  47885. * @returns true if blending is enable
  47886. */
  47887. needAlphaBlending(): boolean;
  47888. /**
  47889. * Checks wether the material is ready to be rendered for a given mesh.
  47890. * @param mesh The mesh to render
  47891. * @param subMesh The submesh to check against
  47892. * @param useInstances Specify wether or not the material is used with instances
  47893. * @returns true if all the dependencies are ready (Textures, Effects...)
  47894. */
  47895. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47896. /**
  47897. * Compute the primary color according to the chosen perceptual color.
  47898. */
  47899. private _computePrimaryColorFromPerceptualColor;
  47900. /**
  47901. * Compute the highlights and shadow colors according to their chosen levels.
  47902. */
  47903. private _computePrimaryColors;
  47904. /**
  47905. * Build the uniform buffer used in the material.
  47906. */
  47907. buildUniformLayout(): void;
  47908. /**
  47909. * Unbind the material.
  47910. */
  47911. unbind(): void;
  47912. /**
  47913. * Bind only the world matrix to the material.
  47914. * @param world The world matrix to bind.
  47915. */
  47916. bindOnlyWorldMatrix(world: Matrix): void;
  47917. /**
  47918. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47919. * @param world The world matrix to bind.
  47920. * @param subMesh The submesh to bind for.
  47921. */
  47922. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47923. /**
  47924. * Checks to see if a texture is used in the material.
  47925. * @param texture - Base texture to use.
  47926. * @returns - Boolean specifying if a texture is used in the material.
  47927. */
  47928. hasTexture(texture: BaseTexture): boolean;
  47929. /**
  47930. * Dispose the material.
  47931. * @param forceDisposeEffect Force disposal of the associated effect.
  47932. * @param forceDisposeTextures Force disposal of the associated textures.
  47933. */
  47934. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47935. /**
  47936. * Clones the material.
  47937. * @param name The cloned name.
  47938. * @returns The cloned material.
  47939. */
  47940. clone(name: string): BackgroundMaterial;
  47941. /**
  47942. * Serializes the current material to its JSON representation.
  47943. * @returns The JSON representation.
  47944. */
  47945. serialize(): any;
  47946. /**
  47947. * Gets the class name of the material
  47948. * @returns "BackgroundMaterial"
  47949. */
  47950. getClassName(): string;
  47951. /**
  47952. * Parse a JSON input to create back a background material.
  47953. * @param source The JSON data to parse
  47954. * @param scene The scene to create the parsed material in
  47955. * @param rootUrl The root url of the assets the material depends upon
  47956. * @returns the instantiated BackgroundMaterial.
  47957. */
  47958. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47959. }
  47960. }
  47961. declare module "babylonjs/Helpers/environmentHelper" {
  47962. import { Observable } from "babylonjs/Misc/observable";
  47963. import { Nullable } from "babylonjs/types";
  47964. import { Scene } from "babylonjs/scene";
  47965. import { Vector3 } from "babylonjs/Maths/math.vector";
  47966. import { Color3 } from "babylonjs/Maths/math.color";
  47967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47968. import { Mesh } from "babylonjs/Meshes/mesh";
  47969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47970. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47971. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47972. import "babylonjs/Meshes/Builders/planeBuilder";
  47973. import "babylonjs/Meshes/Builders/boxBuilder";
  47974. /**
  47975. * Represents the different options available during the creation of
  47976. * a Environment helper.
  47977. *
  47978. * This can control the default ground, skybox and image processing setup of your scene.
  47979. */
  47980. export interface IEnvironmentHelperOptions {
  47981. /**
  47982. * Specifies wether or not to create a ground.
  47983. * True by default.
  47984. */
  47985. createGround: boolean;
  47986. /**
  47987. * Specifies the ground size.
  47988. * 15 by default.
  47989. */
  47990. groundSize: number;
  47991. /**
  47992. * The texture used on the ground for the main color.
  47993. * Comes from the BabylonJS CDN by default.
  47994. *
  47995. * Remarks: Can be either a texture or a url.
  47996. */
  47997. groundTexture: string | BaseTexture;
  47998. /**
  47999. * The color mixed in the ground texture by default.
  48000. * BabylonJS clearColor by default.
  48001. */
  48002. groundColor: Color3;
  48003. /**
  48004. * Specifies the ground opacity.
  48005. * 1 by default.
  48006. */
  48007. groundOpacity: number;
  48008. /**
  48009. * Enables the ground to receive shadows.
  48010. * True by default.
  48011. */
  48012. enableGroundShadow: boolean;
  48013. /**
  48014. * Helps preventing the shadow to be fully black on the ground.
  48015. * 0.5 by default.
  48016. */
  48017. groundShadowLevel: number;
  48018. /**
  48019. * Creates a mirror texture attach to the ground.
  48020. * false by default.
  48021. */
  48022. enableGroundMirror: boolean;
  48023. /**
  48024. * Specifies the ground mirror size ratio.
  48025. * 0.3 by default as the default kernel is 64.
  48026. */
  48027. groundMirrorSizeRatio: number;
  48028. /**
  48029. * Specifies the ground mirror blur kernel size.
  48030. * 64 by default.
  48031. */
  48032. groundMirrorBlurKernel: number;
  48033. /**
  48034. * Specifies the ground mirror visibility amount.
  48035. * 1 by default
  48036. */
  48037. groundMirrorAmount: number;
  48038. /**
  48039. * Specifies the ground mirror reflectance weight.
  48040. * This uses the standard weight of the background material to setup the fresnel effect
  48041. * of the mirror.
  48042. * 1 by default.
  48043. */
  48044. groundMirrorFresnelWeight: number;
  48045. /**
  48046. * Specifies the ground mirror Falloff distance.
  48047. * This can helps reducing the size of the reflection.
  48048. * 0 by Default.
  48049. */
  48050. groundMirrorFallOffDistance: number;
  48051. /**
  48052. * Specifies the ground mirror texture type.
  48053. * Unsigned Int by Default.
  48054. */
  48055. groundMirrorTextureType: number;
  48056. /**
  48057. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48058. * the shown objects.
  48059. */
  48060. groundYBias: number;
  48061. /**
  48062. * Specifies wether or not to create a skybox.
  48063. * True by default.
  48064. */
  48065. createSkybox: boolean;
  48066. /**
  48067. * Specifies the skybox size.
  48068. * 20 by default.
  48069. */
  48070. skyboxSize: number;
  48071. /**
  48072. * The texture used on the skybox for the main color.
  48073. * Comes from the BabylonJS CDN by default.
  48074. *
  48075. * Remarks: Can be either a texture or a url.
  48076. */
  48077. skyboxTexture: string | BaseTexture;
  48078. /**
  48079. * The color mixed in the skybox texture by default.
  48080. * BabylonJS clearColor by default.
  48081. */
  48082. skyboxColor: Color3;
  48083. /**
  48084. * The background rotation around the Y axis of the scene.
  48085. * This helps aligning the key lights of your scene with the background.
  48086. * 0 by default.
  48087. */
  48088. backgroundYRotation: number;
  48089. /**
  48090. * Compute automatically the size of the elements to best fit with the scene.
  48091. */
  48092. sizeAuto: boolean;
  48093. /**
  48094. * Default position of the rootMesh if autoSize is not true.
  48095. */
  48096. rootPosition: Vector3;
  48097. /**
  48098. * Sets up the image processing in the scene.
  48099. * true by default.
  48100. */
  48101. setupImageProcessing: boolean;
  48102. /**
  48103. * The texture used as your environment texture in the scene.
  48104. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48105. *
  48106. * Remarks: Can be either a texture or a url.
  48107. */
  48108. environmentTexture: string | BaseTexture;
  48109. /**
  48110. * The value of the exposure to apply to the scene.
  48111. * 0.6 by default if setupImageProcessing is true.
  48112. */
  48113. cameraExposure: number;
  48114. /**
  48115. * The value of the contrast to apply to the scene.
  48116. * 1.6 by default if setupImageProcessing is true.
  48117. */
  48118. cameraContrast: number;
  48119. /**
  48120. * Specifies wether or not tonemapping should be enabled in the scene.
  48121. * true by default if setupImageProcessing is true.
  48122. */
  48123. toneMappingEnabled: boolean;
  48124. }
  48125. /**
  48126. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48127. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48128. * It also helps with the default setup of your imageProcessing configuration.
  48129. */
  48130. export class EnvironmentHelper {
  48131. /**
  48132. * Default ground texture URL.
  48133. */
  48134. private static _groundTextureCDNUrl;
  48135. /**
  48136. * Default skybox texture URL.
  48137. */
  48138. private static _skyboxTextureCDNUrl;
  48139. /**
  48140. * Default environment texture URL.
  48141. */
  48142. private static _environmentTextureCDNUrl;
  48143. /**
  48144. * Creates the default options for the helper.
  48145. */
  48146. private static _getDefaultOptions;
  48147. private _rootMesh;
  48148. /**
  48149. * Gets the root mesh created by the helper.
  48150. */
  48151. readonly rootMesh: Mesh;
  48152. private _skybox;
  48153. /**
  48154. * Gets the skybox created by the helper.
  48155. */
  48156. readonly skybox: Nullable<Mesh>;
  48157. private _skyboxTexture;
  48158. /**
  48159. * Gets the skybox texture created by the helper.
  48160. */
  48161. readonly skyboxTexture: Nullable<BaseTexture>;
  48162. private _skyboxMaterial;
  48163. /**
  48164. * Gets the skybox material created by the helper.
  48165. */
  48166. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48167. private _ground;
  48168. /**
  48169. * Gets the ground mesh created by the helper.
  48170. */
  48171. readonly ground: Nullable<Mesh>;
  48172. private _groundTexture;
  48173. /**
  48174. * Gets the ground texture created by the helper.
  48175. */
  48176. readonly groundTexture: Nullable<BaseTexture>;
  48177. private _groundMirror;
  48178. /**
  48179. * Gets the ground mirror created by the helper.
  48180. */
  48181. readonly groundMirror: Nullable<MirrorTexture>;
  48182. /**
  48183. * Gets the ground mirror render list to helps pushing the meshes
  48184. * you wish in the ground reflection.
  48185. */
  48186. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48187. private _groundMaterial;
  48188. /**
  48189. * Gets the ground material created by the helper.
  48190. */
  48191. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48192. /**
  48193. * Stores the creation options.
  48194. */
  48195. private readonly _scene;
  48196. private _options;
  48197. /**
  48198. * This observable will be notified with any error during the creation of the environment,
  48199. * mainly texture creation errors.
  48200. */
  48201. onErrorObservable: Observable<{
  48202. message?: string;
  48203. exception?: any;
  48204. }>;
  48205. /**
  48206. * constructor
  48207. * @param options Defines the options we want to customize the helper
  48208. * @param scene The scene to add the material to
  48209. */
  48210. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48211. /**
  48212. * Updates the background according to the new options
  48213. * @param options
  48214. */
  48215. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48216. /**
  48217. * Sets the primary color of all the available elements.
  48218. * @param color the main color to affect to the ground and the background
  48219. */
  48220. setMainColor(color: Color3): void;
  48221. /**
  48222. * Setup the image processing according to the specified options.
  48223. */
  48224. private _setupImageProcessing;
  48225. /**
  48226. * Setup the environment texture according to the specified options.
  48227. */
  48228. private _setupEnvironmentTexture;
  48229. /**
  48230. * Setup the background according to the specified options.
  48231. */
  48232. private _setupBackground;
  48233. /**
  48234. * Get the scene sizes according to the setup.
  48235. */
  48236. private _getSceneSize;
  48237. /**
  48238. * Setup the ground according to the specified options.
  48239. */
  48240. private _setupGround;
  48241. /**
  48242. * Setup the ground material according to the specified options.
  48243. */
  48244. private _setupGroundMaterial;
  48245. /**
  48246. * Setup the ground diffuse texture according to the specified options.
  48247. */
  48248. private _setupGroundDiffuseTexture;
  48249. /**
  48250. * Setup the ground mirror texture according to the specified options.
  48251. */
  48252. private _setupGroundMirrorTexture;
  48253. /**
  48254. * Setup the ground to receive the mirror texture.
  48255. */
  48256. private _setupMirrorInGroundMaterial;
  48257. /**
  48258. * Setup the skybox according to the specified options.
  48259. */
  48260. private _setupSkybox;
  48261. /**
  48262. * Setup the skybox material according to the specified options.
  48263. */
  48264. private _setupSkyboxMaterial;
  48265. /**
  48266. * Setup the skybox reflection texture according to the specified options.
  48267. */
  48268. private _setupSkyboxReflectionTexture;
  48269. private _errorHandler;
  48270. /**
  48271. * Dispose all the elements created by the Helper.
  48272. */
  48273. dispose(): void;
  48274. }
  48275. }
  48276. declare module "babylonjs/Helpers/photoDome" {
  48277. import { Observable } from "babylonjs/Misc/observable";
  48278. import { Nullable } from "babylonjs/types";
  48279. import { Scene } from "babylonjs/scene";
  48280. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48281. import { Mesh } from "babylonjs/Meshes/mesh";
  48282. import { Texture } from "babylonjs/Materials/Textures/texture";
  48283. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48284. import "babylonjs/Meshes/Builders/sphereBuilder";
  48285. /**
  48286. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48287. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48288. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48289. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48290. */
  48291. export class PhotoDome extends TransformNode {
  48292. /**
  48293. * Define the image as a Monoscopic panoramic 360 image.
  48294. */
  48295. static readonly MODE_MONOSCOPIC: number;
  48296. /**
  48297. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48298. */
  48299. static readonly MODE_TOPBOTTOM: number;
  48300. /**
  48301. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48302. */
  48303. static readonly MODE_SIDEBYSIDE: number;
  48304. private _useDirectMapping;
  48305. /**
  48306. * The texture being displayed on the sphere
  48307. */
  48308. protected _photoTexture: Texture;
  48309. /**
  48310. * Gets or sets the texture being displayed on the sphere
  48311. */
  48312. photoTexture: Texture;
  48313. /**
  48314. * Observable raised when an error occured while loading the 360 image
  48315. */
  48316. onLoadErrorObservable: Observable<string>;
  48317. /**
  48318. * The skybox material
  48319. */
  48320. protected _material: BackgroundMaterial;
  48321. /**
  48322. * The surface used for the skybox
  48323. */
  48324. protected _mesh: Mesh;
  48325. /**
  48326. * Gets the mesh used for the skybox.
  48327. */
  48328. readonly mesh: Mesh;
  48329. /**
  48330. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48331. * Also see the options.resolution property.
  48332. */
  48333. fovMultiplier: number;
  48334. private _imageMode;
  48335. /**
  48336. * Gets or set the current video mode for the video. It can be:
  48337. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48338. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48339. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48340. */
  48341. imageMode: number;
  48342. /**
  48343. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48344. * @param name Element's name, child elements will append suffixes for their own names.
  48345. * @param urlsOfPhoto defines the url of the photo to display
  48346. * @param options defines an object containing optional or exposed sub element properties
  48347. * @param onError defines a callback called when an error occured while loading the texture
  48348. */
  48349. constructor(name: string, urlOfPhoto: string, options: {
  48350. resolution?: number;
  48351. size?: number;
  48352. useDirectMapping?: boolean;
  48353. faceForward?: boolean;
  48354. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48355. private _onBeforeCameraRenderObserver;
  48356. private _changeImageMode;
  48357. /**
  48358. * Releases resources associated with this node.
  48359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48361. */
  48362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48363. }
  48364. }
  48365. declare module "babylonjs/Misc/rgbdTextureTools" {
  48366. import "babylonjs/Shaders/rgbdDecode.fragment";
  48367. import { Texture } from "babylonjs/Materials/Textures/texture";
  48368. /**
  48369. * Class used to host RGBD texture specific utilities
  48370. */
  48371. export class RGBDTextureTools {
  48372. /**
  48373. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48374. * @param texture the texture to expand.
  48375. */
  48376. static ExpandRGBDTexture(texture: Texture): void;
  48377. }
  48378. }
  48379. declare module "babylonjs/Misc/brdfTextureTools" {
  48380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48381. import { Scene } from "babylonjs/scene";
  48382. /**
  48383. * Class used to host texture specific utilities
  48384. */
  48385. export class BRDFTextureTools {
  48386. /**
  48387. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48388. * @param scene defines the hosting scene
  48389. * @returns the environment BRDF texture
  48390. */
  48391. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48392. private static _environmentBRDFBase64Texture;
  48393. }
  48394. }
  48395. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48396. import { Nullable } from "babylonjs/types";
  48397. import { Color3 } from "babylonjs/Maths/math.color";
  48398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48399. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48400. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48401. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48402. import { Engine } from "babylonjs/Engines/engine";
  48403. import { Scene } from "babylonjs/scene";
  48404. /**
  48405. * @hidden
  48406. */
  48407. export interface IMaterialClearCoatDefines {
  48408. CLEARCOAT: boolean;
  48409. CLEARCOAT_DEFAULTIOR: boolean;
  48410. CLEARCOAT_TEXTURE: boolean;
  48411. CLEARCOAT_TEXTUREDIRECTUV: number;
  48412. CLEARCOAT_BUMP: boolean;
  48413. CLEARCOAT_BUMPDIRECTUV: number;
  48414. CLEARCOAT_TINT: boolean;
  48415. CLEARCOAT_TINT_TEXTURE: boolean;
  48416. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48417. /** @hidden */
  48418. _areTexturesDirty: boolean;
  48419. }
  48420. /**
  48421. * Define the code related to the clear coat parameters of the pbr material.
  48422. */
  48423. export class PBRClearCoatConfiguration {
  48424. /**
  48425. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48426. * The default fits with a polyurethane material.
  48427. */
  48428. private static readonly _DefaultIndexOfRefraction;
  48429. private _isEnabled;
  48430. /**
  48431. * Defines if the clear coat is enabled in the material.
  48432. */
  48433. isEnabled: boolean;
  48434. /**
  48435. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48436. */
  48437. intensity: number;
  48438. /**
  48439. * Defines the clear coat layer roughness.
  48440. */
  48441. roughness: number;
  48442. private _indexOfRefraction;
  48443. /**
  48444. * Defines the index of refraction of the clear coat.
  48445. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48446. * The default fits with a polyurethane material.
  48447. * Changing the default value is more performance intensive.
  48448. */
  48449. indexOfRefraction: number;
  48450. private _texture;
  48451. /**
  48452. * Stores the clear coat values in a texture.
  48453. */
  48454. texture: Nullable<BaseTexture>;
  48455. private _bumpTexture;
  48456. /**
  48457. * Define the clear coat specific bump texture.
  48458. */
  48459. bumpTexture: Nullable<BaseTexture>;
  48460. private _isTintEnabled;
  48461. /**
  48462. * Defines if the clear coat tint is enabled in the material.
  48463. */
  48464. isTintEnabled: boolean;
  48465. /**
  48466. * Defines the clear coat tint of the material.
  48467. * This is only use if tint is enabled
  48468. */
  48469. tintColor: Color3;
  48470. /**
  48471. * Defines the distance at which the tint color should be found in the
  48472. * clear coat media.
  48473. * This is only use if tint is enabled
  48474. */
  48475. tintColorAtDistance: number;
  48476. /**
  48477. * Defines the clear coat layer thickness.
  48478. * This is only use if tint is enabled
  48479. */
  48480. tintThickness: number;
  48481. private _tintTexture;
  48482. /**
  48483. * Stores the clear tint values in a texture.
  48484. * rgb is tint
  48485. * a is a thickness factor
  48486. */
  48487. tintTexture: Nullable<BaseTexture>;
  48488. /** @hidden */
  48489. private _internalMarkAllSubMeshesAsTexturesDirty;
  48490. /** @hidden */
  48491. _markAllSubMeshesAsTexturesDirty(): void;
  48492. /**
  48493. * Instantiate a new istance of clear coat configuration.
  48494. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48495. */
  48496. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48497. /**
  48498. * Gets wehter the submesh is ready to be used or not.
  48499. * @param defines the list of "defines" to update.
  48500. * @param scene defines the scene the material belongs to.
  48501. * @param engine defines the engine the material belongs to.
  48502. * @param disableBumpMap defines wether the material disables bump or not.
  48503. * @returns - boolean indicating that the submesh is ready or not.
  48504. */
  48505. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48506. /**
  48507. * Checks to see if a texture is used in the material.
  48508. * @param defines the list of "defines" to update.
  48509. * @param scene defines the scene to the material belongs to.
  48510. */
  48511. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48512. /**
  48513. * Binds the material data.
  48514. * @param uniformBuffer defines the Uniform buffer to fill in.
  48515. * @param scene defines the scene the material belongs to.
  48516. * @param engine defines the engine the material belongs to.
  48517. * @param disableBumpMap defines wether the material disables bump or not.
  48518. * @param isFrozen defines wether the material is frozen or not.
  48519. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48520. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48521. */
  48522. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48523. /**
  48524. * Checks to see if a texture is used in the material.
  48525. * @param texture - Base texture to use.
  48526. * @returns - Boolean specifying if a texture is used in the material.
  48527. */
  48528. hasTexture(texture: BaseTexture): boolean;
  48529. /**
  48530. * Returns an array of the actively used textures.
  48531. * @param activeTextures Array of BaseTextures
  48532. */
  48533. getActiveTextures(activeTextures: BaseTexture[]): void;
  48534. /**
  48535. * Returns the animatable textures.
  48536. * @param animatables Array of animatable textures.
  48537. */
  48538. getAnimatables(animatables: IAnimatable[]): void;
  48539. /**
  48540. * Disposes the resources of the material.
  48541. * @param forceDisposeTextures - Forces the disposal of all textures.
  48542. */
  48543. dispose(forceDisposeTextures?: boolean): void;
  48544. /**
  48545. * Get the current class name of the texture useful for serialization or dynamic coding.
  48546. * @returns "PBRClearCoatConfiguration"
  48547. */
  48548. getClassName(): string;
  48549. /**
  48550. * Add fallbacks to the effect fallbacks list.
  48551. * @param defines defines the Base texture to use.
  48552. * @param fallbacks defines the current fallback list.
  48553. * @param currentRank defines the current fallback rank.
  48554. * @returns the new fallback rank.
  48555. */
  48556. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48557. /**
  48558. * Add the required uniforms to the current list.
  48559. * @param uniforms defines the current uniform list.
  48560. */
  48561. static AddUniforms(uniforms: string[]): void;
  48562. /**
  48563. * Add the required samplers to the current list.
  48564. * @param samplers defines the current sampler list.
  48565. */
  48566. static AddSamplers(samplers: string[]): void;
  48567. /**
  48568. * Add the required uniforms to the current buffer.
  48569. * @param uniformBuffer defines the current uniform buffer.
  48570. */
  48571. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48572. /**
  48573. * Makes a duplicate of the current configuration into another one.
  48574. * @param clearCoatConfiguration define the config where to copy the info
  48575. */
  48576. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48577. /**
  48578. * Serializes this clear coat configuration.
  48579. * @returns - An object with the serialized config.
  48580. */
  48581. serialize(): any;
  48582. /**
  48583. * Parses a anisotropy Configuration from a serialized object.
  48584. * @param source - Serialized object.
  48585. * @param scene Defines the scene we are parsing for
  48586. * @param rootUrl Defines the rootUrl to load from
  48587. */
  48588. parse(source: any, scene: Scene, rootUrl: string): void;
  48589. }
  48590. }
  48591. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48592. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48594. import { Vector2 } from "babylonjs/Maths/math.vector";
  48595. import { Scene } from "babylonjs/scene";
  48596. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48597. import { Nullable } from "babylonjs/types";
  48598. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48599. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48600. /**
  48601. * @hidden
  48602. */
  48603. export interface IMaterialAnisotropicDefines {
  48604. ANISOTROPIC: boolean;
  48605. ANISOTROPIC_TEXTURE: boolean;
  48606. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48607. MAINUV1: boolean;
  48608. _areTexturesDirty: boolean;
  48609. _needUVs: boolean;
  48610. }
  48611. /**
  48612. * Define the code related to the anisotropic parameters of the pbr material.
  48613. */
  48614. export class PBRAnisotropicConfiguration {
  48615. private _isEnabled;
  48616. /**
  48617. * Defines if the anisotropy is enabled in the material.
  48618. */
  48619. isEnabled: boolean;
  48620. /**
  48621. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48622. */
  48623. intensity: number;
  48624. /**
  48625. * Defines if the effect is along the tangents, bitangents or in between.
  48626. * By default, the effect is "strectching" the highlights along the tangents.
  48627. */
  48628. direction: Vector2;
  48629. private _texture;
  48630. /**
  48631. * Stores the anisotropy values in a texture.
  48632. * rg is direction (like normal from -1 to 1)
  48633. * b is a intensity
  48634. */
  48635. texture: Nullable<BaseTexture>;
  48636. /** @hidden */
  48637. private _internalMarkAllSubMeshesAsTexturesDirty;
  48638. /** @hidden */
  48639. _markAllSubMeshesAsTexturesDirty(): void;
  48640. /**
  48641. * Instantiate a new istance of anisotropy configuration.
  48642. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48643. */
  48644. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48645. /**
  48646. * Specifies that the submesh is ready to be used.
  48647. * @param defines the list of "defines" to update.
  48648. * @param scene defines the scene the material belongs to.
  48649. * @returns - boolean indicating that the submesh is ready or not.
  48650. */
  48651. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48652. /**
  48653. * Checks to see if a texture is used in the material.
  48654. * @param defines the list of "defines" to update.
  48655. * @param mesh the mesh we are preparing the defines for.
  48656. * @param scene defines the scene the material belongs to.
  48657. */
  48658. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48659. /**
  48660. * Binds the material data.
  48661. * @param uniformBuffer defines the Uniform buffer to fill in.
  48662. * @param scene defines the scene the material belongs to.
  48663. * @param isFrozen defines wether the material is frozen or not.
  48664. */
  48665. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48666. /**
  48667. * Checks to see if a texture is used in the material.
  48668. * @param texture - Base texture to use.
  48669. * @returns - Boolean specifying if a texture is used in the material.
  48670. */
  48671. hasTexture(texture: BaseTexture): boolean;
  48672. /**
  48673. * Returns an array of the actively used textures.
  48674. * @param activeTextures Array of BaseTextures
  48675. */
  48676. getActiveTextures(activeTextures: BaseTexture[]): void;
  48677. /**
  48678. * Returns the animatable textures.
  48679. * @param animatables Array of animatable textures.
  48680. */
  48681. getAnimatables(animatables: IAnimatable[]): void;
  48682. /**
  48683. * Disposes the resources of the material.
  48684. * @param forceDisposeTextures - Forces the disposal of all textures.
  48685. */
  48686. dispose(forceDisposeTextures?: boolean): void;
  48687. /**
  48688. * Get the current class name of the texture useful for serialization or dynamic coding.
  48689. * @returns "PBRAnisotropicConfiguration"
  48690. */
  48691. getClassName(): string;
  48692. /**
  48693. * Add fallbacks to the effect fallbacks list.
  48694. * @param defines defines the Base texture to use.
  48695. * @param fallbacks defines the current fallback list.
  48696. * @param currentRank defines the current fallback rank.
  48697. * @returns the new fallback rank.
  48698. */
  48699. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48700. /**
  48701. * Add the required uniforms to the current list.
  48702. * @param uniforms defines the current uniform list.
  48703. */
  48704. static AddUniforms(uniforms: string[]): void;
  48705. /**
  48706. * Add the required uniforms to the current buffer.
  48707. * @param uniformBuffer defines the current uniform buffer.
  48708. */
  48709. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48710. /**
  48711. * Add the required samplers to the current list.
  48712. * @param samplers defines the current sampler list.
  48713. */
  48714. static AddSamplers(samplers: string[]): void;
  48715. /**
  48716. * Makes a duplicate of the current configuration into another one.
  48717. * @param anisotropicConfiguration define the config where to copy the info
  48718. */
  48719. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48720. /**
  48721. * Serializes this anisotropy configuration.
  48722. * @returns - An object with the serialized config.
  48723. */
  48724. serialize(): any;
  48725. /**
  48726. * Parses a anisotropy Configuration from a serialized object.
  48727. * @param source - Serialized object.
  48728. * @param scene Defines the scene we are parsing for
  48729. * @param rootUrl Defines the rootUrl to load from
  48730. */
  48731. parse(source: any, scene: Scene, rootUrl: string): void;
  48732. }
  48733. }
  48734. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48735. import { Scene } from "babylonjs/scene";
  48736. /**
  48737. * @hidden
  48738. */
  48739. export interface IMaterialBRDFDefines {
  48740. BRDF_V_HEIGHT_CORRELATED: boolean;
  48741. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48742. SPHERICAL_HARMONICS: boolean;
  48743. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48744. /** @hidden */
  48745. _areMiscDirty: boolean;
  48746. }
  48747. /**
  48748. * Define the code related to the BRDF parameters of the pbr material.
  48749. */
  48750. export class PBRBRDFConfiguration {
  48751. /**
  48752. * Default value used for the energy conservation.
  48753. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48754. */
  48755. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48756. /**
  48757. * Default value used for the Smith Visibility Height Correlated mode.
  48758. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48759. */
  48760. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48761. /**
  48762. * Default value used for the IBL diffuse part.
  48763. * This can help switching back to the polynomials mode globally which is a tiny bit
  48764. * less GPU intensive at the drawback of a lower quality.
  48765. */
  48766. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48767. /**
  48768. * Default value used for activating energy conservation for the specular workflow.
  48769. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48770. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48771. */
  48772. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48773. private _useEnergyConservation;
  48774. /**
  48775. * Defines if the material uses energy conservation.
  48776. */
  48777. useEnergyConservation: boolean;
  48778. private _useSmithVisibilityHeightCorrelated;
  48779. /**
  48780. * LEGACY Mode set to false
  48781. * Defines if the material uses height smith correlated visibility term.
  48782. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48783. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48784. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48785. * Not relying on height correlated will also disable energy conservation.
  48786. */
  48787. useSmithVisibilityHeightCorrelated: boolean;
  48788. private _useSphericalHarmonics;
  48789. /**
  48790. * LEGACY Mode set to false
  48791. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48792. * diffuse part of the IBL.
  48793. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48794. * to the ground truth.
  48795. */
  48796. useSphericalHarmonics: boolean;
  48797. private _useSpecularGlossinessInputEnergyConservation;
  48798. /**
  48799. * Defines if the material uses energy conservation, when the specular workflow is active.
  48800. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48801. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48802. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48803. */
  48804. useSpecularGlossinessInputEnergyConservation: boolean;
  48805. /** @hidden */
  48806. private _internalMarkAllSubMeshesAsMiscDirty;
  48807. /** @hidden */
  48808. _markAllSubMeshesAsMiscDirty(): void;
  48809. /**
  48810. * Instantiate a new istance of clear coat configuration.
  48811. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48812. */
  48813. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48814. /**
  48815. * Checks to see if a texture is used in the material.
  48816. * @param defines the list of "defines" to update.
  48817. */
  48818. prepareDefines(defines: IMaterialBRDFDefines): void;
  48819. /**
  48820. * Get the current class name of the texture useful for serialization or dynamic coding.
  48821. * @returns "PBRClearCoatConfiguration"
  48822. */
  48823. getClassName(): string;
  48824. /**
  48825. * Makes a duplicate of the current configuration into another one.
  48826. * @param brdfConfiguration define the config where to copy the info
  48827. */
  48828. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48829. /**
  48830. * Serializes this BRDF configuration.
  48831. * @returns - An object with the serialized config.
  48832. */
  48833. serialize(): any;
  48834. /**
  48835. * Parses a anisotropy Configuration from a serialized object.
  48836. * @param source - Serialized object.
  48837. * @param scene Defines the scene we are parsing for
  48838. * @param rootUrl Defines the rootUrl to load from
  48839. */
  48840. parse(source: any, scene: Scene, rootUrl: string): void;
  48841. }
  48842. }
  48843. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48844. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48845. import { Color3 } from "babylonjs/Maths/math.color";
  48846. import { Scene } from "babylonjs/scene";
  48847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48848. import { Nullable } from "babylonjs/types";
  48849. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48850. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48851. /**
  48852. * @hidden
  48853. */
  48854. export interface IMaterialSheenDefines {
  48855. SHEEN: boolean;
  48856. SHEEN_TEXTURE: boolean;
  48857. SHEEN_TEXTUREDIRECTUV: number;
  48858. SHEEN_LINKWITHALBEDO: boolean;
  48859. /** @hidden */
  48860. _areTexturesDirty: boolean;
  48861. }
  48862. /**
  48863. * Define the code related to the Sheen parameters of the pbr material.
  48864. */
  48865. export class PBRSheenConfiguration {
  48866. private _isEnabled;
  48867. /**
  48868. * Defines if the material uses sheen.
  48869. */
  48870. isEnabled: boolean;
  48871. private _linkSheenWithAlbedo;
  48872. /**
  48873. * Defines if the sheen is linked to the sheen color.
  48874. */
  48875. linkSheenWithAlbedo: boolean;
  48876. /**
  48877. * Defines the sheen intensity.
  48878. */
  48879. intensity: number;
  48880. /**
  48881. * Defines the sheen color.
  48882. */
  48883. color: Color3;
  48884. private _texture;
  48885. /**
  48886. * Stores the sheen tint values in a texture.
  48887. * rgb is tint
  48888. * a is a intensity
  48889. */
  48890. texture: Nullable<BaseTexture>;
  48891. /** @hidden */
  48892. private _internalMarkAllSubMeshesAsTexturesDirty;
  48893. /** @hidden */
  48894. _markAllSubMeshesAsTexturesDirty(): void;
  48895. /**
  48896. * Instantiate a new istance of clear coat configuration.
  48897. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48898. */
  48899. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48900. /**
  48901. * Specifies that the submesh is ready to be used.
  48902. * @param defines the list of "defines" to update.
  48903. * @param scene defines the scene the material belongs to.
  48904. * @returns - boolean indicating that the submesh is ready or not.
  48905. */
  48906. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48907. /**
  48908. * Checks to see if a texture is used in the material.
  48909. * @param defines the list of "defines" to update.
  48910. * @param scene defines the scene the material belongs to.
  48911. */
  48912. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48913. /**
  48914. * Binds the material data.
  48915. * @param uniformBuffer defines the Uniform buffer to fill in.
  48916. * @param scene defines the scene the material belongs to.
  48917. * @param isFrozen defines wether the material is frozen or not.
  48918. */
  48919. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48920. /**
  48921. * Checks to see if a texture is used in the material.
  48922. * @param texture - Base texture to use.
  48923. * @returns - Boolean specifying if a texture is used in the material.
  48924. */
  48925. hasTexture(texture: BaseTexture): boolean;
  48926. /**
  48927. * Returns an array of the actively used textures.
  48928. * @param activeTextures Array of BaseTextures
  48929. */
  48930. getActiveTextures(activeTextures: BaseTexture[]): void;
  48931. /**
  48932. * Returns the animatable textures.
  48933. * @param animatables Array of animatable textures.
  48934. */
  48935. getAnimatables(animatables: IAnimatable[]): void;
  48936. /**
  48937. * Disposes the resources of the material.
  48938. * @param forceDisposeTextures - Forces the disposal of all textures.
  48939. */
  48940. dispose(forceDisposeTextures?: boolean): void;
  48941. /**
  48942. * Get the current class name of the texture useful for serialization or dynamic coding.
  48943. * @returns "PBRSheenConfiguration"
  48944. */
  48945. getClassName(): string;
  48946. /**
  48947. * Add fallbacks to the effect fallbacks list.
  48948. * @param defines defines the Base texture to use.
  48949. * @param fallbacks defines the current fallback list.
  48950. * @param currentRank defines the current fallback rank.
  48951. * @returns the new fallback rank.
  48952. */
  48953. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48954. /**
  48955. * Add the required uniforms to the current list.
  48956. * @param uniforms defines the current uniform list.
  48957. */
  48958. static AddUniforms(uniforms: string[]): void;
  48959. /**
  48960. * Add the required uniforms to the current buffer.
  48961. * @param uniformBuffer defines the current uniform buffer.
  48962. */
  48963. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48964. /**
  48965. * Add the required samplers to the current list.
  48966. * @param samplers defines the current sampler list.
  48967. */
  48968. static AddSamplers(samplers: string[]): void;
  48969. /**
  48970. * Makes a duplicate of the current configuration into another one.
  48971. * @param sheenConfiguration define the config where to copy the info
  48972. */
  48973. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48974. /**
  48975. * Serializes this BRDF configuration.
  48976. * @returns - An object with the serialized config.
  48977. */
  48978. serialize(): any;
  48979. /**
  48980. * Parses a anisotropy Configuration from a serialized object.
  48981. * @param source - Serialized object.
  48982. * @param scene Defines the scene we are parsing for
  48983. * @param rootUrl Defines the rootUrl to load from
  48984. */
  48985. parse(source: any, scene: Scene, rootUrl: string): void;
  48986. }
  48987. }
  48988. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48989. import { Nullable } from "babylonjs/types";
  48990. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48991. import { Color3 } from "babylonjs/Maths/math.color";
  48992. import { SmartArray } from "babylonjs/Misc/smartArray";
  48993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48994. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48995. import { Effect } from "babylonjs/Materials/effect";
  48996. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48997. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48998. import { Engine } from "babylonjs/Engines/engine";
  48999. import { Scene } from "babylonjs/scene";
  49000. /**
  49001. * @hidden
  49002. */
  49003. export interface IMaterialSubSurfaceDefines {
  49004. SUBSURFACE: boolean;
  49005. SS_REFRACTION: boolean;
  49006. SS_TRANSLUCENCY: boolean;
  49007. SS_SCATERRING: boolean;
  49008. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49009. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49010. SS_REFRACTIONMAP_3D: boolean;
  49011. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49012. SS_LODINREFRACTIONALPHA: boolean;
  49013. SS_GAMMAREFRACTION: boolean;
  49014. SS_RGBDREFRACTION: boolean;
  49015. SS_LINEARSPECULARREFRACTION: boolean;
  49016. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49017. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49018. /** @hidden */
  49019. _areTexturesDirty: boolean;
  49020. }
  49021. /**
  49022. * Define the code related to the sub surface parameters of the pbr material.
  49023. */
  49024. export class PBRSubSurfaceConfiguration {
  49025. private _isRefractionEnabled;
  49026. /**
  49027. * Defines if the refraction is enabled in the material.
  49028. */
  49029. isRefractionEnabled: boolean;
  49030. private _isTranslucencyEnabled;
  49031. /**
  49032. * Defines if the translucency is enabled in the material.
  49033. */
  49034. isTranslucencyEnabled: boolean;
  49035. private _isScatteringEnabled;
  49036. /**
  49037. * Defines the refraction intensity of the material.
  49038. * The refraction when enabled replaces the Diffuse part of the material.
  49039. * The intensity helps transitionning between diffuse and refraction.
  49040. */
  49041. refractionIntensity: number;
  49042. /**
  49043. * Defines the translucency intensity of the material.
  49044. * When translucency has been enabled, this defines how much of the "translucency"
  49045. * is addded to the diffuse part of the material.
  49046. */
  49047. translucencyIntensity: number;
  49048. /**
  49049. * Defines the scattering intensity of the material.
  49050. * When scattering has been enabled, this defines how much of the "scattered light"
  49051. * is addded to the diffuse part of the material.
  49052. */
  49053. scatteringIntensity: number;
  49054. private _thicknessTexture;
  49055. /**
  49056. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49057. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49058. * 0 would mean minimumThickness
  49059. * 1 would mean maximumThickness
  49060. * The other channels might be use as a mask to vary the different effects intensity.
  49061. */
  49062. thicknessTexture: Nullable<BaseTexture>;
  49063. private _refractionTexture;
  49064. /**
  49065. * Defines the texture to use for refraction.
  49066. */
  49067. refractionTexture: Nullable<BaseTexture>;
  49068. private _indexOfRefraction;
  49069. /**
  49070. * Defines the index of refraction used in the material.
  49071. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49072. */
  49073. indexOfRefraction: number;
  49074. private _invertRefractionY;
  49075. /**
  49076. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49077. */
  49078. invertRefractionY: boolean;
  49079. private _linkRefractionWithTransparency;
  49080. /**
  49081. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49082. * Materials half opaque for instance using refraction could benefit from this control.
  49083. */
  49084. linkRefractionWithTransparency: boolean;
  49085. /**
  49086. * Defines the minimum thickness stored in the thickness map.
  49087. * If no thickness map is defined, this value will be used to simulate thickness.
  49088. */
  49089. minimumThickness: number;
  49090. /**
  49091. * Defines the maximum thickness stored in the thickness map.
  49092. */
  49093. maximumThickness: number;
  49094. /**
  49095. * Defines the volume tint of the material.
  49096. * This is used for both translucency and scattering.
  49097. */
  49098. tintColor: Color3;
  49099. /**
  49100. * Defines the distance at which the tint color should be found in the media.
  49101. * This is used for refraction only.
  49102. */
  49103. tintColorAtDistance: number;
  49104. /**
  49105. * Defines how far each channel transmit through the media.
  49106. * It is defined as a color to simplify it selection.
  49107. */
  49108. diffusionDistance: Color3;
  49109. private _useMaskFromThicknessTexture;
  49110. /**
  49111. * Stores the intensity of the different subsurface effects in the thickness texture.
  49112. * * the green channel is the translucency intensity.
  49113. * * the blue channel is the scattering intensity.
  49114. * * the alpha channel is the refraction intensity.
  49115. */
  49116. useMaskFromThicknessTexture: boolean;
  49117. /** @hidden */
  49118. private _internalMarkAllSubMeshesAsTexturesDirty;
  49119. /** @hidden */
  49120. _markAllSubMeshesAsTexturesDirty(): void;
  49121. /**
  49122. * Instantiate a new istance of sub surface configuration.
  49123. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49124. */
  49125. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49126. /**
  49127. * Gets wehter the submesh is ready to be used or not.
  49128. * @param defines the list of "defines" to update.
  49129. * @param scene defines the scene the material belongs to.
  49130. * @returns - boolean indicating that the submesh is ready or not.
  49131. */
  49132. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49133. /**
  49134. * Checks to see if a texture is used in the material.
  49135. * @param defines the list of "defines" to update.
  49136. * @param scene defines the scene to the material belongs to.
  49137. */
  49138. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49139. /**
  49140. * Binds the material data.
  49141. * @param uniformBuffer defines the Uniform buffer to fill in.
  49142. * @param scene defines the scene the material belongs to.
  49143. * @param engine defines the engine the material belongs to.
  49144. * @param isFrozen defines wether the material is frozen or not.
  49145. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49146. */
  49147. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49148. /**
  49149. * Unbinds the material from the mesh.
  49150. * @param activeEffect defines the effect that should be unbound from.
  49151. * @returns true if unbound, otherwise false
  49152. */
  49153. unbind(activeEffect: Effect): boolean;
  49154. /**
  49155. * Returns the texture used for refraction or null if none is used.
  49156. * @param scene defines the scene the material belongs to.
  49157. * @returns - Refraction texture if present. If no refraction texture and refraction
  49158. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49159. */
  49160. private _getRefractionTexture;
  49161. /**
  49162. * Returns true if alpha blending should be disabled.
  49163. */
  49164. readonly disableAlphaBlending: boolean;
  49165. /**
  49166. * Fills the list of render target textures.
  49167. * @param renderTargets the list of render targets to update
  49168. */
  49169. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49170. /**
  49171. * Checks to see if a texture is used in the material.
  49172. * @param texture - Base texture to use.
  49173. * @returns - Boolean specifying if a texture is used in the material.
  49174. */
  49175. hasTexture(texture: BaseTexture): boolean;
  49176. /**
  49177. * Gets a boolean indicating that current material needs to register RTT
  49178. * @returns true if this uses a render target otherwise false.
  49179. */
  49180. hasRenderTargetTextures(): boolean;
  49181. /**
  49182. * Returns an array of the actively used textures.
  49183. * @param activeTextures Array of BaseTextures
  49184. */
  49185. getActiveTextures(activeTextures: BaseTexture[]): void;
  49186. /**
  49187. * Returns the animatable textures.
  49188. * @param animatables Array of animatable textures.
  49189. */
  49190. getAnimatables(animatables: IAnimatable[]): void;
  49191. /**
  49192. * Disposes the resources of the material.
  49193. * @param forceDisposeTextures - Forces the disposal of all textures.
  49194. */
  49195. dispose(forceDisposeTextures?: boolean): void;
  49196. /**
  49197. * Get the current class name of the texture useful for serialization or dynamic coding.
  49198. * @returns "PBRSubSurfaceConfiguration"
  49199. */
  49200. getClassName(): string;
  49201. /**
  49202. * Add fallbacks to the effect fallbacks list.
  49203. * @param defines defines the Base texture to use.
  49204. * @param fallbacks defines the current fallback list.
  49205. * @param currentRank defines the current fallback rank.
  49206. * @returns the new fallback rank.
  49207. */
  49208. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49209. /**
  49210. * Add the required uniforms to the current list.
  49211. * @param uniforms defines the current uniform list.
  49212. */
  49213. static AddUniforms(uniforms: string[]): void;
  49214. /**
  49215. * Add the required samplers to the current list.
  49216. * @param samplers defines the current sampler list.
  49217. */
  49218. static AddSamplers(samplers: string[]): void;
  49219. /**
  49220. * Add the required uniforms to the current buffer.
  49221. * @param uniformBuffer defines the current uniform buffer.
  49222. */
  49223. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49224. /**
  49225. * Makes a duplicate of the current configuration into another one.
  49226. * @param configuration define the config where to copy the info
  49227. */
  49228. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49229. /**
  49230. * Serializes this Sub Surface configuration.
  49231. * @returns - An object with the serialized config.
  49232. */
  49233. serialize(): any;
  49234. /**
  49235. * Parses a anisotropy Configuration from a serialized object.
  49236. * @param source - Serialized object.
  49237. * @param scene Defines the scene we are parsing for
  49238. * @param rootUrl Defines the rootUrl to load from
  49239. */
  49240. parse(source: any, scene: Scene, rootUrl: string): void;
  49241. }
  49242. }
  49243. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49244. /** @hidden */
  49245. export var pbrFragmentDeclaration: {
  49246. name: string;
  49247. shader: string;
  49248. };
  49249. }
  49250. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49251. /** @hidden */
  49252. export var pbrUboDeclaration: {
  49253. name: string;
  49254. shader: string;
  49255. };
  49256. }
  49257. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49258. /** @hidden */
  49259. export var pbrFragmentExtraDeclaration: {
  49260. name: string;
  49261. shader: string;
  49262. };
  49263. }
  49264. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49265. /** @hidden */
  49266. export var pbrFragmentSamplersDeclaration: {
  49267. name: string;
  49268. shader: string;
  49269. };
  49270. }
  49271. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49272. /** @hidden */
  49273. export var pbrHelperFunctions: {
  49274. name: string;
  49275. shader: string;
  49276. };
  49277. }
  49278. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49279. /** @hidden */
  49280. export var harmonicsFunctions: {
  49281. name: string;
  49282. shader: string;
  49283. };
  49284. }
  49285. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49286. /** @hidden */
  49287. export var pbrDirectLightingSetupFunctions: {
  49288. name: string;
  49289. shader: string;
  49290. };
  49291. }
  49292. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49293. /** @hidden */
  49294. export var pbrDirectLightingFalloffFunctions: {
  49295. name: string;
  49296. shader: string;
  49297. };
  49298. }
  49299. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49300. /** @hidden */
  49301. export var pbrBRDFFunctions: {
  49302. name: string;
  49303. shader: string;
  49304. };
  49305. }
  49306. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49307. /** @hidden */
  49308. export var pbrDirectLightingFunctions: {
  49309. name: string;
  49310. shader: string;
  49311. };
  49312. }
  49313. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49314. /** @hidden */
  49315. export var pbrIBLFunctions: {
  49316. name: string;
  49317. shader: string;
  49318. };
  49319. }
  49320. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49321. /** @hidden */
  49322. export var pbrDebug: {
  49323. name: string;
  49324. shader: string;
  49325. };
  49326. }
  49327. declare module "babylonjs/Shaders/pbr.fragment" {
  49328. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49329. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49330. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49331. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49332. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49333. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49334. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49335. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49336. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49337. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49338. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49339. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49340. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49341. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49342. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49343. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49344. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49345. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49346. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49347. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49348. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49349. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49351. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49352. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49353. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49354. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49355. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49356. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49357. /** @hidden */
  49358. export var pbrPixelShader: {
  49359. name: string;
  49360. shader: string;
  49361. };
  49362. }
  49363. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49364. /** @hidden */
  49365. export var pbrVertexDeclaration: {
  49366. name: string;
  49367. shader: string;
  49368. };
  49369. }
  49370. declare module "babylonjs/Shaders/pbr.vertex" {
  49371. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49372. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49373. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49375. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49376. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49377. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49378. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49379. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49380. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49381. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49382. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49383. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49384. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49386. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49387. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49388. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49389. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49390. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49391. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49392. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49393. /** @hidden */
  49394. export var pbrVertexShader: {
  49395. name: string;
  49396. shader: string;
  49397. };
  49398. }
  49399. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49400. import { Nullable } from "babylonjs/types";
  49401. import { Scene } from "babylonjs/scene";
  49402. import { Matrix } from "babylonjs/Maths/math.vector";
  49403. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49405. import { Mesh } from "babylonjs/Meshes/mesh";
  49406. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49407. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49408. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49409. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49410. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49411. import { Color3 } from "babylonjs/Maths/math.color";
  49412. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49413. import { Material } from "babylonjs/Materials/material";
  49414. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49415. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49417. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49418. import "babylonjs/Shaders/pbr.fragment";
  49419. import "babylonjs/Shaders/pbr.vertex";
  49420. /**
  49421. * Manages the defines for the PBR Material.
  49422. * @hidden
  49423. */
  49424. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49425. PBR: boolean;
  49426. MAINUV1: boolean;
  49427. MAINUV2: boolean;
  49428. UV1: boolean;
  49429. UV2: boolean;
  49430. ALBEDO: boolean;
  49431. ALBEDODIRECTUV: number;
  49432. VERTEXCOLOR: boolean;
  49433. AMBIENT: boolean;
  49434. AMBIENTDIRECTUV: number;
  49435. AMBIENTINGRAYSCALE: boolean;
  49436. OPACITY: boolean;
  49437. VERTEXALPHA: boolean;
  49438. OPACITYDIRECTUV: number;
  49439. OPACITYRGB: boolean;
  49440. ALPHATEST: boolean;
  49441. DEPTHPREPASS: boolean;
  49442. ALPHABLEND: boolean;
  49443. ALPHAFROMALBEDO: boolean;
  49444. ALPHATESTVALUE: string;
  49445. SPECULAROVERALPHA: boolean;
  49446. RADIANCEOVERALPHA: boolean;
  49447. ALPHAFRESNEL: boolean;
  49448. LINEARALPHAFRESNEL: boolean;
  49449. PREMULTIPLYALPHA: boolean;
  49450. EMISSIVE: boolean;
  49451. EMISSIVEDIRECTUV: number;
  49452. REFLECTIVITY: boolean;
  49453. REFLECTIVITYDIRECTUV: number;
  49454. SPECULARTERM: boolean;
  49455. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49456. MICROSURFACEAUTOMATIC: boolean;
  49457. LODBASEDMICROSFURACE: boolean;
  49458. MICROSURFACEMAP: boolean;
  49459. MICROSURFACEMAPDIRECTUV: number;
  49460. METALLICWORKFLOW: boolean;
  49461. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49462. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49463. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49464. AOSTOREINMETALMAPRED: boolean;
  49465. ENVIRONMENTBRDF: boolean;
  49466. ENVIRONMENTBRDF_RGBD: boolean;
  49467. NORMAL: boolean;
  49468. TANGENT: boolean;
  49469. BUMP: boolean;
  49470. BUMPDIRECTUV: number;
  49471. OBJECTSPACE_NORMALMAP: boolean;
  49472. PARALLAX: boolean;
  49473. PARALLAXOCCLUSION: boolean;
  49474. NORMALXYSCALE: boolean;
  49475. LIGHTMAP: boolean;
  49476. LIGHTMAPDIRECTUV: number;
  49477. USELIGHTMAPASSHADOWMAP: boolean;
  49478. GAMMALIGHTMAP: boolean;
  49479. RGBDLIGHTMAP: boolean;
  49480. REFLECTION: boolean;
  49481. REFLECTIONMAP_3D: boolean;
  49482. REFLECTIONMAP_SPHERICAL: boolean;
  49483. REFLECTIONMAP_PLANAR: boolean;
  49484. REFLECTIONMAP_CUBIC: boolean;
  49485. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49486. REFLECTIONMAP_PROJECTION: boolean;
  49487. REFLECTIONMAP_SKYBOX: boolean;
  49488. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49489. REFLECTIONMAP_EXPLICIT: boolean;
  49490. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49491. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49492. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49493. INVERTCUBICMAP: boolean;
  49494. USESPHERICALFROMREFLECTIONMAP: boolean;
  49495. USEIRRADIANCEMAP: boolean;
  49496. SPHERICAL_HARMONICS: boolean;
  49497. USESPHERICALINVERTEX: boolean;
  49498. REFLECTIONMAP_OPPOSITEZ: boolean;
  49499. LODINREFLECTIONALPHA: boolean;
  49500. GAMMAREFLECTION: boolean;
  49501. RGBDREFLECTION: boolean;
  49502. LINEARSPECULARREFLECTION: boolean;
  49503. RADIANCEOCCLUSION: boolean;
  49504. HORIZONOCCLUSION: boolean;
  49505. INSTANCES: boolean;
  49506. NUM_BONE_INFLUENCERS: number;
  49507. BonesPerMesh: number;
  49508. BONETEXTURE: boolean;
  49509. NONUNIFORMSCALING: boolean;
  49510. MORPHTARGETS: boolean;
  49511. MORPHTARGETS_NORMAL: boolean;
  49512. MORPHTARGETS_TANGENT: boolean;
  49513. MORPHTARGETS_UV: boolean;
  49514. NUM_MORPH_INFLUENCERS: number;
  49515. IMAGEPROCESSING: boolean;
  49516. VIGNETTE: boolean;
  49517. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49518. VIGNETTEBLENDMODEOPAQUE: boolean;
  49519. TONEMAPPING: boolean;
  49520. TONEMAPPING_ACES: boolean;
  49521. CONTRAST: boolean;
  49522. COLORCURVES: boolean;
  49523. COLORGRADING: boolean;
  49524. COLORGRADING3D: boolean;
  49525. SAMPLER3DGREENDEPTH: boolean;
  49526. SAMPLER3DBGRMAP: boolean;
  49527. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49528. EXPOSURE: boolean;
  49529. MULTIVIEW: boolean;
  49530. USEPHYSICALLIGHTFALLOFF: boolean;
  49531. USEGLTFLIGHTFALLOFF: boolean;
  49532. TWOSIDEDLIGHTING: boolean;
  49533. SHADOWFLOAT: boolean;
  49534. CLIPPLANE: boolean;
  49535. CLIPPLANE2: boolean;
  49536. CLIPPLANE3: boolean;
  49537. CLIPPLANE4: boolean;
  49538. POINTSIZE: boolean;
  49539. FOG: boolean;
  49540. LOGARITHMICDEPTH: boolean;
  49541. FORCENORMALFORWARD: boolean;
  49542. SPECULARAA: boolean;
  49543. CLEARCOAT: boolean;
  49544. CLEARCOAT_DEFAULTIOR: boolean;
  49545. CLEARCOAT_TEXTURE: boolean;
  49546. CLEARCOAT_TEXTUREDIRECTUV: number;
  49547. CLEARCOAT_BUMP: boolean;
  49548. CLEARCOAT_BUMPDIRECTUV: number;
  49549. CLEARCOAT_TINT: boolean;
  49550. CLEARCOAT_TINT_TEXTURE: boolean;
  49551. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49552. ANISOTROPIC: boolean;
  49553. ANISOTROPIC_TEXTURE: boolean;
  49554. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49555. BRDF_V_HEIGHT_CORRELATED: boolean;
  49556. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49557. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49558. SHEEN: boolean;
  49559. SHEEN_TEXTURE: boolean;
  49560. SHEEN_TEXTUREDIRECTUV: number;
  49561. SHEEN_LINKWITHALBEDO: boolean;
  49562. SUBSURFACE: boolean;
  49563. SS_REFRACTION: boolean;
  49564. SS_TRANSLUCENCY: boolean;
  49565. SS_SCATERRING: boolean;
  49566. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49567. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49568. SS_REFRACTIONMAP_3D: boolean;
  49569. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49570. SS_LODINREFRACTIONALPHA: boolean;
  49571. SS_GAMMAREFRACTION: boolean;
  49572. SS_RGBDREFRACTION: boolean;
  49573. SS_LINEARSPECULARREFRACTION: boolean;
  49574. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49575. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49576. UNLIT: boolean;
  49577. DEBUGMODE: number;
  49578. /**
  49579. * Initializes the PBR Material defines.
  49580. */
  49581. constructor();
  49582. /**
  49583. * Resets the PBR Material defines.
  49584. */
  49585. reset(): void;
  49586. }
  49587. /**
  49588. * The Physically based material base class of BJS.
  49589. *
  49590. * This offers the main features of a standard PBR material.
  49591. * For more information, please refer to the documentation :
  49592. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49593. */
  49594. export abstract class PBRBaseMaterial extends PushMaterial {
  49595. /**
  49596. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49597. */
  49598. static readonly PBRMATERIAL_OPAQUE: number;
  49599. /**
  49600. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49601. */
  49602. static readonly PBRMATERIAL_ALPHATEST: number;
  49603. /**
  49604. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49605. */
  49606. static readonly PBRMATERIAL_ALPHABLEND: number;
  49607. /**
  49608. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49609. * They are also discarded below the alpha cutoff threshold to improve performances.
  49610. */
  49611. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49612. /**
  49613. * Defines the default value of how much AO map is occluding the analytical lights
  49614. * (point spot...).
  49615. */
  49616. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49617. /**
  49618. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49619. */
  49620. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49621. /**
  49622. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49623. * to enhance interoperability with other engines.
  49624. */
  49625. static readonly LIGHTFALLOFF_GLTF: number;
  49626. /**
  49627. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49628. * to enhance interoperability with other materials.
  49629. */
  49630. static readonly LIGHTFALLOFF_STANDARD: number;
  49631. /**
  49632. * Intensity of the direct lights e.g. the four lights available in your scene.
  49633. * This impacts both the direct diffuse and specular highlights.
  49634. */
  49635. protected _directIntensity: number;
  49636. /**
  49637. * Intensity of the emissive part of the material.
  49638. * This helps controlling the emissive effect without modifying the emissive color.
  49639. */
  49640. protected _emissiveIntensity: number;
  49641. /**
  49642. * Intensity of the environment e.g. how much the environment will light the object
  49643. * either through harmonics for rough material or through the refelction for shiny ones.
  49644. */
  49645. protected _environmentIntensity: number;
  49646. /**
  49647. * This is a special control allowing the reduction of the specular highlights coming from the
  49648. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49649. */
  49650. protected _specularIntensity: number;
  49651. /**
  49652. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49653. */
  49654. private _lightingInfos;
  49655. /**
  49656. * Debug Control allowing disabling the bump map on this material.
  49657. */
  49658. protected _disableBumpMap: boolean;
  49659. /**
  49660. * AKA Diffuse Texture in standard nomenclature.
  49661. */
  49662. protected _albedoTexture: Nullable<BaseTexture>;
  49663. /**
  49664. * AKA Occlusion Texture in other nomenclature.
  49665. */
  49666. protected _ambientTexture: Nullable<BaseTexture>;
  49667. /**
  49668. * AKA Occlusion Texture Intensity in other nomenclature.
  49669. */
  49670. protected _ambientTextureStrength: number;
  49671. /**
  49672. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49673. * 1 means it completely occludes it
  49674. * 0 mean it has no impact
  49675. */
  49676. protected _ambientTextureImpactOnAnalyticalLights: number;
  49677. /**
  49678. * Stores the alpha values in a texture.
  49679. */
  49680. protected _opacityTexture: Nullable<BaseTexture>;
  49681. /**
  49682. * Stores the reflection values in a texture.
  49683. */
  49684. protected _reflectionTexture: Nullable<BaseTexture>;
  49685. /**
  49686. * Stores the emissive values in a texture.
  49687. */
  49688. protected _emissiveTexture: Nullable<BaseTexture>;
  49689. /**
  49690. * AKA Specular texture in other nomenclature.
  49691. */
  49692. protected _reflectivityTexture: Nullable<BaseTexture>;
  49693. /**
  49694. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49695. */
  49696. protected _metallicTexture: Nullable<BaseTexture>;
  49697. /**
  49698. * Specifies the metallic scalar of the metallic/roughness workflow.
  49699. * Can also be used to scale the metalness values of the metallic texture.
  49700. */
  49701. protected _metallic: Nullable<number>;
  49702. /**
  49703. * Specifies the roughness scalar of the metallic/roughness workflow.
  49704. * Can also be used to scale the roughness values of the metallic texture.
  49705. */
  49706. protected _roughness: Nullable<number>;
  49707. /**
  49708. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49709. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49710. */
  49711. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49712. /**
  49713. * Stores surface normal data used to displace a mesh in a texture.
  49714. */
  49715. protected _bumpTexture: Nullable<BaseTexture>;
  49716. /**
  49717. * Stores the pre-calculated light information of a mesh in a texture.
  49718. */
  49719. protected _lightmapTexture: Nullable<BaseTexture>;
  49720. /**
  49721. * The color of a material in ambient lighting.
  49722. */
  49723. protected _ambientColor: Color3;
  49724. /**
  49725. * AKA Diffuse Color in other nomenclature.
  49726. */
  49727. protected _albedoColor: Color3;
  49728. /**
  49729. * AKA Specular Color in other nomenclature.
  49730. */
  49731. protected _reflectivityColor: Color3;
  49732. /**
  49733. * The color applied when light is reflected from a material.
  49734. */
  49735. protected _reflectionColor: Color3;
  49736. /**
  49737. * The color applied when light is emitted from a material.
  49738. */
  49739. protected _emissiveColor: Color3;
  49740. /**
  49741. * AKA Glossiness in other nomenclature.
  49742. */
  49743. protected _microSurface: number;
  49744. /**
  49745. * Specifies that the material will use the light map as a show map.
  49746. */
  49747. protected _useLightmapAsShadowmap: boolean;
  49748. /**
  49749. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49750. * makes the reflect vector face the model (under horizon).
  49751. */
  49752. protected _useHorizonOcclusion: boolean;
  49753. /**
  49754. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49755. * too much the area relying on ambient texture to define their ambient occlusion.
  49756. */
  49757. protected _useRadianceOcclusion: boolean;
  49758. /**
  49759. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49760. */
  49761. protected _useAlphaFromAlbedoTexture: boolean;
  49762. /**
  49763. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49764. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49765. */
  49766. protected _useSpecularOverAlpha: boolean;
  49767. /**
  49768. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49769. */
  49770. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49771. /**
  49772. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49773. */
  49774. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49775. /**
  49776. * Specifies if the metallic texture contains the roughness information in its green channel.
  49777. */
  49778. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49779. /**
  49780. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49781. */
  49782. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49783. /**
  49784. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49785. */
  49786. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49787. /**
  49788. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49789. */
  49790. protected _useAmbientInGrayScale: boolean;
  49791. /**
  49792. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49793. * The material will try to infer what glossiness each pixel should be.
  49794. */
  49795. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49796. /**
  49797. * Defines the falloff type used in this material.
  49798. * It by default is Physical.
  49799. */
  49800. protected _lightFalloff: number;
  49801. /**
  49802. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49803. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49804. */
  49805. protected _useRadianceOverAlpha: boolean;
  49806. /**
  49807. * Allows using an object space normal map (instead of tangent space).
  49808. */
  49809. protected _useObjectSpaceNormalMap: boolean;
  49810. /**
  49811. * Allows using the bump map in parallax mode.
  49812. */
  49813. protected _useParallax: boolean;
  49814. /**
  49815. * Allows using the bump map in parallax occlusion mode.
  49816. */
  49817. protected _useParallaxOcclusion: boolean;
  49818. /**
  49819. * Controls the scale bias of the parallax mode.
  49820. */
  49821. protected _parallaxScaleBias: number;
  49822. /**
  49823. * If sets to true, disables all the lights affecting the material.
  49824. */
  49825. protected _disableLighting: boolean;
  49826. /**
  49827. * Number of Simultaneous lights allowed on the material.
  49828. */
  49829. protected _maxSimultaneousLights: number;
  49830. /**
  49831. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49832. */
  49833. protected _invertNormalMapX: boolean;
  49834. /**
  49835. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49836. */
  49837. protected _invertNormalMapY: boolean;
  49838. /**
  49839. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49840. */
  49841. protected _twoSidedLighting: boolean;
  49842. /**
  49843. * Defines the alpha limits in alpha test mode.
  49844. */
  49845. protected _alphaCutOff: number;
  49846. /**
  49847. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49848. */
  49849. protected _forceAlphaTest: boolean;
  49850. /**
  49851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49853. */
  49854. protected _useAlphaFresnel: boolean;
  49855. /**
  49856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49858. */
  49859. protected _useLinearAlphaFresnel: boolean;
  49860. /**
  49861. * The transparency mode of the material.
  49862. */
  49863. protected _transparencyMode: Nullable<number>;
  49864. /**
  49865. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49866. * from cos thetav and roughness:
  49867. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49868. */
  49869. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49870. /**
  49871. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49872. */
  49873. protected _forceIrradianceInFragment: boolean;
  49874. /**
  49875. * Force normal to face away from face.
  49876. */
  49877. protected _forceNormalForward: boolean;
  49878. /**
  49879. * Enables specular anti aliasing in the PBR shader.
  49880. * It will both interacts on the Geometry for analytical and IBL lighting.
  49881. * It also prefilter the roughness map based on the bump values.
  49882. */
  49883. protected _enableSpecularAntiAliasing: boolean;
  49884. /**
  49885. * Default configuration related to image processing available in the PBR Material.
  49886. */
  49887. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49888. /**
  49889. * Keep track of the image processing observer to allow dispose and replace.
  49890. */
  49891. private _imageProcessingObserver;
  49892. /**
  49893. * Attaches a new image processing configuration to the PBR Material.
  49894. * @param configuration
  49895. */
  49896. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49897. /**
  49898. * Stores the available render targets.
  49899. */
  49900. private _renderTargets;
  49901. /**
  49902. * Sets the global ambient color for the material used in lighting calculations.
  49903. */
  49904. private _globalAmbientColor;
  49905. /**
  49906. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49907. */
  49908. private _useLogarithmicDepth;
  49909. /**
  49910. * If set to true, no lighting calculations will be applied.
  49911. */
  49912. private _unlit;
  49913. private _debugMode;
  49914. /**
  49915. * @hidden
  49916. * This is reserved for the inspector.
  49917. * Defines the material debug mode.
  49918. * It helps seeing only some components of the material while troubleshooting.
  49919. */
  49920. debugMode: number;
  49921. /**
  49922. * @hidden
  49923. * This is reserved for the inspector.
  49924. * Specify from where on screen the debug mode should start.
  49925. * The value goes from -1 (full screen) to 1 (not visible)
  49926. * It helps with side by side comparison against the final render
  49927. * This defaults to -1
  49928. */
  49929. private debugLimit;
  49930. /**
  49931. * @hidden
  49932. * This is reserved for the inspector.
  49933. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49934. * You can use the factor to better multiply the final value.
  49935. */
  49936. private debugFactor;
  49937. /**
  49938. * Defines the clear coat layer parameters for the material.
  49939. */
  49940. readonly clearCoat: PBRClearCoatConfiguration;
  49941. /**
  49942. * Defines the anisotropic parameters for the material.
  49943. */
  49944. readonly anisotropy: PBRAnisotropicConfiguration;
  49945. /**
  49946. * Defines the BRDF parameters for the material.
  49947. */
  49948. readonly brdf: PBRBRDFConfiguration;
  49949. /**
  49950. * Defines the Sheen parameters for the material.
  49951. */
  49952. readonly sheen: PBRSheenConfiguration;
  49953. /**
  49954. * Defines the SubSurface parameters for the material.
  49955. */
  49956. readonly subSurface: PBRSubSurfaceConfiguration;
  49957. /**
  49958. * Custom callback helping to override the default shader used in the material.
  49959. */
  49960. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49961. protected _rebuildInParallel: boolean;
  49962. /**
  49963. * Instantiates a new PBRMaterial instance.
  49964. *
  49965. * @param name The material name
  49966. * @param scene The scene the material will be use in.
  49967. */
  49968. constructor(name: string, scene: Scene);
  49969. /**
  49970. * Gets a boolean indicating that current material needs to register RTT
  49971. */
  49972. readonly hasRenderTargetTextures: boolean;
  49973. /**
  49974. * Gets the name of the material class.
  49975. */
  49976. getClassName(): string;
  49977. /**
  49978. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49979. */
  49980. /**
  49981. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49982. */
  49983. useLogarithmicDepth: boolean;
  49984. /**
  49985. * Gets the current transparency mode.
  49986. */
  49987. /**
  49988. * Sets the transparency mode of the material.
  49989. *
  49990. * | Value | Type | Description |
  49991. * | ----- | ----------------------------------- | ----------- |
  49992. * | 0 | OPAQUE | |
  49993. * | 1 | ALPHATEST | |
  49994. * | 2 | ALPHABLEND | |
  49995. * | 3 | ALPHATESTANDBLEND | |
  49996. *
  49997. */
  49998. transparencyMode: Nullable<number>;
  49999. /**
  50000. * Returns true if alpha blending should be disabled.
  50001. */
  50002. private readonly _disableAlphaBlending;
  50003. /**
  50004. * Specifies whether or not this material should be rendered in alpha blend mode.
  50005. */
  50006. needAlphaBlending(): boolean;
  50007. /**
  50008. * Specifies if the mesh will require alpha blending.
  50009. * @param mesh - BJS mesh.
  50010. */
  50011. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50012. /**
  50013. * Specifies whether or not this material should be rendered in alpha test mode.
  50014. */
  50015. needAlphaTesting(): boolean;
  50016. /**
  50017. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50018. */
  50019. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50020. /**
  50021. * Gets the texture used for the alpha test.
  50022. */
  50023. getAlphaTestTexture(): Nullable<BaseTexture>;
  50024. /**
  50025. * Specifies that the submesh is ready to be used.
  50026. * @param mesh - BJS mesh.
  50027. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50028. * @param useInstances - Specifies that instances should be used.
  50029. * @returns - boolean indicating that the submesh is ready or not.
  50030. */
  50031. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50032. /**
  50033. * Specifies if the material uses metallic roughness workflow.
  50034. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50035. */
  50036. isMetallicWorkflow(): boolean;
  50037. private _prepareEffect;
  50038. private _prepareDefines;
  50039. /**
  50040. * Force shader compilation
  50041. */
  50042. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50043. clipPlane: boolean;
  50044. }>): void;
  50045. /**
  50046. * Initializes the uniform buffer layout for the shader.
  50047. */
  50048. buildUniformLayout(): void;
  50049. /**
  50050. * Unbinds the material from the mesh
  50051. */
  50052. unbind(): void;
  50053. /**
  50054. * Binds the submesh data.
  50055. * @param world - The world matrix.
  50056. * @param mesh - The BJS mesh.
  50057. * @param subMesh - A submesh of the BJS mesh.
  50058. */
  50059. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50060. /**
  50061. * Returns the animatable textures.
  50062. * @returns - Array of animatable textures.
  50063. */
  50064. getAnimatables(): IAnimatable[];
  50065. /**
  50066. * Returns the texture used for reflections.
  50067. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50068. */
  50069. private _getReflectionTexture;
  50070. /**
  50071. * Returns an array of the actively used textures.
  50072. * @returns - Array of BaseTextures
  50073. */
  50074. getActiveTextures(): BaseTexture[];
  50075. /**
  50076. * Checks to see if a texture is used in the material.
  50077. * @param texture - Base texture to use.
  50078. * @returns - Boolean specifying if a texture is used in the material.
  50079. */
  50080. hasTexture(texture: BaseTexture): boolean;
  50081. /**
  50082. * Disposes the resources of the material.
  50083. * @param forceDisposeEffect - Forces the disposal of effects.
  50084. * @param forceDisposeTextures - Forces the disposal of all textures.
  50085. */
  50086. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50087. }
  50088. }
  50089. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50090. import { Nullable } from "babylonjs/types";
  50091. import { Scene } from "babylonjs/scene";
  50092. import { Color3 } from "babylonjs/Maths/math.color";
  50093. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50094. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50096. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50097. /**
  50098. * The Physically based material of BJS.
  50099. *
  50100. * This offers the main features of a standard PBR material.
  50101. * For more information, please refer to the documentation :
  50102. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50103. */
  50104. export class PBRMaterial extends PBRBaseMaterial {
  50105. /**
  50106. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50107. */
  50108. static readonly PBRMATERIAL_OPAQUE: number;
  50109. /**
  50110. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50111. */
  50112. static readonly PBRMATERIAL_ALPHATEST: number;
  50113. /**
  50114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50115. */
  50116. static readonly PBRMATERIAL_ALPHABLEND: number;
  50117. /**
  50118. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50119. * They are also discarded below the alpha cutoff threshold to improve performances.
  50120. */
  50121. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50122. /**
  50123. * Defines the default value of how much AO map is occluding the analytical lights
  50124. * (point spot...).
  50125. */
  50126. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50127. /**
  50128. * Intensity of the direct lights e.g. the four lights available in your scene.
  50129. * This impacts both the direct diffuse and specular highlights.
  50130. */
  50131. directIntensity: number;
  50132. /**
  50133. * Intensity of the emissive part of the material.
  50134. * This helps controlling the emissive effect without modifying the emissive color.
  50135. */
  50136. emissiveIntensity: number;
  50137. /**
  50138. * Intensity of the environment e.g. how much the environment will light the object
  50139. * either through harmonics for rough material or through the refelction for shiny ones.
  50140. */
  50141. environmentIntensity: number;
  50142. /**
  50143. * This is a special control allowing the reduction of the specular highlights coming from the
  50144. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50145. */
  50146. specularIntensity: number;
  50147. /**
  50148. * Debug Control allowing disabling the bump map on this material.
  50149. */
  50150. disableBumpMap: boolean;
  50151. /**
  50152. * AKA Diffuse Texture in standard nomenclature.
  50153. */
  50154. albedoTexture: BaseTexture;
  50155. /**
  50156. * AKA Occlusion Texture in other nomenclature.
  50157. */
  50158. ambientTexture: BaseTexture;
  50159. /**
  50160. * AKA Occlusion Texture Intensity in other nomenclature.
  50161. */
  50162. ambientTextureStrength: number;
  50163. /**
  50164. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50165. * 1 means it completely occludes it
  50166. * 0 mean it has no impact
  50167. */
  50168. ambientTextureImpactOnAnalyticalLights: number;
  50169. /**
  50170. * Stores the alpha values in a texture.
  50171. */
  50172. opacityTexture: BaseTexture;
  50173. /**
  50174. * Stores the reflection values in a texture.
  50175. */
  50176. reflectionTexture: Nullable<BaseTexture>;
  50177. /**
  50178. * Stores the emissive values in a texture.
  50179. */
  50180. emissiveTexture: BaseTexture;
  50181. /**
  50182. * AKA Specular texture in other nomenclature.
  50183. */
  50184. reflectivityTexture: BaseTexture;
  50185. /**
  50186. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50187. */
  50188. metallicTexture: BaseTexture;
  50189. /**
  50190. * Specifies the metallic scalar of the metallic/roughness workflow.
  50191. * Can also be used to scale the metalness values of the metallic texture.
  50192. */
  50193. metallic: Nullable<number>;
  50194. /**
  50195. * Specifies the roughness scalar of the metallic/roughness workflow.
  50196. * Can also be used to scale the roughness values of the metallic texture.
  50197. */
  50198. roughness: Nullable<number>;
  50199. /**
  50200. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50201. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50202. */
  50203. microSurfaceTexture: BaseTexture;
  50204. /**
  50205. * Stores surface normal data used to displace a mesh in a texture.
  50206. */
  50207. bumpTexture: BaseTexture;
  50208. /**
  50209. * Stores the pre-calculated light information of a mesh in a texture.
  50210. */
  50211. lightmapTexture: BaseTexture;
  50212. /**
  50213. * Stores the refracted light information in a texture.
  50214. */
  50215. refractionTexture: Nullable<BaseTexture>;
  50216. /**
  50217. * The color of a material in ambient lighting.
  50218. */
  50219. ambientColor: Color3;
  50220. /**
  50221. * AKA Diffuse Color in other nomenclature.
  50222. */
  50223. albedoColor: Color3;
  50224. /**
  50225. * AKA Specular Color in other nomenclature.
  50226. */
  50227. reflectivityColor: Color3;
  50228. /**
  50229. * The color reflected from the material.
  50230. */
  50231. reflectionColor: Color3;
  50232. /**
  50233. * The color emitted from the material.
  50234. */
  50235. emissiveColor: Color3;
  50236. /**
  50237. * AKA Glossiness in other nomenclature.
  50238. */
  50239. microSurface: number;
  50240. /**
  50241. * source material index of refraction (IOR)' / 'destination material IOR.
  50242. */
  50243. indexOfRefraction: number;
  50244. /**
  50245. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50246. */
  50247. invertRefractionY: boolean;
  50248. /**
  50249. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50250. * Materials half opaque for instance using refraction could benefit from this control.
  50251. */
  50252. linkRefractionWithTransparency: boolean;
  50253. /**
  50254. * If true, the light map contains occlusion information instead of lighting info.
  50255. */
  50256. useLightmapAsShadowmap: boolean;
  50257. /**
  50258. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50259. */
  50260. useAlphaFromAlbedoTexture: boolean;
  50261. /**
  50262. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50263. */
  50264. forceAlphaTest: boolean;
  50265. /**
  50266. * Defines the alpha limits in alpha test mode.
  50267. */
  50268. alphaCutOff: number;
  50269. /**
  50270. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50271. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50272. */
  50273. useSpecularOverAlpha: boolean;
  50274. /**
  50275. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50276. */
  50277. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50278. /**
  50279. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50280. */
  50281. useRoughnessFromMetallicTextureAlpha: boolean;
  50282. /**
  50283. * Specifies if the metallic texture contains the roughness information in its green channel.
  50284. */
  50285. useRoughnessFromMetallicTextureGreen: boolean;
  50286. /**
  50287. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50288. */
  50289. useMetallnessFromMetallicTextureBlue: boolean;
  50290. /**
  50291. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50292. */
  50293. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50294. /**
  50295. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50296. */
  50297. useAmbientInGrayScale: boolean;
  50298. /**
  50299. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50300. * The material will try to infer what glossiness each pixel should be.
  50301. */
  50302. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50303. /**
  50304. * BJS is using an harcoded light falloff based on a manually sets up range.
  50305. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50306. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50307. */
  50308. /**
  50309. * BJS is using an harcoded light falloff based on a manually sets up range.
  50310. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50311. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50312. */
  50313. usePhysicalLightFalloff: boolean;
  50314. /**
  50315. * In order to support the falloff compatibility with gltf, a special mode has been added
  50316. * to reproduce the gltf light falloff.
  50317. */
  50318. /**
  50319. * In order to support the falloff compatibility with gltf, a special mode has been added
  50320. * to reproduce the gltf light falloff.
  50321. */
  50322. useGLTFLightFalloff: boolean;
  50323. /**
  50324. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50325. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50326. */
  50327. useRadianceOverAlpha: boolean;
  50328. /**
  50329. * Allows using an object space normal map (instead of tangent space).
  50330. */
  50331. useObjectSpaceNormalMap: boolean;
  50332. /**
  50333. * Allows using the bump map in parallax mode.
  50334. */
  50335. useParallax: boolean;
  50336. /**
  50337. * Allows using the bump map in parallax occlusion mode.
  50338. */
  50339. useParallaxOcclusion: boolean;
  50340. /**
  50341. * Controls the scale bias of the parallax mode.
  50342. */
  50343. parallaxScaleBias: number;
  50344. /**
  50345. * If sets to true, disables all the lights affecting the material.
  50346. */
  50347. disableLighting: boolean;
  50348. /**
  50349. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50350. */
  50351. forceIrradianceInFragment: boolean;
  50352. /**
  50353. * Number of Simultaneous lights allowed on the material.
  50354. */
  50355. maxSimultaneousLights: number;
  50356. /**
  50357. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50358. */
  50359. invertNormalMapX: boolean;
  50360. /**
  50361. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50362. */
  50363. invertNormalMapY: boolean;
  50364. /**
  50365. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50366. */
  50367. twoSidedLighting: boolean;
  50368. /**
  50369. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50370. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50371. */
  50372. useAlphaFresnel: boolean;
  50373. /**
  50374. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50375. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50376. */
  50377. useLinearAlphaFresnel: boolean;
  50378. /**
  50379. * Let user defines the brdf lookup texture used for IBL.
  50380. * A default 8bit version is embedded but you could point at :
  50381. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50382. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50383. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50384. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50385. */
  50386. environmentBRDFTexture: Nullable<BaseTexture>;
  50387. /**
  50388. * Force normal to face away from face.
  50389. */
  50390. forceNormalForward: boolean;
  50391. /**
  50392. * Enables specular anti aliasing in the PBR shader.
  50393. * It will both interacts on the Geometry for analytical and IBL lighting.
  50394. * It also prefilter the roughness map based on the bump values.
  50395. */
  50396. enableSpecularAntiAliasing: boolean;
  50397. /**
  50398. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50399. * makes the reflect vector face the model (under horizon).
  50400. */
  50401. useHorizonOcclusion: boolean;
  50402. /**
  50403. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50404. * too much the area relying on ambient texture to define their ambient occlusion.
  50405. */
  50406. useRadianceOcclusion: boolean;
  50407. /**
  50408. * If set to true, no lighting calculations will be applied.
  50409. */
  50410. unlit: boolean;
  50411. /**
  50412. * Gets the image processing configuration used either in this material.
  50413. */
  50414. /**
  50415. * Sets the Default image processing configuration used either in the this material.
  50416. *
  50417. * If sets to null, the scene one is in use.
  50418. */
  50419. imageProcessingConfiguration: ImageProcessingConfiguration;
  50420. /**
  50421. * Gets wether the color curves effect is enabled.
  50422. */
  50423. /**
  50424. * Sets wether the color curves effect is enabled.
  50425. */
  50426. cameraColorCurvesEnabled: boolean;
  50427. /**
  50428. * Gets wether the color grading effect is enabled.
  50429. */
  50430. /**
  50431. * Gets wether the color grading effect is enabled.
  50432. */
  50433. cameraColorGradingEnabled: boolean;
  50434. /**
  50435. * Gets wether tonemapping is enabled or not.
  50436. */
  50437. /**
  50438. * Sets wether tonemapping is enabled or not
  50439. */
  50440. cameraToneMappingEnabled: boolean;
  50441. /**
  50442. * The camera exposure used on this material.
  50443. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50444. * This corresponds to a photographic exposure.
  50445. */
  50446. /**
  50447. * The camera exposure used on this material.
  50448. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50449. * This corresponds to a photographic exposure.
  50450. */
  50451. cameraExposure: number;
  50452. /**
  50453. * Gets The camera contrast used on this material.
  50454. */
  50455. /**
  50456. * Sets The camera contrast used on this material.
  50457. */
  50458. cameraContrast: number;
  50459. /**
  50460. * Gets the Color Grading 2D Lookup Texture.
  50461. */
  50462. /**
  50463. * Sets the Color Grading 2D Lookup Texture.
  50464. */
  50465. cameraColorGradingTexture: Nullable<BaseTexture>;
  50466. /**
  50467. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50468. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50469. * 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;
  50470. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50471. */
  50472. /**
  50473. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50474. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50475. * 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;
  50476. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50477. */
  50478. cameraColorCurves: Nullable<ColorCurves>;
  50479. /**
  50480. * Instantiates a new PBRMaterial instance.
  50481. *
  50482. * @param name The material name
  50483. * @param scene The scene the material will be use in.
  50484. */
  50485. constructor(name: string, scene: Scene);
  50486. /**
  50487. * Returns the name of this material class.
  50488. */
  50489. getClassName(): string;
  50490. /**
  50491. * Makes a duplicate of the current material.
  50492. * @param name - name to use for the new material.
  50493. */
  50494. clone(name: string): PBRMaterial;
  50495. /**
  50496. * Serializes this PBR Material.
  50497. * @returns - An object with the serialized material.
  50498. */
  50499. serialize(): any;
  50500. /**
  50501. * Parses a PBR Material from a serialized object.
  50502. * @param source - Serialized object.
  50503. * @param scene - BJS scene instance.
  50504. * @param rootUrl - url for the scene object
  50505. * @returns - PBRMaterial
  50506. */
  50507. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50508. }
  50509. }
  50510. declare module "babylonjs/Misc/dds" {
  50511. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50513. import { Nullable } from "babylonjs/types";
  50514. import { Scene } from "babylonjs/scene";
  50515. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50516. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50517. /**
  50518. * Direct draw surface info
  50519. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50520. */
  50521. export interface DDSInfo {
  50522. /**
  50523. * Width of the texture
  50524. */
  50525. width: number;
  50526. /**
  50527. * Width of the texture
  50528. */
  50529. height: number;
  50530. /**
  50531. * Number of Mipmaps for the texture
  50532. * @see https://en.wikipedia.org/wiki/Mipmap
  50533. */
  50534. mipmapCount: number;
  50535. /**
  50536. * If the textures format is a known fourCC format
  50537. * @see https://www.fourcc.org/
  50538. */
  50539. isFourCC: boolean;
  50540. /**
  50541. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50542. */
  50543. isRGB: boolean;
  50544. /**
  50545. * If the texture is a lumincance format
  50546. */
  50547. isLuminance: boolean;
  50548. /**
  50549. * If this is a cube texture
  50550. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50551. */
  50552. isCube: boolean;
  50553. /**
  50554. * If the texture is a compressed format eg. FOURCC_DXT1
  50555. */
  50556. isCompressed: boolean;
  50557. /**
  50558. * The dxgiFormat of the texture
  50559. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50560. */
  50561. dxgiFormat: number;
  50562. /**
  50563. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50564. */
  50565. textureType: number;
  50566. /**
  50567. * Sphericle polynomial created for the dds texture
  50568. */
  50569. sphericalPolynomial?: SphericalPolynomial;
  50570. }
  50571. /**
  50572. * Class used to provide DDS decompression tools
  50573. */
  50574. export class DDSTools {
  50575. /**
  50576. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50577. */
  50578. static StoreLODInAlphaChannel: boolean;
  50579. /**
  50580. * Gets DDS information from an array buffer
  50581. * @param arrayBuffer defines the array buffer to read data from
  50582. * @returns the DDS information
  50583. */
  50584. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50585. private static _FloatView;
  50586. private static _Int32View;
  50587. private static _ToHalfFloat;
  50588. private static _FromHalfFloat;
  50589. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50590. private static _GetHalfFloatRGBAArrayBuffer;
  50591. private static _GetFloatRGBAArrayBuffer;
  50592. private static _GetFloatAsUIntRGBAArrayBuffer;
  50593. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50594. private static _GetRGBAArrayBuffer;
  50595. private static _ExtractLongWordOrder;
  50596. private static _GetRGBArrayBuffer;
  50597. private static _GetLuminanceArrayBuffer;
  50598. /**
  50599. * Uploads DDS Levels to a Babylon Texture
  50600. * @hidden
  50601. */
  50602. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50603. }
  50604. module "babylonjs/Engines/thinEngine" {
  50605. interface ThinEngine {
  50606. /**
  50607. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50608. * @param rootUrl defines the url where the file to load is located
  50609. * @param scene defines the current scene
  50610. * @param lodScale defines scale to apply to the mip map selection
  50611. * @param lodOffset defines offset to apply to the mip map selection
  50612. * @param onLoad defines an optional callback raised when the texture is loaded
  50613. * @param onError defines an optional callback raised if there is an issue to load the texture
  50614. * @param format defines the format of the data
  50615. * @param forcedExtension defines the extension to use to pick the right loader
  50616. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50617. * @returns the cube texture as an InternalTexture
  50618. */
  50619. 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;
  50620. }
  50621. }
  50622. }
  50623. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50624. import { Nullable } from "babylonjs/types";
  50625. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50626. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50627. /**
  50628. * Implementation of the DDS Texture Loader.
  50629. * @hidden
  50630. */
  50631. export class _DDSTextureLoader implements IInternalTextureLoader {
  50632. /**
  50633. * Defines wether the loader supports cascade loading the different faces.
  50634. */
  50635. readonly supportCascades: boolean;
  50636. /**
  50637. * This returns if the loader support the current file information.
  50638. * @param extension defines the file extension of the file being loaded
  50639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50640. * @param fallback defines the fallback internal texture if any
  50641. * @param isBase64 defines whether the texture is encoded as a base64
  50642. * @param isBuffer defines whether the texture data are stored as a buffer
  50643. * @returns true if the loader can load the specified file
  50644. */
  50645. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50646. /**
  50647. * Transform the url before loading if required.
  50648. * @param rootUrl the url of the texture
  50649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50650. * @returns the transformed texture
  50651. */
  50652. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50653. /**
  50654. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50655. * @param rootUrl the url of the texture
  50656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50657. * @returns the fallback texture
  50658. */
  50659. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50660. /**
  50661. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50662. * @param data contains the texture data
  50663. * @param texture defines the BabylonJS internal texture
  50664. * @param createPolynomials will be true if polynomials have been requested
  50665. * @param onLoad defines the callback to trigger once the texture is ready
  50666. * @param onError defines the callback to trigger in case of error
  50667. */
  50668. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50669. /**
  50670. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50671. * @param data contains the texture data
  50672. * @param texture defines the BabylonJS internal texture
  50673. * @param callback defines the method to call once ready to upload
  50674. */
  50675. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50676. }
  50677. }
  50678. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50679. import { Nullable } from "babylonjs/types";
  50680. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50681. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50682. /**
  50683. * Implementation of the ENV Texture Loader.
  50684. * @hidden
  50685. */
  50686. export class _ENVTextureLoader implements IInternalTextureLoader {
  50687. /**
  50688. * Defines wether the loader supports cascade loading the different faces.
  50689. */
  50690. readonly supportCascades: boolean;
  50691. /**
  50692. * This returns if the loader support the current file information.
  50693. * @param extension defines the file extension of the file being loaded
  50694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50695. * @param fallback defines the fallback internal texture if any
  50696. * @param isBase64 defines whether the texture is encoded as a base64
  50697. * @param isBuffer defines whether the texture data are stored as a buffer
  50698. * @returns true if the loader can load the specified file
  50699. */
  50700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50701. /**
  50702. * Transform the url before loading if required.
  50703. * @param rootUrl the url of the texture
  50704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50705. * @returns the transformed texture
  50706. */
  50707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50708. /**
  50709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50710. * @param rootUrl the url of the texture
  50711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50712. * @returns the fallback texture
  50713. */
  50714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50715. /**
  50716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50717. * @param data contains the texture data
  50718. * @param texture defines the BabylonJS internal texture
  50719. * @param createPolynomials will be true if polynomials have been requested
  50720. * @param onLoad defines the callback to trigger once the texture is ready
  50721. * @param onError defines the callback to trigger in case of error
  50722. */
  50723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50724. /**
  50725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50726. * @param data contains the texture data
  50727. * @param texture defines the BabylonJS internal texture
  50728. * @param callback defines the method to call once ready to upload
  50729. */
  50730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50731. }
  50732. }
  50733. declare module "babylonjs/Misc/khronosTextureContainer" {
  50734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50735. /**
  50736. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50737. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50738. */
  50739. export class KhronosTextureContainer {
  50740. /** contents of the KTX container file */
  50741. arrayBuffer: any;
  50742. private static HEADER_LEN;
  50743. private static COMPRESSED_2D;
  50744. private static COMPRESSED_3D;
  50745. private static TEX_2D;
  50746. private static TEX_3D;
  50747. /**
  50748. * Gets the openGL type
  50749. */
  50750. glType: number;
  50751. /**
  50752. * Gets the openGL type size
  50753. */
  50754. glTypeSize: number;
  50755. /**
  50756. * Gets the openGL format
  50757. */
  50758. glFormat: number;
  50759. /**
  50760. * Gets the openGL internal format
  50761. */
  50762. glInternalFormat: number;
  50763. /**
  50764. * Gets the base internal format
  50765. */
  50766. glBaseInternalFormat: number;
  50767. /**
  50768. * Gets image width in pixel
  50769. */
  50770. pixelWidth: number;
  50771. /**
  50772. * Gets image height in pixel
  50773. */
  50774. pixelHeight: number;
  50775. /**
  50776. * Gets image depth in pixels
  50777. */
  50778. pixelDepth: number;
  50779. /**
  50780. * Gets the number of array elements
  50781. */
  50782. numberOfArrayElements: number;
  50783. /**
  50784. * Gets the number of faces
  50785. */
  50786. numberOfFaces: number;
  50787. /**
  50788. * Gets the number of mipmap levels
  50789. */
  50790. numberOfMipmapLevels: number;
  50791. /**
  50792. * Gets the bytes of key value data
  50793. */
  50794. bytesOfKeyValueData: number;
  50795. /**
  50796. * Gets the load type
  50797. */
  50798. loadType: number;
  50799. /**
  50800. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50801. */
  50802. isInvalid: boolean;
  50803. /**
  50804. * Creates a new KhronosTextureContainer
  50805. * @param arrayBuffer contents of the KTX container file
  50806. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50807. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50808. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50809. */
  50810. constructor(
  50811. /** contents of the KTX container file */
  50812. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50813. /**
  50814. * Uploads KTX content to a Babylon Texture.
  50815. * It is assumed that the texture has already been created & is currently bound
  50816. * @hidden
  50817. */
  50818. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50819. private _upload2DCompressedLevels;
  50820. }
  50821. }
  50822. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50823. import { Nullable } from "babylonjs/types";
  50824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50825. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50826. /**
  50827. * Implementation of the KTX Texture Loader.
  50828. * @hidden
  50829. */
  50830. export class _KTXTextureLoader implements IInternalTextureLoader {
  50831. /**
  50832. * Defines wether the loader supports cascade loading the different faces.
  50833. */
  50834. readonly supportCascades: boolean;
  50835. /**
  50836. * This returns if the loader support the current file information.
  50837. * @param extension defines the file extension of the file being loaded
  50838. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50839. * @param fallback defines the fallback internal texture if any
  50840. * @param isBase64 defines whether the texture is encoded as a base64
  50841. * @param isBuffer defines whether the texture data are stored as a buffer
  50842. * @returns true if the loader can load the specified file
  50843. */
  50844. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50845. /**
  50846. * Transform the url before loading if required.
  50847. * @param rootUrl the url of the texture
  50848. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50849. * @returns the transformed texture
  50850. */
  50851. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50852. /**
  50853. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50854. * @param rootUrl the url of the texture
  50855. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50856. * @returns the fallback texture
  50857. */
  50858. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50859. /**
  50860. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50861. * @param data contains the texture data
  50862. * @param texture defines the BabylonJS internal texture
  50863. * @param createPolynomials will be true if polynomials have been requested
  50864. * @param onLoad defines the callback to trigger once the texture is ready
  50865. * @param onError defines the callback to trigger in case of error
  50866. */
  50867. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50868. /**
  50869. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50870. * @param data contains the texture data
  50871. * @param texture defines the BabylonJS internal texture
  50872. * @param callback defines the method to call once ready to upload
  50873. */
  50874. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50875. }
  50876. }
  50877. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50878. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50879. import { Scene } from "babylonjs/scene";
  50880. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50881. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50882. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50883. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50884. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50885. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50887. /**
  50888. * Options for the default xr helper
  50889. */
  50890. export class WebXRDefaultExperienceOptions {
  50891. /**
  50892. * Floor meshes that should be used for teleporting
  50893. */
  50894. floorMeshes: Array<AbstractMesh>;
  50895. }
  50896. /**
  50897. * Default experience which provides a similar setup to the previous webVRExperience
  50898. */
  50899. export class WebXRDefaultExperience {
  50900. /**
  50901. * Base experience
  50902. */
  50903. baseExperience: WebXRExperienceHelper;
  50904. /**
  50905. * Input experience extension
  50906. */
  50907. input: WebXRInput;
  50908. /**
  50909. * Loads the controller models
  50910. */
  50911. controllerModelLoader: WebXRControllerModelLoader;
  50912. /**
  50913. * Enables laser pointer and selection
  50914. */
  50915. pointerSelection: WebXRControllerPointerSelection;
  50916. /**
  50917. * Enables teleportation
  50918. */
  50919. teleportation: WebXRControllerTeleportation;
  50920. /**
  50921. * Enables ui for enetering/exiting xr
  50922. */
  50923. enterExitUI: WebXREnterExitUI;
  50924. /**
  50925. * Default output canvas xr should render to
  50926. */
  50927. outputCanvas: WebXRManagedOutputCanvas;
  50928. /**
  50929. * Creates the default xr experience
  50930. * @param scene scene
  50931. * @param options options for basic configuration
  50932. * @returns resulting WebXRDefaultExperience
  50933. */
  50934. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50935. private constructor();
  50936. /**
  50937. * DIsposes of the experience helper
  50938. */
  50939. dispose(): void;
  50940. }
  50941. }
  50942. declare module "babylonjs/Helpers/sceneHelpers" {
  50943. import { Nullable } from "babylonjs/types";
  50944. import { Mesh } from "babylonjs/Meshes/mesh";
  50945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50946. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50947. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50948. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50949. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50950. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50951. import "babylonjs/Meshes/Builders/boxBuilder";
  50952. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50953. /** @hidden */
  50954. export var _forceSceneHelpersToBundle: boolean;
  50955. module "babylonjs/scene" {
  50956. interface Scene {
  50957. /**
  50958. * Creates a default light for the scene.
  50959. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50960. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50961. */
  50962. createDefaultLight(replace?: boolean): void;
  50963. /**
  50964. * Creates a default camera for the scene.
  50965. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50966. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50967. * @param replace has default false, when true replaces the active camera in the scene
  50968. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50969. */
  50970. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50971. /**
  50972. * Creates a default camera and a default light.
  50973. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50974. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50975. * @param replace has the default false, when true replaces the active camera/light in the scene
  50976. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50977. */
  50978. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50979. /**
  50980. * Creates a new sky box
  50981. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50982. * @param environmentTexture defines the texture to use as environment texture
  50983. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50984. * @param scale defines the overall scale of the skybox
  50985. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50986. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50987. * @returns a new mesh holding the sky box
  50988. */
  50989. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50990. /**
  50991. * Creates a new environment
  50992. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50993. * @param options defines the options you can use to configure the environment
  50994. * @returns the new EnvironmentHelper
  50995. */
  50996. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50997. /**
  50998. * Creates a new VREXperienceHelper
  50999. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51000. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51001. * @returns a new VREXperienceHelper
  51002. */
  51003. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51004. /**
  51005. * Creates a new WebXRDefaultExperience
  51006. * @see http://doc.babylonjs.com/how_to/webxr
  51007. * @param options experience options
  51008. * @returns a promise for a new WebXRDefaultExperience
  51009. */
  51010. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51011. }
  51012. }
  51013. }
  51014. declare module "babylonjs/Helpers/videoDome" {
  51015. import { Scene } from "babylonjs/scene";
  51016. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51017. import { Mesh } from "babylonjs/Meshes/mesh";
  51018. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51019. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51020. import "babylonjs/Meshes/Builders/sphereBuilder";
  51021. /**
  51022. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51023. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51024. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51025. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51026. */
  51027. export class VideoDome extends TransformNode {
  51028. /**
  51029. * Define the video source as a Monoscopic panoramic 360 video.
  51030. */
  51031. static readonly MODE_MONOSCOPIC: number;
  51032. /**
  51033. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51034. */
  51035. static readonly MODE_TOPBOTTOM: number;
  51036. /**
  51037. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51038. */
  51039. static readonly MODE_SIDEBYSIDE: number;
  51040. private _halfDome;
  51041. private _useDirectMapping;
  51042. /**
  51043. * The video texture being displayed on the sphere
  51044. */
  51045. protected _videoTexture: VideoTexture;
  51046. /**
  51047. * Gets the video texture being displayed on the sphere
  51048. */
  51049. readonly videoTexture: VideoTexture;
  51050. /**
  51051. * The skybox material
  51052. */
  51053. protected _material: BackgroundMaterial;
  51054. /**
  51055. * The surface used for the skybox
  51056. */
  51057. protected _mesh: Mesh;
  51058. /**
  51059. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51060. */
  51061. private _halfDomeMask;
  51062. /**
  51063. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51064. * Also see the options.resolution property.
  51065. */
  51066. fovMultiplier: number;
  51067. private _videoMode;
  51068. /**
  51069. * Gets or set the current video mode for the video. It can be:
  51070. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51071. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51072. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51073. */
  51074. videoMode: number;
  51075. /**
  51076. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51077. *
  51078. */
  51079. /**
  51080. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51081. */
  51082. halfDome: boolean;
  51083. /**
  51084. * Oberserver used in Stereoscopic VR Mode.
  51085. */
  51086. private _onBeforeCameraRenderObserver;
  51087. /**
  51088. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51089. * @param name Element's name, child elements will append suffixes for their own names.
  51090. * @param urlsOrVideo defines the url(s) or the video element to use
  51091. * @param options An object containing optional or exposed sub element properties
  51092. */
  51093. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51094. resolution?: number;
  51095. clickToPlay?: boolean;
  51096. autoPlay?: boolean;
  51097. loop?: boolean;
  51098. size?: number;
  51099. poster?: string;
  51100. faceForward?: boolean;
  51101. useDirectMapping?: boolean;
  51102. halfDomeMode?: boolean;
  51103. }, scene: Scene);
  51104. private _changeVideoMode;
  51105. /**
  51106. * Releases resources associated with this node.
  51107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51109. */
  51110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51111. }
  51112. }
  51113. declare module "babylonjs/Helpers/index" {
  51114. export * from "babylonjs/Helpers/environmentHelper";
  51115. export * from "babylonjs/Helpers/photoDome";
  51116. export * from "babylonjs/Helpers/sceneHelpers";
  51117. export * from "babylonjs/Helpers/videoDome";
  51118. }
  51119. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51120. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51121. import { IDisposable } from "babylonjs/scene";
  51122. import { Engine } from "babylonjs/Engines/engine";
  51123. /**
  51124. * This class can be used to get instrumentation data from a Babylon engine
  51125. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51126. */
  51127. export class EngineInstrumentation implements IDisposable {
  51128. /**
  51129. * Define the instrumented engine.
  51130. */
  51131. engine: Engine;
  51132. private _captureGPUFrameTime;
  51133. private _gpuFrameTimeToken;
  51134. private _gpuFrameTime;
  51135. private _captureShaderCompilationTime;
  51136. private _shaderCompilationTime;
  51137. private _onBeginFrameObserver;
  51138. private _onEndFrameObserver;
  51139. private _onBeforeShaderCompilationObserver;
  51140. private _onAfterShaderCompilationObserver;
  51141. /**
  51142. * Gets the perf counter used for GPU frame time
  51143. */
  51144. readonly gpuFrameTimeCounter: PerfCounter;
  51145. /**
  51146. * Gets the GPU frame time capture status
  51147. */
  51148. /**
  51149. * Enable or disable the GPU frame time capture
  51150. */
  51151. captureGPUFrameTime: boolean;
  51152. /**
  51153. * Gets the perf counter used for shader compilation time
  51154. */
  51155. readonly shaderCompilationTimeCounter: PerfCounter;
  51156. /**
  51157. * Gets the shader compilation time capture status
  51158. */
  51159. /**
  51160. * Enable or disable the shader compilation time capture
  51161. */
  51162. captureShaderCompilationTime: boolean;
  51163. /**
  51164. * Instantiates a new engine instrumentation.
  51165. * This class can be used to get instrumentation data from a Babylon engine
  51166. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51167. * @param engine Defines the engine to instrument
  51168. */
  51169. constructor(
  51170. /**
  51171. * Define the instrumented engine.
  51172. */
  51173. engine: Engine);
  51174. /**
  51175. * Dispose and release associated resources.
  51176. */
  51177. dispose(): void;
  51178. }
  51179. }
  51180. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51181. import { Scene, IDisposable } from "babylonjs/scene";
  51182. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51183. /**
  51184. * This class can be used to get instrumentation data from a Babylon engine
  51185. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51186. */
  51187. export class SceneInstrumentation implements IDisposable {
  51188. /**
  51189. * Defines the scene to instrument
  51190. */
  51191. scene: Scene;
  51192. private _captureActiveMeshesEvaluationTime;
  51193. private _activeMeshesEvaluationTime;
  51194. private _captureRenderTargetsRenderTime;
  51195. private _renderTargetsRenderTime;
  51196. private _captureFrameTime;
  51197. private _frameTime;
  51198. private _captureRenderTime;
  51199. private _renderTime;
  51200. private _captureInterFrameTime;
  51201. private _interFrameTime;
  51202. private _captureParticlesRenderTime;
  51203. private _particlesRenderTime;
  51204. private _captureSpritesRenderTime;
  51205. private _spritesRenderTime;
  51206. private _capturePhysicsTime;
  51207. private _physicsTime;
  51208. private _captureAnimationsTime;
  51209. private _animationsTime;
  51210. private _captureCameraRenderTime;
  51211. private _cameraRenderTime;
  51212. private _onBeforeActiveMeshesEvaluationObserver;
  51213. private _onAfterActiveMeshesEvaluationObserver;
  51214. private _onBeforeRenderTargetsRenderObserver;
  51215. private _onAfterRenderTargetsRenderObserver;
  51216. private _onAfterRenderObserver;
  51217. private _onBeforeDrawPhaseObserver;
  51218. private _onAfterDrawPhaseObserver;
  51219. private _onBeforeAnimationsObserver;
  51220. private _onBeforeParticlesRenderingObserver;
  51221. private _onAfterParticlesRenderingObserver;
  51222. private _onBeforeSpritesRenderingObserver;
  51223. private _onAfterSpritesRenderingObserver;
  51224. private _onBeforePhysicsObserver;
  51225. private _onAfterPhysicsObserver;
  51226. private _onAfterAnimationsObserver;
  51227. private _onBeforeCameraRenderObserver;
  51228. private _onAfterCameraRenderObserver;
  51229. /**
  51230. * Gets the perf counter used for active meshes evaluation time
  51231. */
  51232. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51233. /**
  51234. * Gets the active meshes evaluation time capture status
  51235. */
  51236. /**
  51237. * Enable or disable the active meshes evaluation time capture
  51238. */
  51239. captureActiveMeshesEvaluationTime: boolean;
  51240. /**
  51241. * Gets the perf counter used for render targets render time
  51242. */
  51243. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51244. /**
  51245. * Gets the render targets render time capture status
  51246. */
  51247. /**
  51248. * Enable or disable the render targets render time capture
  51249. */
  51250. captureRenderTargetsRenderTime: boolean;
  51251. /**
  51252. * Gets the perf counter used for particles render time
  51253. */
  51254. readonly particlesRenderTimeCounter: PerfCounter;
  51255. /**
  51256. * Gets the particles render time capture status
  51257. */
  51258. /**
  51259. * Enable or disable the particles render time capture
  51260. */
  51261. captureParticlesRenderTime: boolean;
  51262. /**
  51263. * Gets the perf counter used for sprites render time
  51264. */
  51265. readonly spritesRenderTimeCounter: PerfCounter;
  51266. /**
  51267. * Gets the sprites render time capture status
  51268. */
  51269. /**
  51270. * Enable or disable the sprites render time capture
  51271. */
  51272. captureSpritesRenderTime: boolean;
  51273. /**
  51274. * Gets the perf counter used for physics time
  51275. */
  51276. readonly physicsTimeCounter: PerfCounter;
  51277. /**
  51278. * Gets the physics time capture status
  51279. */
  51280. /**
  51281. * Enable or disable the physics time capture
  51282. */
  51283. capturePhysicsTime: boolean;
  51284. /**
  51285. * Gets the perf counter used for animations time
  51286. */
  51287. readonly animationsTimeCounter: PerfCounter;
  51288. /**
  51289. * Gets the animations time capture status
  51290. */
  51291. /**
  51292. * Enable or disable the animations time capture
  51293. */
  51294. captureAnimationsTime: boolean;
  51295. /**
  51296. * Gets the perf counter used for frame time capture
  51297. */
  51298. readonly frameTimeCounter: PerfCounter;
  51299. /**
  51300. * Gets the frame time capture status
  51301. */
  51302. /**
  51303. * Enable or disable the frame time capture
  51304. */
  51305. captureFrameTime: boolean;
  51306. /**
  51307. * Gets the perf counter used for inter-frames time capture
  51308. */
  51309. readonly interFrameTimeCounter: PerfCounter;
  51310. /**
  51311. * Gets the inter-frames time capture status
  51312. */
  51313. /**
  51314. * Enable or disable the inter-frames time capture
  51315. */
  51316. captureInterFrameTime: boolean;
  51317. /**
  51318. * Gets the perf counter used for render time capture
  51319. */
  51320. readonly renderTimeCounter: PerfCounter;
  51321. /**
  51322. * Gets the render time capture status
  51323. */
  51324. /**
  51325. * Enable or disable the render time capture
  51326. */
  51327. captureRenderTime: boolean;
  51328. /**
  51329. * Gets the perf counter used for camera render time capture
  51330. */
  51331. readonly cameraRenderTimeCounter: PerfCounter;
  51332. /**
  51333. * Gets the camera render time capture status
  51334. */
  51335. /**
  51336. * Enable or disable the camera render time capture
  51337. */
  51338. captureCameraRenderTime: boolean;
  51339. /**
  51340. * Gets the perf counter used for draw calls
  51341. */
  51342. readonly drawCallsCounter: PerfCounter;
  51343. /**
  51344. * Instantiates a new scene instrumentation.
  51345. * This class can be used to get instrumentation data from a Babylon engine
  51346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51347. * @param scene Defines the scene to instrument
  51348. */
  51349. constructor(
  51350. /**
  51351. * Defines the scene to instrument
  51352. */
  51353. scene: Scene);
  51354. /**
  51355. * Dispose and release associated resources.
  51356. */
  51357. dispose(): void;
  51358. }
  51359. }
  51360. declare module "babylonjs/Instrumentation/index" {
  51361. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51362. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51363. export * from "babylonjs/Instrumentation/timeToken";
  51364. }
  51365. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51366. /** @hidden */
  51367. export var glowMapGenerationPixelShader: {
  51368. name: string;
  51369. shader: string;
  51370. };
  51371. }
  51372. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51373. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51374. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51376. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51377. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51378. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51379. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51380. /** @hidden */
  51381. export var glowMapGenerationVertexShader: {
  51382. name: string;
  51383. shader: string;
  51384. };
  51385. }
  51386. declare module "babylonjs/Layers/effectLayer" {
  51387. import { Observable } from "babylonjs/Misc/observable";
  51388. import { Nullable } from "babylonjs/types";
  51389. import { Camera } from "babylonjs/Cameras/camera";
  51390. import { Scene } from "babylonjs/scene";
  51391. import { ISize } from "babylonjs/Maths/math.size";
  51392. import { Color4 } from "babylonjs/Maths/math.color";
  51393. import { Engine } from "babylonjs/Engines/engine";
  51394. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51396. import { Mesh } from "babylonjs/Meshes/mesh";
  51397. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51400. import { Effect } from "babylonjs/Materials/effect";
  51401. import { Material } from "babylonjs/Materials/material";
  51402. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51403. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51404. /**
  51405. * Effect layer options. This helps customizing the behaviour
  51406. * of the effect layer.
  51407. */
  51408. export interface IEffectLayerOptions {
  51409. /**
  51410. * Multiplication factor apply to the canvas size to compute the render target size
  51411. * used to generated the objects (the smaller the faster).
  51412. */
  51413. mainTextureRatio: number;
  51414. /**
  51415. * Enforces a fixed size texture to ensure effect stability across devices.
  51416. */
  51417. mainTextureFixedSize?: number;
  51418. /**
  51419. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51420. */
  51421. alphaBlendingMode: number;
  51422. /**
  51423. * The camera attached to the layer.
  51424. */
  51425. camera: Nullable<Camera>;
  51426. /**
  51427. * The rendering group to draw the layer in.
  51428. */
  51429. renderingGroupId: number;
  51430. }
  51431. /**
  51432. * The effect layer Helps adding post process effect blended with the main pass.
  51433. *
  51434. * This can be for instance use to generate glow or higlight effects on the scene.
  51435. *
  51436. * The effect layer class can not be used directly and is intented to inherited from to be
  51437. * customized per effects.
  51438. */
  51439. export abstract class EffectLayer {
  51440. private _vertexBuffers;
  51441. private _indexBuffer;
  51442. private _cachedDefines;
  51443. private _effectLayerMapGenerationEffect;
  51444. private _effectLayerOptions;
  51445. private _mergeEffect;
  51446. protected _scene: Scene;
  51447. protected _engine: Engine;
  51448. protected _maxSize: number;
  51449. protected _mainTextureDesiredSize: ISize;
  51450. protected _mainTexture: RenderTargetTexture;
  51451. protected _shouldRender: boolean;
  51452. protected _postProcesses: PostProcess[];
  51453. protected _textures: BaseTexture[];
  51454. protected _emissiveTextureAndColor: {
  51455. texture: Nullable<BaseTexture>;
  51456. color: Color4;
  51457. };
  51458. /**
  51459. * The name of the layer
  51460. */
  51461. name: string;
  51462. /**
  51463. * The clear color of the texture used to generate the glow map.
  51464. */
  51465. neutralColor: Color4;
  51466. /**
  51467. * Specifies wether the highlight layer is enabled or not.
  51468. */
  51469. isEnabled: boolean;
  51470. /**
  51471. * Gets the camera attached to the layer.
  51472. */
  51473. readonly camera: Nullable<Camera>;
  51474. /**
  51475. * Gets the rendering group id the layer should render in.
  51476. */
  51477. renderingGroupId: number;
  51478. /**
  51479. * An event triggered when the effect layer has been disposed.
  51480. */
  51481. onDisposeObservable: Observable<EffectLayer>;
  51482. /**
  51483. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51484. */
  51485. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51486. /**
  51487. * An event triggered when the generated texture is being merged in the scene.
  51488. */
  51489. onBeforeComposeObservable: Observable<EffectLayer>;
  51490. /**
  51491. * An event triggered when the generated texture has been merged in the scene.
  51492. */
  51493. onAfterComposeObservable: Observable<EffectLayer>;
  51494. /**
  51495. * An event triggered when the efffect layer changes its size.
  51496. */
  51497. onSizeChangedObservable: Observable<EffectLayer>;
  51498. /** @hidden */
  51499. static _SceneComponentInitialization: (scene: Scene) => void;
  51500. /**
  51501. * Instantiates a new effect Layer and references it in the scene.
  51502. * @param name The name of the layer
  51503. * @param scene The scene to use the layer in
  51504. */
  51505. constructor(
  51506. /** The Friendly of the effect in the scene */
  51507. name: string, scene: Scene);
  51508. /**
  51509. * Get the effect name of the layer.
  51510. * @return The effect name
  51511. */
  51512. abstract getEffectName(): string;
  51513. /**
  51514. * Checks for the readiness of the element composing the layer.
  51515. * @param subMesh the mesh to check for
  51516. * @param useInstances specify wether or not to use instances to render the mesh
  51517. * @return true if ready otherwise, false
  51518. */
  51519. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51520. /**
  51521. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51522. * @returns true if the effect requires stencil during the main canvas render pass.
  51523. */
  51524. abstract needStencil(): boolean;
  51525. /**
  51526. * Create the merge effect. This is the shader use to blit the information back
  51527. * to the main canvas at the end of the scene rendering.
  51528. * @returns The effect containing the shader used to merge the effect on the main canvas
  51529. */
  51530. protected abstract _createMergeEffect(): Effect;
  51531. /**
  51532. * Creates the render target textures and post processes used in the effect layer.
  51533. */
  51534. protected abstract _createTextureAndPostProcesses(): void;
  51535. /**
  51536. * Implementation specific of rendering the generating effect on the main canvas.
  51537. * @param effect The effect used to render through
  51538. */
  51539. protected abstract _internalRender(effect: Effect): void;
  51540. /**
  51541. * Sets the required values for both the emissive texture and and the main color.
  51542. */
  51543. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51544. /**
  51545. * Free any resources and references associated to a mesh.
  51546. * Internal use
  51547. * @param mesh The mesh to free.
  51548. */
  51549. abstract _disposeMesh(mesh: Mesh): void;
  51550. /**
  51551. * Serializes this layer (Glow or Highlight for example)
  51552. * @returns a serialized layer object
  51553. */
  51554. abstract serialize?(): any;
  51555. /**
  51556. * Initializes the effect layer with the required options.
  51557. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51558. */
  51559. protected _init(options: Partial<IEffectLayerOptions>): void;
  51560. /**
  51561. * Generates the index buffer of the full screen quad blending to the main canvas.
  51562. */
  51563. private _generateIndexBuffer;
  51564. /**
  51565. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51566. */
  51567. private _generateVertexBuffer;
  51568. /**
  51569. * Sets the main texture desired size which is the closest power of two
  51570. * of the engine canvas size.
  51571. */
  51572. private _setMainTextureSize;
  51573. /**
  51574. * Creates the main texture for the effect layer.
  51575. */
  51576. protected _createMainTexture(): void;
  51577. /**
  51578. * Adds specific effects defines.
  51579. * @param defines The defines to add specifics to.
  51580. */
  51581. protected _addCustomEffectDefines(defines: string[]): void;
  51582. /**
  51583. * Checks for the readiness of the element composing the layer.
  51584. * @param subMesh the mesh to check for
  51585. * @param useInstances specify wether or not to use instances to render the mesh
  51586. * @param emissiveTexture the associated emissive texture used to generate the glow
  51587. * @return true if ready otherwise, false
  51588. */
  51589. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51590. /**
  51591. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51592. */
  51593. render(): void;
  51594. /**
  51595. * Determine if a given mesh will be used in the current effect.
  51596. * @param mesh mesh to test
  51597. * @returns true if the mesh will be used
  51598. */
  51599. hasMesh(mesh: AbstractMesh): boolean;
  51600. /**
  51601. * Returns true if the layer contains information to display, otherwise false.
  51602. * @returns true if the glow layer should be rendered
  51603. */
  51604. shouldRender(): boolean;
  51605. /**
  51606. * Returns true if the mesh should render, otherwise false.
  51607. * @param mesh The mesh to render
  51608. * @returns true if it should render otherwise false
  51609. */
  51610. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51611. /**
  51612. * Returns true if the mesh can be rendered, otherwise false.
  51613. * @param mesh The mesh to render
  51614. * @param material The material used on the mesh
  51615. * @returns true if it can be rendered otherwise false
  51616. */
  51617. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51618. /**
  51619. * Returns true if the mesh should render, otherwise false.
  51620. * @param mesh The mesh to render
  51621. * @returns true if it should render otherwise false
  51622. */
  51623. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51624. /**
  51625. * Renders the submesh passed in parameter to the generation map.
  51626. */
  51627. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51628. /**
  51629. * Rebuild the required buffers.
  51630. * @hidden Internal use only.
  51631. */
  51632. _rebuild(): void;
  51633. /**
  51634. * Dispose only the render target textures and post process.
  51635. */
  51636. private _disposeTextureAndPostProcesses;
  51637. /**
  51638. * Dispose the highlight layer and free resources.
  51639. */
  51640. dispose(): void;
  51641. /**
  51642. * Gets the class name of the effect layer
  51643. * @returns the string with the class name of the effect layer
  51644. */
  51645. getClassName(): string;
  51646. /**
  51647. * Creates an effect layer from parsed effect layer data
  51648. * @param parsedEffectLayer defines effect layer data
  51649. * @param scene defines the current scene
  51650. * @param rootUrl defines the root URL containing the effect layer information
  51651. * @returns a parsed effect Layer
  51652. */
  51653. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51654. }
  51655. }
  51656. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51657. import { Scene } from "babylonjs/scene";
  51658. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51659. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51660. import { AbstractScene } from "babylonjs/abstractScene";
  51661. module "babylonjs/abstractScene" {
  51662. interface AbstractScene {
  51663. /**
  51664. * The list of effect layers (highlights/glow) added to the scene
  51665. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51666. * @see http://doc.babylonjs.com/how_to/glow_layer
  51667. */
  51668. effectLayers: Array<EffectLayer>;
  51669. /**
  51670. * Removes the given effect layer from this scene.
  51671. * @param toRemove defines the effect layer to remove
  51672. * @returns the index of the removed effect layer
  51673. */
  51674. removeEffectLayer(toRemove: EffectLayer): number;
  51675. /**
  51676. * Adds the given effect layer to this scene
  51677. * @param newEffectLayer defines the effect layer to add
  51678. */
  51679. addEffectLayer(newEffectLayer: EffectLayer): void;
  51680. }
  51681. }
  51682. /**
  51683. * Defines the layer scene component responsible to manage any effect layers
  51684. * in a given scene.
  51685. */
  51686. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51687. /**
  51688. * The component name helpfull to identify the component in the list of scene components.
  51689. */
  51690. readonly name: string;
  51691. /**
  51692. * The scene the component belongs to.
  51693. */
  51694. scene: Scene;
  51695. private _engine;
  51696. private _renderEffects;
  51697. private _needStencil;
  51698. private _previousStencilState;
  51699. /**
  51700. * Creates a new instance of the component for the given scene
  51701. * @param scene Defines the scene to register the component in
  51702. */
  51703. constructor(scene: Scene);
  51704. /**
  51705. * Registers the component in a given scene
  51706. */
  51707. register(): void;
  51708. /**
  51709. * Rebuilds the elements related to this component in case of
  51710. * context lost for instance.
  51711. */
  51712. rebuild(): void;
  51713. /**
  51714. * Serializes the component data to the specified json object
  51715. * @param serializationObject The object to serialize to
  51716. */
  51717. serialize(serializationObject: any): void;
  51718. /**
  51719. * Adds all the elements from the container to the scene
  51720. * @param container the container holding the elements
  51721. */
  51722. addFromContainer(container: AbstractScene): void;
  51723. /**
  51724. * Removes all the elements in the container from the scene
  51725. * @param container contains the elements to remove
  51726. * @param dispose if the removed element should be disposed (default: false)
  51727. */
  51728. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51729. /**
  51730. * Disposes the component and the associated ressources.
  51731. */
  51732. dispose(): void;
  51733. private _isReadyForMesh;
  51734. private _renderMainTexture;
  51735. private _setStencil;
  51736. private _setStencilBack;
  51737. private _draw;
  51738. private _drawCamera;
  51739. private _drawRenderingGroup;
  51740. }
  51741. }
  51742. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51743. /** @hidden */
  51744. export var glowMapMergePixelShader: {
  51745. name: string;
  51746. shader: string;
  51747. };
  51748. }
  51749. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51750. /** @hidden */
  51751. export var glowMapMergeVertexShader: {
  51752. name: string;
  51753. shader: string;
  51754. };
  51755. }
  51756. declare module "babylonjs/Layers/glowLayer" {
  51757. import { Nullable } from "babylonjs/types";
  51758. import { Camera } from "babylonjs/Cameras/camera";
  51759. import { Scene } from "babylonjs/scene";
  51760. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51762. import { Mesh } from "babylonjs/Meshes/mesh";
  51763. import { Texture } from "babylonjs/Materials/Textures/texture";
  51764. import { Effect } from "babylonjs/Materials/effect";
  51765. import { Material } from "babylonjs/Materials/material";
  51766. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51767. import { Color4 } from "babylonjs/Maths/math.color";
  51768. import "babylonjs/Shaders/glowMapMerge.fragment";
  51769. import "babylonjs/Shaders/glowMapMerge.vertex";
  51770. import "babylonjs/Layers/effectLayerSceneComponent";
  51771. module "babylonjs/abstractScene" {
  51772. interface AbstractScene {
  51773. /**
  51774. * Return a the first highlight layer of the scene with a given name.
  51775. * @param name The name of the highlight layer to look for.
  51776. * @return The highlight layer if found otherwise null.
  51777. */
  51778. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51779. }
  51780. }
  51781. /**
  51782. * Glow layer options. This helps customizing the behaviour
  51783. * of the glow layer.
  51784. */
  51785. export interface IGlowLayerOptions {
  51786. /**
  51787. * Multiplication factor apply to the canvas size to compute the render target size
  51788. * used to generated the glowing objects (the smaller the faster).
  51789. */
  51790. mainTextureRatio: number;
  51791. /**
  51792. * Enforces a fixed size texture to ensure resize independant blur.
  51793. */
  51794. mainTextureFixedSize?: number;
  51795. /**
  51796. * How big is the kernel of the blur texture.
  51797. */
  51798. blurKernelSize: number;
  51799. /**
  51800. * The camera attached to the layer.
  51801. */
  51802. camera: Nullable<Camera>;
  51803. /**
  51804. * Enable MSAA by chosing the number of samples.
  51805. */
  51806. mainTextureSamples?: number;
  51807. /**
  51808. * The rendering group to draw the layer in.
  51809. */
  51810. renderingGroupId: number;
  51811. }
  51812. /**
  51813. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51814. *
  51815. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51816. * glowy meshes to your scene.
  51817. *
  51818. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51819. */
  51820. export class GlowLayer extends EffectLayer {
  51821. /**
  51822. * Effect Name of the layer.
  51823. */
  51824. static readonly EffectName: string;
  51825. /**
  51826. * The default blur kernel size used for the glow.
  51827. */
  51828. static DefaultBlurKernelSize: number;
  51829. /**
  51830. * The default texture size ratio used for the glow.
  51831. */
  51832. static DefaultTextureRatio: number;
  51833. /**
  51834. * Sets the kernel size of the blur.
  51835. */
  51836. /**
  51837. * Gets the kernel size of the blur.
  51838. */
  51839. blurKernelSize: number;
  51840. /**
  51841. * Sets the glow intensity.
  51842. */
  51843. /**
  51844. * Gets the glow intensity.
  51845. */
  51846. intensity: number;
  51847. private _options;
  51848. private _intensity;
  51849. private _horizontalBlurPostprocess1;
  51850. private _verticalBlurPostprocess1;
  51851. private _horizontalBlurPostprocess2;
  51852. private _verticalBlurPostprocess2;
  51853. private _blurTexture1;
  51854. private _blurTexture2;
  51855. private _postProcesses1;
  51856. private _postProcesses2;
  51857. private _includedOnlyMeshes;
  51858. private _excludedMeshes;
  51859. /**
  51860. * Callback used to let the user override the color selection on a per mesh basis
  51861. */
  51862. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51863. /**
  51864. * Callback used to let the user override the texture selection on a per mesh basis
  51865. */
  51866. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51867. /**
  51868. * Instantiates a new glow Layer and references it to the scene.
  51869. * @param name The name of the layer
  51870. * @param scene The scene to use the layer in
  51871. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51872. */
  51873. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51874. /**
  51875. * Get the effect name of the layer.
  51876. * @return The effect name
  51877. */
  51878. getEffectName(): string;
  51879. /**
  51880. * Create the merge effect. This is the shader use to blit the information back
  51881. * to the main canvas at the end of the scene rendering.
  51882. */
  51883. protected _createMergeEffect(): Effect;
  51884. /**
  51885. * Creates the render target textures and post processes used in the glow layer.
  51886. */
  51887. protected _createTextureAndPostProcesses(): void;
  51888. /**
  51889. * Checks for the readiness of the element composing the layer.
  51890. * @param subMesh the mesh to check for
  51891. * @param useInstances specify wether or not to use instances to render the mesh
  51892. * @param emissiveTexture the associated emissive texture used to generate the glow
  51893. * @return true if ready otherwise, false
  51894. */
  51895. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51896. /**
  51897. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51898. */
  51899. needStencil(): boolean;
  51900. /**
  51901. * Returns true if the mesh can be rendered, otherwise false.
  51902. * @param mesh The mesh to render
  51903. * @param material The material used on the mesh
  51904. * @returns true if it can be rendered otherwise false
  51905. */
  51906. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51907. /**
  51908. * Implementation specific of rendering the generating effect on the main canvas.
  51909. * @param effect The effect used to render through
  51910. */
  51911. protected _internalRender(effect: Effect): void;
  51912. /**
  51913. * Sets the required values for both the emissive texture and and the main color.
  51914. */
  51915. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51916. /**
  51917. * Returns true if the mesh should render, otherwise false.
  51918. * @param mesh The mesh to render
  51919. * @returns true if it should render otherwise false
  51920. */
  51921. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51922. /**
  51923. * Adds specific effects defines.
  51924. * @param defines The defines to add specifics to.
  51925. */
  51926. protected _addCustomEffectDefines(defines: string[]): void;
  51927. /**
  51928. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51929. * @param mesh The mesh to exclude from the glow layer
  51930. */
  51931. addExcludedMesh(mesh: Mesh): void;
  51932. /**
  51933. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51934. * @param mesh The mesh to remove
  51935. */
  51936. removeExcludedMesh(mesh: Mesh): void;
  51937. /**
  51938. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51939. * @param mesh The mesh to include in the glow layer
  51940. */
  51941. addIncludedOnlyMesh(mesh: Mesh): void;
  51942. /**
  51943. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51944. * @param mesh The mesh to remove
  51945. */
  51946. removeIncludedOnlyMesh(mesh: Mesh): void;
  51947. /**
  51948. * Determine if a given mesh will be used in the glow layer
  51949. * @param mesh The mesh to test
  51950. * @returns true if the mesh will be highlighted by the current glow layer
  51951. */
  51952. hasMesh(mesh: AbstractMesh): boolean;
  51953. /**
  51954. * Free any resources and references associated to a mesh.
  51955. * Internal use
  51956. * @param mesh The mesh to free.
  51957. * @hidden
  51958. */
  51959. _disposeMesh(mesh: Mesh): void;
  51960. /**
  51961. * Gets the class name of the effect layer
  51962. * @returns the string with the class name of the effect layer
  51963. */
  51964. getClassName(): string;
  51965. /**
  51966. * Serializes this glow layer
  51967. * @returns a serialized glow layer object
  51968. */
  51969. serialize(): any;
  51970. /**
  51971. * Creates a Glow Layer from parsed glow layer data
  51972. * @param parsedGlowLayer defines glow layer data
  51973. * @param scene defines the current scene
  51974. * @param rootUrl defines the root URL containing the glow layer information
  51975. * @returns a parsed Glow Layer
  51976. */
  51977. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51978. }
  51979. }
  51980. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51981. /** @hidden */
  51982. export var glowBlurPostProcessPixelShader: {
  51983. name: string;
  51984. shader: string;
  51985. };
  51986. }
  51987. declare module "babylonjs/Layers/highlightLayer" {
  51988. import { Observable } from "babylonjs/Misc/observable";
  51989. import { Nullable } from "babylonjs/types";
  51990. import { Camera } from "babylonjs/Cameras/camera";
  51991. import { Scene } from "babylonjs/scene";
  51992. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51994. import { Mesh } from "babylonjs/Meshes/mesh";
  51995. import { Effect } from "babylonjs/Materials/effect";
  51996. import { Material } from "babylonjs/Materials/material";
  51997. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51998. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51999. import "babylonjs/Shaders/glowMapMerge.fragment";
  52000. import "babylonjs/Shaders/glowMapMerge.vertex";
  52001. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52002. module "babylonjs/abstractScene" {
  52003. interface AbstractScene {
  52004. /**
  52005. * Return a the first highlight layer of the scene with a given name.
  52006. * @param name The name of the highlight layer to look for.
  52007. * @return The highlight layer if found otherwise null.
  52008. */
  52009. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52010. }
  52011. }
  52012. /**
  52013. * Highlight layer options. This helps customizing the behaviour
  52014. * of the highlight layer.
  52015. */
  52016. export interface IHighlightLayerOptions {
  52017. /**
  52018. * Multiplication factor apply to the canvas size to compute the render target size
  52019. * used to generated the glowing objects (the smaller the faster).
  52020. */
  52021. mainTextureRatio: number;
  52022. /**
  52023. * Enforces a fixed size texture to ensure resize independant blur.
  52024. */
  52025. mainTextureFixedSize?: number;
  52026. /**
  52027. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52028. * of the picture to blur (the smaller the faster).
  52029. */
  52030. blurTextureSizeRatio: number;
  52031. /**
  52032. * How big in texel of the blur texture is the vertical blur.
  52033. */
  52034. blurVerticalSize: number;
  52035. /**
  52036. * How big in texel of the blur texture is the horizontal blur.
  52037. */
  52038. blurHorizontalSize: number;
  52039. /**
  52040. * Alpha blending mode used to apply the blur. Default is combine.
  52041. */
  52042. alphaBlendingMode: number;
  52043. /**
  52044. * The camera attached to the layer.
  52045. */
  52046. camera: Nullable<Camera>;
  52047. /**
  52048. * Should we display highlight as a solid stroke?
  52049. */
  52050. isStroke?: boolean;
  52051. /**
  52052. * The rendering group to draw the layer in.
  52053. */
  52054. renderingGroupId: number;
  52055. }
  52056. /**
  52057. * The highlight layer Helps adding a glow effect around a mesh.
  52058. *
  52059. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52060. * glowy meshes to your scene.
  52061. *
  52062. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52063. */
  52064. export class HighlightLayer extends EffectLayer {
  52065. name: string;
  52066. /**
  52067. * Effect Name of the highlight layer.
  52068. */
  52069. static readonly EffectName: string;
  52070. /**
  52071. * The neutral color used during the preparation of the glow effect.
  52072. * This is black by default as the blend operation is a blend operation.
  52073. */
  52074. static NeutralColor: Color4;
  52075. /**
  52076. * Stencil value used for glowing meshes.
  52077. */
  52078. static GlowingMeshStencilReference: number;
  52079. /**
  52080. * Stencil value used for the other meshes in the scene.
  52081. */
  52082. static NormalMeshStencilReference: number;
  52083. /**
  52084. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52085. */
  52086. innerGlow: boolean;
  52087. /**
  52088. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52089. */
  52090. outerGlow: boolean;
  52091. /**
  52092. * Specifies the horizontal size of the blur.
  52093. */
  52094. /**
  52095. * Gets the horizontal size of the blur.
  52096. */
  52097. blurHorizontalSize: number;
  52098. /**
  52099. * Specifies the vertical size of the blur.
  52100. */
  52101. /**
  52102. * Gets the vertical size of the blur.
  52103. */
  52104. blurVerticalSize: number;
  52105. /**
  52106. * An event triggered when the highlight layer is being blurred.
  52107. */
  52108. onBeforeBlurObservable: Observable<HighlightLayer>;
  52109. /**
  52110. * An event triggered when the highlight layer has been blurred.
  52111. */
  52112. onAfterBlurObservable: Observable<HighlightLayer>;
  52113. private _instanceGlowingMeshStencilReference;
  52114. private _options;
  52115. private _downSamplePostprocess;
  52116. private _horizontalBlurPostprocess;
  52117. private _verticalBlurPostprocess;
  52118. private _blurTexture;
  52119. private _meshes;
  52120. private _excludedMeshes;
  52121. /**
  52122. * Instantiates a new highlight Layer and references it to the scene..
  52123. * @param name The name of the layer
  52124. * @param scene The scene to use the layer in
  52125. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52126. */
  52127. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52128. /**
  52129. * Get the effect name of the layer.
  52130. * @return The effect name
  52131. */
  52132. getEffectName(): string;
  52133. /**
  52134. * Create the merge effect. This is the shader use to blit the information back
  52135. * to the main canvas at the end of the scene rendering.
  52136. */
  52137. protected _createMergeEffect(): Effect;
  52138. /**
  52139. * Creates the render target textures and post processes used in the highlight layer.
  52140. */
  52141. protected _createTextureAndPostProcesses(): void;
  52142. /**
  52143. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52144. */
  52145. needStencil(): boolean;
  52146. /**
  52147. * Checks for the readiness of the element composing the layer.
  52148. * @param subMesh the mesh to check for
  52149. * @param useInstances specify wether or not to use instances to render the mesh
  52150. * @param emissiveTexture the associated emissive texture used to generate the glow
  52151. * @return true if ready otherwise, false
  52152. */
  52153. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52154. /**
  52155. * Implementation specific of rendering the generating effect on the main canvas.
  52156. * @param effect The effect used to render through
  52157. */
  52158. protected _internalRender(effect: Effect): void;
  52159. /**
  52160. * Returns true if the layer contains information to display, otherwise false.
  52161. */
  52162. shouldRender(): boolean;
  52163. /**
  52164. * Returns true if the mesh should render, otherwise false.
  52165. * @param mesh The mesh to render
  52166. * @returns true if it should render otherwise false
  52167. */
  52168. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52169. /**
  52170. * Sets the required values for both the emissive texture and and the main color.
  52171. */
  52172. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52173. /**
  52174. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52175. * @param mesh The mesh to exclude from the highlight layer
  52176. */
  52177. addExcludedMesh(mesh: Mesh): void;
  52178. /**
  52179. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52180. * @param mesh The mesh to highlight
  52181. */
  52182. removeExcludedMesh(mesh: Mesh): void;
  52183. /**
  52184. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52185. * @param mesh mesh to test
  52186. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52187. */
  52188. hasMesh(mesh: AbstractMesh): boolean;
  52189. /**
  52190. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52191. * @param mesh The mesh to highlight
  52192. * @param color The color of the highlight
  52193. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52194. */
  52195. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52196. /**
  52197. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52198. * @param mesh The mesh to highlight
  52199. */
  52200. removeMesh(mesh: Mesh): void;
  52201. /**
  52202. * Force the stencil to the normal expected value for none glowing parts
  52203. */
  52204. private _defaultStencilReference;
  52205. /**
  52206. * Free any resources and references associated to a mesh.
  52207. * Internal use
  52208. * @param mesh The mesh to free.
  52209. * @hidden
  52210. */
  52211. _disposeMesh(mesh: Mesh): void;
  52212. /**
  52213. * Dispose the highlight layer and free resources.
  52214. */
  52215. dispose(): void;
  52216. /**
  52217. * Gets the class name of the effect layer
  52218. * @returns the string with the class name of the effect layer
  52219. */
  52220. getClassName(): string;
  52221. /**
  52222. * Serializes this Highlight layer
  52223. * @returns a serialized Highlight layer object
  52224. */
  52225. serialize(): any;
  52226. /**
  52227. * Creates a Highlight layer from parsed Highlight layer data
  52228. * @param parsedHightlightLayer defines the Highlight layer data
  52229. * @param scene defines the current scene
  52230. * @param rootUrl defines the root URL containing the Highlight layer information
  52231. * @returns a parsed Highlight layer
  52232. */
  52233. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52234. }
  52235. }
  52236. declare module "babylonjs/Layers/layerSceneComponent" {
  52237. import { Scene } from "babylonjs/scene";
  52238. import { ISceneComponent } from "babylonjs/sceneComponent";
  52239. import { Layer } from "babylonjs/Layers/layer";
  52240. import { AbstractScene } from "babylonjs/abstractScene";
  52241. module "babylonjs/abstractScene" {
  52242. interface AbstractScene {
  52243. /**
  52244. * The list of layers (background and foreground) of the scene
  52245. */
  52246. layers: Array<Layer>;
  52247. }
  52248. }
  52249. /**
  52250. * Defines the layer scene component responsible to manage any layers
  52251. * in a given scene.
  52252. */
  52253. export class LayerSceneComponent implements ISceneComponent {
  52254. /**
  52255. * The component name helpfull to identify the component in the list of scene components.
  52256. */
  52257. readonly name: string;
  52258. /**
  52259. * The scene the component belongs to.
  52260. */
  52261. scene: Scene;
  52262. private _engine;
  52263. /**
  52264. * Creates a new instance of the component for the given scene
  52265. * @param scene Defines the scene to register the component in
  52266. */
  52267. constructor(scene: Scene);
  52268. /**
  52269. * Registers the component in a given scene
  52270. */
  52271. register(): void;
  52272. /**
  52273. * Rebuilds the elements related to this component in case of
  52274. * context lost for instance.
  52275. */
  52276. rebuild(): void;
  52277. /**
  52278. * Disposes the component and the associated ressources.
  52279. */
  52280. dispose(): void;
  52281. private _draw;
  52282. private _drawCameraPredicate;
  52283. private _drawCameraBackground;
  52284. private _drawCameraForeground;
  52285. private _drawRenderTargetPredicate;
  52286. private _drawRenderTargetBackground;
  52287. private _drawRenderTargetForeground;
  52288. /**
  52289. * Adds all the elements from the container to the scene
  52290. * @param container the container holding the elements
  52291. */
  52292. addFromContainer(container: AbstractScene): void;
  52293. /**
  52294. * Removes all the elements in the container from the scene
  52295. * @param container contains the elements to remove
  52296. * @param dispose if the removed element should be disposed (default: false)
  52297. */
  52298. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52299. }
  52300. }
  52301. declare module "babylonjs/Shaders/layer.fragment" {
  52302. /** @hidden */
  52303. export var layerPixelShader: {
  52304. name: string;
  52305. shader: string;
  52306. };
  52307. }
  52308. declare module "babylonjs/Shaders/layer.vertex" {
  52309. /** @hidden */
  52310. export var layerVertexShader: {
  52311. name: string;
  52312. shader: string;
  52313. };
  52314. }
  52315. declare module "babylonjs/Layers/layer" {
  52316. import { Observable } from "babylonjs/Misc/observable";
  52317. import { Nullable } from "babylonjs/types";
  52318. import { Scene } from "babylonjs/scene";
  52319. import { Vector2 } from "babylonjs/Maths/math.vector";
  52320. import { Color4 } from "babylonjs/Maths/math.color";
  52321. import { Texture } from "babylonjs/Materials/Textures/texture";
  52322. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52323. import "babylonjs/Shaders/layer.fragment";
  52324. import "babylonjs/Shaders/layer.vertex";
  52325. /**
  52326. * This represents a full screen 2d layer.
  52327. * This can be useful to display a picture in the background of your scene for instance.
  52328. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52329. */
  52330. export class Layer {
  52331. /**
  52332. * Define the name of the layer.
  52333. */
  52334. name: string;
  52335. /**
  52336. * Define the texture the layer should display.
  52337. */
  52338. texture: Nullable<Texture>;
  52339. /**
  52340. * Is the layer in background or foreground.
  52341. */
  52342. isBackground: boolean;
  52343. /**
  52344. * Define the color of the layer (instead of texture).
  52345. */
  52346. color: Color4;
  52347. /**
  52348. * Define the scale of the layer in order to zoom in out of the texture.
  52349. */
  52350. scale: Vector2;
  52351. /**
  52352. * Define an offset for the layer in order to shift the texture.
  52353. */
  52354. offset: Vector2;
  52355. /**
  52356. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52357. */
  52358. alphaBlendingMode: number;
  52359. /**
  52360. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52361. * Alpha test will not mix with the background color in case of transparency.
  52362. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52363. */
  52364. alphaTest: boolean;
  52365. /**
  52366. * Define a mask to restrict the layer to only some of the scene cameras.
  52367. */
  52368. layerMask: number;
  52369. /**
  52370. * Define the list of render target the layer is visible into.
  52371. */
  52372. renderTargetTextures: RenderTargetTexture[];
  52373. /**
  52374. * Define if the layer is only used in renderTarget or if it also
  52375. * renders in the main frame buffer of the canvas.
  52376. */
  52377. renderOnlyInRenderTargetTextures: boolean;
  52378. private _scene;
  52379. private _vertexBuffers;
  52380. private _indexBuffer;
  52381. private _effect;
  52382. private _alphaTestEffect;
  52383. /**
  52384. * An event triggered when the layer is disposed.
  52385. */
  52386. onDisposeObservable: Observable<Layer>;
  52387. private _onDisposeObserver;
  52388. /**
  52389. * Back compatibility with callback before the onDisposeObservable existed.
  52390. * The set callback will be triggered when the layer has been disposed.
  52391. */
  52392. onDispose: () => void;
  52393. /**
  52394. * An event triggered before rendering the scene
  52395. */
  52396. onBeforeRenderObservable: Observable<Layer>;
  52397. private _onBeforeRenderObserver;
  52398. /**
  52399. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52400. * The set callback will be triggered just before rendering the layer.
  52401. */
  52402. onBeforeRender: () => void;
  52403. /**
  52404. * An event triggered after rendering the scene
  52405. */
  52406. onAfterRenderObservable: Observable<Layer>;
  52407. private _onAfterRenderObserver;
  52408. /**
  52409. * Back compatibility with callback before the onAfterRenderObservable existed.
  52410. * The set callback will be triggered just after rendering the layer.
  52411. */
  52412. onAfterRender: () => void;
  52413. /**
  52414. * Instantiates a new layer.
  52415. * This represents a full screen 2d layer.
  52416. * This can be useful to display a picture in the background of your scene for instance.
  52417. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52418. * @param name Define the name of the layer in the scene
  52419. * @param imgUrl Define the url of the texture to display in the layer
  52420. * @param scene Define the scene the layer belongs to
  52421. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52422. * @param color Defines a color for the layer
  52423. */
  52424. constructor(
  52425. /**
  52426. * Define the name of the layer.
  52427. */
  52428. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52429. private _createIndexBuffer;
  52430. /** @hidden */
  52431. _rebuild(): void;
  52432. /**
  52433. * Renders the layer in the scene.
  52434. */
  52435. render(): void;
  52436. /**
  52437. * Disposes and releases the associated ressources.
  52438. */
  52439. dispose(): void;
  52440. }
  52441. }
  52442. declare module "babylonjs/Layers/index" {
  52443. export * from "babylonjs/Layers/effectLayer";
  52444. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52445. export * from "babylonjs/Layers/glowLayer";
  52446. export * from "babylonjs/Layers/highlightLayer";
  52447. export * from "babylonjs/Layers/layer";
  52448. export * from "babylonjs/Layers/layerSceneComponent";
  52449. }
  52450. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52451. /** @hidden */
  52452. export var lensFlarePixelShader: {
  52453. name: string;
  52454. shader: string;
  52455. };
  52456. }
  52457. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52458. /** @hidden */
  52459. export var lensFlareVertexShader: {
  52460. name: string;
  52461. shader: string;
  52462. };
  52463. }
  52464. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52465. import { Scene } from "babylonjs/scene";
  52466. import { Vector3 } from "babylonjs/Maths/math.vector";
  52467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52468. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52469. import "babylonjs/Shaders/lensFlare.fragment";
  52470. import "babylonjs/Shaders/lensFlare.vertex";
  52471. import { Viewport } from "babylonjs/Maths/math.viewport";
  52472. /**
  52473. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52474. * It is usually composed of several `lensFlare`.
  52475. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52476. */
  52477. export class LensFlareSystem {
  52478. /**
  52479. * Define the name of the lens flare system
  52480. */
  52481. name: string;
  52482. /**
  52483. * List of lens flares used in this system.
  52484. */
  52485. lensFlares: LensFlare[];
  52486. /**
  52487. * Define a limit from the border the lens flare can be visible.
  52488. */
  52489. borderLimit: number;
  52490. /**
  52491. * Define a viewport border we do not want to see the lens flare in.
  52492. */
  52493. viewportBorder: number;
  52494. /**
  52495. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52496. */
  52497. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52498. /**
  52499. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52500. */
  52501. layerMask: number;
  52502. /**
  52503. * Define the id of the lens flare system in the scene.
  52504. * (equal to name by default)
  52505. */
  52506. id: string;
  52507. private _scene;
  52508. private _emitter;
  52509. private _vertexBuffers;
  52510. private _indexBuffer;
  52511. private _effect;
  52512. private _positionX;
  52513. private _positionY;
  52514. private _isEnabled;
  52515. /** @hidden */
  52516. static _SceneComponentInitialization: (scene: Scene) => void;
  52517. /**
  52518. * Instantiates a lens flare system.
  52519. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52520. * It is usually composed of several `lensFlare`.
  52521. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52522. * @param name Define the name of the lens flare system in the scene
  52523. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52524. * @param scene Define the scene the lens flare system belongs to
  52525. */
  52526. constructor(
  52527. /**
  52528. * Define the name of the lens flare system
  52529. */
  52530. name: string, emitter: any, scene: Scene);
  52531. /**
  52532. * Define if the lens flare system is enabled.
  52533. */
  52534. isEnabled: boolean;
  52535. /**
  52536. * Get the scene the effects belongs to.
  52537. * @returns the scene holding the lens flare system
  52538. */
  52539. getScene(): Scene;
  52540. /**
  52541. * Get the emitter of the lens flare system.
  52542. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52543. * @returns the emitter of the lens flare system
  52544. */
  52545. getEmitter(): any;
  52546. /**
  52547. * Set the emitter of the lens flare system.
  52548. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52549. * @param newEmitter Define the new emitter of the system
  52550. */
  52551. setEmitter(newEmitter: any): void;
  52552. /**
  52553. * Get the lens flare system emitter position.
  52554. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52555. * @returns the position
  52556. */
  52557. getEmitterPosition(): Vector3;
  52558. /**
  52559. * @hidden
  52560. */
  52561. computeEffectivePosition(globalViewport: Viewport): boolean;
  52562. /** @hidden */
  52563. _isVisible(): boolean;
  52564. /**
  52565. * @hidden
  52566. */
  52567. render(): boolean;
  52568. /**
  52569. * Dispose and release the lens flare with its associated resources.
  52570. */
  52571. dispose(): void;
  52572. /**
  52573. * Parse a lens flare system from a JSON repressentation
  52574. * @param parsedLensFlareSystem Define the JSON to parse
  52575. * @param scene Define the scene the parsed system should be instantiated in
  52576. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52577. * @returns the parsed system
  52578. */
  52579. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52580. /**
  52581. * Serialize the current Lens Flare System into a JSON representation.
  52582. * @returns the serialized JSON
  52583. */
  52584. serialize(): any;
  52585. }
  52586. }
  52587. declare module "babylonjs/LensFlares/lensFlare" {
  52588. import { Nullable } from "babylonjs/types";
  52589. import { Color3 } from "babylonjs/Maths/math.color";
  52590. import { Texture } from "babylonjs/Materials/Textures/texture";
  52591. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52592. /**
  52593. * This represents one of the lens effect in a `lensFlareSystem`.
  52594. * It controls one of the indiviual texture used in the effect.
  52595. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52596. */
  52597. export class LensFlare {
  52598. /**
  52599. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52600. */
  52601. size: number;
  52602. /**
  52603. * 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.
  52604. */
  52605. position: number;
  52606. /**
  52607. * Define the lens color.
  52608. */
  52609. color: Color3;
  52610. /**
  52611. * Define the lens texture.
  52612. */
  52613. texture: Nullable<Texture>;
  52614. /**
  52615. * Define the alpha mode to render this particular lens.
  52616. */
  52617. alphaMode: number;
  52618. private _system;
  52619. /**
  52620. * Creates a new Lens Flare.
  52621. * This represents one of the lens effect in a `lensFlareSystem`.
  52622. * It controls one of the indiviual texture used in the effect.
  52623. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52624. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52625. * @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.
  52626. * @param color Define the lens color
  52627. * @param imgUrl Define the lens texture url
  52628. * @param system Define the `lensFlareSystem` this flare is part of
  52629. * @returns The newly created Lens Flare
  52630. */
  52631. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52632. /**
  52633. * Instantiates a new Lens Flare.
  52634. * This represents one of the lens effect in a `lensFlareSystem`.
  52635. * It controls one of the indiviual texture used in the effect.
  52636. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52637. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52638. * @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.
  52639. * @param color Define the lens color
  52640. * @param imgUrl Define the lens texture url
  52641. * @param system Define the `lensFlareSystem` this flare is part of
  52642. */
  52643. constructor(
  52644. /**
  52645. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52646. */
  52647. size: number,
  52648. /**
  52649. * 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.
  52650. */
  52651. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52652. /**
  52653. * Dispose and release the lens flare with its associated resources.
  52654. */
  52655. dispose(): void;
  52656. }
  52657. }
  52658. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52659. import { Nullable } from "babylonjs/types";
  52660. import { Scene } from "babylonjs/scene";
  52661. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52662. import { AbstractScene } from "babylonjs/abstractScene";
  52663. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52664. module "babylonjs/abstractScene" {
  52665. interface AbstractScene {
  52666. /**
  52667. * The list of lens flare system added to the scene
  52668. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52669. */
  52670. lensFlareSystems: Array<LensFlareSystem>;
  52671. /**
  52672. * Removes the given lens flare system from this scene.
  52673. * @param toRemove The lens flare system to remove
  52674. * @returns The index of the removed lens flare system
  52675. */
  52676. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52677. /**
  52678. * Adds the given lens flare system to this scene
  52679. * @param newLensFlareSystem The lens flare system to add
  52680. */
  52681. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52682. /**
  52683. * Gets a lens flare system using its name
  52684. * @param name defines the name to look for
  52685. * @returns the lens flare system or null if not found
  52686. */
  52687. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52688. /**
  52689. * Gets a lens flare system using its id
  52690. * @param id defines the id to look for
  52691. * @returns the lens flare system or null if not found
  52692. */
  52693. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52694. }
  52695. }
  52696. /**
  52697. * Defines the lens flare scene component responsible to manage any lens flares
  52698. * in a given scene.
  52699. */
  52700. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52701. /**
  52702. * The component name helpfull to identify the component in the list of scene components.
  52703. */
  52704. readonly name: string;
  52705. /**
  52706. * The scene the component belongs to.
  52707. */
  52708. scene: Scene;
  52709. /**
  52710. * Creates a new instance of the component for the given scene
  52711. * @param scene Defines the scene to register the component in
  52712. */
  52713. constructor(scene: Scene);
  52714. /**
  52715. * Registers the component in a given scene
  52716. */
  52717. register(): void;
  52718. /**
  52719. * Rebuilds the elements related to this component in case of
  52720. * context lost for instance.
  52721. */
  52722. rebuild(): void;
  52723. /**
  52724. * Adds all the elements from the container to the scene
  52725. * @param container the container holding the elements
  52726. */
  52727. addFromContainer(container: AbstractScene): void;
  52728. /**
  52729. * Removes all the elements in the container from the scene
  52730. * @param container contains the elements to remove
  52731. * @param dispose if the removed element should be disposed (default: false)
  52732. */
  52733. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52734. /**
  52735. * Serializes the component data to the specified json object
  52736. * @param serializationObject The object to serialize to
  52737. */
  52738. serialize(serializationObject: any): void;
  52739. /**
  52740. * Disposes the component and the associated ressources.
  52741. */
  52742. dispose(): void;
  52743. private _draw;
  52744. }
  52745. }
  52746. declare module "babylonjs/LensFlares/index" {
  52747. export * from "babylonjs/LensFlares/lensFlare";
  52748. export * from "babylonjs/LensFlares/lensFlareSystem";
  52749. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52750. }
  52751. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52752. import { Scene } from "babylonjs/scene";
  52753. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52754. import { AbstractScene } from "babylonjs/abstractScene";
  52755. /**
  52756. * Defines the shadow generator component responsible to manage any shadow generators
  52757. * in a given scene.
  52758. */
  52759. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52760. /**
  52761. * The component name helpfull to identify the component in the list of scene components.
  52762. */
  52763. readonly name: string;
  52764. /**
  52765. * The scene the component belongs to.
  52766. */
  52767. scene: Scene;
  52768. /**
  52769. * Creates a new instance of the component for the given scene
  52770. * @param scene Defines the scene to register the component in
  52771. */
  52772. constructor(scene: Scene);
  52773. /**
  52774. * Registers the component in a given scene
  52775. */
  52776. register(): void;
  52777. /**
  52778. * Rebuilds the elements related to this component in case of
  52779. * context lost for instance.
  52780. */
  52781. rebuild(): void;
  52782. /**
  52783. * Serializes the component data to the specified json object
  52784. * @param serializationObject The object to serialize to
  52785. */
  52786. serialize(serializationObject: any): void;
  52787. /**
  52788. * Adds all the elements from the container to the scene
  52789. * @param container the container holding the elements
  52790. */
  52791. addFromContainer(container: AbstractScene): void;
  52792. /**
  52793. * Removes all the elements in the container from the scene
  52794. * @param container contains the elements to remove
  52795. * @param dispose if the removed element should be disposed (default: false)
  52796. */
  52797. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52798. /**
  52799. * Rebuilds the elements related to this component in case of
  52800. * context lost for instance.
  52801. */
  52802. dispose(): void;
  52803. private _gatherRenderTargets;
  52804. }
  52805. }
  52806. declare module "babylonjs/Lights/Shadows/index" {
  52807. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52808. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52809. }
  52810. declare module "babylonjs/Lights/pointLight" {
  52811. import { Scene } from "babylonjs/scene";
  52812. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52814. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52815. import { Effect } from "babylonjs/Materials/effect";
  52816. /**
  52817. * A point light is a light defined by an unique point in world space.
  52818. * The light is emitted in every direction from this point.
  52819. * A good example of a point light is a standard light bulb.
  52820. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52821. */
  52822. export class PointLight extends ShadowLight {
  52823. private _shadowAngle;
  52824. /**
  52825. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52826. * This specifies what angle the shadow will use to be created.
  52827. *
  52828. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52829. */
  52830. /**
  52831. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52832. * This specifies what angle the shadow will use to be created.
  52833. *
  52834. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52835. */
  52836. shadowAngle: number;
  52837. /**
  52838. * Gets the direction if it has been set.
  52839. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52840. */
  52841. /**
  52842. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52843. */
  52844. direction: Vector3;
  52845. /**
  52846. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52847. * A PointLight emits the light in every direction.
  52848. * It can cast shadows.
  52849. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52850. * ```javascript
  52851. * var pointLight = new PointLight("pl", camera.position, scene);
  52852. * ```
  52853. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52854. * @param name The light friendly name
  52855. * @param position The position of the point light in the scene
  52856. * @param scene The scene the lights belongs to
  52857. */
  52858. constructor(name: string, position: Vector3, scene: Scene);
  52859. /**
  52860. * Returns the string "PointLight"
  52861. * @returns the class name
  52862. */
  52863. getClassName(): string;
  52864. /**
  52865. * Returns the integer 0.
  52866. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52867. */
  52868. getTypeID(): number;
  52869. /**
  52870. * Specifies wether or not the shadowmap should be a cube texture.
  52871. * @returns true if the shadowmap needs to be a cube texture.
  52872. */
  52873. needCube(): boolean;
  52874. /**
  52875. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52878. */
  52879. getShadowDirection(faceIndex?: number): Vector3;
  52880. /**
  52881. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52882. * - fov = PI / 2
  52883. * - aspect ratio : 1.0
  52884. * - z-near and far equal to the active camera minZ and maxZ.
  52885. * Returns the PointLight.
  52886. */
  52887. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52888. protected _buildUniformLayout(): void;
  52889. /**
  52890. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52891. * @param effect The effect to update
  52892. * @param lightIndex The index of the light in the effect to update
  52893. * @returns The point light
  52894. */
  52895. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52896. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52897. /**
  52898. * Prepares the list of defines specific to the light type.
  52899. * @param defines the list of defines
  52900. * @param lightIndex defines the index of the light for the effect
  52901. */
  52902. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52903. }
  52904. }
  52905. declare module "babylonjs/Lights/index" {
  52906. export * from "babylonjs/Lights/light";
  52907. export * from "babylonjs/Lights/shadowLight";
  52908. export * from "babylonjs/Lights/Shadows/index";
  52909. export * from "babylonjs/Lights/directionalLight";
  52910. export * from "babylonjs/Lights/hemisphericLight";
  52911. export * from "babylonjs/Lights/pointLight";
  52912. export * from "babylonjs/Lights/spotLight";
  52913. }
  52914. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52915. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52916. /**
  52917. * Header information of HDR texture files.
  52918. */
  52919. export interface HDRInfo {
  52920. /**
  52921. * The height of the texture in pixels.
  52922. */
  52923. height: number;
  52924. /**
  52925. * The width of the texture in pixels.
  52926. */
  52927. width: number;
  52928. /**
  52929. * The index of the beginning of the data in the binary file.
  52930. */
  52931. dataPosition: number;
  52932. }
  52933. /**
  52934. * This groups tools to convert HDR texture to native colors array.
  52935. */
  52936. export class HDRTools {
  52937. private static Ldexp;
  52938. private static Rgbe2float;
  52939. private static readStringLine;
  52940. /**
  52941. * Reads header information from an RGBE texture stored in a native array.
  52942. * More information on this format are available here:
  52943. * https://en.wikipedia.org/wiki/RGBE_image_format
  52944. *
  52945. * @param uint8array The binary file stored in native array.
  52946. * @return The header information.
  52947. */
  52948. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52949. /**
  52950. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52951. * This RGBE texture needs to store the information as a panorama.
  52952. *
  52953. * More information on this format are available here:
  52954. * https://en.wikipedia.org/wiki/RGBE_image_format
  52955. *
  52956. * @param buffer The binary file stored in an array buffer.
  52957. * @param size The expected size of the extracted cubemap.
  52958. * @return The Cube Map information.
  52959. */
  52960. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52961. /**
  52962. * Returns the pixels data extracted from an RGBE texture.
  52963. * This pixels will be stored left to right up to down in the R G B order in one array.
  52964. *
  52965. * More information on this format are available here:
  52966. * https://en.wikipedia.org/wiki/RGBE_image_format
  52967. *
  52968. * @param uint8array The binary file stored in an array buffer.
  52969. * @param hdrInfo The header information of the file.
  52970. * @return The pixels data in RGB right to left up to down order.
  52971. */
  52972. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52973. private static RGBE_ReadPixels_RLE;
  52974. }
  52975. }
  52976. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52977. import { Nullable } from "babylonjs/types";
  52978. import { Scene } from "babylonjs/scene";
  52979. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52981. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52982. /**
  52983. * This represents a texture coming from an HDR input.
  52984. *
  52985. * The only supported format is currently panorama picture stored in RGBE format.
  52986. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52987. */
  52988. export class HDRCubeTexture extends BaseTexture {
  52989. private static _facesMapping;
  52990. private _generateHarmonics;
  52991. private _noMipmap;
  52992. private _textureMatrix;
  52993. private _size;
  52994. private _onLoad;
  52995. private _onError;
  52996. /**
  52997. * The texture URL.
  52998. */
  52999. url: string;
  53000. /**
  53001. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53002. */
  53003. coordinatesMode: number;
  53004. protected _isBlocking: boolean;
  53005. /**
  53006. * Sets wether or not the texture is blocking during loading.
  53007. */
  53008. /**
  53009. * Gets wether or not the texture is blocking during loading.
  53010. */
  53011. isBlocking: boolean;
  53012. protected _rotationY: number;
  53013. /**
  53014. * Sets texture matrix rotation angle around Y axis in radians.
  53015. */
  53016. /**
  53017. * Gets texture matrix rotation angle around Y axis radians.
  53018. */
  53019. rotationY: number;
  53020. /**
  53021. * Gets or sets the center of the bounding box associated with the cube texture
  53022. * It must define where the camera used to render the texture was set
  53023. */
  53024. boundingBoxPosition: Vector3;
  53025. private _boundingBoxSize;
  53026. /**
  53027. * Gets or sets the size of the bounding box associated with the cube texture
  53028. * When defined, the cubemap will switch to local mode
  53029. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53030. * @example https://www.babylonjs-playground.com/#RNASML
  53031. */
  53032. boundingBoxSize: Vector3;
  53033. /**
  53034. * Instantiates an HDRTexture from the following parameters.
  53035. *
  53036. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53037. * @param scene The scene the texture will be used in
  53038. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53039. * @param noMipmap Forces to not generate the mipmap if true
  53040. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53041. * @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)
  53042. * @param reserved Reserved flag for internal use.
  53043. */
  53044. 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>);
  53045. /**
  53046. * Get the current class name of the texture useful for serialization or dynamic coding.
  53047. * @returns "HDRCubeTexture"
  53048. */
  53049. getClassName(): string;
  53050. /**
  53051. * Occurs when the file is raw .hdr file.
  53052. */
  53053. private loadTexture;
  53054. clone(): HDRCubeTexture;
  53055. delayLoad(): void;
  53056. /**
  53057. * Get the texture reflection matrix used to rotate/transform the reflection.
  53058. * @returns the reflection matrix
  53059. */
  53060. getReflectionTextureMatrix(): Matrix;
  53061. /**
  53062. * Set the texture reflection matrix used to rotate/transform the reflection.
  53063. * @param value Define the reflection matrix to set
  53064. */
  53065. setReflectionTextureMatrix(value: Matrix): void;
  53066. /**
  53067. * Parses a JSON representation of an HDR Texture in order to create the texture
  53068. * @param parsedTexture Define the JSON representation
  53069. * @param scene Define the scene the texture should be created in
  53070. * @param rootUrl Define the root url in case we need to load relative dependencies
  53071. * @returns the newly created texture after parsing
  53072. */
  53073. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53074. serialize(): any;
  53075. }
  53076. }
  53077. declare module "babylonjs/Physics/physicsEngine" {
  53078. import { Nullable } from "babylonjs/types";
  53079. import { Vector3 } from "babylonjs/Maths/math.vector";
  53080. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53081. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53082. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53083. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53084. /**
  53085. * Class used to control physics engine
  53086. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53087. */
  53088. export class PhysicsEngine implements IPhysicsEngine {
  53089. private _physicsPlugin;
  53090. /**
  53091. * Global value used to control the smallest number supported by the simulation
  53092. */
  53093. static Epsilon: number;
  53094. private _impostors;
  53095. private _joints;
  53096. /**
  53097. * Gets the gravity vector used by the simulation
  53098. */
  53099. gravity: Vector3;
  53100. /**
  53101. * Factory used to create the default physics plugin.
  53102. * @returns The default physics plugin
  53103. */
  53104. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53105. /**
  53106. * Creates a new Physics Engine
  53107. * @param gravity defines the gravity vector used by the simulation
  53108. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53109. */
  53110. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53111. /**
  53112. * Sets the gravity vector used by the simulation
  53113. * @param gravity defines the gravity vector to use
  53114. */
  53115. setGravity(gravity: Vector3): void;
  53116. /**
  53117. * Set the time step of the physics engine.
  53118. * Default is 1/60.
  53119. * To slow it down, enter 1/600 for example.
  53120. * To speed it up, 1/30
  53121. * @param newTimeStep defines the new timestep to apply to this world.
  53122. */
  53123. setTimeStep(newTimeStep?: number): void;
  53124. /**
  53125. * Get the time step of the physics engine.
  53126. * @returns the current time step
  53127. */
  53128. getTimeStep(): number;
  53129. /**
  53130. * Release all resources
  53131. */
  53132. dispose(): void;
  53133. /**
  53134. * Gets the name of the current physics plugin
  53135. * @returns the name of the plugin
  53136. */
  53137. getPhysicsPluginName(): string;
  53138. /**
  53139. * Adding a new impostor for the impostor tracking.
  53140. * This will be done by the impostor itself.
  53141. * @param impostor the impostor to add
  53142. */
  53143. addImpostor(impostor: PhysicsImpostor): void;
  53144. /**
  53145. * Remove an impostor from the engine.
  53146. * This impostor and its mesh will not longer be updated by the physics engine.
  53147. * @param impostor the impostor to remove
  53148. */
  53149. removeImpostor(impostor: PhysicsImpostor): void;
  53150. /**
  53151. * Add a joint to the physics engine
  53152. * @param mainImpostor defines the main impostor to which the joint is added.
  53153. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53154. * @param joint defines the joint that will connect both impostors.
  53155. */
  53156. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53157. /**
  53158. * Removes a joint from the simulation
  53159. * @param mainImpostor defines the impostor used with the joint
  53160. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53161. * @param joint defines the joint to remove
  53162. */
  53163. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53164. /**
  53165. * Called by the scene. No need to call it.
  53166. * @param delta defines the timespam between frames
  53167. */
  53168. _step(delta: number): void;
  53169. /**
  53170. * Gets the current plugin used to run the simulation
  53171. * @returns current plugin
  53172. */
  53173. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53174. /**
  53175. * Gets the list of physic impostors
  53176. * @returns an array of PhysicsImpostor
  53177. */
  53178. getImpostors(): Array<PhysicsImpostor>;
  53179. /**
  53180. * Gets the impostor for a physics enabled object
  53181. * @param object defines the object impersonated by the impostor
  53182. * @returns the PhysicsImpostor or null if not found
  53183. */
  53184. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53185. /**
  53186. * Gets the impostor for a physics body object
  53187. * @param body defines physics body used by the impostor
  53188. * @returns the PhysicsImpostor or null if not found
  53189. */
  53190. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53191. /**
  53192. * Does a raycast in the physics world
  53193. * @param from when should the ray start?
  53194. * @param to when should the ray end?
  53195. * @returns PhysicsRaycastResult
  53196. */
  53197. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53198. }
  53199. }
  53200. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53201. import { Nullable } from "babylonjs/types";
  53202. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53204. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53205. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53206. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53207. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53208. /** @hidden */
  53209. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53210. private _useDeltaForWorldStep;
  53211. world: any;
  53212. name: string;
  53213. private _physicsMaterials;
  53214. private _fixedTimeStep;
  53215. private _cannonRaycastResult;
  53216. private _raycastResult;
  53217. private _physicsBodysToRemoveAfterStep;
  53218. BJSCANNON: any;
  53219. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53220. setGravity(gravity: Vector3): void;
  53221. setTimeStep(timeStep: number): void;
  53222. getTimeStep(): number;
  53223. executeStep(delta: number): void;
  53224. private _removeMarkedPhysicsBodiesFromWorld;
  53225. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53226. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53227. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53228. private _processChildMeshes;
  53229. removePhysicsBody(impostor: PhysicsImpostor): void;
  53230. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53231. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53232. private _addMaterial;
  53233. private _checkWithEpsilon;
  53234. private _createShape;
  53235. private _createHeightmap;
  53236. private _minus90X;
  53237. private _plus90X;
  53238. private _tmpPosition;
  53239. private _tmpDeltaPosition;
  53240. private _tmpUnityRotation;
  53241. private _updatePhysicsBodyTransformation;
  53242. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53243. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53244. isSupported(): boolean;
  53245. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53246. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53247. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53248. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53249. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53250. getBodyMass(impostor: PhysicsImpostor): number;
  53251. getBodyFriction(impostor: PhysicsImpostor): number;
  53252. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53253. getBodyRestitution(impostor: PhysicsImpostor): number;
  53254. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53255. sleepBody(impostor: PhysicsImpostor): void;
  53256. wakeUpBody(impostor: PhysicsImpostor): void;
  53257. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53258. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53259. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53260. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53261. getRadius(impostor: PhysicsImpostor): number;
  53262. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53263. dispose(): void;
  53264. private _extendNamespace;
  53265. /**
  53266. * Does a raycast in the physics world
  53267. * @param from when should the ray start?
  53268. * @param to when should the ray end?
  53269. * @returns PhysicsRaycastResult
  53270. */
  53271. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53272. }
  53273. }
  53274. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53275. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53276. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53277. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53279. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53280. import { Nullable } from "babylonjs/types";
  53281. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53282. /** @hidden */
  53283. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53284. world: any;
  53285. name: string;
  53286. BJSOIMO: any;
  53287. private _raycastResult;
  53288. constructor(iterations?: number, oimoInjection?: any);
  53289. setGravity(gravity: Vector3): void;
  53290. setTimeStep(timeStep: number): void;
  53291. getTimeStep(): number;
  53292. private _tmpImpostorsArray;
  53293. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53294. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53295. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53296. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53297. private _tmpPositionVector;
  53298. removePhysicsBody(impostor: PhysicsImpostor): void;
  53299. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53300. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53301. isSupported(): boolean;
  53302. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53303. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53304. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53305. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53306. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53307. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53308. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53309. getBodyMass(impostor: PhysicsImpostor): number;
  53310. getBodyFriction(impostor: PhysicsImpostor): number;
  53311. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53312. getBodyRestitution(impostor: PhysicsImpostor): number;
  53313. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53314. sleepBody(impostor: PhysicsImpostor): void;
  53315. wakeUpBody(impostor: PhysicsImpostor): void;
  53316. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53317. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53318. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53319. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53320. getRadius(impostor: PhysicsImpostor): number;
  53321. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53322. dispose(): void;
  53323. /**
  53324. * Does a raycast in the physics world
  53325. * @param from when should the ray start?
  53326. * @param to when should the ray end?
  53327. * @returns PhysicsRaycastResult
  53328. */
  53329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53330. }
  53331. }
  53332. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53333. import { Nullable } from "babylonjs/types";
  53334. import { Scene } from "babylonjs/scene";
  53335. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53336. import { Color4 } from "babylonjs/Maths/math.color";
  53337. import { Mesh } from "babylonjs/Meshes/mesh";
  53338. /**
  53339. * Class containing static functions to help procedurally build meshes
  53340. */
  53341. export class RibbonBuilder {
  53342. /**
  53343. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53344. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53345. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53346. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53347. * * 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
  53348. * * 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
  53349. * * 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
  53350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53352. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53353. * * 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
  53354. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53355. * * 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
  53356. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53358. * @param name defines the name of the mesh
  53359. * @param options defines the options used to create the mesh
  53360. * @param scene defines the hosting scene
  53361. * @returns the ribbon mesh
  53362. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53364. */
  53365. static CreateRibbon(name: string, options: {
  53366. pathArray: Vector3[][];
  53367. closeArray?: boolean;
  53368. closePath?: boolean;
  53369. offset?: number;
  53370. updatable?: boolean;
  53371. sideOrientation?: number;
  53372. frontUVs?: Vector4;
  53373. backUVs?: Vector4;
  53374. instance?: Mesh;
  53375. invertUV?: boolean;
  53376. uvs?: Vector2[];
  53377. colors?: Color4[];
  53378. }, scene?: Nullable<Scene>): Mesh;
  53379. }
  53380. }
  53381. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53382. import { Nullable } from "babylonjs/types";
  53383. import { Scene } from "babylonjs/scene";
  53384. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53385. import { Mesh } from "babylonjs/Meshes/mesh";
  53386. /**
  53387. * Class containing static functions to help procedurally build meshes
  53388. */
  53389. export class ShapeBuilder {
  53390. /**
  53391. * 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.
  53392. * * 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.
  53393. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53394. * * 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.
  53395. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53396. * * 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
  53397. * * 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
  53398. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53403. * @param name defines the name of the mesh
  53404. * @param options defines the options used to create the mesh
  53405. * @param scene defines the hosting scene
  53406. * @returns the extruded shape mesh
  53407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53409. */
  53410. static ExtrudeShape(name: string, options: {
  53411. shape: Vector3[];
  53412. path: Vector3[];
  53413. scale?: number;
  53414. rotation?: number;
  53415. cap?: number;
  53416. updatable?: boolean;
  53417. sideOrientation?: number;
  53418. frontUVs?: Vector4;
  53419. backUVs?: Vector4;
  53420. instance?: Mesh;
  53421. invertUV?: boolean;
  53422. }, scene?: Nullable<Scene>): Mesh;
  53423. /**
  53424. * Creates an custom extruded shape mesh.
  53425. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53426. * * 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.
  53427. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53428. * * 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
  53429. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53430. * * 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
  53431. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53432. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53433. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53434. * * 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
  53435. * * 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
  53436. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53441. * @param name defines the name of the mesh
  53442. * @param options defines the options used to create the mesh
  53443. * @param scene defines the hosting scene
  53444. * @returns the custom extruded shape mesh
  53445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53448. */
  53449. static ExtrudeShapeCustom(name: string, options: {
  53450. shape: Vector3[];
  53451. path: Vector3[];
  53452. scaleFunction?: any;
  53453. rotationFunction?: any;
  53454. ribbonCloseArray?: boolean;
  53455. ribbonClosePath?: boolean;
  53456. cap?: number;
  53457. updatable?: boolean;
  53458. sideOrientation?: number;
  53459. frontUVs?: Vector4;
  53460. backUVs?: Vector4;
  53461. instance?: Mesh;
  53462. invertUV?: boolean;
  53463. }, scene?: Nullable<Scene>): Mesh;
  53464. private static _ExtrudeShapeGeneric;
  53465. }
  53466. }
  53467. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53468. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53469. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53470. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53471. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53472. import { Nullable } from "babylonjs/types";
  53473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53474. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53475. /**
  53476. * AmmoJS Physics plugin
  53477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53478. * @see https://github.com/kripken/ammo.js/
  53479. */
  53480. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53481. private _useDeltaForWorldStep;
  53482. /**
  53483. * Reference to the Ammo library
  53484. */
  53485. bjsAMMO: any;
  53486. /**
  53487. * Created ammoJS world which physics bodies are added to
  53488. */
  53489. world: any;
  53490. /**
  53491. * Name of the plugin
  53492. */
  53493. name: string;
  53494. private _timeStep;
  53495. private _fixedTimeStep;
  53496. private _maxSteps;
  53497. private _tmpQuaternion;
  53498. private _tmpAmmoTransform;
  53499. private _tmpAmmoQuaternion;
  53500. private _tmpAmmoConcreteContactResultCallback;
  53501. private _collisionConfiguration;
  53502. private _dispatcher;
  53503. private _overlappingPairCache;
  53504. private _solver;
  53505. private _softBodySolver;
  53506. private _tmpAmmoVectorA;
  53507. private _tmpAmmoVectorB;
  53508. private _tmpAmmoVectorC;
  53509. private _tmpAmmoVectorD;
  53510. private _tmpContactCallbackResult;
  53511. private _tmpAmmoVectorRCA;
  53512. private _tmpAmmoVectorRCB;
  53513. private _raycastResult;
  53514. private static readonly DISABLE_COLLISION_FLAG;
  53515. private static readonly KINEMATIC_FLAG;
  53516. private static readonly DISABLE_DEACTIVATION_FLAG;
  53517. /**
  53518. * Initializes the ammoJS plugin
  53519. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53520. * @param ammoInjection can be used to inject your own ammo reference
  53521. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53522. */
  53523. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53524. /**
  53525. * Sets the gravity of the physics world (m/(s^2))
  53526. * @param gravity Gravity to set
  53527. */
  53528. setGravity(gravity: Vector3): void;
  53529. /**
  53530. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53531. * @param timeStep timestep to use in seconds
  53532. */
  53533. setTimeStep(timeStep: number): void;
  53534. /**
  53535. * 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)
  53536. * @param fixedTimeStep fixedTimeStep to use in seconds
  53537. */
  53538. setFixedTimeStep(fixedTimeStep: number): void;
  53539. /**
  53540. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53541. * @param maxSteps the maximum number of steps by the physics engine per frame
  53542. */
  53543. setMaxSteps(maxSteps: number): void;
  53544. /**
  53545. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53546. * @returns the current timestep in seconds
  53547. */
  53548. getTimeStep(): number;
  53549. private _isImpostorInContact;
  53550. private _isImpostorPairInContact;
  53551. private _stepSimulation;
  53552. /**
  53553. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53554. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53555. * After the step the babylon meshes are set to the position of the physics imposters
  53556. * @param delta amount of time to step forward
  53557. * @param impostors array of imposters to update before/after the step
  53558. */
  53559. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53560. /**
  53561. * Update babylon mesh to match physics world object
  53562. * @param impostor imposter to match
  53563. */
  53564. private _afterSoftStep;
  53565. /**
  53566. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53567. * @param impostor imposter to match
  53568. */
  53569. private _ropeStep;
  53570. /**
  53571. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53572. * @param impostor imposter to match
  53573. */
  53574. private _softbodyOrClothStep;
  53575. private _tmpVector;
  53576. private _tmpMatrix;
  53577. /**
  53578. * Applies an impulse on the imposter
  53579. * @param impostor imposter to apply impulse to
  53580. * @param force amount of force to be applied to the imposter
  53581. * @param contactPoint the location to apply the impulse on the imposter
  53582. */
  53583. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53584. /**
  53585. * Applies a force on the imposter
  53586. * @param impostor imposter to apply force
  53587. * @param force amount of force to be applied to the imposter
  53588. * @param contactPoint the location to apply the force on the imposter
  53589. */
  53590. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53591. /**
  53592. * Creates a physics body using the plugin
  53593. * @param impostor the imposter to create the physics body on
  53594. */
  53595. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53596. /**
  53597. * Removes the physics body from the imposter and disposes of the body's memory
  53598. * @param impostor imposter to remove the physics body from
  53599. */
  53600. removePhysicsBody(impostor: PhysicsImpostor): void;
  53601. /**
  53602. * Generates a joint
  53603. * @param impostorJoint the imposter joint to create the joint with
  53604. */
  53605. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53606. /**
  53607. * Removes a joint
  53608. * @param impostorJoint the imposter joint to remove the joint from
  53609. */
  53610. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53611. private _addMeshVerts;
  53612. /**
  53613. * Initialise the soft body vertices to match its object's (mesh) vertices
  53614. * Softbody vertices (nodes) are in world space and to match this
  53615. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53616. * @param impostor to create the softbody for
  53617. */
  53618. private _softVertexData;
  53619. /**
  53620. * Create an impostor's soft body
  53621. * @param impostor to create the softbody for
  53622. */
  53623. private _createSoftbody;
  53624. /**
  53625. * Create cloth for an impostor
  53626. * @param impostor to create the softbody for
  53627. */
  53628. private _createCloth;
  53629. /**
  53630. * Create rope for an impostor
  53631. * @param impostor to create the softbody for
  53632. */
  53633. private _createRope;
  53634. private _addHullVerts;
  53635. private _createShape;
  53636. /**
  53637. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53638. * @param impostor imposter containing the physics body and babylon object
  53639. */
  53640. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53641. /**
  53642. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53643. * @param impostor imposter containing the physics body and babylon object
  53644. * @param newPosition new position
  53645. * @param newRotation new rotation
  53646. */
  53647. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53648. /**
  53649. * If this plugin is supported
  53650. * @returns true if its supported
  53651. */
  53652. isSupported(): boolean;
  53653. /**
  53654. * Sets the linear velocity of the physics body
  53655. * @param impostor imposter to set the velocity on
  53656. * @param velocity velocity to set
  53657. */
  53658. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53659. /**
  53660. * Sets the angular velocity of the physics body
  53661. * @param impostor imposter to set the velocity on
  53662. * @param velocity velocity to set
  53663. */
  53664. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53665. /**
  53666. * gets the linear velocity
  53667. * @param impostor imposter to get linear velocity from
  53668. * @returns linear velocity
  53669. */
  53670. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53671. /**
  53672. * gets the angular velocity
  53673. * @param impostor imposter to get angular velocity from
  53674. * @returns angular velocity
  53675. */
  53676. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53677. /**
  53678. * Sets the mass of physics body
  53679. * @param impostor imposter to set the mass on
  53680. * @param mass mass to set
  53681. */
  53682. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53683. /**
  53684. * Gets the mass of the physics body
  53685. * @param impostor imposter to get the mass from
  53686. * @returns mass
  53687. */
  53688. getBodyMass(impostor: PhysicsImpostor): number;
  53689. /**
  53690. * Gets friction of the impostor
  53691. * @param impostor impostor to get friction from
  53692. * @returns friction value
  53693. */
  53694. getBodyFriction(impostor: PhysicsImpostor): number;
  53695. /**
  53696. * Sets friction of the impostor
  53697. * @param impostor impostor to set friction on
  53698. * @param friction friction value
  53699. */
  53700. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53701. /**
  53702. * Gets restitution of the impostor
  53703. * @param impostor impostor to get restitution from
  53704. * @returns restitution value
  53705. */
  53706. getBodyRestitution(impostor: PhysicsImpostor): number;
  53707. /**
  53708. * Sets resitution of the impostor
  53709. * @param impostor impostor to set resitution on
  53710. * @param restitution resitution value
  53711. */
  53712. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53713. /**
  53714. * Gets pressure inside the impostor
  53715. * @param impostor impostor to get pressure from
  53716. * @returns pressure value
  53717. */
  53718. getBodyPressure(impostor: PhysicsImpostor): number;
  53719. /**
  53720. * Sets pressure inside a soft body impostor
  53721. * Cloth and rope must remain 0 pressure
  53722. * @param impostor impostor to set pressure on
  53723. * @param pressure pressure value
  53724. */
  53725. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53726. /**
  53727. * Gets stiffness of the impostor
  53728. * @param impostor impostor to get stiffness from
  53729. * @returns pressure value
  53730. */
  53731. getBodyStiffness(impostor: PhysicsImpostor): number;
  53732. /**
  53733. * Sets stiffness of the impostor
  53734. * @param impostor impostor to set stiffness on
  53735. * @param stiffness stiffness value from 0 to 1
  53736. */
  53737. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53738. /**
  53739. * Gets velocityIterations of the impostor
  53740. * @param impostor impostor to get velocity iterations from
  53741. * @returns velocityIterations value
  53742. */
  53743. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53744. /**
  53745. * Sets velocityIterations of the impostor
  53746. * @param impostor impostor to set velocity iterations on
  53747. * @param velocityIterations velocityIterations value
  53748. */
  53749. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53750. /**
  53751. * Gets positionIterations of the impostor
  53752. * @param impostor impostor to get position iterations from
  53753. * @returns positionIterations value
  53754. */
  53755. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53756. /**
  53757. * Sets positionIterations of the impostor
  53758. * @param impostor impostor to set position on
  53759. * @param positionIterations positionIterations value
  53760. */
  53761. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53762. /**
  53763. * Append an anchor to a cloth object
  53764. * @param impostor is the cloth impostor to add anchor to
  53765. * @param otherImpostor is the rigid impostor to anchor to
  53766. * @param width ratio across width from 0 to 1
  53767. * @param height ratio up height from 0 to 1
  53768. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53769. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53770. */
  53771. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53772. /**
  53773. * Append an hook to a rope object
  53774. * @param impostor is the rope impostor to add hook to
  53775. * @param otherImpostor is the rigid impostor to hook to
  53776. * @param length ratio along the rope from 0 to 1
  53777. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53778. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53779. */
  53780. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53781. /**
  53782. * Sleeps the physics body and stops it from being active
  53783. * @param impostor impostor to sleep
  53784. */
  53785. sleepBody(impostor: PhysicsImpostor): void;
  53786. /**
  53787. * Activates the physics body
  53788. * @param impostor impostor to activate
  53789. */
  53790. wakeUpBody(impostor: PhysicsImpostor): void;
  53791. /**
  53792. * Updates the distance parameters of the joint
  53793. * @param joint joint to update
  53794. * @param maxDistance maximum distance of the joint
  53795. * @param minDistance minimum distance of the joint
  53796. */
  53797. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53798. /**
  53799. * Sets a motor on the joint
  53800. * @param joint joint to set motor on
  53801. * @param speed speed of the motor
  53802. * @param maxForce maximum force of the motor
  53803. * @param motorIndex index of the motor
  53804. */
  53805. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53806. /**
  53807. * Sets the motors limit
  53808. * @param joint joint to set limit on
  53809. * @param upperLimit upper limit
  53810. * @param lowerLimit lower limit
  53811. */
  53812. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53813. /**
  53814. * Syncs the position and rotation of a mesh with the impostor
  53815. * @param mesh mesh to sync
  53816. * @param impostor impostor to update the mesh with
  53817. */
  53818. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53819. /**
  53820. * Gets the radius of the impostor
  53821. * @param impostor impostor to get radius from
  53822. * @returns the radius
  53823. */
  53824. getRadius(impostor: PhysicsImpostor): number;
  53825. /**
  53826. * Gets the box size of the impostor
  53827. * @param impostor impostor to get box size from
  53828. * @param result the resulting box size
  53829. */
  53830. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53831. /**
  53832. * Disposes of the impostor
  53833. */
  53834. dispose(): void;
  53835. /**
  53836. * Does a raycast in the physics world
  53837. * @param from when should the ray start?
  53838. * @param to when should the ray end?
  53839. * @returns PhysicsRaycastResult
  53840. */
  53841. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53842. }
  53843. }
  53844. declare module "babylonjs/Probes/reflectionProbe" {
  53845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53846. import { Vector3 } from "babylonjs/Maths/math.vector";
  53847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53848. import { Nullable } from "babylonjs/types";
  53849. import { Scene } from "babylonjs/scene";
  53850. module "babylonjs/abstractScene" {
  53851. interface AbstractScene {
  53852. /**
  53853. * The list of reflection probes added to the scene
  53854. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53855. */
  53856. reflectionProbes: Array<ReflectionProbe>;
  53857. /**
  53858. * Removes the given reflection probe from this scene.
  53859. * @param toRemove The reflection probe to remove
  53860. * @returns The index of the removed reflection probe
  53861. */
  53862. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53863. /**
  53864. * Adds the given reflection probe to this scene.
  53865. * @param newReflectionProbe The reflection probe to add
  53866. */
  53867. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53868. }
  53869. }
  53870. /**
  53871. * Class used to generate realtime reflection / refraction cube textures
  53872. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53873. */
  53874. export class ReflectionProbe {
  53875. /** defines the name of the probe */
  53876. name: string;
  53877. private _scene;
  53878. private _renderTargetTexture;
  53879. private _projectionMatrix;
  53880. private _viewMatrix;
  53881. private _target;
  53882. private _add;
  53883. private _attachedMesh;
  53884. private _invertYAxis;
  53885. /** Gets or sets probe position (center of the cube map) */
  53886. position: Vector3;
  53887. /**
  53888. * Creates a new reflection probe
  53889. * @param name defines the name of the probe
  53890. * @param size defines the texture resolution (for each face)
  53891. * @param scene defines the hosting scene
  53892. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53893. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53894. */
  53895. constructor(
  53896. /** defines the name of the probe */
  53897. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53898. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53899. samples: number;
  53900. /** Gets or sets the refresh rate to use (on every frame by default) */
  53901. refreshRate: number;
  53902. /**
  53903. * Gets the hosting scene
  53904. * @returns a Scene
  53905. */
  53906. getScene(): Scene;
  53907. /** Gets the internal CubeTexture used to render to */
  53908. readonly cubeTexture: RenderTargetTexture;
  53909. /** Gets the list of meshes to render */
  53910. readonly renderList: Nullable<AbstractMesh[]>;
  53911. /**
  53912. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53913. * @param mesh defines the mesh to attach to
  53914. */
  53915. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53916. /**
  53917. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53918. * @param renderingGroupId The rendering group id corresponding to its index
  53919. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53920. */
  53921. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53922. /**
  53923. * Clean all associated resources
  53924. */
  53925. dispose(): void;
  53926. /**
  53927. * Converts the reflection probe information to a readable string for debug purpose.
  53928. * @param fullDetails Supports for multiple levels of logging within scene loading
  53929. * @returns the human readable reflection probe info
  53930. */
  53931. toString(fullDetails?: boolean): string;
  53932. /**
  53933. * Get the class name of the relfection probe.
  53934. * @returns "ReflectionProbe"
  53935. */
  53936. getClassName(): string;
  53937. /**
  53938. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53939. * @returns The JSON representation of the texture
  53940. */
  53941. serialize(): any;
  53942. /**
  53943. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53944. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53945. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53946. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53947. * @returns The parsed reflection probe if successful
  53948. */
  53949. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53950. }
  53951. }
  53952. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53953. /** @hidden */
  53954. export var _BabylonLoaderRegistered: boolean;
  53955. }
  53956. declare module "babylonjs/Loading/Plugins/index" {
  53957. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53958. }
  53959. declare module "babylonjs/Loading/index" {
  53960. export * from "babylonjs/Loading/loadingScreen";
  53961. export * from "babylonjs/Loading/Plugins/index";
  53962. export * from "babylonjs/Loading/sceneLoader";
  53963. export * from "babylonjs/Loading/sceneLoaderFlags";
  53964. }
  53965. declare module "babylonjs/Materials/Background/index" {
  53966. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53967. }
  53968. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53969. import { Scene } from "babylonjs/scene";
  53970. import { Color3 } from "babylonjs/Maths/math.color";
  53971. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53973. /**
  53974. * The Physically based simple base material of BJS.
  53975. *
  53976. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53977. * It is used as the base class for both the specGloss and metalRough conventions.
  53978. */
  53979. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53980. /**
  53981. * Number of Simultaneous lights allowed on the material.
  53982. */
  53983. maxSimultaneousLights: number;
  53984. /**
  53985. * If sets to true, disables all the lights affecting the material.
  53986. */
  53987. disableLighting: boolean;
  53988. /**
  53989. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53990. */
  53991. environmentTexture: BaseTexture;
  53992. /**
  53993. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53994. */
  53995. invertNormalMapX: boolean;
  53996. /**
  53997. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53998. */
  53999. invertNormalMapY: boolean;
  54000. /**
  54001. * Normal map used in the model.
  54002. */
  54003. normalTexture: BaseTexture;
  54004. /**
  54005. * Emissivie color used to self-illuminate the model.
  54006. */
  54007. emissiveColor: Color3;
  54008. /**
  54009. * Emissivie texture used to self-illuminate the model.
  54010. */
  54011. emissiveTexture: BaseTexture;
  54012. /**
  54013. * Occlusion Channel Strenght.
  54014. */
  54015. occlusionStrength: number;
  54016. /**
  54017. * Occlusion Texture of the material (adding extra occlusion effects).
  54018. */
  54019. occlusionTexture: BaseTexture;
  54020. /**
  54021. * Defines the alpha limits in alpha test mode.
  54022. */
  54023. alphaCutOff: number;
  54024. /**
  54025. * Gets the current double sided mode.
  54026. */
  54027. /**
  54028. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54029. */
  54030. doubleSided: boolean;
  54031. /**
  54032. * Stores the pre-calculated light information of a mesh in a texture.
  54033. */
  54034. lightmapTexture: BaseTexture;
  54035. /**
  54036. * If true, the light map contains occlusion information instead of lighting info.
  54037. */
  54038. useLightmapAsShadowmap: boolean;
  54039. /**
  54040. * Instantiates a new PBRMaterial instance.
  54041. *
  54042. * @param name The material name
  54043. * @param scene The scene the material will be use in.
  54044. */
  54045. constructor(name: string, scene: Scene);
  54046. getClassName(): string;
  54047. }
  54048. }
  54049. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54050. import { Scene } from "babylonjs/scene";
  54051. import { Color3 } from "babylonjs/Maths/math.color";
  54052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54053. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54054. /**
  54055. * The PBR material of BJS following the metal roughness convention.
  54056. *
  54057. * This fits to the PBR convention in the GLTF definition:
  54058. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54059. */
  54060. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54061. /**
  54062. * The base color has two different interpretations depending on the value of metalness.
  54063. * When the material is a metal, the base color is the specific measured reflectance value
  54064. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54065. * of the material.
  54066. */
  54067. baseColor: Color3;
  54068. /**
  54069. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54070. * well as opacity information in the alpha channel.
  54071. */
  54072. baseTexture: BaseTexture;
  54073. /**
  54074. * Specifies the metallic scalar value of the material.
  54075. * Can also be used to scale the metalness values of the metallic texture.
  54076. */
  54077. metallic: number;
  54078. /**
  54079. * Specifies the roughness scalar value of the material.
  54080. * Can also be used to scale the roughness values of the metallic texture.
  54081. */
  54082. roughness: number;
  54083. /**
  54084. * Texture containing both the metallic value in the B channel and the
  54085. * roughness value in the G channel to keep better precision.
  54086. */
  54087. metallicRoughnessTexture: BaseTexture;
  54088. /**
  54089. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54090. *
  54091. * @param name The material name
  54092. * @param scene The scene the material will be use in.
  54093. */
  54094. constructor(name: string, scene: Scene);
  54095. /**
  54096. * Return the currrent class name of the material.
  54097. */
  54098. getClassName(): string;
  54099. /**
  54100. * Makes a duplicate of the current material.
  54101. * @param name - name to use for the new material.
  54102. */
  54103. clone(name: string): PBRMetallicRoughnessMaterial;
  54104. /**
  54105. * Serialize the material to a parsable JSON object.
  54106. */
  54107. serialize(): any;
  54108. /**
  54109. * Parses a JSON object correponding to the serialize function.
  54110. */
  54111. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54112. }
  54113. }
  54114. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54115. import { Scene } from "babylonjs/scene";
  54116. import { Color3 } from "babylonjs/Maths/math.color";
  54117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54118. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54119. /**
  54120. * The PBR material of BJS following the specular glossiness convention.
  54121. *
  54122. * This fits to the PBR convention in the GLTF definition:
  54123. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54124. */
  54125. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54126. /**
  54127. * Specifies the diffuse color of the material.
  54128. */
  54129. diffuseColor: Color3;
  54130. /**
  54131. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54132. * channel.
  54133. */
  54134. diffuseTexture: BaseTexture;
  54135. /**
  54136. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54137. */
  54138. specularColor: Color3;
  54139. /**
  54140. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54141. */
  54142. glossiness: number;
  54143. /**
  54144. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54145. */
  54146. specularGlossinessTexture: BaseTexture;
  54147. /**
  54148. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54149. *
  54150. * @param name The material name
  54151. * @param scene The scene the material will be use in.
  54152. */
  54153. constructor(name: string, scene: Scene);
  54154. /**
  54155. * Return the currrent class name of the material.
  54156. */
  54157. getClassName(): string;
  54158. /**
  54159. * Makes a duplicate of the current material.
  54160. * @param name - name to use for the new material.
  54161. */
  54162. clone(name: string): PBRSpecularGlossinessMaterial;
  54163. /**
  54164. * Serialize the material to a parsable JSON object.
  54165. */
  54166. serialize(): any;
  54167. /**
  54168. * Parses a JSON object correponding to the serialize function.
  54169. */
  54170. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54171. }
  54172. }
  54173. declare module "babylonjs/Materials/PBR/index" {
  54174. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54175. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54176. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54177. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54178. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54179. }
  54180. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54181. import { Nullable } from "babylonjs/types";
  54182. import { Scene } from "babylonjs/scene";
  54183. import { Matrix } from "babylonjs/Maths/math.vector";
  54184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54185. /**
  54186. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54187. * It can help converting any input color in a desired output one. This can then be used to create effects
  54188. * from sepia, black and white to sixties or futuristic rendering...
  54189. *
  54190. * The only supported format is currently 3dl.
  54191. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54192. */
  54193. export class ColorGradingTexture extends BaseTexture {
  54194. /**
  54195. * The current texture matrix. (will always be identity in color grading texture)
  54196. */
  54197. private _textureMatrix;
  54198. /**
  54199. * The texture URL.
  54200. */
  54201. url: string;
  54202. /**
  54203. * Empty line regex stored for GC.
  54204. */
  54205. private static _noneEmptyLineRegex;
  54206. private _engine;
  54207. /**
  54208. * Instantiates a ColorGradingTexture from the following parameters.
  54209. *
  54210. * @param url The location of the color gradind data (currently only supporting 3dl)
  54211. * @param scene The scene the texture will be used in
  54212. */
  54213. constructor(url: string, scene: Scene);
  54214. /**
  54215. * Returns the texture matrix used in most of the material.
  54216. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54217. */
  54218. getTextureMatrix(): Matrix;
  54219. /**
  54220. * Occurs when the file being loaded is a .3dl LUT file.
  54221. */
  54222. private load3dlTexture;
  54223. /**
  54224. * Starts the loading process of the texture.
  54225. */
  54226. private loadTexture;
  54227. /**
  54228. * Clones the color gradind texture.
  54229. */
  54230. clone(): ColorGradingTexture;
  54231. /**
  54232. * Called during delayed load for textures.
  54233. */
  54234. delayLoad(): void;
  54235. /**
  54236. * Parses a color grading texture serialized by Babylon.
  54237. * @param parsedTexture The texture information being parsedTexture
  54238. * @param scene The scene to load the texture in
  54239. * @param rootUrl The root url of the data assets to load
  54240. * @return A color gradind texture
  54241. */
  54242. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54243. /**
  54244. * Serializes the LUT texture to json format.
  54245. */
  54246. serialize(): any;
  54247. }
  54248. }
  54249. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54251. import { Scene } from "babylonjs/scene";
  54252. import { Nullable } from "babylonjs/types";
  54253. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54254. /**
  54255. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54256. */
  54257. export class EquiRectangularCubeTexture extends BaseTexture {
  54258. /** The six faces of the cube. */
  54259. private static _FacesMapping;
  54260. private _noMipmap;
  54261. private _onLoad;
  54262. private _onError;
  54263. /** The size of the cubemap. */
  54264. private _size;
  54265. /** The buffer of the image. */
  54266. private _buffer;
  54267. /** The width of the input image. */
  54268. private _width;
  54269. /** The height of the input image. */
  54270. private _height;
  54271. /** The URL to the image. */
  54272. url: string;
  54273. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54274. coordinatesMode: number;
  54275. /**
  54276. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54277. * @param url The location of the image
  54278. * @param scene The scene the texture will be used in
  54279. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54280. * @param noMipmap Forces to not generate the mipmap if true
  54281. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54282. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54283. * @param onLoad — defines a callback called when texture is loaded
  54284. * @param onError — defines a callback called if there is an error
  54285. */
  54286. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54287. /**
  54288. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54289. */
  54290. private loadImage;
  54291. /**
  54292. * Convert the image buffer into a cubemap and create a CubeTexture.
  54293. */
  54294. private loadTexture;
  54295. /**
  54296. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54297. * @param buffer The ArrayBuffer that should be converted.
  54298. * @returns The buffer as Float32Array.
  54299. */
  54300. private getFloat32ArrayFromArrayBuffer;
  54301. /**
  54302. * Get the current class name of the texture useful for serialization or dynamic coding.
  54303. * @returns "EquiRectangularCubeTexture"
  54304. */
  54305. getClassName(): string;
  54306. /**
  54307. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54308. * @returns A clone of the current EquiRectangularCubeTexture.
  54309. */
  54310. clone(): EquiRectangularCubeTexture;
  54311. }
  54312. }
  54313. declare module "babylonjs/Misc/tga" {
  54314. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54315. /**
  54316. * Based on jsTGALoader - Javascript loader for TGA file
  54317. * By Vincent Thibault
  54318. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54319. */
  54320. export class TGATools {
  54321. private static _TYPE_INDEXED;
  54322. private static _TYPE_RGB;
  54323. private static _TYPE_GREY;
  54324. private static _TYPE_RLE_INDEXED;
  54325. private static _TYPE_RLE_RGB;
  54326. private static _TYPE_RLE_GREY;
  54327. private static _ORIGIN_MASK;
  54328. private static _ORIGIN_SHIFT;
  54329. private static _ORIGIN_BL;
  54330. private static _ORIGIN_BR;
  54331. private static _ORIGIN_UL;
  54332. private static _ORIGIN_UR;
  54333. /**
  54334. * Gets the header of a TGA file
  54335. * @param data defines the TGA data
  54336. * @returns the header
  54337. */
  54338. static GetTGAHeader(data: Uint8Array): any;
  54339. /**
  54340. * Uploads TGA content to a Babylon Texture
  54341. * @hidden
  54342. */
  54343. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54344. /** @hidden */
  54345. 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;
  54346. /** @hidden */
  54347. 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;
  54348. /** @hidden */
  54349. 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;
  54350. /** @hidden */
  54351. 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;
  54352. /** @hidden */
  54353. 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;
  54354. /** @hidden */
  54355. 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;
  54356. }
  54357. }
  54358. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54359. import { Nullable } from "babylonjs/types";
  54360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54361. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54362. /**
  54363. * Implementation of the TGA Texture Loader.
  54364. * @hidden
  54365. */
  54366. export class _TGATextureLoader implements IInternalTextureLoader {
  54367. /**
  54368. * Defines wether the loader supports cascade loading the different faces.
  54369. */
  54370. readonly supportCascades: boolean;
  54371. /**
  54372. * This returns if the loader support the current file information.
  54373. * @param extension defines the file extension of the file being loaded
  54374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54375. * @param fallback defines the fallback internal texture if any
  54376. * @param isBase64 defines whether the texture is encoded as a base64
  54377. * @param isBuffer defines whether the texture data are stored as a buffer
  54378. * @returns true if the loader can load the specified file
  54379. */
  54380. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54381. /**
  54382. * Transform the url before loading if required.
  54383. * @param rootUrl the url of the texture
  54384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54385. * @returns the transformed texture
  54386. */
  54387. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54388. /**
  54389. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54390. * @param rootUrl the url of the texture
  54391. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54392. * @returns the fallback texture
  54393. */
  54394. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54395. /**
  54396. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54397. * @param data contains the texture data
  54398. * @param texture defines the BabylonJS internal texture
  54399. * @param createPolynomials will be true if polynomials have been requested
  54400. * @param onLoad defines the callback to trigger once the texture is ready
  54401. * @param onError defines the callback to trigger in case of error
  54402. */
  54403. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54404. /**
  54405. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54406. * @param data contains the texture data
  54407. * @param texture defines the BabylonJS internal texture
  54408. * @param callback defines the method to call once ready to upload
  54409. */
  54410. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54411. }
  54412. }
  54413. declare module "babylonjs/Misc/basis" {
  54414. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54415. /**
  54416. * Info about the .basis files
  54417. */
  54418. class BasisFileInfo {
  54419. /**
  54420. * If the file has alpha
  54421. */
  54422. hasAlpha: boolean;
  54423. /**
  54424. * Info about each image of the basis file
  54425. */
  54426. images: Array<{
  54427. levels: Array<{
  54428. width: number;
  54429. height: number;
  54430. transcodedPixels: ArrayBufferView;
  54431. }>;
  54432. }>;
  54433. }
  54434. /**
  54435. * Result of transcoding a basis file
  54436. */
  54437. class TranscodeResult {
  54438. /**
  54439. * Info about the .basis file
  54440. */
  54441. fileInfo: BasisFileInfo;
  54442. /**
  54443. * Format to use when loading the file
  54444. */
  54445. format: number;
  54446. }
  54447. /**
  54448. * Configuration options for the Basis transcoder
  54449. */
  54450. export class BasisTranscodeConfiguration {
  54451. /**
  54452. * Supported compression formats used to determine the supported output format of the transcoder
  54453. */
  54454. supportedCompressionFormats?: {
  54455. /**
  54456. * etc1 compression format
  54457. */
  54458. etc1?: boolean;
  54459. /**
  54460. * s3tc compression format
  54461. */
  54462. s3tc?: boolean;
  54463. /**
  54464. * pvrtc compression format
  54465. */
  54466. pvrtc?: boolean;
  54467. /**
  54468. * etc2 compression format
  54469. */
  54470. etc2?: boolean;
  54471. };
  54472. /**
  54473. * If mipmap levels should be loaded for transcoded images (Default: true)
  54474. */
  54475. loadMipmapLevels?: boolean;
  54476. /**
  54477. * Index of a single image to load (Default: all images)
  54478. */
  54479. loadSingleImage?: number;
  54480. }
  54481. /**
  54482. * Used to load .Basis files
  54483. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54484. */
  54485. export class BasisTools {
  54486. private static _IgnoreSupportedFormats;
  54487. /**
  54488. * URL to use when loading the basis transcoder
  54489. */
  54490. static JSModuleURL: string;
  54491. /**
  54492. * URL to use when loading the wasm module for the transcoder
  54493. */
  54494. static WasmModuleURL: string;
  54495. /**
  54496. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54497. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54498. * @returns internal format corresponding to the Basis format
  54499. */
  54500. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54501. private static _WorkerPromise;
  54502. private static _Worker;
  54503. private static _actionId;
  54504. private static _CreateWorkerAsync;
  54505. /**
  54506. * Transcodes a loaded image file to compressed pixel data
  54507. * @param imageData image data to transcode
  54508. * @param config configuration options for the transcoding
  54509. * @returns a promise resulting in the transcoded image
  54510. */
  54511. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54512. /**
  54513. * Loads a texture from the transcode result
  54514. * @param texture texture load to
  54515. * @param transcodeResult the result of transcoding the basis file to load from
  54516. */
  54517. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54518. }
  54519. }
  54520. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54521. import { Nullable } from "babylonjs/types";
  54522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54523. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54524. /**
  54525. * Loader for .basis file format
  54526. */
  54527. export class _BasisTextureLoader implements IInternalTextureLoader {
  54528. /**
  54529. * Defines whether the loader supports cascade loading the different faces.
  54530. */
  54531. readonly supportCascades: boolean;
  54532. /**
  54533. * This returns if the loader support the current file information.
  54534. * @param extension defines the file extension of the file being loaded
  54535. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54536. * @param fallback defines the fallback internal texture if any
  54537. * @param isBase64 defines whether the texture is encoded as a base64
  54538. * @param isBuffer defines whether the texture data are stored as a buffer
  54539. * @returns true if the loader can load the specified file
  54540. */
  54541. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54542. /**
  54543. * Transform the url before loading if required.
  54544. * @param rootUrl the url of the texture
  54545. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54546. * @returns the transformed texture
  54547. */
  54548. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54549. /**
  54550. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54551. * @param rootUrl the url of the texture
  54552. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54553. * @returns the fallback texture
  54554. */
  54555. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54556. /**
  54557. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54558. * @param data contains the texture data
  54559. * @param texture defines the BabylonJS internal texture
  54560. * @param createPolynomials will be true if polynomials have been requested
  54561. * @param onLoad defines the callback to trigger once the texture is ready
  54562. * @param onError defines the callback to trigger in case of error
  54563. */
  54564. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54565. /**
  54566. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54567. * @param data contains the texture data
  54568. * @param texture defines the BabylonJS internal texture
  54569. * @param callback defines the method to call once ready to upload
  54570. */
  54571. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54572. }
  54573. }
  54574. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54575. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54576. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54577. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54578. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54579. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54580. }
  54581. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54582. import { Scene } from "babylonjs/scene";
  54583. import { Texture } from "babylonjs/Materials/Textures/texture";
  54584. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54585. /**
  54586. * 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.
  54587. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54588. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54589. */
  54590. export class CustomProceduralTexture extends ProceduralTexture {
  54591. private _animate;
  54592. private _time;
  54593. private _config;
  54594. private _texturePath;
  54595. /**
  54596. * Instantiates a new Custom Procedural Texture.
  54597. * 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.
  54598. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54599. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54600. * @param name Define the name of the texture
  54601. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54602. * @param size Define the size of the texture to create
  54603. * @param scene Define the scene the texture belongs to
  54604. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54605. * @param generateMipMaps Define if the texture should creates mip maps or not
  54606. */
  54607. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54608. private _loadJson;
  54609. /**
  54610. * Is the texture ready to be used ? (rendered at least once)
  54611. * @returns true if ready, otherwise, false.
  54612. */
  54613. isReady(): boolean;
  54614. /**
  54615. * Render the texture to its associated render target.
  54616. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54617. */
  54618. render(useCameraPostProcess?: boolean): void;
  54619. /**
  54620. * Update the list of dependant textures samplers in the shader.
  54621. */
  54622. updateTextures(): void;
  54623. /**
  54624. * Update the uniform values of the procedural texture in the shader.
  54625. */
  54626. updateShaderUniforms(): void;
  54627. /**
  54628. * Define if the texture animates or not.
  54629. */
  54630. animate: boolean;
  54631. }
  54632. }
  54633. declare module "babylonjs/Shaders/noise.fragment" {
  54634. /** @hidden */
  54635. export var noisePixelShader: {
  54636. name: string;
  54637. shader: string;
  54638. };
  54639. }
  54640. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54641. import { Nullable } from "babylonjs/types";
  54642. import { Scene } from "babylonjs/scene";
  54643. import { Texture } from "babylonjs/Materials/Textures/texture";
  54644. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54645. import "babylonjs/Shaders/noise.fragment";
  54646. /**
  54647. * Class used to generate noise procedural textures
  54648. */
  54649. export class NoiseProceduralTexture extends ProceduralTexture {
  54650. private _time;
  54651. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54652. brightness: number;
  54653. /** Defines the number of octaves to process */
  54654. octaves: number;
  54655. /** Defines the level of persistence (0.8 by default) */
  54656. persistence: number;
  54657. /** Gets or sets animation speed factor (default is 1) */
  54658. animationSpeedFactor: number;
  54659. /**
  54660. * Creates a new NoiseProceduralTexture
  54661. * @param name defines the name fo the texture
  54662. * @param size defines the size of the texture (default is 256)
  54663. * @param scene defines the hosting scene
  54664. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54665. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54666. */
  54667. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54668. private _updateShaderUniforms;
  54669. protected _getDefines(): string;
  54670. /** Generate the current state of the procedural texture */
  54671. render(useCameraPostProcess?: boolean): void;
  54672. /**
  54673. * Serializes this noise procedural texture
  54674. * @returns a serialized noise procedural texture object
  54675. */
  54676. serialize(): any;
  54677. /**
  54678. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54679. * @param parsedTexture defines parsed texture data
  54680. * @param scene defines the current scene
  54681. * @param rootUrl defines the root URL containing noise procedural texture information
  54682. * @returns a parsed NoiseProceduralTexture
  54683. */
  54684. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54685. }
  54686. }
  54687. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54688. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54689. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54690. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54691. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54692. }
  54693. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54694. import { Nullable } from "babylonjs/types";
  54695. import { Scene } from "babylonjs/scene";
  54696. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54697. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54698. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54699. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54700. /**
  54701. * Raw cube texture where the raw buffers are passed in
  54702. */
  54703. export class RawCubeTexture extends CubeTexture {
  54704. /**
  54705. * Creates a cube texture where the raw buffers are passed in.
  54706. * @param scene defines the scene the texture is attached to
  54707. * @param data defines the array of data to use to create each face
  54708. * @param size defines the size of the textures
  54709. * @param format defines the format of the data
  54710. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54711. * @param generateMipMaps defines if the engine should generate the mip levels
  54712. * @param invertY defines if data must be stored with Y axis inverted
  54713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54714. * @param compression defines the compression used (null by default)
  54715. */
  54716. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54717. /**
  54718. * Updates the raw cube texture.
  54719. * @param data defines the data to store
  54720. * @param format defines the data format
  54721. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54722. * @param invertY defines if data must be stored with Y axis inverted
  54723. * @param compression defines the compression used (null by default)
  54724. * @param level defines which level of the texture to update
  54725. */
  54726. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54727. /**
  54728. * Updates a raw cube texture with RGBD encoded data.
  54729. * @param data defines the array of data [mipmap][face] to use to create each face
  54730. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54731. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54732. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54733. * @returns a promsie that resolves when the operation is complete
  54734. */
  54735. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54736. /**
  54737. * Clones the raw cube texture.
  54738. * @return a new cube texture
  54739. */
  54740. clone(): CubeTexture;
  54741. /** @hidden */
  54742. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54743. }
  54744. }
  54745. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54746. import { Scene } from "babylonjs/scene";
  54747. import { Texture } from "babylonjs/Materials/Textures/texture";
  54748. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54749. /**
  54750. * Class used to store 3D textures containing user data
  54751. */
  54752. export class RawTexture3D extends Texture {
  54753. /** Gets or sets the texture format to use */
  54754. format: number;
  54755. private _engine;
  54756. /**
  54757. * Create a new RawTexture3D
  54758. * @param data defines the data of the texture
  54759. * @param width defines the width of the texture
  54760. * @param height defines the height of the texture
  54761. * @param depth defines the depth of the texture
  54762. * @param format defines the texture format to use
  54763. * @param scene defines the hosting scene
  54764. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54765. * @param invertY defines if texture must be stored with Y axis inverted
  54766. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54767. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54768. */
  54769. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54770. /** Gets or sets the texture format to use */
  54771. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54772. /**
  54773. * Update the texture with new data
  54774. * @param data defines the data to store in the texture
  54775. */
  54776. update(data: ArrayBufferView): void;
  54777. }
  54778. }
  54779. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54780. import { Scene } from "babylonjs/scene";
  54781. import { Plane } from "babylonjs/Maths/math.plane";
  54782. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54783. /**
  54784. * Creates a refraction texture used by refraction channel of the standard material.
  54785. * It is like a mirror but to see through a material.
  54786. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54787. */
  54788. export class RefractionTexture extends RenderTargetTexture {
  54789. /**
  54790. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54791. * 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.
  54792. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54793. */
  54794. refractionPlane: Plane;
  54795. /**
  54796. * Define how deep under the surface we should see.
  54797. */
  54798. depth: number;
  54799. /**
  54800. * Creates a refraction texture used by refraction channel of the standard material.
  54801. * It is like a mirror but to see through a material.
  54802. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54803. * @param name Define the texture name
  54804. * @param size Define the size of the underlying texture
  54805. * @param scene Define the scene the refraction belongs to
  54806. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54807. */
  54808. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54809. /**
  54810. * Clone the refraction texture.
  54811. * @returns the cloned texture
  54812. */
  54813. clone(): RefractionTexture;
  54814. /**
  54815. * Serialize the texture to a JSON representation you could use in Parse later on
  54816. * @returns the serialized JSON representation
  54817. */
  54818. serialize(): any;
  54819. }
  54820. }
  54821. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54822. import { Nullable } from "babylonjs/types";
  54823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54824. import { Matrix } from "babylonjs/Maths/math.vector";
  54825. import { Engine } from "babylonjs/Engines/engine";
  54826. import { Scene } from "babylonjs/scene";
  54827. /**
  54828. * Defines the options related to the creation of an HtmlElementTexture
  54829. */
  54830. export interface IHtmlElementTextureOptions {
  54831. /**
  54832. * Defines wether mip maps should be created or not.
  54833. */
  54834. generateMipMaps?: boolean;
  54835. /**
  54836. * Defines the sampling mode of the texture.
  54837. */
  54838. samplingMode?: number;
  54839. /**
  54840. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54841. */
  54842. engine: Nullable<Engine>;
  54843. /**
  54844. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54845. */
  54846. scene: Nullable<Scene>;
  54847. }
  54848. /**
  54849. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54850. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54851. * is automatically managed.
  54852. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54853. * in your application.
  54854. *
  54855. * As the update is not automatic, you need to call them manually.
  54856. */
  54857. export class HtmlElementTexture extends BaseTexture {
  54858. /**
  54859. * The texture URL.
  54860. */
  54861. element: HTMLVideoElement | HTMLCanvasElement;
  54862. private static readonly DefaultOptions;
  54863. private _textureMatrix;
  54864. private _engine;
  54865. private _isVideo;
  54866. private _generateMipMaps;
  54867. private _samplingMode;
  54868. /**
  54869. * Instantiates a HtmlElementTexture from the following parameters.
  54870. *
  54871. * @param name Defines the name of the texture
  54872. * @param element Defines the video or canvas the texture is filled with
  54873. * @param options Defines the other none mandatory texture creation options
  54874. */
  54875. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54876. private _createInternalTexture;
  54877. /**
  54878. * Returns the texture matrix used in most of the material.
  54879. */
  54880. getTextureMatrix(): Matrix;
  54881. /**
  54882. * Updates the content of the texture.
  54883. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54884. */
  54885. update(invertY?: Nullable<boolean>): void;
  54886. }
  54887. }
  54888. declare module "babylonjs/Materials/Textures/index" {
  54889. export * from "babylonjs/Materials/Textures/baseTexture";
  54890. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54891. export * from "babylonjs/Materials/Textures/cubeTexture";
  54892. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54893. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54894. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54895. export * from "babylonjs/Materials/Textures/internalTexture";
  54896. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54897. export * from "babylonjs/Materials/Textures/Loaders/index";
  54898. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54899. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54900. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54901. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54902. export * from "babylonjs/Materials/Textures/rawTexture";
  54903. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54904. export * from "babylonjs/Materials/Textures/refractionTexture";
  54905. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54906. export * from "babylonjs/Materials/Textures/texture";
  54907. export * from "babylonjs/Materials/Textures/videoTexture";
  54908. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54909. }
  54910. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54911. /**
  54912. * Enum used to define the target of a block
  54913. */
  54914. export enum NodeMaterialBlockTargets {
  54915. /** Vertex shader */
  54916. Vertex = 1,
  54917. /** Fragment shader */
  54918. Fragment = 2,
  54919. /** Neutral */
  54920. Neutral = 4,
  54921. /** Vertex and Fragment */
  54922. VertexAndFragment = 3
  54923. }
  54924. }
  54925. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54926. /**
  54927. * Defines the kind of connection point for node based material
  54928. */
  54929. export enum NodeMaterialBlockConnectionPointTypes {
  54930. /** Float */
  54931. Float = 1,
  54932. /** Int */
  54933. Int = 2,
  54934. /** Vector2 */
  54935. Vector2 = 4,
  54936. /** Vector3 */
  54937. Vector3 = 8,
  54938. /** Vector4 */
  54939. Vector4 = 16,
  54940. /** Color3 */
  54941. Color3 = 32,
  54942. /** Color4 */
  54943. Color4 = 64,
  54944. /** Matrix */
  54945. Matrix = 128,
  54946. /** Detect type based on connection */
  54947. AutoDetect = 1024,
  54948. /** Output type that will be defined by input type */
  54949. BasedOnInput = 2048
  54950. }
  54951. }
  54952. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54953. /**
  54954. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54955. */
  54956. export enum NodeMaterialBlockConnectionPointMode {
  54957. /** Value is an uniform */
  54958. Uniform = 0,
  54959. /** Value is a mesh attribute */
  54960. Attribute = 1,
  54961. /** Value is a varying between vertex and fragment shaders */
  54962. Varying = 2,
  54963. /** Mode is undefined */
  54964. Undefined = 3
  54965. }
  54966. }
  54967. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54968. /**
  54969. * Enum used to define system values e.g. values automatically provided by the system
  54970. */
  54971. export enum NodeMaterialSystemValues {
  54972. /** World */
  54973. World = 1,
  54974. /** View */
  54975. View = 2,
  54976. /** Projection */
  54977. Projection = 3,
  54978. /** ViewProjection */
  54979. ViewProjection = 4,
  54980. /** WorldView */
  54981. WorldView = 5,
  54982. /** WorldViewProjection */
  54983. WorldViewProjection = 6,
  54984. /** CameraPosition */
  54985. CameraPosition = 7,
  54986. /** Fog Color */
  54987. FogColor = 8
  54988. }
  54989. }
  54990. declare module "babylonjs/Materials/Node/Enums/index" {
  54991. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  54992. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  54993. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  54994. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  54995. }
  54996. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54998. /**
  54999. * Root class for all node material optimizers
  55000. */
  55001. export class NodeMaterialOptimizer {
  55002. /**
  55003. * Function used to optimize a NodeMaterial graph
  55004. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55005. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55006. */
  55007. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55008. }
  55009. }
  55010. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55014. import { Scene } from "babylonjs/scene";
  55015. /**
  55016. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55017. */
  55018. export class TransformBlock extends NodeMaterialBlock {
  55019. /**
  55020. * Defines the value to use to complement W value to transform it to a Vector4
  55021. */
  55022. complementW: number;
  55023. /**
  55024. * Defines the value to use to complement z value to transform it to a Vector4
  55025. */
  55026. complementZ: number;
  55027. /**
  55028. * Creates a new TransformBlock
  55029. * @param name defines the block name
  55030. */
  55031. constructor(name: string);
  55032. /**
  55033. * Gets the current class name
  55034. * @returns the class name
  55035. */
  55036. getClassName(): string;
  55037. /**
  55038. * Gets the vector input
  55039. */
  55040. readonly vector: NodeMaterialConnectionPoint;
  55041. /**
  55042. * Gets the output component
  55043. */
  55044. readonly output: NodeMaterialConnectionPoint;
  55045. /**
  55046. * Gets the matrix transform input
  55047. */
  55048. readonly transform: NodeMaterialConnectionPoint;
  55049. protected _buildBlock(state: NodeMaterialBuildState): this;
  55050. serialize(): any;
  55051. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55052. protected _dumpPropertiesCode(): string;
  55053. }
  55054. }
  55055. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55059. /**
  55060. * Block used to output the vertex position
  55061. */
  55062. export class VertexOutputBlock extends NodeMaterialBlock {
  55063. /**
  55064. * Creates a new VertexOutputBlock
  55065. * @param name defines the block name
  55066. */
  55067. constructor(name: string);
  55068. /**
  55069. * Gets the current class name
  55070. * @returns the class name
  55071. */
  55072. getClassName(): string;
  55073. /**
  55074. * Gets the vector input component
  55075. */
  55076. readonly vector: NodeMaterialConnectionPoint;
  55077. protected _buildBlock(state: NodeMaterialBuildState): this;
  55078. }
  55079. }
  55080. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55084. /**
  55085. * Block used to output the final color
  55086. */
  55087. export class FragmentOutputBlock extends NodeMaterialBlock {
  55088. /**
  55089. * Create a new FragmentOutputBlock
  55090. * @param name defines the block name
  55091. */
  55092. constructor(name: string);
  55093. /**
  55094. * Gets the current class name
  55095. * @returns the class name
  55096. */
  55097. getClassName(): string;
  55098. /**
  55099. * Gets the rgba input component
  55100. */
  55101. readonly rgba: NodeMaterialConnectionPoint;
  55102. /**
  55103. * Gets the rgb input component
  55104. */
  55105. readonly rgb: NodeMaterialConnectionPoint;
  55106. /**
  55107. * Gets the a input component
  55108. */
  55109. readonly a: NodeMaterialConnectionPoint;
  55110. protected _buildBlock(state: NodeMaterialBuildState): this;
  55111. }
  55112. }
  55113. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55115. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55119. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55120. import { Effect } from "babylonjs/Materials/effect";
  55121. import { Mesh } from "babylonjs/Meshes/mesh";
  55122. import { Nullable } from "babylonjs/types";
  55123. import { Scene } from "babylonjs/scene";
  55124. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55125. /**
  55126. * Block used to read a reflection texture from a sampler
  55127. */
  55128. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55129. private _define3DName;
  55130. private _defineCubicName;
  55131. private _defineExplicitName;
  55132. private _defineProjectionName;
  55133. private _defineLocalCubicName;
  55134. private _defineSphericalName;
  55135. private _definePlanarName;
  55136. private _defineEquirectangularName;
  55137. private _defineMirroredEquirectangularFixedName;
  55138. private _defineEquirectangularFixedName;
  55139. private _defineSkyboxName;
  55140. private _cubeSamplerName;
  55141. private _2DSamplerName;
  55142. private _positionUVWName;
  55143. private _directionWName;
  55144. private _reflectionCoordsName;
  55145. private _reflection2DCoordsName;
  55146. private _reflectionColorName;
  55147. private _reflectionMatrixName;
  55148. /**
  55149. * Gets or sets the texture associated with the node
  55150. */
  55151. texture: Nullable<BaseTexture>;
  55152. /**
  55153. * Create a new TextureBlock
  55154. * @param name defines the block name
  55155. */
  55156. constructor(name: string);
  55157. /**
  55158. * Gets the current class name
  55159. * @returns the class name
  55160. */
  55161. getClassName(): string;
  55162. /**
  55163. * Gets the world position input component
  55164. */
  55165. readonly position: NodeMaterialConnectionPoint;
  55166. /**
  55167. * Gets the world position input component
  55168. */
  55169. readonly worldPosition: NodeMaterialConnectionPoint;
  55170. /**
  55171. * Gets the world normal input component
  55172. */
  55173. readonly worldNormal: NodeMaterialConnectionPoint;
  55174. /**
  55175. * Gets the world input component
  55176. */
  55177. readonly world: NodeMaterialConnectionPoint;
  55178. /**
  55179. * Gets the camera (or eye) position component
  55180. */
  55181. readonly cameraPosition: NodeMaterialConnectionPoint;
  55182. /**
  55183. * Gets the view input component
  55184. */
  55185. readonly view: NodeMaterialConnectionPoint;
  55186. /**
  55187. * Gets the rgb output component
  55188. */
  55189. readonly rgb: NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the r output component
  55192. */
  55193. readonly r: NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the g output component
  55196. */
  55197. readonly g: NodeMaterialConnectionPoint;
  55198. /**
  55199. * Gets the b output component
  55200. */
  55201. readonly b: NodeMaterialConnectionPoint;
  55202. autoConfigure(material: NodeMaterial): void;
  55203. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55204. isReady(): boolean;
  55205. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55206. private _injectVertexCode;
  55207. private _writeOutput;
  55208. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55209. serialize(): any;
  55210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55211. }
  55212. }
  55213. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55215. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55216. import { Scene } from "babylonjs/scene";
  55217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55218. import { Matrix } from "babylonjs/Maths/math.vector";
  55219. import { Mesh } from "babylonjs/Meshes/mesh";
  55220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55221. import { Observable } from "babylonjs/Misc/observable";
  55222. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55223. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55224. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55225. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55226. import { Nullable } from "babylonjs/types";
  55227. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55228. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55229. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55230. /**
  55231. * Interface used to configure the node material editor
  55232. */
  55233. export interface INodeMaterialEditorOptions {
  55234. /** Define the URl to load node editor script */
  55235. editorURL?: string;
  55236. }
  55237. /** @hidden */
  55238. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55239. /** BONES */
  55240. NUM_BONE_INFLUENCERS: number;
  55241. BonesPerMesh: number;
  55242. BONETEXTURE: boolean;
  55243. /** MORPH TARGETS */
  55244. MORPHTARGETS: boolean;
  55245. MORPHTARGETS_NORMAL: boolean;
  55246. MORPHTARGETS_TANGENT: boolean;
  55247. MORPHTARGETS_UV: boolean;
  55248. NUM_MORPH_INFLUENCERS: number;
  55249. /** IMAGE PROCESSING */
  55250. IMAGEPROCESSING: boolean;
  55251. VIGNETTE: boolean;
  55252. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55253. VIGNETTEBLENDMODEOPAQUE: boolean;
  55254. TONEMAPPING: boolean;
  55255. TONEMAPPING_ACES: boolean;
  55256. CONTRAST: boolean;
  55257. EXPOSURE: boolean;
  55258. COLORCURVES: boolean;
  55259. COLORGRADING: boolean;
  55260. COLORGRADING3D: boolean;
  55261. SAMPLER3DGREENDEPTH: boolean;
  55262. SAMPLER3DBGRMAP: boolean;
  55263. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55264. /** MISC. */
  55265. BUMPDIRECTUV: number;
  55266. constructor();
  55267. setValue(name: string, value: boolean): void;
  55268. }
  55269. /**
  55270. * Class used to configure NodeMaterial
  55271. */
  55272. export interface INodeMaterialOptions {
  55273. /**
  55274. * Defines if blocks should emit comments
  55275. */
  55276. emitComments: boolean;
  55277. }
  55278. /**
  55279. * Class used to create a node based material built by assembling shader blocks
  55280. */
  55281. export class NodeMaterial extends PushMaterial {
  55282. private static _BuildIdGenerator;
  55283. private _options;
  55284. private _vertexCompilationState;
  55285. private _fragmentCompilationState;
  55286. private _sharedData;
  55287. private _buildId;
  55288. private _buildWasSuccessful;
  55289. private _cachedWorldViewMatrix;
  55290. private _cachedWorldViewProjectionMatrix;
  55291. private _optimizers;
  55292. private _animationFrame;
  55293. /** Define the URl to load node editor script */
  55294. static EditorURL: string;
  55295. private BJSNODEMATERIALEDITOR;
  55296. /** Get the inspector from bundle or global */
  55297. private _getGlobalNodeMaterialEditor;
  55298. /**
  55299. * 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)
  55300. */
  55301. ignoreAlpha: boolean;
  55302. /**
  55303. * Defines the maximum number of lights that can be used in the material
  55304. */
  55305. maxSimultaneousLights: number;
  55306. /**
  55307. * Observable raised when the material is built
  55308. */
  55309. onBuildObservable: Observable<NodeMaterial>;
  55310. /**
  55311. * Gets or sets the root nodes of the material vertex shader
  55312. */
  55313. _vertexOutputNodes: NodeMaterialBlock[];
  55314. /**
  55315. * Gets or sets the root nodes of the material fragment (pixel) shader
  55316. */
  55317. _fragmentOutputNodes: NodeMaterialBlock[];
  55318. /** Gets or sets options to control the node material overall behavior */
  55319. options: INodeMaterialOptions;
  55320. /**
  55321. * Default configuration related to image processing available in the standard Material.
  55322. */
  55323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55324. /**
  55325. * Gets the image processing configuration used either in this material.
  55326. */
  55327. /**
  55328. * Sets the Default image processing configuration used either in the this material.
  55329. *
  55330. * If sets to null, the scene one is in use.
  55331. */
  55332. imageProcessingConfiguration: ImageProcessingConfiguration;
  55333. /**
  55334. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55335. */
  55336. attachedBlocks: NodeMaterialBlock[];
  55337. /**
  55338. * Create a new node based material
  55339. * @param name defines the material name
  55340. * @param scene defines the hosting scene
  55341. * @param options defines creation option
  55342. */
  55343. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55344. /**
  55345. * Gets the current class name of the material e.g. "NodeMaterial"
  55346. * @returns the class name
  55347. */
  55348. getClassName(): string;
  55349. /**
  55350. * Keep track of the image processing observer to allow dispose and replace.
  55351. */
  55352. private _imageProcessingObserver;
  55353. /**
  55354. * Attaches a new image processing configuration to the Standard Material.
  55355. * @param configuration
  55356. */
  55357. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55358. /**
  55359. * Get a block by its name
  55360. * @param name defines the name of the block to retrieve
  55361. * @returns the required block or null if not found
  55362. */
  55363. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55364. /**
  55365. * Get a block by its name
  55366. * @param predicate defines the predicate used to find the good candidate
  55367. * @returns the required block or null if not found
  55368. */
  55369. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55370. /**
  55371. * Get an input block by its name
  55372. * @param predicate defines the predicate used to find the good candidate
  55373. * @returns the required input block or null if not found
  55374. */
  55375. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55376. /**
  55377. * Gets the list of input blocks attached to this material
  55378. * @returns an array of InputBlocks
  55379. */
  55380. getInputBlocks(): InputBlock[];
  55381. /**
  55382. * Adds a new optimizer to the list of optimizers
  55383. * @param optimizer defines the optimizers to add
  55384. * @returns the current material
  55385. */
  55386. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55387. /**
  55388. * Remove an optimizer from the list of optimizers
  55389. * @param optimizer defines the optimizers to remove
  55390. * @returns the current material
  55391. */
  55392. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55393. /**
  55394. * Add a new block to the list of output nodes
  55395. * @param node defines the node to add
  55396. * @returns the current material
  55397. */
  55398. addOutputNode(node: NodeMaterialBlock): this;
  55399. /**
  55400. * Remove a block from the list of root nodes
  55401. * @param node defines the node to remove
  55402. * @returns the current material
  55403. */
  55404. removeOutputNode(node: NodeMaterialBlock): this;
  55405. private _addVertexOutputNode;
  55406. private _removeVertexOutputNode;
  55407. private _addFragmentOutputNode;
  55408. private _removeFragmentOutputNode;
  55409. /**
  55410. * Specifies if the material will require alpha blending
  55411. * @returns a boolean specifying if alpha blending is needed
  55412. */
  55413. needAlphaBlending(): boolean;
  55414. /**
  55415. * Specifies if this material should be rendered in alpha test mode
  55416. * @returns a boolean specifying if an alpha test is needed.
  55417. */
  55418. needAlphaTesting(): boolean;
  55419. private _initializeBlock;
  55420. private _resetDualBlocks;
  55421. /**
  55422. * Build the material and generates the inner effect
  55423. * @param verbose defines if the build should log activity
  55424. */
  55425. build(verbose?: boolean): void;
  55426. /**
  55427. * Runs an otpimization phase to try to improve the shader code
  55428. */
  55429. optimize(): void;
  55430. private _prepareDefinesForAttributes;
  55431. /**
  55432. * Get if the submesh is ready to be used and all its information available.
  55433. * Child classes can use it to update shaders
  55434. * @param mesh defines the mesh to check
  55435. * @param subMesh defines which submesh to check
  55436. * @param useInstances specifies that instances should be used
  55437. * @returns a boolean indicating that the submesh is ready or not
  55438. */
  55439. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55440. /**
  55441. * Get a string representing the shaders built by the current node graph
  55442. */
  55443. readonly compiledShaders: string;
  55444. /**
  55445. * Binds the world matrix to the material
  55446. * @param world defines the world transformation matrix
  55447. */
  55448. bindOnlyWorldMatrix(world: Matrix): void;
  55449. /**
  55450. * Binds the submesh to this material by preparing the effect and shader to draw
  55451. * @param world defines the world transformation matrix
  55452. * @param mesh defines the mesh containing the submesh
  55453. * @param subMesh defines the submesh to bind the material to
  55454. */
  55455. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55456. /**
  55457. * Gets the active textures from the material
  55458. * @returns an array of textures
  55459. */
  55460. getActiveTextures(): BaseTexture[];
  55461. /**
  55462. * Gets the list of texture blocks
  55463. * @returns an array of texture blocks
  55464. */
  55465. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55466. /**
  55467. * Specifies if the material uses a texture
  55468. * @param texture defines the texture to check against the material
  55469. * @returns a boolean specifying if the material uses the texture
  55470. */
  55471. hasTexture(texture: BaseTexture): boolean;
  55472. /**
  55473. * Disposes the material
  55474. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55475. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55476. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55477. */
  55478. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55479. /** Creates the node editor window. */
  55480. private _createNodeEditor;
  55481. /**
  55482. * Launch the node material editor
  55483. * @param config Define the configuration of the editor
  55484. * @return a promise fulfilled when the node editor is visible
  55485. */
  55486. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55487. /**
  55488. * Clear the current material
  55489. */
  55490. clear(): void;
  55491. /**
  55492. * Clear the current material and set it to a default state
  55493. */
  55494. setToDefault(): void;
  55495. /**
  55496. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55497. * @param url defines the url to load from
  55498. * @returns a promise that will fullfil when the material is fully loaded
  55499. */
  55500. loadAsync(url: string): Promise<unknown>;
  55501. private _gatherBlocks;
  55502. /**
  55503. * Generate a string containing the code declaration required to create an equivalent of this material
  55504. * @returns a string
  55505. */
  55506. generateCode(): string;
  55507. /**
  55508. * Serializes this material in a JSON representation
  55509. * @returns the serialized material object
  55510. */
  55511. serialize(): any;
  55512. private _restoreConnections;
  55513. /**
  55514. * Clear the current graph and load a new one from a serialization object
  55515. * @param source defines the JSON representation of the material
  55516. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55517. */
  55518. loadFromSerialization(source: any, rootUrl?: string): void;
  55519. /**
  55520. * Creates a node material from parsed material data
  55521. * @param source defines the JSON representation of the material
  55522. * @param scene defines the hosting scene
  55523. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55524. * @returns a new node material
  55525. */
  55526. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55527. /**
  55528. * Creates a new node material set to default basic configuration
  55529. * @param name defines the name of the material
  55530. * @param scene defines the hosting scene
  55531. * @returns a new NodeMaterial
  55532. */
  55533. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55534. }
  55535. }
  55536. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55539. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55542. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55543. import { Effect } from "babylonjs/Materials/effect";
  55544. import { Mesh } from "babylonjs/Meshes/mesh";
  55545. import { Nullable } from "babylonjs/types";
  55546. import { Texture } from "babylonjs/Materials/Textures/texture";
  55547. import { Scene } from "babylonjs/scene";
  55548. /**
  55549. * Block used to read a texture from a sampler
  55550. */
  55551. export class TextureBlock extends NodeMaterialBlock {
  55552. private _defineName;
  55553. private _samplerName;
  55554. private _transformedUVName;
  55555. private _textureTransformName;
  55556. private _textureInfoName;
  55557. private _mainUVName;
  55558. private _mainUVDefineName;
  55559. /**
  55560. * Gets or sets the texture associated with the node
  55561. */
  55562. texture: Nullable<Texture>;
  55563. /**
  55564. * Create a new TextureBlock
  55565. * @param name defines the block name
  55566. */
  55567. constructor(name: string);
  55568. /**
  55569. * Gets the current class name
  55570. * @returns the class name
  55571. */
  55572. getClassName(): string;
  55573. /**
  55574. * Gets the uv input component
  55575. */
  55576. readonly uv: NodeMaterialConnectionPoint;
  55577. /**
  55578. * Gets the rgba output component
  55579. */
  55580. readonly rgba: NodeMaterialConnectionPoint;
  55581. /**
  55582. * Gets the rgb output component
  55583. */
  55584. readonly rgb: NodeMaterialConnectionPoint;
  55585. /**
  55586. * Gets the r output component
  55587. */
  55588. readonly r: NodeMaterialConnectionPoint;
  55589. /**
  55590. * Gets the g output component
  55591. */
  55592. readonly g: NodeMaterialConnectionPoint;
  55593. /**
  55594. * Gets the b output component
  55595. */
  55596. readonly b: NodeMaterialConnectionPoint;
  55597. /**
  55598. * Gets the a output component
  55599. */
  55600. readonly a: NodeMaterialConnectionPoint;
  55601. readonly target: NodeMaterialBlockTargets;
  55602. autoConfigure(material: NodeMaterial): void;
  55603. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55605. isReady(): boolean;
  55606. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55607. private readonly _isMixed;
  55608. private _injectVertexCode;
  55609. private _writeOutput;
  55610. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55611. protected _dumpPropertiesCode(): string;
  55612. serialize(): any;
  55613. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55614. }
  55615. }
  55616. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55617. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55619. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55620. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55621. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55622. import { Scene } from "babylonjs/scene";
  55623. /**
  55624. * Class used to store shared data between 2 NodeMaterialBuildState
  55625. */
  55626. export class NodeMaterialBuildStateSharedData {
  55627. /**
  55628. * Gets the list of emitted varyings
  55629. */
  55630. temps: string[];
  55631. /**
  55632. * Gets the list of emitted varyings
  55633. */
  55634. varyings: string[];
  55635. /**
  55636. * Gets the varying declaration string
  55637. */
  55638. varyingDeclaration: string;
  55639. /**
  55640. * Input blocks
  55641. */
  55642. inputBlocks: InputBlock[];
  55643. /**
  55644. * Input blocks
  55645. */
  55646. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55647. /**
  55648. * Bindable blocks (Blocks that need to set data to the effect)
  55649. */
  55650. bindableBlocks: NodeMaterialBlock[];
  55651. /**
  55652. * List of blocks that can provide a compilation fallback
  55653. */
  55654. blocksWithFallbacks: NodeMaterialBlock[];
  55655. /**
  55656. * List of blocks that can provide a define update
  55657. */
  55658. blocksWithDefines: NodeMaterialBlock[];
  55659. /**
  55660. * List of blocks that can provide a repeatable content
  55661. */
  55662. repeatableContentBlocks: NodeMaterialBlock[];
  55663. /**
  55664. * List of blocks that can provide a dynamic list of uniforms
  55665. */
  55666. dynamicUniformBlocks: NodeMaterialBlock[];
  55667. /**
  55668. * List of blocks that can block the isReady function for the material
  55669. */
  55670. blockingBlocks: NodeMaterialBlock[];
  55671. /**
  55672. * Gets the list of animated inputs
  55673. */
  55674. animatedInputs: InputBlock[];
  55675. /**
  55676. * Build Id used to avoid multiple recompilations
  55677. */
  55678. buildId: number;
  55679. /** List of emitted variables */
  55680. variableNames: {
  55681. [key: string]: number;
  55682. };
  55683. /** List of emitted defines */
  55684. defineNames: {
  55685. [key: string]: number;
  55686. };
  55687. /** Should emit comments? */
  55688. emitComments: boolean;
  55689. /** Emit build activity */
  55690. verbose: boolean;
  55691. /** Gets or sets the hosting scene */
  55692. scene: Scene;
  55693. /**
  55694. * Gets the compilation hints emitted at compilation time
  55695. */
  55696. hints: {
  55697. needWorldViewMatrix: boolean;
  55698. needWorldViewProjectionMatrix: boolean;
  55699. needAlphaBlending: boolean;
  55700. needAlphaTesting: boolean;
  55701. };
  55702. /**
  55703. * List of compilation checks
  55704. */
  55705. checks: {
  55706. emitVertex: boolean;
  55707. emitFragment: boolean;
  55708. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55709. };
  55710. /** Creates a new shared data */
  55711. constructor();
  55712. /**
  55713. * Emits console errors and exceptions if there is a failing check
  55714. */
  55715. emitErrors(): void;
  55716. }
  55717. }
  55718. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55719. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55720. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55721. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55722. /**
  55723. * Class used to store node based material build state
  55724. */
  55725. export class NodeMaterialBuildState {
  55726. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55727. supportUniformBuffers: boolean;
  55728. /**
  55729. * Gets the list of emitted attributes
  55730. */
  55731. attributes: string[];
  55732. /**
  55733. * Gets the list of emitted uniforms
  55734. */
  55735. uniforms: string[];
  55736. /**
  55737. * Gets the list of emitted constants
  55738. */
  55739. constants: string[];
  55740. /**
  55741. * Gets the list of emitted uniform buffers
  55742. */
  55743. uniformBuffers: string[];
  55744. /**
  55745. * Gets the list of emitted samplers
  55746. */
  55747. samplers: string[];
  55748. /**
  55749. * Gets the list of emitted functions
  55750. */
  55751. functions: {
  55752. [key: string]: string;
  55753. };
  55754. /**
  55755. * Gets the list of emitted extensions
  55756. */
  55757. extensions: {
  55758. [key: string]: string;
  55759. };
  55760. /**
  55761. * Gets the target of the compilation state
  55762. */
  55763. target: NodeMaterialBlockTargets;
  55764. /**
  55765. * Gets the list of emitted counters
  55766. */
  55767. counters: {
  55768. [key: string]: number;
  55769. };
  55770. /**
  55771. * Shared data between multiple NodeMaterialBuildState instances
  55772. */
  55773. sharedData: NodeMaterialBuildStateSharedData;
  55774. /** @hidden */
  55775. _vertexState: NodeMaterialBuildState;
  55776. /** @hidden */
  55777. _attributeDeclaration: string;
  55778. /** @hidden */
  55779. _uniformDeclaration: string;
  55780. /** @hidden */
  55781. _constantDeclaration: string;
  55782. /** @hidden */
  55783. _samplerDeclaration: string;
  55784. /** @hidden */
  55785. _varyingTransfer: string;
  55786. private _repeatableContentAnchorIndex;
  55787. /** @hidden */
  55788. _builtCompilationString: string;
  55789. /**
  55790. * Gets the emitted compilation strings
  55791. */
  55792. compilationString: string;
  55793. /**
  55794. * Finalize the compilation strings
  55795. * @param state defines the current compilation state
  55796. */
  55797. finalize(state: NodeMaterialBuildState): void;
  55798. /** @hidden */
  55799. readonly _repeatableContentAnchor: string;
  55800. /** @hidden */
  55801. _getFreeVariableName(prefix: string): string;
  55802. /** @hidden */
  55803. _getFreeDefineName(prefix: string): string;
  55804. /** @hidden */
  55805. _excludeVariableName(name: string): void;
  55806. /** @hidden */
  55807. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55808. /** @hidden */
  55809. _emitExtension(name: string, extension: string): void;
  55810. /** @hidden */
  55811. _emitFunction(name: string, code: string, comments: string): void;
  55812. /** @hidden */
  55813. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55814. replaceStrings?: {
  55815. search: RegExp;
  55816. replace: string;
  55817. }[];
  55818. repeatKey?: string;
  55819. }): string;
  55820. /** @hidden */
  55821. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55822. repeatKey?: string;
  55823. removeAttributes?: boolean;
  55824. removeUniforms?: boolean;
  55825. removeVaryings?: boolean;
  55826. removeIfDef?: boolean;
  55827. replaceStrings?: {
  55828. search: RegExp;
  55829. replace: string;
  55830. }[];
  55831. }, storeKey?: string): void;
  55832. /** @hidden */
  55833. _registerTempVariable(name: string): boolean;
  55834. /** @hidden */
  55835. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55836. /** @hidden */
  55837. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55838. }
  55839. }
  55840. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55841. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55843. import { Nullable } from "babylonjs/types";
  55844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55845. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55846. import { Effect } from "babylonjs/Materials/effect";
  55847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55848. import { Mesh } from "babylonjs/Meshes/mesh";
  55849. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55850. import { Scene } from "babylonjs/scene";
  55851. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55852. /**
  55853. * Defines a block that can be used inside a node based material
  55854. */
  55855. export class NodeMaterialBlock {
  55856. private _buildId;
  55857. private _buildTarget;
  55858. private _target;
  55859. private _isFinalMerger;
  55860. private _isInput;
  55861. /** @hidden */
  55862. _codeVariableName: string;
  55863. /** @hidden */
  55864. _inputs: NodeMaterialConnectionPoint[];
  55865. /** @hidden */
  55866. _outputs: NodeMaterialConnectionPoint[];
  55867. /** @hidden */
  55868. _preparationId: number;
  55869. /**
  55870. * Gets or sets the name of the block
  55871. */
  55872. name: string;
  55873. /**
  55874. * Gets or sets the unique id of the node
  55875. */
  55876. uniqueId: number;
  55877. /**
  55878. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55879. */
  55880. readonly isFinalMerger: boolean;
  55881. /**
  55882. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55883. */
  55884. readonly isInput: boolean;
  55885. /**
  55886. * Gets or sets the build Id
  55887. */
  55888. buildId: number;
  55889. /**
  55890. * Gets or sets the target of the block
  55891. */
  55892. target: NodeMaterialBlockTargets;
  55893. /**
  55894. * Gets the list of input points
  55895. */
  55896. readonly inputs: NodeMaterialConnectionPoint[];
  55897. /** Gets the list of output points */
  55898. readonly outputs: NodeMaterialConnectionPoint[];
  55899. /**
  55900. * Find an input by its name
  55901. * @param name defines the name of the input to look for
  55902. * @returns the input or null if not found
  55903. */
  55904. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55905. /**
  55906. * Find an output by its name
  55907. * @param name defines the name of the outputto look for
  55908. * @returns the output or null if not found
  55909. */
  55910. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55911. /**
  55912. * Creates a new NodeMaterialBlock
  55913. * @param name defines the block name
  55914. * @param target defines the target of that block (Vertex by default)
  55915. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55916. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55917. */
  55918. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55919. /**
  55920. * Initialize the block and prepare the context for build
  55921. * @param state defines the state that will be used for the build
  55922. */
  55923. initialize(state: NodeMaterialBuildState): void;
  55924. /**
  55925. * Bind data to effect. Will only be called for blocks with isBindable === true
  55926. * @param effect defines the effect to bind data to
  55927. * @param nodeMaterial defines the hosting NodeMaterial
  55928. * @param mesh defines the mesh that will be rendered
  55929. */
  55930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55931. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55932. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55933. protected _writeFloat(value: number): string;
  55934. /**
  55935. * Gets the current class name e.g. "NodeMaterialBlock"
  55936. * @returns the class name
  55937. */
  55938. getClassName(): string;
  55939. /**
  55940. * Register a new input. Must be called inside a block constructor
  55941. * @param name defines the connection point name
  55942. * @param type defines the connection point type
  55943. * @param isOptional defines a boolean indicating that this input can be omitted
  55944. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55945. * @returns the current block
  55946. */
  55947. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55948. /**
  55949. * Register a new output. Must be called inside a block constructor
  55950. * @param name defines the connection point name
  55951. * @param type defines the connection point type
  55952. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55953. * @returns the current block
  55954. */
  55955. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55956. /**
  55957. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55958. * @param forOutput defines an optional connection point to check compatibility with
  55959. * @returns the first available input or null
  55960. */
  55961. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55962. /**
  55963. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55964. * @param forBlock defines an optional block to check compatibility with
  55965. * @returns the first available input or null
  55966. */
  55967. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55968. /**
  55969. * Gets the sibling of the given output
  55970. * @param current defines the current output
  55971. * @returns the next output in the list or null
  55972. */
  55973. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55974. /**
  55975. * Connect current block with another block
  55976. * @param other defines the block to connect with
  55977. * @param options define the various options to help pick the right connections
  55978. * @returns the current block
  55979. */
  55980. connectTo(other: NodeMaterialBlock, options?: {
  55981. input?: string;
  55982. output?: string;
  55983. outputSwizzle?: string;
  55984. }): this | undefined;
  55985. protected _buildBlock(state: NodeMaterialBuildState): void;
  55986. /**
  55987. * Add uniforms, samplers and uniform buffers at compilation time
  55988. * @param state defines the state to update
  55989. * @param nodeMaterial defines the node material requesting the update
  55990. * @param defines defines the material defines to update
  55991. */
  55992. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55993. /**
  55994. * Add potential fallbacks if shader compilation fails
  55995. * @param mesh defines the mesh to be rendered
  55996. * @param fallbacks defines the current prioritized list of fallbacks
  55997. */
  55998. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55999. /**
  56000. * Initialize defines for shader compilation
  56001. * @param mesh defines the mesh to be rendered
  56002. * @param nodeMaterial defines the node material requesting the update
  56003. * @param defines defines the material defines to update
  56004. * @param useInstances specifies that instances should be used
  56005. */
  56006. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56007. /**
  56008. * Update defines for shader compilation
  56009. * @param mesh defines the mesh to be rendered
  56010. * @param nodeMaterial defines the node material requesting the update
  56011. * @param defines defines the material defines to update
  56012. * @param useInstances specifies that instances should be used
  56013. */
  56014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56015. /**
  56016. * Lets the block try to connect some inputs automatically
  56017. * @param material defines the hosting NodeMaterial
  56018. */
  56019. autoConfigure(material: NodeMaterial): void;
  56020. /**
  56021. * Function called when a block is declared as repeatable content generator
  56022. * @param vertexShaderState defines the current compilation state for the vertex shader
  56023. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56024. * @param mesh defines the mesh to be rendered
  56025. * @param defines defines the material defines to update
  56026. */
  56027. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56028. /**
  56029. * Checks if the block is ready
  56030. * @param mesh defines the mesh to be rendered
  56031. * @param nodeMaterial defines the node material requesting the update
  56032. * @param defines defines the material defines to update
  56033. * @param useInstances specifies that instances should be used
  56034. * @returns true if the block is ready
  56035. */
  56036. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56037. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56038. private _processBuild;
  56039. /**
  56040. * Compile the current node and generate the shader code
  56041. * @param state defines the current compilation state (uniforms, samplers, current string)
  56042. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56043. * @returns true if already built
  56044. */
  56045. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56046. protected _inputRename(name: string): string;
  56047. protected _outputRename(name: string): string;
  56048. protected _dumpPropertiesCode(): string;
  56049. /** @hidden */
  56050. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56051. /**
  56052. * Clone the current block to a new identical block
  56053. * @param scene defines the hosting scene
  56054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56055. * @returns a copy of the current block
  56056. */
  56057. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56058. /**
  56059. * Serializes this block in a JSON representation
  56060. * @returns the serialized block object
  56061. */
  56062. serialize(): any;
  56063. /** @hidden */
  56064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56065. }
  56066. }
  56067. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56068. /**
  56069. * Enum defining the type of animations supported by InputBlock
  56070. */
  56071. export enum AnimatedInputBlockTypes {
  56072. /** No animation */
  56073. None = 0,
  56074. /** Time based animation. Will only work for floats */
  56075. Time = 1
  56076. }
  56077. }
  56078. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56080. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56081. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56082. import { Nullable } from "babylonjs/types";
  56083. import { Effect } from "babylonjs/Materials/effect";
  56084. import { Matrix } from "babylonjs/Maths/math.vector";
  56085. import { Scene } from "babylonjs/scene";
  56086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56088. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56089. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56090. /**
  56091. * Block used to expose an input value
  56092. */
  56093. export class InputBlock extends NodeMaterialBlock {
  56094. private _mode;
  56095. private _associatedVariableName;
  56096. private _storedValue;
  56097. private _valueCallback;
  56098. private _type;
  56099. private _animationType;
  56100. /** Gets or set a value used to limit the range of float values */
  56101. min: number;
  56102. /** Gets or set a value used to limit the range of float values */
  56103. max: number;
  56104. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56105. matrixMode: number;
  56106. /** @hidden */
  56107. _systemValue: Nullable<NodeMaterialSystemValues>;
  56108. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56109. visibleInInspector: boolean;
  56110. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56111. isConstant: boolean;
  56112. /**
  56113. * Gets or sets the connection point type (default is float)
  56114. */
  56115. readonly type: NodeMaterialBlockConnectionPointTypes;
  56116. /**
  56117. * Creates a new InputBlock
  56118. * @param name defines the block name
  56119. * @param target defines the target of that block (Vertex by default)
  56120. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56121. */
  56122. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56123. /**
  56124. * Gets the output component
  56125. */
  56126. readonly output: NodeMaterialConnectionPoint;
  56127. /**
  56128. * Set the source of this connection point to a vertex attribute
  56129. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56130. * @returns the current connection point
  56131. */
  56132. setAsAttribute(attributeName?: string): InputBlock;
  56133. /**
  56134. * Set the source of this connection point to a system value
  56135. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56136. * @returns the current connection point
  56137. */
  56138. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56139. /**
  56140. * Gets or sets the value of that point.
  56141. * Please note that this value will be ignored if valueCallback is defined
  56142. */
  56143. value: any;
  56144. /**
  56145. * Gets or sets a callback used to get the value of that point.
  56146. * Please note that setting this value will force the connection point to ignore the value property
  56147. */
  56148. valueCallback: () => any;
  56149. /**
  56150. * Gets or sets the associated variable name in the shader
  56151. */
  56152. associatedVariableName: string;
  56153. /** Gets or sets the type of animation applied to the input */
  56154. animationType: AnimatedInputBlockTypes;
  56155. /**
  56156. * Gets a boolean indicating that this connection point not defined yet
  56157. */
  56158. readonly isUndefined: boolean;
  56159. /**
  56160. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56161. * In this case the connection point name must be the name of the uniform to use.
  56162. * Can only be set on inputs
  56163. */
  56164. isUniform: boolean;
  56165. /**
  56166. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56167. * In this case the connection point name must be the name of the attribute to use
  56168. * Can only be set on inputs
  56169. */
  56170. isAttribute: boolean;
  56171. /**
  56172. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56173. * Can only be set on exit points
  56174. */
  56175. isVarying: boolean;
  56176. /**
  56177. * Gets a boolean indicating that the current connection point is a system value
  56178. */
  56179. readonly isSystemValue: boolean;
  56180. /**
  56181. * Gets or sets the current well known value or null if not defined as a system value
  56182. */
  56183. systemValue: Nullable<NodeMaterialSystemValues>;
  56184. /**
  56185. * Gets the current class name
  56186. * @returns the class name
  56187. */
  56188. getClassName(): string;
  56189. /**
  56190. * Animate the input if animationType !== None
  56191. * @param scene defines the rendering scene
  56192. */
  56193. animate(scene: Scene): void;
  56194. private _emitDefine;
  56195. initialize(state: NodeMaterialBuildState): void;
  56196. /**
  56197. * Set the input block to its default value (based on its type)
  56198. */
  56199. setDefaultValue(): void;
  56200. private _emitConstant;
  56201. private _emit;
  56202. /** @hidden */
  56203. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56204. /** @hidden */
  56205. _transmit(effect: Effect, scene: Scene): void;
  56206. protected _buildBlock(state: NodeMaterialBuildState): void;
  56207. protected _dumpPropertiesCode(): string;
  56208. serialize(): any;
  56209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56210. }
  56211. }
  56212. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56213. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56214. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56215. import { Nullable } from "babylonjs/types";
  56216. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56218. /**
  56219. * Defines a connection point for a block
  56220. */
  56221. export class NodeMaterialConnectionPoint {
  56222. /** @hidden */
  56223. _ownerBlock: NodeMaterialBlock;
  56224. /** @hidden */
  56225. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56226. private _endpoints;
  56227. private _associatedVariableName;
  56228. /** @hidden */
  56229. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56230. /** @hidden */
  56231. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56232. private _type;
  56233. /** @hidden */
  56234. _enforceAssociatedVariableName: boolean;
  56235. /**
  56236. * Gets or sets the additional types supported by this connection point
  56237. */
  56238. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56239. /**
  56240. * Gets or sets the additional types excluded by this connection point
  56241. */
  56242. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56243. /**
  56244. * Gets or sets the associated variable name in the shader
  56245. */
  56246. associatedVariableName: string;
  56247. /**
  56248. * Gets or sets the connection point type (default is float)
  56249. */
  56250. type: NodeMaterialBlockConnectionPointTypes;
  56251. /**
  56252. * Gets or sets the connection point name
  56253. */
  56254. name: string;
  56255. /**
  56256. * Gets or sets a boolean indicating that this connection point can be omitted
  56257. */
  56258. isOptional: boolean;
  56259. /**
  56260. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56261. */
  56262. define: string;
  56263. /** Gets or sets the target of that connection point */
  56264. target: NodeMaterialBlockTargets;
  56265. /**
  56266. * Gets a boolean indicating that the current point is connected
  56267. */
  56268. readonly isConnected: boolean;
  56269. /**
  56270. * Gets a boolean indicating that the current point is connected to an input block
  56271. */
  56272. readonly isConnectedToInputBlock: boolean;
  56273. /**
  56274. * Gets a the connected input block (if any)
  56275. */
  56276. readonly connectInputBlock: Nullable<InputBlock>;
  56277. /** Get the other side of the connection (if any) */
  56278. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56279. /** Get the block that owns this connection point */
  56280. readonly ownerBlock: NodeMaterialBlock;
  56281. /** Get the block connected on the other side of this connection (if any) */
  56282. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56283. /** Get the block connected on the endpoints of this connection (if any) */
  56284. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56285. /** Gets the list of connected endpoints */
  56286. readonly endpoints: NodeMaterialConnectionPoint[];
  56287. /** Gets a boolean indicating if that output point is connected to at least one input */
  56288. readonly hasEndpoints: boolean;
  56289. /**
  56290. * Creates a new connection point
  56291. * @param name defines the connection point name
  56292. * @param ownerBlock defines the block hosting this connection point
  56293. */
  56294. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56295. /**
  56296. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56297. * @returns the class name
  56298. */
  56299. getClassName(): string;
  56300. /**
  56301. * Gets an boolean indicating if the current point can be connected to another point
  56302. * @param connectionPoint defines the other connection point
  56303. * @returns true if the connection is possible
  56304. */
  56305. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56306. /**
  56307. * Connect this point to another connection point
  56308. * @param connectionPoint defines the other connection point
  56309. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56310. * @returns the current connection point
  56311. */
  56312. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56313. /**
  56314. * Disconnect this point from one of his endpoint
  56315. * @param endpoint defines the other connection point
  56316. * @returns the current connection point
  56317. */
  56318. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56319. /**
  56320. * Serializes this point in a JSON representation
  56321. * @returns the serialized point object
  56322. */
  56323. serialize(): any;
  56324. }
  56325. }
  56326. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56330. import { Mesh } from "babylonjs/Meshes/mesh";
  56331. import { Effect } from "babylonjs/Materials/effect";
  56332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56333. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56334. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56335. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56336. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56337. /**
  56338. * Block used to add support for vertex skinning (bones)
  56339. */
  56340. export class BonesBlock extends NodeMaterialBlock {
  56341. /**
  56342. * Creates a new BonesBlock
  56343. * @param name defines the block name
  56344. */
  56345. constructor(name: string);
  56346. /**
  56347. * Initialize the block and prepare the context for build
  56348. * @param state defines the state that will be used for the build
  56349. */
  56350. initialize(state: NodeMaterialBuildState): void;
  56351. /**
  56352. * Gets the current class name
  56353. * @returns the class name
  56354. */
  56355. getClassName(): string;
  56356. /**
  56357. * Gets the matrix indices input component
  56358. */
  56359. readonly matricesIndices: NodeMaterialConnectionPoint;
  56360. /**
  56361. * Gets the matrix weights input component
  56362. */
  56363. readonly matricesWeights: NodeMaterialConnectionPoint;
  56364. /**
  56365. * Gets the extra matrix indices input component
  56366. */
  56367. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56368. /**
  56369. * Gets the extra matrix weights input component
  56370. */
  56371. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56372. /**
  56373. * Gets the world input component
  56374. */
  56375. readonly world: NodeMaterialConnectionPoint;
  56376. /**
  56377. * Gets the output component
  56378. */
  56379. readonly output: NodeMaterialConnectionPoint;
  56380. autoConfigure(material: NodeMaterial): void;
  56381. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56382. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56383. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56384. protected _buildBlock(state: NodeMaterialBuildState): this;
  56385. }
  56386. }
  56387. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56390. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56392. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56393. /**
  56394. * Block used to add support for instances
  56395. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56396. */
  56397. export class InstancesBlock extends NodeMaterialBlock {
  56398. /**
  56399. * Creates a new InstancesBlock
  56400. * @param name defines the block name
  56401. */
  56402. constructor(name: string);
  56403. /**
  56404. * Gets the current class name
  56405. * @returns the class name
  56406. */
  56407. getClassName(): string;
  56408. /**
  56409. * Gets the first world row input component
  56410. */
  56411. readonly world0: NodeMaterialConnectionPoint;
  56412. /**
  56413. * Gets the second world row input component
  56414. */
  56415. readonly world1: NodeMaterialConnectionPoint;
  56416. /**
  56417. * Gets the third world row input component
  56418. */
  56419. readonly world2: NodeMaterialConnectionPoint;
  56420. /**
  56421. * Gets the forth world row input component
  56422. */
  56423. readonly world3: NodeMaterialConnectionPoint;
  56424. /**
  56425. * Gets the world input component
  56426. */
  56427. readonly world: NodeMaterialConnectionPoint;
  56428. /**
  56429. * Gets the output component
  56430. */
  56431. readonly output: NodeMaterialConnectionPoint;
  56432. autoConfigure(material: NodeMaterial): void;
  56433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56434. protected _buildBlock(state: NodeMaterialBuildState): this;
  56435. }
  56436. }
  56437. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56442. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56443. import { Effect } from "babylonjs/Materials/effect";
  56444. import { Mesh } from "babylonjs/Meshes/mesh";
  56445. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56447. /**
  56448. * Block used to add morph targets support to vertex shader
  56449. */
  56450. export class MorphTargetsBlock extends NodeMaterialBlock {
  56451. private _repeatableContentAnchor;
  56452. private _repeatebleContentGenerated;
  56453. /**
  56454. * Create a new MorphTargetsBlock
  56455. * @param name defines the block name
  56456. */
  56457. constructor(name: string);
  56458. /**
  56459. * Gets the current class name
  56460. * @returns the class name
  56461. */
  56462. getClassName(): string;
  56463. /**
  56464. * Gets the position input component
  56465. */
  56466. readonly position: NodeMaterialConnectionPoint;
  56467. /**
  56468. * Gets the normal input component
  56469. */
  56470. readonly normal: NodeMaterialConnectionPoint;
  56471. /**
  56472. * Gets the tangent input component
  56473. */
  56474. readonly tangent: NodeMaterialConnectionPoint;
  56475. /**
  56476. * Gets the tangent input component
  56477. */
  56478. readonly uv: NodeMaterialConnectionPoint;
  56479. /**
  56480. * Gets the position output component
  56481. */
  56482. readonly positionOutput: NodeMaterialConnectionPoint;
  56483. /**
  56484. * Gets the normal output component
  56485. */
  56486. readonly normalOutput: NodeMaterialConnectionPoint;
  56487. /**
  56488. * Gets the tangent output component
  56489. */
  56490. readonly tangentOutput: NodeMaterialConnectionPoint;
  56491. /**
  56492. * Gets the tangent output component
  56493. */
  56494. readonly uvOutput: NodeMaterialConnectionPoint;
  56495. initialize(state: NodeMaterialBuildState): void;
  56496. autoConfigure(material: NodeMaterial): void;
  56497. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56498. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56499. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56500. protected _buildBlock(state: NodeMaterialBuildState): this;
  56501. }
  56502. }
  56503. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56507. import { Nullable } from "babylonjs/types";
  56508. import { Scene } from "babylonjs/scene";
  56509. import { Effect } from "babylonjs/Materials/effect";
  56510. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56511. import { Mesh } from "babylonjs/Meshes/mesh";
  56512. import { Light } from "babylonjs/Lights/light";
  56513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56514. /**
  56515. * Block used to get data information from a light
  56516. */
  56517. export class LightInformationBlock extends NodeMaterialBlock {
  56518. private _lightDataUniformName;
  56519. private _lightColorUniformName;
  56520. private _lightTypeDefineName;
  56521. /**
  56522. * Gets or sets the light associated with this block
  56523. */
  56524. light: Nullable<Light>;
  56525. /**
  56526. * Creates a new LightInformationBlock
  56527. * @param name defines the block name
  56528. */
  56529. constructor(name: string);
  56530. /**
  56531. * Gets the current class name
  56532. * @returns the class name
  56533. */
  56534. getClassName(): string;
  56535. /**
  56536. * Gets the world position input component
  56537. */
  56538. readonly worldPosition: NodeMaterialConnectionPoint;
  56539. /**
  56540. * Gets the direction output component
  56541. */
  56542. readonly direction: NodeMaterialConnectionPoint;
  56543. /**
  56544. * Gets the direction output component
  56545. */
  56546. readonly color: NodeMaterialConnectionPoint;
  56547. /**
  56548. * Gets the direction output component
  56549. */
  56550. readonly intensity: NodeMaterialConnectionPoint;
  56551. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56553. protected _buildBlock(state: NodeMaterialBuildState): this;
  56554. serialize(): any;
  56555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56556. }
  56557. }
  56558. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56559. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56560. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56561. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56562. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56563. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56564. }
  56565. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56570. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56571. import { Effect } from "babylonjs/Materials/effect";
  56572. import { Mesh } from "babylonjs/Meshes/mesh";
  56573. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56574. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56575. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56576. /**
  56577. * Block used to add image processing support to fragment shader
  56578. */
  56579. export class ImageProcessingBlock extends NodeMaterialBlock {
  56580. /**
  56581. * Create a new ImageProcessingBlock
  56582. * @param name defines the block name
  56583. */
  56584. constructor(name: string);
  56585. /**
  56586. * Gets the current class name
  56587. * @returns the class name
  56588. */
  56589. getClassName(): string;
  56590. /**
  56591. * Gets the color input component
  56592. */
  56593. readonly color: NodeMaterialConnectionPoint;
  56594. /**
  56595. * Gets the output component
  56596. */
  56597. readonly output: NodeMaterialConnectionPoint;
  56598. /**
  56599. * Initialize the block and prepare the context for build
  56600. * @param state defines the state that will be used for the build
  56601. */
  56602. initialize(state: NodeMaterialBuildState): void;
  56603. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56605. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56606. protected _buildBlock(state: NodeMaterialBuildState): this;
  56607. }
  56608. }
  56609. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56613. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56615. import { Effect } from "babylonjs/Materials/effect";
  56616. import { Mesh } from "babylonjs/Meshes/mesh";
  56617. import { Scene } from "babylonjs/scene";
  56618. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56619. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56620. /**
  56621. * Block used to pertub normals based on a normal map
  56622. */
  56623. export class PerturbNormalBlock extends NodeMaterialBlock {
  56624. private _tangentSpaceParameterName;
  56625. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56626. invertX: boolean;
  56627. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56628. invertY: boolean;
  56629. /**
  56630. * Create a new PerturbNormalBlock
  56631. * @param name defines the block name
  56632. */
  56633. constructor(name: string);
  56634. /**
  56635. * Gets the current class name
  56636. * @returns the class name
  56637. */
  56638. getClassName(): string;
  56639. /**
  56640. * Gets the world position input component
  56641. */
  56642. readonly worldPosition: NodeMaterialConnectionPoint;
  56643. /**
  56644. * Gets the world normal input component
  56645. */
  56646. readonly worldNormal: NodeMaterialConnectionPoint;
  56647. /**
  56648. * Gets the uv input component
  56649. */
  56650. readonly uv: NodeMaterialConnectionPoint;
  56651. /**
  56652. * Gets the normal map color input component
  56653. */
  56654. readonly normalMapColor: NodeMaterialConnectionPoint;
  56655. /**
  56656. * Gets the strength input component
  56657. */
  56658. readonly strength: NodeMaterialConnectionPoint;
  56659. /**
  56660. * Gets the output component
  56661. */
  56662. readonly output: NodeMaterialConnectionPoint;
  56663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56665. autoConfigure(material: NodeMaterial): void;
  56666. protected _buildBlock(state: NodeMaterialBuildState): this;
  56667. protected _dumpPropertiesCode(): string;
  56668. serialize(): any;
  56669. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56670. }
  56671. }
  56672. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56673. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56674. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56675. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56676. /**
  56677. * Block used to discard a pixel if a value is smaller than a cutoff
  56678. */
  56679. export class DiscardBlock extends NodeMaterialBlock {
  56680. /**
  56681. * Create a new DiscardBlock
  56682. * @param name defines the block name
  56683. */
  56684. constructor(name: string);
  56685. /**
  56686. * Gets the current class name
  56687. * @returns the class name
  56688. */
  56689. getClassName(): string;
  56690. /**
  56691. * Gets the color input component
  56692. */
  56693. readonly value: NodeMaterialConnectionPoint;
  56694. /**
  56695. * Gets the cutoff input component
  56696. */
  56697. readonly cutoff: NodeMaterialConnectionPoint;
  56698. protected _buildBlock(state: NodeMaterialBuildState): this;
  56699. }
  56700. }
  56701. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56702. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56703. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56704. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56705. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56706. }
  56707. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56710. import { Mesh } from "babylonjs/Meshes/mesh";
  56711. import { Effect } from "babylonjs/Materials/effect";
  56712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56714. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56715. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56716. /**
  56717. * Block used to add support for scene fog
  56718. */
  56719. export class FogBlock extends NodeMaterialBlock {
  56720. private _fogDistanceName;
  56721. private _fogParameters;
  56722. /**
  56723. * Create a new FogBlock
  56724. * @param name defines the block name
  56725. */
  56726. constructor(name: string);
  56727. /**
  56728. * Gets the current class name
  56729. * @returns the class name
  56730. */
  56731. getClassName(): string;
  56732. /**
  56733. * Gets the world position input component
  56734. */
  56735. readonly worldPosition: NodeMaterialConnectionPoint;
  56736. /**
  56737. * Gets the view input component
  56738. */
  56739. readonly view: NodeMaterialConnectionPoint;
  56740. /**
  56741. * Gets the color input component
  56742. */
  56743. readonly input: NodeMaterialConnectionPoint;
  56744. /**
  56745. * Gets the fog color input component
  56746. */
  56747. readonly fogColor: NodeMaterialConnectionPoint;
  56748. /**
  56749. * Gets the output component
  56750. */
  56751. readonly output: NodeMaterialConnectionPoint;
  56752. autoConfigure(material: NodeMaterial): void;
  56753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56755. protected _buildBlock(state: NodeMaterialBuildState): this;
  56756. }
  56757. }
  56758. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56763. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56764. import { Effect } from "babylonjs/Materials/effect";
  56765. import { Mesh } from "babylonjs/Meshes/mesh";
  56766. import { Light } from "babylonjs/Lights/light";
  56767. import { Nullable } from "babylonjs/types";
  56768. import { Scene } from "babylonjs/scene";
  56769. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56770. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56771. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56772. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56773. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56774. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56775. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56776. /**
  56777. * Block used to add light in the fragment shader
  56778. */
  56779. export class LightBlock extends NodeMaterialBlock {
  56780. private _lightId;
  56781. /**
  56782. * Gets or sets the light associated with this block
  56783. */
  56784. light: Nullable<Light>;
  56785. /**
  56786. * Create a new LightBlock
  56787. * @param name defines the block name
  56788. */
  56789. constructor(name: string);
  56790. /**
  56791. * Gets the current class name
  56792. * @returns the class name
  56793. */
  56794. getClassName(): string;
  56795. /**
  56796. * Gets the world position input component
  56797. */
  56798. readonly worldPosition: NodeMaterialConnectionPoint;
  56799. /**
  56800. * Gets the world normal input component
  56801. */
  56802. readonly worldNormal: NodeMaterialConnectionPoint;
  56803. /**
  56804. * Gets the camera (or eye) position component
  56805. */
  56806. readonly cameraPosition: NodeMaterialConnectionPoint;
  56807. /**
  56808. * Gets the glossiness component
  56809. */
  56810. readonly glossiness: NodeMaterialConnectionPoint;
  56811. /**
  56812. * Gets the diffuse color component
  56813. */
  56814. readonly diffuseColor: NodeMaterialConnectionPoint;
  56815. /**
  56816. * Gets the specular color component
  56817. */
  56818. readonly specularColor: NodeMaterialConnectionPoint;
  56819. /**
  56820. * Gets the diffuse output component
  56821. */
  56822. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56823. /**
  56824. * Gets the specular output component
  56825. */
  56826. readonly specularOutput: NodeMaterialConnectionPoint;
  56827. autoConfigure(material: NodeMaterial): void;
  56828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56829. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56830. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56831. private _injectVertexCode;
  56832. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56833. serialize(): any;
  56834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56835. }
  56836. }
  56837. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56838. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56839. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56840. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56841. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56842. }
  56843. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56844. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56845. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56846. }
  56847. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56848. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56849. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56851. /**
  56852. * Block used to multiply 2 values
  56853. */
  56854. export class MultiplyBlock extends NodeMaterialBlock {
  56855. /**
  56856. * Creates a new MultiplyBlock
  56857. * @param name defines the block name
  56858. */
  56859. constructor(name: string);
  56860. /**
  56861. * Gets the current class name
  56862. * @returns the class name
  56863. */
  56864. getClassName(): string;
  56865. /**
  56866. * Gets the left operand input component
  56867. */
  56868. readonly left: NodeMaterialConnectionPoint;
  56869. /**
  56870. * Gets the right operand input component
  56871. */
  56872. readonly right: NodeMaterialConnectionPoint;
  56873. /**
  56874. * Gets the output component
  56875. */
  56876. readonly output: NodeMaterialConnectionPoint;
  56877. protected _buildBlock(state: NodeMaterialBuildState): this;
  56878. }
  56879. }
  56880. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56884. /**
  56885. * Block used to add 2 vectors
  56886. */
  56887. export class AddBlock extends NodeMaterialBlock {
  56888. /**
  56889. * Creates a new AddBlock
  56890. * @param name defines the block name
  56891. */
  56892. constructor(name: string);
  56893. /**
  56894. * Gets the current class name
  56895. * @returns the class name
  56896. */
  56897. getClassName(): string;
  56898. /**
  56899. * Gets the left operand input component
  56900. */
  56901. readonly left: NodeMaterialConnectionPoint;
  56902. /**
  56903. * Gets the right operand input component
  56904. */
  56905. readonly right: NodeMaterialConnectionPoint;
  56906. /**
  56907. * Gets the output component
  56908. */
  56909. readonly output: NodeMaterialConnectionPoint;
  56910. protected _buildBlock(state: NodeMaterialBuildState): this;
  56911. }
  56912. }
  56913. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56917. /**
  56918. * Block used to scale a vector by a float
  56919. */
  56920. export class ScaleBlock extends NodeMaterialBlock {
  56921. /**
  56922. * Creates a new ScaleBlock
  56923. * @param name defines the block name
  56924. */
  56925. constructor(name: string);
  56926. /**
  56927. * Gets the current class name
  56928. * @returns the class name
  56929. */
  56930. getClassName(): string;
  56931. /**
  56932. * Gets the input component
  56933. */
  56934. readonly input: NodeMaterialConnectionPoint;
  56935. /**
  56936. * Gets the factor input component
  56937. */
  56938. readonly factor: NodeMaterialConnectionPoint;
  56939. /**
  56940. * Gets the output component
  56941. */
  56942. readonly output: NodeMaterialConnectionPoint;
  56943. protected _buildBlock(state: NodeMaterialBuildState): this;
  56944. }
  56945. }
  56946. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56950. import { Scene } from "babylonjs/scene";
  56951. /**
  56952. * Block used to clamp a float
  56953. */
  56954. export class ClampBlock extends NodeMaterialBlock {
  56955. /** Gets or sets the minimum range */
  56956. minimum: number;
  56957. /** Gets or sets the maximum range */
  56958. maximum: number;
  56959. /**
  56960. * Creates a new ClampBlock
  56961. * @param name defines the block name
  56962. */
  56963. constructor(name: string);
  56964. /**
  56965. * Gets the current class name
  56966. * @returns the class name
  56967. */
  56968. getClassName(): string;
  56969. /**
  56970. * Gets the value input component
  56971. */
  56972. readonly value: NodeMaterialConnectionPoint;
  56973. /**
  56974. * Gets the output component
  56975. */
  56976. readonly output: NodeMaterialConnectionPoint;
  56977. protected _buildBlock(state: NodeMaterialBuildState): this;
  56978. protected _dumpPropertiesCode(): string;
  56979. serialize(): any;
  56980. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56981. }
  56982. }
  56983. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56987. /**
  56988. * Block used to apply a cross product between 2 vectors
  56989. */
  56990. export class CrossBlock extends NodeMaterialBlock {
  56991. /**
  56992. * Creates a new CrossBlock
  56993. * @param name defines the block name
  56994. */
  56995. constructor(name: string);
  56996. /**
  56997. * Gets the current class name
  56998. * @returns the class name
  56999. */
  57000. getClassName(): string;
  57001. /**
  57002. * Gets the left operand input component
  57003. */
  57004. readonly left: NodeMaterialConnectionPoint;
  57005. /**
  57006. * Gets the right operand input component
  57007. */
  57008. readonly right: NodeMaterialConnectionPoint;
  57009. /**
  57010. * Gets the output component
  57011. */
  57012. readonly output: NodeMaterialConnectionPoint;
  57013. protected _buildBlock(state: NodeMaterialBuildState): this;
  57014. }
  57015. }
  57016. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57017. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57018. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57020. /**
  57021. * Block used to apply a dot product between 2 vectors
  57022. */
  57023. export class DotBlock extends NodeMaterialBlock {
  57024. /**
  57025. * Creates a new DotBlock
  57026. * @param name defines the block name
  57027. */
  57028. constructor(name: string);
  57029. /**
  57030. * Gets the current class name
  57031. * @returns the class name
  57032. */
  57033. getClassName(): string;
  57034. /**
  57035. * Gets the left operand input component
  57036. */
  57037. readonly left: NodeMaterialConnectionPoint;
  57038. /**
  57039. * Gets the right operand input component
  57040. */
  57041. readonly right: NodeMaterialConnectionPoint;
  57042. /**
  57043. * Gets the output component
  57044. */
  57045. readonly output: NodeMaterialConnectionPoint;
  57046. protected _buildBlock(state: NodeMaterialBuildState): this;
  57047. }
  57048. }
  57049. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57053. import { Vector2 } from "babylonjs/Maths/math.vector";
  57054. import { Scene } from "babylonjs/scene";
  57055. /**
  57056. * Block used to remap a float from a range to a new one
  57057. */
  57058. export class RemapBlock extends NodeMaterialBlock {
  57059. /**
  57060. * Gets or sets the source range
  57061. */
  57062. sourceRange: Vector2;
  57063. /**
  57064. * Gets or sets the target range
  57065. */
  57066. targetRange: Vector2;
  57067. /**
  57068. * Creates a new RemapBlock
  57069. * @param name defines the block name
  57070. */
  57071. constructor(name: string);
  57072. /**
  57073. * Gets the current class name
  57074. * @returns the class name
  57075. */
  57076. getClassName(): string;
  57077. /**
  57078. * Gets the input component
  57079. */
  57080. readonly input: NodeMaterialConnectionPoint;
  57081. /**
  57082. * Gets the source min input component
  57083. */
  57084. readonly sourceMin: NodeMaterialConnectionPoint;
  57085. /**
  57086. * Gets the source max input component
  57087. */
  57088. readonly sourceMax: NodeMaterialConnectionPoint;
  57089. /**
  57090. * Gets the target min input component
  57091. */
  57092. readonly targetMin: NodeMaterialConnectionPoint;
  57093. /**
  57094. * Gets the target max input component
  57095. */
  57096. readonly targetMax: NodeMaterialConnectionPoint;
  57097. /**
  57098. * Gets the output component
  57099. */
  57100. readonly output: NodeMaterialConnectionPoint;
  57101. protected _buildBlock(state: NodeMaterialBuildState): this;
  57102. protected _dumpPropertiesCode(): string;
  57103. serialize(): any;
  57104. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57105. }
  57106. }
  57107. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57111. /**
  57112. * Block used to normalize a vector
  57113. */
  57114. export class NormalizeBlock extends NodeMaterialBlock {
  57115. /**
  57116. * Creates a new NormalizeBlock
  57117. * @param name defines the block name
  57118. */
  57119. constructor(name: string);
  57120. /**
  57121. * Gets the current class name
  57122. * @returns the class name
  57123. */
  57124. getClassName(): string;
  57125. /**
  57126. * Gets the input component
  57127. */
  57128. readonly input: NodeMaterialConnectionPoint;
  57129. /**
  57130. * Gets the output component
  57131. */
  57132. readonly output: NodeMaterialConnectionPoint;
  57133. protected _buildBlock(state: NodeMaterialBuildState): this;
  57134. }
  57135. }
  57136. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57137. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57138. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57139. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57140. import { Scene } from "babylonjs/scene";
  57141. /**
  57142. * Operations supported by the Trigonometry block
  57143. */
  57144. export enum TrigonometryBlockOperations {
  57145. /** Cos */
  57146. Cos = 0,
  57147. /** Sin */
  57148. Sin = 1,
  57149. /** Abs */
  57150. Abs = 2,
  57151. /** Exp */
  57152. Exp = 3,
  57153. /** Exp2 */
  57154. Exp2 = 4,
  57155. /** Round */
  57156. Round = 5,
  57157. /** Floor */
  57158. Floor = 6,
  57159. /** Ceiling */
  57160. Ceiling = 7,
  57161. /** Square root */
  57162. Sqrt = 8,
  57163. /** Log */
  57164. Log = 9,
  57165. /** Tangent */
  57166. Tan = 10,
  57167. /** Arc tangent */
  57168. ATan = 11,
  57169. /** Arc cosinus */
  57170. ACos = 12,
  57171. /** Arc sinus */
  57172. ASin = 13,
  57173. /** Fraction */
  57174. Fract = 14,
  57175. /** Sign */
  57176. Sign = 15
  57177. }
  57178. /**
  57179. * Block used to apply trigonometry operation to floats
  57180. */
  57181. export class TrigonometryBlock extends NodeMaterialBlock {
  57182. /**
  57183. * Gets or sets the operation applied by the block
  57184. */
  57185. operation: TrigonometryBlockOperations;
  57186. /**
  57187. * Creates a new TrigonometryBlock
  57188. * @param name defines the block name
  57189. */
  57190. constructor(name: string);
  57191. /**
  57192. * Gets the current class name
  57193. * @returns the class name
  57194. */
  57195. getClassName(): string;
  57196. /**
  57197. * Gets the input component
  57198. */
  57199. readonly input: NodeMaterialConnectionPoint;
  57200. /**
  57201. * Gets the output component
  57202. */
  57203. readonly output: NodeMaterialConnectionPoint;
  57204. protected _buildBlock(state: NodeMaterialBuildState): this;
  57205. serialize(): any;
  57206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57207. }
  57208. }
  57209. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57213. /**
  57214. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57215. */
  57216. export class ColorMergerBlock extends NodeMaterialBlock {
  57217. /**
  57218. * Create a new ColorMergerBlock
  57219. * @param name defines the block name
  57220. */
  57221. constructor(name: string);
  57222. /**
  57223. * Gets the current class name
  57224. * @returns the class name
  57225. */
  57226. getClassName(): string;
  57227. /**
  57228. * Gets the r component (input)
  57229. */
  57230. readonly r: NodeMaterialConnectionPoint;
  57231. /**
  57232. * Gets the g component (input)
  57233. */
  57234. readonly g: NodeMaterialConnectionPoint;
  57235. /**
  57236. * Gets the b component (input)
  57237. */
  57238. readonly b: NodeMaterialConnectionPoint;
  57239. /**
  57240. * Gets the a component (input)
  57241. */
  57242. readonly a: NodeMaterialConnectionPoint;
  57243. /**
  57244. * Gets the rgba component (output)
  57245. */
  57246. readonly rgba: NodeMaterialConnectionPoint;
  57247. /**
  57248. * Gets the rgb component (output)
  57249. */
  57250. readonly rgb: NodeMaterialConnectionPoint;
  57251. protected _buildBlock(state: NodeMaterialBuildState): this;
  57252. }
  57253. }
  57254. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57258. /**
  57259. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57260. */
  57261. export class VectorMergerBlock extends NodeMaterialBlock {
  57262. /**
  57263. * Create a new VectorMergerBlock
  57264. * @param name defines the block name
  57265. */
  57266. constructor(name: string);
  57267. /**
  57268. * Gets the current class name
  57269. * @returns the class name
  57270. */
  57271. getClassName(): string;
  57272. /**
  57273. * Gets the x component (input)
  57274. */
  57275. readonly x: NodeMaterialConnectionPoint;
  57276. /**
  57277. * Gets the y component (input)
  57278. */
  57279. readonly y: NodeMaterialConnectionPoint;
  57280. /**
  57281. * Gets the z component (input)
  57282. */
  57283. readonly z: NodeMaterialConnectionPoint;
  57284. /**
  57285. * Gets the w component (input)
  57286. */
  57287. readonly w: NodeMaterialConnectionPoint;
  57288. /**
  57289. * Gets the xyzw component (output)
  57290. */
  57291. readonly xyzw: NodeMaterialConnectionPoint;
  57292. /**
  57293. * Gets the xyz component (output)
  57294. */
  57295. readonly xyz: NodeMaterialConnectionPoint;
  57296. /**
  57297. * Gets the xy component (output)
  57298. */
  57299. readonly xy: NodeMaterialConnectionPoint;
  57300. protected _buildBlock(state: NodeMaterialBuildState): this;
  57301. }
  57302. }
  57303. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57305. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57306. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57307. /**
  57308. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57309. */
  57310. export class ColorSplitterBlock extends NodeMaterialBlock {
  57311. /**
  57312. * Create a new ColorSplitterBlock
  57313. * @param name defines the block name
  57314. */
  57315. constructor(name: string);
  57316. /**
  57317. * Gets the current class name
  57318. * @returns the class name
  57319. */
  57320. getClassName(): string;
  57321. /**
  57322. * Gets the rgba component (input)
  57323. */
  57324. readonly rgba: NodeMaterialConnectionPoint;
  57325. /**
  57326. * Gets the rgb component (input)
  57327. */
  57328. readonly rgbIn: NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the rgb component (output)
  57331. */
  57332. readonly rgbOut: NodeMaterialConnectionPoint;
  57333. /**
  57334. * Gets the r component (output)
  57335. */
  57336. readonly r: NodeMaterialConnectionPoint;
  57337. /**
  57338. * Gets the g component (output)
  57339. */
  57340. readonly g: NodeMaterialConnectionPoint;
  57341. /**
  57342. * Gets the b component (output)
  57343. */
  57344. readonly b: NodeMaterialConnectionPoint;
  57345. /**
  57346. * Gets the a component (output)
  57347. */
  57348. readonly a: NodeMaterialConnectionPoint;
  57349. protected _inputRename(name: string): string;
  57350. protected _outputRename(name: string): string;
  57351. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57352. }
  57353. }
  57354. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57358. /**
  57359. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57360. */
  57361. export class VectorSplitterBlock extends NodeMaterialBlock {
  57362. /**
  57363. * Create a new VectorSplitterBlock
  57364. * @param name defines the block name
  57365. */
  57366. constructor(name: string);
  57367. /**
  57368. * Gets the current class name
  57369. * @returns the class name
  57370. */
  57371. getClassName(): string;
  57372. /**
  57373. * Gets the xyzw component (input)
  57374. */
  57375. readonly xyzw: NodeMaterialConnectionPoint;
  57376. /**
  57377. * Gets the xyz component (input)
  57378. */
  57379. readonly xyzIn: NodeMaterialConnectionPoint;
  57380. /**
  57381. * Gets the xy component (input)
  57382. */
  57383. readonly xyIn: NodeMaterialConnectionPoint;
  57384. /**
  57385. * Gets the xyz component (output)
  57386. */
  57387. readonly xyzOut: NodeMaterialConnectionPoint;
  57388. /**
  57389. * Gets the xy component (output)
  57390. */
  57391. readonly xyOut: NodeMaterialConnectionPoint;
  57392. /**
  57393. * Gets the x component (output)
  57394. */
  57395. readonly x: NodeMaterialConnectionPoint;
  57396. /**
  57397. * Gets the y component (output)
  57398. */
  57399. readonly y: NodeMaterialConnectionPoint;
  57400. /**
  57401. * Gets the z component (output)
  57402. */
  57403. readonly z: NodeMaterialConnectionPoint;
  57404. /**
  57405. * Gets the w component (output)
  57406. */
  57407. readonly w: NodeMaterialConnectionPoint;
  57408. protected _inputRename(name: string): string;
  57409. protected _outputRename(name: string): string;
  57410. protected _buildBlock(state: NodeMaterialBuildState): this;
  57411. }
  57412. }
  57413. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57417. /**
  57418. * Block used to lerp 2 values
  57419. */
  57420. export class LerpBlock extends NodeMaterialBlock {
  57421. /**
  57422. * Creates a new LerpBlock
  57423. * @param name defines the block name
  57424. */
  57425. constructor(name: string);
  57426. /**
  57427. * Gets the current class name
  57428. * @returns the class name
  57429. */
  57430. getClassName(): string;
  57431. /**
  57432. * Gets the left operand input component
  57433. */
  57434. readonly left: NodeMaterialConnectionPoint;
  57435. /**
  57436. * Gets the right operand input component
  57437. */
  57438. readonly right: NodeMaterialConnectionPoint;
  57439. /**
  57440. * Gets the gradient operand input component
  57441. */
  57442. readonly gradient: NodeMaterialConnectionPoint;
  57443. /**
  57444. * Gets the output component
  57445. */
  57446. readonly output: NodeMaterialConnectionPoint;
  57447. protected _buildBlock(state: NodeMaterialBuildState): this;
  57448. }
  57449. }
  57450. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57454. /**
  57455. * Block used to divide 2 vectors
  57456. */
  57457. export class DivideBlock extends NodeMaterialBlock {
  57458. /**
  57459. * Creates a new DivideBlock
  57460. * @param name defines the block name
  57461. */
  57462. constructor(name: string);
  57463. /**
  57464. * Gets the current class name
  57465. * @returns the class name
  57466. */
  57467. getClassName(): string;
  57468. /**
  57469. * Gets the left operand input component
  57470. */
  57471. readonly left: NodeMaterialConnectionPoint;
  57472. /**
  57473. * Gets the right operand input component
  57474. */
  57475. readonly right: NodeMaterialConnectionPoint;
  57476. /**
  57477. * Gets the output component
  57478. */
  57479. readonly output: NodeMaterialConnectionPoint;
  57480. protected _buildBlock(state: NodeMaterialBuildState): this;
  57481. }
  57482. }
  57483. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57487. /**
  57488. * Block used to subtract 2 vectors
  57489. */
  57490. export class SubtractBlock extends NodeMaterialBlock {
  57491. /**
  57492. * Creates a new SubtractBlock
  57493. * @param name defines the block name
  57494. */
  57495. constructor(name: string);
  57496. /**
  57497. * Gets the current class name
  57498. * @returns the class name
  57499. */
  57500. getClassName(): string;
  57501. /**
  57502. * Gets the left operand input component
  57503. */
  57504. readonly left: NodeMaterialConnectionPoint;
  57505. /**
  57506. * Gets the right operand input component
  57507. */
  57508. readonly right: NodeMaterialConnectionPoint;
  57509. /**
  57510. * Gets the output component
  57511. */
  57512. readonly output: NodeMaterialConnectionPoint;
  57513. protected _buildBlock(state: NodeMaterialBuildState): this;
  57514. }
  57515. }
  57516. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57519. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57520. /**
  57521. * Block used to step a value
  57522. */
  57523. export class StepBlock extends NodeMaterialBlock {
  57524. /**
  57525. * Creates a new AddBlock
  57526. * @param name defines the block name
  57527. */
  57528. constructor(name: string);
  57529. /**
  57530. * Gets the current class name
  57531. * @returns the class name
  57532. */
  57533. getClassName(): string;
  57534. /**
  57535. * Gets the value operand input component
  57536. */
  57537. readonly value: NodeMaterialConnectionPoint;
  57538. /**
  57539. * Gets the edge operand input component
  57540. */
  57541. readonly edge: NodeMaterialConnectionPoint;
  57542. /**
  57543. * Gets the output component
  57544. */
  57545. readonly output: NodeMaterialConnectionPoint;
  57546. protected _buildBlock(state: NodeMaterialBuildState): this;
  57547. }
  57548. }
  57549. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57550. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57552. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57553. /**
  57554. * Block used to get the opposite (1 - x) of a value
  57555. */
  57556. export class OneMinusBlock extends NodeMaterialBlock {
  57557. /**
  57558. * Creates a new OneMinusBlock
  57559. * @param name defines the block name
  57560. */
  57561. constructor(name: string);
  57562. /**
  57563. * Gets the current class name
  57564. * @returns the class name
  57565. */
  57566. getClassName(): string;
  57567. /**
  57568. * Gets the input component
  57569. */
  57570. readonly input: NodeMaterialConnectionPoint;
  57571. /**
  57572. * Gets the output component
  57573. */
  57574. readonly output: NodeMaterialConnectionPoint;
  57575. protected _buildBlock(state: NodeMaterialBuildState): this;
  57576. }
  57577. }
  57578. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57582. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57583. /**
  57584. * Block used to get the view direction
  57585. */
  57586. export class ViewDirectionBlock extends NodeMaterialBlock {
  57587. /**
  57588. * Creates a new ViewDirectionBlock
  57589. * @param name defines the block name
  57590. */
  57591. constructor(name: string);
  57592. /**
  57593. * Gets the current class name
  57594. * @returns the class name
  57595. */
  57596. getClassName(): string;
  57597. /**
  57598. * Gets the world position component
  57599. */
  57600. readonly worldPosition: NodeMaterialConnectionPoint;
  57601. /**
  57602. * Gets the camera position component
  57603. */
  57604. readonly cameraPosition: NodeMaterialConnectionPoint;
  57605. /**
  57606. * Gets the output component
  57607. */
  57608. readonly output: NodeMaterialConnectionPoint;
  57609. autoConfigure(material: NodeMaterial): void;
  57610. protected _buildBlock(state: NodeMaterialBuildState): this;
  57611. }
  57612. }
  57613. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57617. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57618. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57619. /**
  57620. * Block used to compute fresnel value
  57621. */
  57622. export class FresnelBlock extends NodeMaterialBlock {
  57623. /**
  57624. * Create a new FresnelBlock
  57625. * @param name defines the block name
  57626. */
  57627. constructor(name: string);
  57628. /**
  57629. * Gets the current class name
  57630. * @returns the class name
  57631. */
  57632. getClassName(): string;
  57633. /**
  57634. * Gets the world normal input component
  57635. */
  57636. readonly worldNormal: NodeMaterialConnectionPoint;
  57637. /**
  57638. * Gets the view direction input component
  57639. */
  57640. readonly viewDirection: NodeMaterialConnectionPoint;
  57641. /**
  57642. * Gets the bias input component
  57643. */
  57644. readonly bias: NodeMaterialConnectionPoint;
  57645. /**
  57646. * Gets the camera (or eye) position component
  57647. */
  57648. readonly power: NodeMaterialConnectionPoint;
  57649. /**
  57650. * Gets the fresnel output component
  57651. */
  57652. readonly fresnel: NodeMaterialConnectionPoint;
  57653. autoConfigure(material: NodeMaterial): void;
  57654. protected _buildBlock(state: NodeMaterialBuildState): this;
  57655. }
  57656. }
  57657. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57661. /**
  57662. * Block used to get the max of 2 values
  57663. */
  57664. export class MaxBlock extends NodeMaterialBlock {
  57665. /**
  57666. * Creates a new MaxBlock
  57667. * @param name defines the block name
  57668. */
  57669. constructor(name: string);
  57670. /**
  57671. * Gets the current class name
  57672. * @returns the class name
  57673. */
  57674. getClassName(): string;
  57675. /**
  57676. * Gets the left operand input component
  57677. */
  57678. readonly left: NodeMaterialConnectionPoint;
  57679. /**
  57680. * Gets the right operand input component
  57681. */
  57682. readonly right: NodeMaterialConnectionPoint;
  57683. /**
  57684. * Gets the output component
  57685. */
  57686. readonly output: NodeMaterialConnectionPoint;
  57687. protected _buildBlock(state: NodeMaterialBuildState): this;
  57688. }
  57689. }
  57690. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57694. /**
  57695. * Block used to get the min of 2 values
  57696. */
  57697. export class MinBlock extends NodeMaterialBlock {
  57698. /**
  57699. * Creates a new MinBlock
  57700. * @param name defines the block name
  57701. */
  57702. constructor(name: string);
  57703. /**
  57704. * Gets the current class name
  57705. * @returns the class name
  57706. */
  57707. getClassName(): string;
  57708. /**
  57709. * Gets the left operand input component
  57710. */
  57711. readonly left: NodeMaterialConnectionPoint;
  57712. /**
  57713. * Gets the right operand input component
  57714. */
  57715. readonly right: NodeMaterialConnectionPoint;
  57716. /**
  57717. * Gets the output component
  57718. */
  57719. readonly output: NodeMaterialConnectionPoint;
  57720. protected _buildBlock(state: NodeMaterialBuildState): this;
  57721. }
  57722. }
  57723. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57727. /**
  57728. * Block used to get the distance between 2 values
  57729. */
  57730. export class DistanceBlock extends NodeMaterialBlock {
  57731. /**
  57732. * Creates a new DistanceBlock
  57733. * @param name defines the block name
  57734. */
  57735. constructor(name: string);
  57736. /**
  57737. * Gets the current class name
  57738. * @returns the class name
  57739. */
  57740. getClassName(): string;
  57741. /**
  57742. * Gets the left operand input component
  57743. */
  57744. readonly left: NodeMaterialConnectionPoint;
  57745. /**
  57746. * Gets the right operand input component
  57747. */
  57748. readonly right: NodeMaterialConnectionPoint;
  57749. /**
  57750. * Gets the output component
  57751. */
  57752. readonly output: NodeMaterialConnectionPoint;
  57753. protected _buildBlock(state: NodeMaterialBuildState): this;
  57754. }
  57755. }
  57756. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57760. /**
  57761. * Block used to get the length of a vector
  57762. */
  57763. export class LengthBlock extends NodeMaterialBlock {
  57764. /**
  57765. * Creates a new LengthBlock
  57766. * @param name defines the block name
  57767. */
  57768. constructor(name: string);
  57769. /**
  57770. * Gets the current class name
  57771. * @returns the class name
  57772. */
  57773. getClassName(): string;
  57774. /**
  57775. * Gets the value input component
  57776. */
  57777. readonly value: NodeMaterialConnectionPoint;
  57778. /**
  57779. * Gets the output component
  57780. */
  57781. readonly output: NodeMaterialConnectionPoint;
  57782. protected _buildBlock(state: NodeMaterialBuildState): this;
  57783. }
  57784. }
  57785. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57787. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57789. /**
  57790. * Block used to get negative version of a value (i.e. x * -1)
  57791. */
  57792. export class NegateBlock extends NodeMaterialBlock {
  57793. /**
  57794. * Creates a new NegateBlock
  57795. * @param name defines the block name
  57796. */
  57797. constructor(name: string);
  57798. /**
  57799. * Gets the current class name
  57800. * @returns the class name
  57801. */
  57802. getClassName(): string;
  57803. /**
  57804. * Gets the value input component
  57805. */
  57806. readonly value: NodeMaterialConnectionPoint;
  57807. /**
  57808. * Gets the output component
  57809. */
  57810. readonly output: NodeMaterialConnectionPoint;
  57811. protected _buildBlock(state: NodeMaterialBuildState): this;
  57812. }
  57813. }
  57814. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57818. /**
  57819. * Block used to get the value of the first parameter raised to the power of the second
  57820. */
  57821. export class PowBlock extends NodeMaterialBlock {
  57822. /**
  57823. * Creates a new PowBlock
  57824. * @param name defines the block name
  57825. */
  57826. constructor(name: string);
  57827. /**
  57828. * Gets the current class name
  57829. * @returns the class name
  57830. */
  57831. getClassName(): string;
  57832. /**
  57833. * Gets the value operand input component
  57834. */
  57835. readonly value: NodeMaterialConnectionPoint;
  57836. /**
  57837. * Gets the power operand input component
  57838. */
  57839. readonly power: NodeMaterialConnectionPoint;
  57840. /**
  57841. * Gets the output component
  57842. */
  57843. readonly output: NodeMaterialConnectionPoint;
  57844. protected _buildBlock(state: NodeMaterialBuildState): this;
  57845. }
  57846. }
  57847. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57848. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57849. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57851. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57852. /**
  57853. * Block used to get a random number
  57854. */
  57855. export class RandomNumberBlock extends NodeMaterialBlock {
  57856. /**
  57857. * Creates a new RandomNumberBlock
  57858. * @param name defines the block name
  57859. */
  57860. constructor(name: string);
  57861. /**
  57862. * Gets the current class name
  57863. * @returns the class name
  57864. */
  57865. getClassName(): string;
  57866. /**
  57867. * Gets the seed input component
  57868. */
  57869. readonly seed: NodeMaterialConnectionPoint;
  57870. /**
  57871. * Gets the output component
  57872. */
  57873. readonly output: NodeMaterialConnectionPoint;
  57874. protected _buildBlock(state: NodeMaterialBuildState): this;
  57875. }
  57876. }
  57877. declare module "babylonjs/Materials/Node/Blocks/index" {
  57878. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57879. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57880. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57881. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57882. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57883. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57884. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57885. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57886. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57887. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57888. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57889. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57890. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57891. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57892. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57893. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57894. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57895. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57896. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57897. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57898. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57899. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57900. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57901. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57902. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57903. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57904. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57905. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57906. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57907. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57908. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57909. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  57910. }
  57911. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57912. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57913. }
  57914. declare module "babylonjs/Materials/Node/index" {
  57915. export * from "babylonjs/Materials/Node/Enums/index";
  57916. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57917. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57918. export * from "babylonjs/Materials/Node/nodeMaterial";
  57919. export * from "babylonjs/Materials/Node/Blocks/index";
  57920. export * from "babylonjs/Materials/Node/Optimizers/index";
  57921. }
  57922. declare module "babylonjs/Materials/effectRenderer" {
  57923. import { Nullable } from "babylonjs/types";
  57924. import { Texture } from "babylonjs/Materials/Textures/texture";
  57925. import { Engine } from "babylonjs/Engines/engine";
  57926. import { Viewport } from "babylonjs/Maths/math.viewport";
  57927. import { Observable } from "babylonjs/Misc/observable";
  57928. import { Effect } from "babylonjs/Materials/effect";
  57929. import "babylonjs/Shaders/postprocess.vertex";
  57930. /**
  57931. * Effect Render Options
  57932. */
  57933. export interface IEffectRendererOptions {
  57934. /**
  57935. * Defines the vertices positions.
  57936. */
  57937. positions?: number[];
  57938. /**
  57939. * Defines the indices.
  57940. */
  57941. indices?: number[];
  57942. }
  57943. /**
  57944. * Helper class to render one or more effects
  57945. */
  57946. export class EffectRenderer {
  57947. private engine;
  57948. private static _DefaultOptions;
  57949. private _vertexBuffers;
  57950. private _indexBuffer;
  57951. private _ringBufferIndex;
  57952. private _ringScreenBuffer;
  57953. private _fullscreenViewport;
  57954. private _getNextFrameBuffer;
  57955. /**
  57956. * Creates an effect renderer
  57957. * @param engine the engine to use for rendering
  57958. * @param options defines the options of the effect renderer
  57959. */
  57960. constructor(engine: Engine, options?: IEffectRendererOptions);
  57961. /**
  57962. * Sets the current viewport in normalized coordinates 0-1
  57963. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57964. */
  57965. setViewport(viewport?: Viewport): void;
  57966. /**
  57967. * Binds the embedded attributes buffer to the effect.
  57968. * @param effect Defines the effect to bind the attributes for
  57969. */
  57970. bindBuffers(effect: Effect): void;
  57971. /**
  57972. * Sets the current effect wrapper to use during draw.
  57973. * The effect needs to be ready before calling this api.
  57974. * This also sets the default full screen position attribute.
  57975. * @param effectWrapper Defines the effect to draw with
  57976. */
  57977. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57978. /**
  57979. * Draws a full screen quad.
  57980. */
  57981. draw(): void;
  57982. /**
  57983. * renders one or more effects to a specified texture
  57984. * @param effectWrappers list of effects to renderer
  57985. * @param outputTexture texture to draw to, if null it will render to the screen
  57986. */
  57987. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57988. /**
  57989. * Disposes of the effect renderer
  57990. */
  57991. dispose(): void;
  57992. }
  57993. /**
  57994. * Options to create an EffectWrapper
  57995. */
  57996. interface EffectWrapperCreationOptions {
  57997. /**
  57998. * Engine to use to create the effect
  57999. */
  58000. engine: Engine;
  58001. /**
  58002. * Fragment shader for the effect
  58003. */
  58004. fragmentShader: string;
  58005. /**
  58006. * Vertex shader for the effect
  58007. */
  58008. vertexShader?: string;
  58009. /**
  58010. * Attributes to use in the shader
  58011. */
  58012. attributeNames?: Array<string>;
  58013. /**
  58014. * Uniforms to use in the shader
  58015. */
  58016. uniformNames?: Array<string>;
  58017. /**
  58018. * Texture sampler names to use in the shader
  58019. */
  58020. samplerNames?: Array<string>;
  58021. /**
  58022. * The friendly name of the effect displayed in Spector.
  58023. */
  58024. name?: string;
  58025. }
  58026. /**
  58027. * Wraps an effect to be used for rendering
  58028. */
  58029. export class EffectWrapper {
  58030. /**
  58031. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58032. */
  58033. onApplyObservable: Observable<{}>;
  58034. /**
  58035. * The underlying effect
  58036. */
  58037. effect: Effect;
  58038. /**
  58039. * Creates an effect to be renderer
  58040. * @param creationOptions options to create the effect
  58041. */
  58042. constructor(creationOptions: EffectWrapperCreationOptions);
  58043. /**
  58044. * Disposes of the effect wrapper
  58045. */
  58046. dispose(): void;
  58047. }
  58048. }
  58049. declare module "babylonjs/Materials/index" {
  58050. export * from "babylonjs/Materials/Background/index";
  58051. export * from "babylonjs/Materials/colorCurves";
  58052. export * from "babylonjs/Materials/iEffectFallbacks";
  58053. export * from "babylonjs/Materials/effectFallbacks";
  58054. export * from "babylonjs/Materials/effect";
  58055. export * from "babylonjs/Materials/fresnelParameters";
  58056. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58057. export * from "babylonjs/Materials/material";
  58058. export * from "babylonjs/Materials/materialDefines";
  58059. export * from "babylonjs/Materials/materialHelper";
  58060. export * from "babylonjs/Materials/multiMaterial";
  58061. export * from "babylonjs/Materials/PBR/index";
  58062. export * from "babylonjs/Materials/pushMaterial";
  58063. export * from "babylonjs/Materials/shaderMaterial";
  58064. export * from "babylonjs/Materials/standardMaterial";
  58065. export * from "babylonjs/Materials/Textures/index";
  58066. export * from "babylonjs/Materials/uniformBuffer";
  58067. export * from "babylonjs/Materials/materialFlags";
  58068. export * from "babylonjs/Materials/Node/index";
  58069. export * from "babylonjs/Materials/effectRenderer";
  58070. }
  58071. declare module "babylonjs/Maths/index" {
  58072. export * from "babylonjs/Maths/math.scalar";
  58073. export * from "babylonjs/Maths/math";
  58074. export * from "babylonjs/Maths/sphericalPolynomial";
  58075. }
  58076. declare module "babylonjs/Misc/workerPool" {
  58077. import { IDisposable } from "babylonjs/scene";
  58078. /**
  58079. * Helper class to push actions to a pool of workers.
  58080. */
  58081. export class WorkerPool implements IDisposable {
  58082. private _workerInfos;
  58083. private _pendingActions;
  58084. /**
  58085. * Constructor
  58086. * @param workers Array of workers to use for actions
  58087. */
  58088. constructor(workers: Array<Worker>);
  58089. /**
  58090. * Terminates all workers and clears any pending actions.
  58091. */
  58092. dispose(): void;
  58093. /**
  58094. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58095. * pended until a worker has completed its action.
  58096. * @param action The action to perform. Call onComplete when the action is complete.
  58097. */
  58098. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58099. private _execute;
  58100. }
  58101. }
  58102. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58103. import { IDisposable } from "babylonjs/scene";
  58104. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58105. /**
  58106. * Configuration for Draco compression
  58107. */
  58108. export interface IDracoCompressionConfiguration {
  58109. /**
  58110. * Configuration for the decoder.
  58111. */
  58112. decoder: {
  58113. /**
  58114. * The url to the WebAssembly module.
  58115. */
  58116. wasmUrl?: string;
  58117. /**
  58118. * The url to the WebAssembly binary.
  58119. */
  58120. wasmBinaryUrl?: string;
  58121. /**
  58122. * The url to the fallback JavaScript module.
  58123. */
  58124. fallbackUrl?: string;
  58125. };
  58126. }
  58127. /**
  58128. * Draco compression (https://google.github.io/draco/)
  58129. *
  58130. * This class wraps the Draco module.
  58131. *
  58132. * **Encoder**
  58133. *
  58134. * The encoder is not currently implemented.
  58135. *
  58136. * **Decoder**
  58137. *
  58138. * 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.
  58139. *
  58140. * To update the configuration, use the following code:
  58141. * ```javascript
  58142. * DracoCompression.Configuration = {
  58143. * decoder: {
  58144. * wasmUrl: "<url to the WebAssembly library>",
  58145. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58146. * fallbackUrl: "<url to the fallback JavaScript library>",
  58147. * }
  58148. * };
  58149. * ```
  58150. *
  58151. * 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.
  58152. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58153. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58154. *
  58155. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58156. * ```javascript
  58157. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58158. * ```
  58159. *
  58160. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58161. */
  58162. export class DracoCompression implements IDisposable {
  58163. private _workerPoolPromise?;
  58164. private _decoderModulePromise?;
  58165. /**
  58166. * The configuration. Defaults to the following urls:
  58167. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58168. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58169. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58170. */
  58171. static Configuration: IDracoCompressionConfiguration;
  58172. /**
  58173. * Returns true if the decoder configuration is available.
  58174. */
  58175. static readonly DecoderAvailable: boolean;
  58176. /**
  58177. * Default number of workers to create when creating the draco compression object.
  58178. */
  58179. static DefaultNumWorkers: number;
  58180. private static GetDefaultNumWorkers;
  58181. private static _Default;
  58182. /**
  58183. * Default instance for the draco compression object.
  58184. */
  58185. static readonly Default: DracoCompression;
  58186. /**
  58187. * Constructor
  58188. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58189. */
  58190. constructor(numWorkers?: number);
  58191. /**
  58192. * Stop all async operations and release resources.
  58193. */
  58194. dispose(): void;
  58195. /**
  58196. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58197. * @returns a promise that resolves when ready
  58198. */
  58199. whenReadyAsync(): Promise<void>;
  58200. /**
  58201. * Decode Draco compressed mesh data to vertex data.
  58202. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58203. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58204. * @returns A promise that resolves with the decoded vertex data
  58205. */
  58206. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58207. [kind: string]: number;
  58208. }): Promise<VertexData>;
  58209. }
  58210. }
  58211. declare module "babylonjs/Meshes/Compression/index" {
  58212. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58213. }
  58214. declare module "babylonjs/Meshes/csg" {
  58215. import { Nullable } from "babylonjs/types";
  58216. import { Scene } from "babylonjs/scene";
  58217. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58218. import { Mesh } from "babylonjs/Meshes/mesh";
  58219. import { Material } from "babylonjs/Materials/material";
  58220. /**
  58221. * Class for building Constructive Solid Geometry
  58222. */
  58223. export class CSG {
  58224. private polygons;
  58225. /**
  58226. * The world matrix
  58227. */
  58228. matrix: Matrix;
  58229. /**
  58230. * Stores the position
  58231. */
  58232. position: Vector3;
  58233. /**
  58234. * Stores the rotation
  58235. */
  58236. rotation: Vector3;
  58237. /**
  58238. * Stores the rotation quaternion
  58239. */
  58240. rotationQuaternion: Nullable<Quaternion>;
  58241. /**
  58242. * Stores the scaling vector
  58243. */
  58244. scaling: Vector3;
  58245. /**
  58246. * Convert the Mesh to CSG
  58247. * @param mesh The Mesh to convert to CSG
  58248. * @returns A new CSG from the Mesh
  58249. */
  58250. static FromMesh(mesh: Mesh): CSG;
  58251. /**
  58252. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58253. * @param polygons Polygons used to construct a CSG solid
  58254. */
  58255. private static FromPolygons;
  58256. /**
  58257. * Clones, or makes a deep copy, of the CSG
  58258. * @returns A new CSG
  58259. */
  58260. clone(): CSG;
  58261. /**
  58262. * Unions this CSG with another CSG
  58263. * @param csg The CSG to union against this CSG
  58264. * @returns The unioned CSG
  58265. */
  58266. union(csg: CSG): CSG;
  58267. /**
  58268. * Unions this CSG with another CSG in place
  58269. * @param csg The CSG to union against this CSG
  58270. */
  58271. unionInPlace(csg: CSG): void;
  58272. /**
  58273. * Subtracts this CSG with another CSG
  58274. * @param csg The CSG to subtract against this CSG
  58275. * @returns A new CSG
  58276. */
  58277. subtract(csg: CSG): CSG;
  58278. /**
  58279. * Subtracts this CSG with another CSG in place
  58280. * @param csg The CSG to subtact against this CSG
  58281. */
  58282. subtractInPlace(csg: CSG): void;
  58283. /**
  58284. * Intersect this CSG with another CSG
  58285. * @param csg The CSG to intersect against this CSG
  58286. * @returns A new CSG
  58287. */
  58288. intersect(csg: CSG): CSG;
  58289. /**
  58290. * Intersects this CSG with another CSG in place
  58291. * @param csg The CSG to intersect against this CSG
  58292. */
  58293. intersectInPlace(csg: CSG): void;
  58294. /**
  58295. * Return a new CSG solid with solid and empty space switched. This solid is
  58296. * not modified.
  58297. * @returns A new CSG solid with solid and empty space switched
  58298. */
  58299. inverse(): CSG;
  58300. /**
  58301. * Inverses the CSG in place
  58302. */
  58303. inverseInPlace(): void;
  58304. /**
  58305. * This is used to keep meshes transformations so they can be restored
  58306. * when we build back a Babylon Mesh
  58307. * NB : All CSG operations are performed in world coordinates
  58308. * @param csg The CSG to copy the transform attributes from
  58309. * @returns This CSG
  58310. */
  58311. copyTransformAttributes(csg: CSG): CSG;
  58312. /**
  58313. * Build Raw mesh from CSG
  58314. * Coordinates here are in world space
  58315. * @param name The name of the mesh geometry
  58316. * @param scene The Scene
  58317. * @param keepSubMeshes Specifies if the submeshes should be kept
  58318. * @returns A new Mesh
  58319. */
  58320. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58321. /**
  58322. * Build Mesh from CSG taking material and transforms into account
  58323. * @param name The name of the Mesh
  58324. * @param material The material of the Mesh
  58325. * @param scene The Scene
  58326. * @param keepSubMeshes Specifies if submeshes should be kept
  58327. * @returns The new Mesh
  58328. */
  58329. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58330. }
  58331. }
  58332. declare module "babylonjs/Meshes/trailMesh" {
  58333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58334. import { Mesh } from "babylonjs/Meshes/mesh";
  58335. import { Scene } from "babylonjs/scene";
  58336. /**
  58337. * Class used to create a trail following a mesh
  58338. */
  58339. export class TrailMesh extends Mesh {
  58340. private _generator;
  58341. private _autoStart;
  58342. private _running;
  58343. private _diameter;
  58344. private _length;
  58345. private _sectionPolygonPointsCount;
  58346. private _sectionVectors;
  58347. private _sectionNormalVectors;
  58348. private _beforeRenderObserver;
  58349. /**
  58350. * @constructor
  58351. * @param name The value used by scene.getMeshByName() to do a lookup.
  58352. * @param generator The mesh to generate a trail.
  58353. * @param scene The scene to add this mesh to.
  58354. * @param diameter Diameter of trailing mesh. Default is 1.
  58355. * @param length Length of trailing mesh. Default is 60.
  58356. * @param autoStart Automatically start trailing mesh. Default true.
  58357. */
  58358. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58359. /**
  58360. * "TrailMesh"
  58361. * @returns "TrailMesh"
  58362. */
  58363. getClassName(): string;
  58364. private _createMesh;
  58365. /**
  58366. * Start trailing mesh.
  58367. */
  58368. start(): void;
  58369. /**
  58370. * Stop trailing mesh.
  58371. */
  58372. stop(): void;
  58373. /**
  58374. * Update trailing mesh geometry.
  58375. */
  58376. update(): void;
  58377. /**
  58378. * Returns a new TrailMesh object.
  58379. * @param name is a string, the name given to the new mesh
  58380. * @param newGenerator use new generator object for cloned trail mesh
  58381. * @returns a new mesh
  58382. */
  58383. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58384. /**
  58385. * Serializes this trail mesh
  58386. * @param serializationObject object to write serialization to
  58387. */
  58388. serialize(serializationObject: any): void;
  58389. /**
  58390. * Parses a serialized trail mesh
  58391. * @param parsedMesh the serialized mesh
  58392. * @param scene the scene to create the trail mesh in
  58393. * @returns the created trail mesh
  58394. */
  58395. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58396. }
  58397. }
  58398. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58399. import { Nullable } from "babylonjs/types";
  58400. import { Scene } from "babylonjs/scene";
  58401. import { Vector4 } from "babylonjs/Maths/math.vector";
  58402. import { Color4 } from "babylonjs/Maths/math.color";
  58403. import { Mesh } from "babylonjs/Meshes/mesh";
  58404. /**
  58405. * Class containing static functions to help procedurally build meshes
  58406. */
  58407. export class TiledBoxBuilder {
  58408. /**
  58409. * Creates a box mesh
  58410. * 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)
  58411. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58415. * @param name defines the name of the mesh
  58416. * @param options defines the options used to create the mesh
  58417. * @param scene defines the hosting scene
  58418. * @returns the box mesh
  58419. */
  58420. static CreateTiledBox(name: string, options: {
  58421. pattern?: number;
  58422. width?: number;
  58423. height?: number;
  58424. depth?: number;
  58425. tileSize?: number;
  58426. tileWidth?: number;
  58427. tileHeight?: number;
  58428. alignHorizontal?: number;
  58429. alignVertical?: number;
  58430. faceUV?: Vector4[];
  58431. faceColors?: Color4[];
  58432. sideOrientation?: number;
  58433. updatable?: boolean;
  58434. }, scene?: Nullable<Scene>): Mesh;
  58435. }
  58436. }
  58437. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58438. import { Vector4 } from "babylonjs/Maths/math.vector";
  58439. import { Mesh } from "babylonjs/Meshes/mesh";
  58440. /**
  58441. * Class containing static functions to help procedurally build meshes
  58442. */
  58443. export class TorusKnotBuilder {
  58444. /**
  58445. * Creates a torus knot mesh
  58446. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58447. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58448. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58449. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58453. * @param name defines the name of the mesh
  58454. * @param options defines the options used to create the mesh
  58455. * @param scene defines the hosting scene
  58456. * @returns the torus knot mesh
  58457. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58458. */
  58459. static CreateTorusKnot(name: string, options: {
  58460. radius?: number;
  58461. tube?: number;
  58462. radialSegments?: number;
  58463. tubularSegments?: number;
  58464. p?: number;
  58465. q?: number;
  58466. updatable?: boolean;
  58467. sideOrientation?: number;
  58468. frontUVs?: Vector4;
  58469. backUVs?: Vector4;
  58470. }, scene: any): Mesh;
  58471. }
  58472. }
  58473. declare module "babylonjs/Meshes/polygonMesh" {
  58474. import { Scene } from "babylonjs/scene";
  58475. import { Vector2 } from "babylonjs/Maths/math.vector";
  58476. import { Mesh } from "babylonjs/Meshes/mesh";
  58477. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58478. import { Path2 } from "babylonjs/Maths/math.path";
  58479. /**
  58480. * Polygon
  58481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58482. */
  58483. export class Polygon {
  58484. /**
  58485. * Creates a rectangle
  58486. * @param xmin bottom X coord
  58487. * @param ymin bottom Y coord
  58488. * @param xmax top X coord
  58489. * @param ymax top Y coord
  58490. * @returns points that make the resulting rectation
  58491. */
  58492. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58493. /**
  58494. * Creates a circle
  58495. * @param radius radius of circle
  58496. * @param cx scale in x
  58497. * @param cy scale in y
  58498. * @param numberOfSides number of sides that make up the circle
  58499. * @returns points that make the resulting circle
  58500. */
  58501. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58502. /**
  58503. * Creates a polygon from input string
  58504. * @param input Input polygon data
  58505. * @returns the parsed points
  58506. */
  58507. static Parse(input: string): Vector2[];
  58508. /**
  58509. * Starts building a polygon from x and y coordinates
  58510. * @param x x coordinate
  58511. * @param y y coordinate
  58512. * @returns the started path2
  58513. */
  58514. static StartingAt(x: number, y: number): Path2;
  58515. }
  58516. /**
  58517. * Builds a polygon
  58518. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58519. */
  58520. export class PolygonMeshBuilder {
  58521. private _points;
  58522. private _outlinepoints;
  58523. private _holes;
  58524. private _name;
  58525. private _scene;
  58526. private _epoints;
  58527. private _eholes;
  58528. private _addToepoint;
  58529. /**
  58530. * Babylon reference to the earcut plugin.
  58531. */
  58532. bjsEarcut: any;
  58533. /**
  58534. * Creates a PolygonMeshBuilder
  58535. * @param name name of the builder
  58536. * @param contours Path of the polygon
  58537. * @param scene scene to add to when creating the mesh
  58538. * @param earcutInjection can be used to inject your own earcut reference
  58539. */
  58540. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58541. /**
  58542. * Adds a whole within the polygon
  58543. * @param hole Array of points defining the hole
  58544. * @returns this
  58545. */
  58546. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58547. /**
  58548. * Creates the polygon
  58549. * @param updatable If the mesh should be updatable
  58550. * @param depth The depth of the mesh created
  58551. * @returns the created mesh
  58552. */
  58553. build(updatable?: boolean, depth?: number): Mesh;
  58554. /**
  58555. * Creates the polygon
  58556. * @param depth The depth of the mesh created
  58557. * @returns the created VertexData
  58558. */
  58559. buildVertexData(depth?: number): VertexData;
  58560. /**
  58561. * Adds a side to the polygon
  58562. * @param positions points that make the polygon
  58563. * @param normals normals of the polygon
  58564. * @param uvs uvs of the polygon
  58565. * @param indices indices of the polygon
  58566. * @param bounds bounds of the polygon
  58567. * @param points points of the polygon
  58568. * @param depth depth of the polygon
  58569. * @param flip flip of the polygon
  58570. */
  58571. private addSide;
  58572. }
  58573. }
  58574. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58575. import { Scene } from "babylonjs/scene";
  58576. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58577. import { Color4 } from "babylonjs/Maths/math.color";
  58578. import { Mesh } from "babylonjs/Meshes/mesh";
  58579. import { Nullable } from "babylonjs/types";
  58580. /**
  58581. * Class containing static functions to help procedurally build meshes
  58582. */
  58583. export class PolygonBuilder {
  58584. /**
  58585. * Creates a polygon mesh
  58586. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58587. * * 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
  58588. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58591. * * Remember you can only change the shape positions, not their number when updating a polygon
  58592. * @param name defines the name of the mesh
  58593. * @param options defines the options used to create the mesh
  58594. * @param scene defines the hosting scene
  58595. * @param earcutInjection can be used to inject your own earcut reference
  58596. * @returns the polygon mesh
  58597. */
  58598. static CreatePolygon(name: string, options: {
  58599. shape: Vector3[];
  58600. holes?: Vector3[][];
  58601. depth?: number;
  58602. faceUV?: Vector4[];
  58603. faceColors?: Color4[];
  58604. updatable?: boolean;
  58605. sideOrientation?: number;
  58606. frontUVs?: Vector4;
  58607. backUVs?: Vector4;
  58608. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58609. /**
  58610. * Creates an extruded polygon mesh, with depth in the Y direction.
  58611. * * 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)
  58612. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58613. * @param name defines the name of the mesh
  58614. * @param options defines the options used to create the mesh
  58615. * @param scene defines the hosting scene
  58616. * @param earcutInjection can be used to inject your own earcut reference
  58617. * @returns the polygon mesh
  58618. */
  58619. static ExtrudePolygon(name: string, options: {
  58620. shape: Vector3[];
  58621. holes?: Vector3[][];
  58622. depth?: number;
  58623. faceUV?: Vector4[];
  58624. faceColors?: Color4[];
  58625. updatable?: boolean;
  58626. sideOrientation?: number;
  58627. frontUVs?: Vector4;
  58628. backUVs?: Vector4;
  58629. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58630. }
  58631. }
  58632. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58633. import { Scene } from "babylonjs/scene";
  58634. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58635. import { Mesh } from "babylonjs/Meshes/mesh";
  58636. import { Nullable } from "babylonjs/types";
  58637. /**
  58638. * Class containing static functions to help procedurally build meshes
  58639. */
  58640. export class LatheBuilder {
  58641. /**
  58642. * Creates lathe mesh.
  58643. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58644. * * 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
  58645. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58646. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58647. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58648. * * 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
  58649. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58650. * * 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
  58651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58653. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58655. * @param name defines the name of the mesh
  58656. * @param options defines the options used to create the mesh
  58657. * @param scene defines the hosting scene
  58658. * @returns the lathe mesh
  58659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58660. */
  58661. static CreateLathe(name: string, options: {
  58662. shape: Vector3[];
  58663. radius?: number;
  58664. tessellation?: number;
  58665. clip?: number;
  58666. arc?: number;
  58667. closed?: boolean;
  58668. updatable?: boolean;
  58669. sideOrientation?: number;
  58670. frontUVs?: Vector4;
  58671. backUVs?: Vector4;
  58672. cap?: number;
  58673. invertUV?: boolean;
  58674. }, scene?: Nullable<Scene>): Mesh;
  58675. }
  58676. }
  58677. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58678. import { Nullable } from "babylonjs/types";
  58679. import { Scene } from "babylonjs/scene";
  58680. import { Vector4 } from "babylonjs/Maths/math.vector";
  58681. import { Mesh } from "babylonjs/Meshes/mesh";
  58682. /**
  58683. * Class containing static functions to help procedurally build meshes
  58684. */
  58685. export class TiledPlaneBuilder {
  58686. /**
  58687. * Creates a tiled plane mesh
  58688. * * The parameter `pattern` will, depending on value, do nothing or
  58689. * * * flip (reflect about central vertical) alternate tiles across and up
  58690. * * * flip every tile on alternate rows
  58691. * * * rotate (180 degs) alternate tiles across and up
  58692. * * * rotate every tile on alternate rows
  58693. * * * flip and rotate alternate tiles across and up
  58694. * * * flip and rotate every tile on alternate rows
  58695. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58696. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58699. * * 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)
  58700. * * 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)
  58701. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58702. * @param name defines the name of the mesh
  58703. * @param options defines the options used to create the mesh
  58704. * @param scene defines the hosting scene
  58705. * @returns the box mesh
  58706. */
  58707. static CreateTiledPlane(name: string, options: {
  58708. pattern?: number;
  58709. tileSize?: number;
  58710. tileWidth?: number;
  58711. tileHeight?: number;
  58712. size?: number;
  58713. width?: number;
  58714. height?: number;
  58715. alignHorizontal?: number;
  58716. alignVertical?: number;
  58717. sideOrientation?: number;
  58718. frontUVs?: Vector4;
  58719. backUVs?: Vector4;
  58720. updatable?: boolean;
  58721. }, scene?: Nullable<Scene>): Mesh;
  58722. }
  58723. }
  58724. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58725. import { Nullable } from "babylonjs/types";
  58726. import { Scene } from "babylonjs/scene";
  58727. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58728. import { Mesh } from "babylonjs/Meshes/mesh";
  58729. /**
  58730. * Class containing static functions to help procedurally build meshes
  58731. */
  58732. export class TubeBuilder {
  58733. /**
  58734. * Creates a tube mesh.
  58735. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58736. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58737. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58738. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58739. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58740. * * 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)
  58741. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58742. * * 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
  58743. * * 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
  58744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58748. * @param name defines the name of the mesh
  58749. * @param options defines the options used to create the mesh
  58750. * @param scene defines the hosting scene
  58751. * @returns the tube mesh
  58752. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58753. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58754. */
  58755. static CreateTube(name: string, options: {
  58756. path: Vector3[];
  58757. radius?: number;
  58758. tessellation?: number;
  58759. radiusFunction?: {
  58760. (i: number, distance: number): number;
  58761. };
  58762. cap?: number;
  58763. arc?: number;
  58764. updatable?: boolean;
  58765. sideOrientation?: number;
  58766. frontUVs?: Vector4;
  58767. backUVs?: Vector4;
  58768. instance?: Mesh;
  58769. invertUV?: boolean;
  58770. }, scene?: Nullable<Scene>): Mesh;
  58771. }
  58772. }
  58773. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58774. import { Scene } from "babylonjs/scene";
  58775. import { Vector4 } from "babylonjs/Maths/math.vector";
  58776. import { Mesh } from "babylonjs/Meshes/mesh";
  58777. import { Nullable } from "babylonjs/types";
  58778. /**
  58779. * Class containing static functions to help procedurally build meshes
  58780. */
  58781. export class IcoSphereBuilder {
  58782. /**
  58783. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58784. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58785. * * 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`)
  58786. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58787. * * 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
  58788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58791. * @param name defines the name of the mesh
  58792. * @param options defines the options used to create the mesh
  58793. * @param scene defines the hosting scene
  58794. * @returns the icosahedron mesh
  58795. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58796. */
  58797. static CreateIcoSphere(name: string, options: {
  58798. radius?: number;
  58799. radiusX?: number;
  58800. radiusY?: number;
  58801. radiusZ?: number;
  58802. flat?: boolean;
  58803. subdivisions?: number;
  58804. sideOrientation?: number;
  58805. frontUVs?: Vector4;
  58806. backUVs?: Vector4;
  58807. updatable?: boolean;
  58808. }, scene?: Nullable<Scene>): Mesh;
  58809. }
  58810. }
  58811. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58812. import { Vector3 } from "babylonjs/Maths/math.vector";
  58813. import { Mesh } from "babylonjs/Meshes/mesh";
  58814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58815. /**
  58816. * Class containing static functions to help procedurally build meshes
  58817. */
  58818. export class DecalBuilder {
  58819. /**
  58820. * Creates a decal mesh.
  58821. * 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
  58822. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58823. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58824. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58825. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58826. * @param name defines the name of the mesh
  58827. * @param sourceMesh defines the mesh where the decal must be applied
  58828. * @param options defines the options used to create the mesh
  58829. * @param scene defines the hosting scene
  58830. * @returns the decal mesh
  58831. * @see https://doc.babylonjs.com/how_to/decals
  58832. */
  58833. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58834. position?: Vector3;
  58835. normal?: Vector3;
  58836. size?: Vector3;
  58837. angle?: number;
  58838. }): Mesh;
  58839. }
  58840. }
  58841. declare module "babylonjs/Meshes/meshBuilder" {
  58842. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58843. import { Nullable } from "babylonjs/types";
  58844. import { Scene } from "babylonjs/scene";
  58845. import { Mesh } from "babylonjs/Meshes/mesh";
  58846. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58847. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58849. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58850. import { Plane } from "babylonjs/Maths/math.plane";
  58851. /**
  58852. * Class containing static functions to help procedurally build meshes
  58853. */
  58854. export class MeshBuilder {
  58855. /**
  58856. * Creates a box mesh
  58857. * * The parameter `size` sets the size (float) of each box side (default 1)
  58858. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58859. * * 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)
  58860. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58864. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58865. * @param name defines the name of the mesh
  58866. * @param options defines the options used to create the mesh
  58867. * @param scene defines the hosting scene
  58868. * @returns the box mesh
  58869. */
  58870. static CreateBox(name: string, options: {
  58871. size?: number;
  58872. width?: number;
  58873. height?: number;
  58874. depth?: number;
  58875. faceUV?: Vector4[];
  58876. faceColors?: Color4[];
  58877. sideOrientation?: number;
  58878. frontUVs?: Vector4;
  58879. backUVs?: Vector4;
  58880. updatable?: boolean;
  58881. }, scene?: Nullable<Scene>): Mesh;
  58882. /**
  58883. * Creates a tiled box mesh
  58884. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58886. * @param name defines the name of the mesh
  58887. * @param options defines the options used to create the mesh
  58888. * @param scene defines the hosting scene
  58889. * @returns the tiled box mesh
  58890. */
  58891. static CreateTiledBox(name: string, options: {
  58892. pattern?: number;
  58893. size?: number;
  58894. width?: number;
  58895. height?: number;
  58896. depth: number;
  58897. tileSize?: number;
  58898. tileWidth?: number;
  58899. tileHeight?: number;
  58900. faceUV?: Vector4[];
  58901. faceColors?: Color4[];
  58902. alignHorizontal?: number;
  58903. alignVertical?: number;
  58904. sideOrientation?: number;
  58905. updatable?: boolean;
  58906. }, scene?: Nullable<Scene>): Mesh;
  58907. /**
  58908. * Creates a sphere mesh
  58909. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58910. * * 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`)
  58911. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58912. * * 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
  58913. * * 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)
  58914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58917. * @param name defines the name of the mesh
  58918. * @param options defines the options used to create the mesh
  58919. * @param scene defines the hosting scene
  58920. * @returns the sphere mesh
  58921. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58922. */
  58923. static CreateSphere(name: string, options: {
  58924. segments?: number;
  58925. diameter?: number;
  58926. diameterX?: number;
  58927. diameterY?: number;
  58928. diameterZ?: number;
  58929. arc?: number;
  58930. slice?: number;
  58931. sideOrientation?: number;
  58932. frontUVs?: Vector4;
  58933. backUVs?: Vector4;
  58934. updatable?: boolean;
  58935. }, scene?: Nullable<Scene>): Mesh;
  58936. /**
  58937. * Creates a plane polygonal mesh. By default, this is a disc
  58938. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58939. * * 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
  58940. * * 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
  58941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58944. * @param name defines the name of the mesh
  58945. * @param options defines the options used to create the mesh
  58946. * @param scene defines the hosting scene
  58947. * @returns the plane polygonal mesh
  58948. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58949. */
  58950. static CreateDisc(name: string, options: {
  58951. radius?: number;
  58952. tessellation?: number;
  58953. arc?: number;
  58954. updatable?: boolean;
  58955. sideOrientation?: number;
  58956. frontUVs?: Vector4;
  58957. backUVs?: Vector4;
  58958. }, scene?: Nullable<Scene>): Mesh;
  58959. /**
  58960. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58961. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58962. * * 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`)
  58963. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58964. * * 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
  58965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58968. * @param name defines the name of the mesh
  58969. * @param options defines the options used to create the mesh
  58970. * @param scene defines the hosting scene
  58971. * @returns the icosahedron mesh
  58972. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58973. */
  58974. static CreateIcoSphere(name: string, options: {
  58975. radius?: number;
  58976. radiusX?: number;
  58977. radiusY?: number;
  58978. radiusZ?: number;
  58979. flat?: boolean;
  58980. subdivisions?: number;
  58981. sideOrientation?: number;
  58982. frontUVs?: Vector4;
  58983. backUVs?: Vector4;
  58984. updatable?: boolean;
  58985. }, scene?: Nullable<Scene>): Mesh;
  58986. /**
  58987. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58988. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58989. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58990. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58991. * * 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
  58992. * * 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
  58993. * * 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
  58994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58996. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58997. * * 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
  58998. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58999. * * 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
  59000. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59002. * @param name defines the name of the mesh
  59003. * @param options defines the options used to create the mesh
  59004. * @param scene defines the hosting scene
  59005. * @returns the ribbon mesh
  59006. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59007. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59008. */
  59009. static CreateRibbon(name: string, options: {
  59010. pathArray: Vector3[][];
  59011. closeArray?: boolean;
  59012. closePath?: boolean;
  59013. offset?: number;
  59014. updatable?: boolean;
  59015. sideOrientation?: number;
  59016. frontUVs?: Vector4;
  59017. backUVs?: Vector4;
  59018. instance?: Mesh;
  59019. invertUV?: boolean;
  59020. uvs?: Vector2[];
  59021. colors?: Color4[];
  59022. }, scene?: Nullable<Scene>): Mesh;
  59023. /**
  59024. * Creates a cylinder or a cone mesh
  59025. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59026. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59027. * * 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.
  59028. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59029. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59030. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59031. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59032. * * 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).
  59033. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59034. * * 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).
  59035. * * 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
  59036. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59037. * * 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
  59038. * * 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.
  59039. * * If `enclose` is false, a ring surface is one element.
  59040. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59041. * * 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
  59042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59045. * @param name defines the name of the mesh
  59046. * @param options defines the options used to create the mesh
  59047. * @param scene defines the hosting scene
  59048. * @returns the cylinder mesh
  59049. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59050. */
  59051. static CreateCylinder(name: string, options: {
  59052. height?: number;
  59053. diameterTop?: number;
  59054. diameterBottom?: number;
  59055. diameter?: number;
  59056. tessellation?: number;
  59057. subdivisions?: number;
  59058. arc?: number;
  59059. faceColors?: Color4[];
  59060. faceUV?: Vector4[];
  59061. updatable?: boolean;
  59062. hasRings?: boolean;
  59063. enclose?: boolean;
  59064. cap?: number;
  59065. sideOrientation?: number;
  59066. frontUVs?: Vector4;
  59067. backUVs?: Vector4;
  59068. }, scene?: Nullable<Scene>): Mesh;
  59069. /**
  59070. * Creates a torus mesh
  59071. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59072. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59073. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59077. * @param name defines the name of the mesh
  59078. * @param options defines the options used to create the mesh
  59079. * @param scene defines the hosting scene
  59080. * @returns the torus mesh
  59081. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59082. */
  59083. static CreateTorus(name: string, options: {
  59084. diameter?: number;
  59085. thickness?: number;
  59086. tessellation?: number;
  59087. updatable?: boolean;
  59088. sideOrientation?: number;
  59089. frontUVs?: Vector4;
  59090. backUVs?: Vector4;
  59091. }, scene?: Nullable<Scene>): Mesh;
  59092. /**
  59093. * Creates a torus knot mesh
  59094. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59095. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59096. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59097. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59101. * @param name defines the name of the mesh
  59102. * @param options defines the options used to create the mesh
  59103. * @param scene defines the hosting scene
  59104. * @returns the torus knot mesh
  59105. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59106. */
  59107. static CreateTorusKnot(name: string, options: {
  59108. radius?: number;
  59109. tube?: number;
  59110. radialSegments?: number;
  59111. tubularSegments?: number;
  59112. p?: number;
  59113. q?: number;
  59114. updatable?: boolean;
  59115. sideOrientation?: number;
  59116. frontUVs?: Vector4;
  59117. backUVs?: Vector4;
  59118. }, scene?: Nullable<Scene>): Mesh;
  59119. /**
  59120. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59121. * * 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
  59122. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59123. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59124. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59125. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59126. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59127. * * 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
  59128. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59131. * @param name defines the name of the new line system
  59132. * @param options defines the options used to create the line system
  59133. * @param scene defines the hosting scene
  59134. * @returns a new line system mesh
  59135. */
  59136. static CreateLineSystem(name: string, options: {
  59137. lines: Vector3[][];
  59138. updatable?: boolean;
  59139. instance?: Nullable<LinesMesh>;
  59140. colors?: Nullable<Color4[][]>;
  59141. useVertexAlpha?: boolean;
  59142. }, scene: Nullable<Scene>): LinesMesh;
  59143. /**
  59144. * Creates a line mesh
  59145. * 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
  59146. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59147. * * The parameter `points` is an array successive Vector3
  59148. * * 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
  59149. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59150. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59151. * * When updating an instance, remember that only point positions can change, not the number of points
  59152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59153. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59154. * @param name defines the name of the new line system
  59155. * @param options defines the options used to create the line system
  59156. * @param scene defines the hosting scene
  59157. * @returns a new line mesh
  59158. */
  59159. static CreateLines(name: string, options: {
  59160. points: Vector3[];
  59161. updatable?: boolean;
  59162. instance?: Nullable<LinesMesh>;
  59163. colors?: Color4[];
  59164. useVertexAlpha?: boolean;
  59165. }, scene?: Nullable<Scene>): LinesMesh;
  59166. /**
  59167. * Creates a dashed line mesh
  59168. * * 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
  59169. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59170. * * The parameter `points` is an array successive Vector3
  59171. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59172. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59173. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59174. * * 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
  59175. * * When updating an instance, remember that only point positions can change, not the number of points
  59176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59177. * @param name defines the name of the mesh
  59178. * @param options defines the options used to create the mesh
  59179. * @param scene defines the hosting scene
  59180. * @returns the dashed line mesh
  59181. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59182. */
  59183. static CreateDashedLines(name: string, options: {
  59184. points: Vector3[];
  59185. dashSize?: number;
  59186. gapSize?: number;
  59187. dashNb?: number;
  59188. updatable?: boolean;
  59189. instance?: LinesMesh;
  59190. }, scene?: Nullable<Scene>): LinesMesh;
  59191. /**
  59192. * 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.
  59193. * * 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.
  59194. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59195. * * 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.
  59196. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59197. * * 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
  59198. * * 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
  59199. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59202. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59204. * @param name defines the name of the mesh
  59205. * @param options defines the options used to create the mesh
  59206. * @param scene defines the hosting scene
  59207. * @returns the extruded shape mesh
  59208. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59210. */
  59211. static ExtrudeShape(name: string, options: {
  59212. shape: Vector3[];
  59213. path: Vector3[];
  59214. scale?: number;
  59215. rotation?: number;
  59216. cap?: number;
  59217. updatable?: boolean;
  59218. sideOrientation?: number;
  59219. frontUVs?: Vector4;
  59220. backUVs?: Vector4;
  59221. instance?: Mesh;
  59222. invertUV?: boolean;
  59223. }, scene?: Nullable<Scene>): Mesh;
  59224. /**
  59225. * Creates an custom extruded shape mesh.
  59226. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59227. * * 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.
  59228. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59229. * * 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
  59230. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59231. * * 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
  59232. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59233. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59234. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59235. * * 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
  59236. * * 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
  59237. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59240. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59242. * @param name defines the name of the mesh
  59243. * @param options defines the options used to create the mesh
  59244. * @param scene defines the hosting scene
  59245. * @returns the custom extruded shape mesh
  59246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59247. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59249. */
  59250. static ExtrudeShapeCustom(name: string, options: {
  59251. shape: Vector3[];
  59252. path: Vector3[];
  59253. scaleFunction?: any;
  59254. rotationFunction?: any;
  59255. ribbonCloseArray?: boolean;
  59256. ribbonClosePath?: boolean;
  59257. cap?: number;
  59258. updatable?: boolean;
  59259. sideOrientation?: number;
  59260. frontUVs?: Vector4;
  59261. backUVs?: Vector4;
  59262. instance?: Mesh;
  59263. invertUV?: boolean;
  59264. }, scene?: Nullable<Scene>): Mesh;
  59265. /**
  59266. * Creates lathe mesh.
  59267. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59268. * * 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
  59269. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59270. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59271. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59272. * * 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
  59273. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59274. * * 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
  59275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59277. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59279. * @param name defines the name of the mesh
  59280. * @param options defines the options used to create the mesh
  59281. * @param scene defines the hosting scene
  59282. * @returns the lathe mesh
  59283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59284. */
  59285. static CreateLathe(name: string, options: {
  59286. shape: Vector3[];
  59287. radius?: number;
  59288. tessellation?: number;
  59289. clip?: number;
  59290. arc?: number;
  59291. closed?: boolean;
  59292. updatable?: boolean;
  59293. sideOrientation?: number;
  59294. frontUVs?: Vector4;
  59295. backUVs?: Vector4;
  59296. cap?: number;
  59297. invertUV?: boolean;
  59298. }, scene?: Nullable<Scene>): Mesh;
  59299. /**
  59300. * Creates a tiled plane mesh
  59301. * * You can set a limited pattern arrangement with the tiles
  59302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59305. * @param name defines the name of the mesh
  59306. * @param options defines the options used to create the mesh
  59307. * @param scene defines the hosting scene
  59308. * @returns the plane mesh
  59309. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59310. */
  59311. static CreateTiledPlane(name: string, options: {
  59312. pattern?: number;
  59313. tileSize?: number;
  59314. tileWidth?: number;
  59315. tileHeight?: number;
  59316. size?: number;
  59317. width?: number;
  59318. height?: number;
  59319. alignHorizontal?: number;
  59320. alignVertical?: number;
  59321. sideOrientation?: number;
  59322. frontUVs?: Vector4;
  59323. backUVs?: Vector4;
  59324. updatable?: boolean;
  59325. }, scene?: Nullable<Scene>): Mesh;
  59326. /**
  59327. * Creates a plane mesh
  59328. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59329. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59330. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59334. * @param name defines the name of the mesh
  59335. * @param options defines the options used to create the mesh
  59336. * @param scene defines the hosting scene
  59337. * @returns the plane mesh
  59338. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59339. */
  59340. static CreatePlane(name: string, options: {
  59341. size?: number;
  59342. width?: number;
  59343. height?: number;
  59344. sideOrientation?: number;
  59345. frontUVs?: Vector4;
  59346. backUVs?: Vector4;
  59347. updatable?: boolean;
  59348. sourcePlane?: Plane;
  59349. }, scene?: Nullable<Scene>): Mesh;
  59350. /**
  59351. * Creates a ground mesh
  59352. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59353. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59355. * @param name defines the name of the mesh
  59356. * @param options defines the options used to create the mesh
  59357. * @param scene defines the hosting scene
  59358. * @returns the ground mesh
  59359. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59360. */
  59361. static CreateGround(name: string, options: {
  59362. width?: number;
  59363. height?: number;
  59364. subdivisions?: number;
  59365. subdivisionsX?: number;
  59366. subdivisionsY?: number;
  59367. updatable?: boolean;
  59368. }, scene?: Nullable<Scene>): Mesh;
  59369. /**
  59370. * Creates a tiled ground mesh
  59371. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59372. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59373. * * 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
  59374. * * 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
  59375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59376. * @param name defines the name of the mesh
  59377. * @param options defines the options used to create the mesh
  59378. * @param scene defines the hosting scene
  59379. * @returns the tiled ground mesh
  59380. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59381. */
  59382. static CreateTiledGround(name: string, options: {
  59383. xmin: number;
  59384. zmin: number;
  59385. xmax: number;
  59386. zmax: number;
  59387. subdivisions?: {
  59388. w: number;
  59389. h: number;
  59390. };
  59391. precision?: {
  59392. w: number;
  59393. h: number;
  59394. };
  59395. updatable?: boolean;
  59396. }, scene?: Nullable<Scene>): Mesh;
  59397. /**
  59398. * Creates a ground mesh from a height map
  59399. * * The parameter `url` sets the URL of the height map image resource.
  59400. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59401. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59402. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59403. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59404. * * 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.
  59405. * * 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).
  59406. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59408. * @param name defines the name of the mesh
  59409. * @param url defines the url to the height map
  59410. * @param options defines the options used to create the mesh
  59411. * @param scene defines the hosting scene
  59412. * @returns the ground mesh
  59413. * @see https://doc.babylonjs.com/babylon101/height_map
  59414. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59415. */
  59416. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59417. width?: number;
  59418. height?: number;
  59419. subdivisions?: number;
  59420. minHeight?: number;
  59421. maxHeight?: number;
  59422. colorFilter?: Color3;
  59423. alphaFilter?: number;
  59424. updatable?: boolean;
  59425. onReady?: (mesh: GroundMesh) => void;
  59426. }, scene?: Nullable<Scene>): GroundMesh;
  59427. /**
  59428. * Creates a polygon mesh
  59429. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59430. * * 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
  59431. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59434. * * Remember you can only change the shape positions, not their number when updating a polygon
  59435. * @param name defines the name of the mesh
  59436. * @param options defines the options used to create the mesh
  59437. * @param scene defines the hosting scene
  59438. * @param earcutInjection can be used to inject your own earcut reference
  59439. * @returns the polygon mesh
  59440. */
  59441. static CreatePolygon(name: string, options: {
  59442. shape: Vector3[];
  59443. holes?: Vector3[][];
  59444. depth?: number;
  59445. faceUV?: Vector4[];
  59446. faceColors?: Color4[];
  59447. updatable?: boolean;
  59448. sideOrientation?: number;
  59449. frontUVs?: Vector4;
  59450. backUVs?: Vector4;
  59451. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59452. /**
  59453. * Creates an extruded polygon mesh, with depth in the Y direction.
  59454. * * 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)
  59455. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59456. * @param name defines the name of the mesh
  59457. * @param options defines the options used to create the mesh
  59458. * @param scene defines the hosting scene
  59459. * @param earcutInjection can be used to inject your own earcut reference
  59460. * @returns the polygon mesh
  59461. */
  59462. static ExtrudePolygon(name: string, options: {
  59463. shape: Vector3[];
  59464. holes?: Vector3[][];
  59465. depth?: number;
  59466. faceUV?: Vector4[];
  59467. faceColors?: Color4[];
  59468. updatable?: boolean;
  59469. sideOrientation?: number;
  59470. frontUVs?: Vector4;
  59471. backUVs?: Vector4;
  59472. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59473. /**
  59474. * Creates a tube mesh.
  59475. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59476. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59477. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59478. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59479. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59480. * * 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)
  59481. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59482. * * 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
  59483. * * 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
  59484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59486. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59488. * @param name defines the name of the mesh
  59489. * @param options defines the options used to create the mesh
  59490. * @param scene defines the hosting scene
  59491. * @returns the tube mesh
  59492. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59493. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59494. */
  59495. static CreateTube(name: string, options: {
  59496. path: Vector3[];
  59497. radius?: number;
  59498. tessellation?: number;
  59499. radiusFunction?: {
  59500. (i: number, distance: number): number;
  59501. };
  59502. cap?: number;
  59503. arc?: number;
  59504. updatable?: boolean;
  59505. sideOrientation?: number;
  59506. frontUVs?: Vector4;
  59507. backUVs?: Vector4;
  59508. instance?: Mesh;
  59509. invertUV?: boolean;
  59510. }, scene?: Nullable<Scene>): Mesh;
  59511. /**
  59512. * Creates a polyhedron mesh
  59513. * * 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
  59514. * * The parameter `size` (positive float, default 1) sets the polygon size
  59515. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59516. * * 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`
  59517. * * 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
  59518. * * 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)`)
  59519. * * 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
  59520. * * 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
  59521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59524. * @param name defines the name of the mesh
  59525. * @param options defines the options used to create the mesh
  59526. * @param scene defines the hosting scene
  59527. * @returns the polyhedron mesh
  59528. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59529. */
  59530. static CreatePolyhedron(name: string, options: {
  59531. type?: number;
  59532. size?: number;
  59533. sizeX?: number;
  59534. sizeY?: number;
  59535. sizeZ?: number;
  59536. custom?: any;
  59537. faceUV?: Vector4[];
  59538. faceColors?: Color4[];
  59539. flat?: boolean;
  59540. updatable?: boolean;
  59541. sideOrientation?: number;
  59542. frontUVs?: Vector4;
  59543. backUVs?: Vector4;
  59544. }, scene?: Nullable<Scene>): Mesh;
  59545. /**
  59546. * Creates a decal mesh.
  59547. * 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
  59548. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59549. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59550. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59551. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59552. * @param name defines the name of the mesh
  59553. * @param sourceMesh defines the mesh where the decal must be applied
  59554. * @param options defines the options used to create the mesh
  59555. * @param scene defines the hosting scene
  59556. * @returns the decal mesh
  59557. * @see https://doc.babylonjs.com/how_to/decals
  59558. */
  59559. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59560. position?: Vector3;
  59561. normal?: Vector3;
  59562. size?: Vector3;
  59563. angle?: number;
  59564. }): Mesh;
  59565. }
  59566. }
  59567. declare module "babylonjs/Meshes/meshSimplification" {
  59568. import { Mesh } from "babylonjs/Meshes/mesh";
  59569. /**
  59570. * A simplifier interface for future simplification implementations
  59571. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59572. */
  59573. export interface ISimplifier {
  59574. /**
  59575. * Simplification of a given mesh according to the given settings.
  59576. * Since this requires computation, it is assumed that the function runs async.
  59577. * @param settings The settings of the simplification, including quality and distance
  59578. * @param successCallback A callback that will be called after the mesh was simplified.
  59579. * @param errorCallback in case of an error, this callback will be called. optional.
  59580. */
  59581. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59582. }
  59583. /**
  59584. * Expected simplification settings.
  59585. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59586. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59587. */
  59588. export interface ISimplificationSettings {
  59589. /**
  59590. * Gets or sets the expected quality
  59591. */
  59592. quality: number;
  59593. /**
  59594. * Gets or sets the distance when this optimized version should be used
  59595. */
  59596. distance: number;
  59597. /**
  59598. * Gets an already optimized mesh
  59599. */
  59600. optimizeMesh?: boolean;
  59601. }
  59602. /**
  59603. * Class used to specify simplification options
  59604. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59605. */
  59606. export class SimplificationSettings implements ISimplificationSettings {
  59607. /** expected quality */
  59608. quality: number;
  59609. /** distance when this optimized version should be used */
  59610. distance: number;
  59611. /** already optimized mesh */
  59612. optimizeMesh?: boolean | undefined;
  59613. /**
  59614. * Creates a SimplificationSettings
  59615. * @param quality expected quality
  59616. * @param distance distance when this optimized version should be used
  59617. * @param optimizeMesh already optimized mesh
  59618. */
  59619. constructor(
  59620. /** expected quality */
  59621. quality: number,
  59622. /** distance when this optimized version should be used */
  59623. distance: number,
  59624. /** already optimized mesh */
  59625. optimizeMesh?: boolean | undefined);
  59626. }
  59627. /**
  59628. * Interface used to define a simplification task
  59629. */
  59630. export interface ISimplificationTask {
  59631. /**
  59632. * Array of settings
  59633. */
  59634. settings: Array<ISimplificationSettings>;
  59635. /**
  59636. * Simplification type
  59637. */
  59638. simplificationType: SimplificationType;
  59639. /**
  59640. * Mesh to simplify
  59641. */
  59642. mesh: Mesh;
  59643. /**
  59644. * Callback called on success
  59645. */
  59646. successCallback?: () => void;
  59647. /**
  59648. * Defines if parallel processing can be used
  59649. */
  59650. parallelProcessing: boolean;
  59651. }
  59652. /**
  59653. * Queue used to order the simplification tasks
  59654. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59655. */
  59656. export class SimplificationQueue {
  59657. private _simplificationArray;
  59658. /**
  59659. * Gets a boolean indicating that the process is still running
  59660. */
  59661. running: boolean;
  59662. /**
  59663. * Creates a new queue
  59664. */
  59665. constructor();
  59666. /**
  59667. * Adds a new simplification task
  59668. * @param task defines a task to add
  59669. */
  59670. addTask(task: ISimplificationTask): void;
  59671. /**
  59672. * Execute next task
  59673. */
  59674. executeNext(): void;
  59675. /**
  59676. * Execute a simplification task
  59677. * @param task defines the task to run
  59678. */
  59679. runSimplification(task: ISimplificationTask): void;
  59680. private getSimplifier;
  59681. }
  59682. /**
  59683. * The implemented types of simplification
  59684. * At the moment only Quadratic Error Decimation is implemented
  59685. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59686. */
  59687. export enum SimplificationType {
  59688. /** Quadratic error decimation */
  59689. QUADRATIC = 0
  59690. }
  59691. }
  59692. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59693. import { Scene } from "babylonjs/scene";
  59694. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59695. import { ISceneComponent } from "babylonjs/sceneComponent";
  59696. module "babylonjs/scene" {
  59697. interface Scene {
  59698. /** @hidden (Backing field) */
  59699. _simplificationQueue: SimplificationQueue;
  59700. /**
  59701. * Gets or sets the simplification queue attached to the scene
  59702. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59703. */
  59704. simplificationQueue: SimplificationQueue;
  59705. }
  59706. }
  59707. module "babylonjs/Meshes/mesh" {
  59708. interface Mesh {
  59709. /**
  59710. * Simplify the mesh according to the given array of settings.
  59711. * Function will return immediately and will simplify async
  59712. * @param settings a collection of simplification settings
  59713. * @param parallelProcessing should all levels calculate parallel or one after the other
  59714. * @param simplificationType the type of simplification to run
  59715. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59716. * @returns the current mesh
  59717. */
  59718. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59719. }
  59720. }
  59721. /**
  59722. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59723. * created in a scene
  59724. */
  59725. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59726. /**
  59727. * The component name helpfull to identify the component in the list of scene components.
  59728. */
  59729. readonly name: string;
  59730. /**
  59731. * The scene the component belongs to.
  59732. */
  59733. scene: Scene;
  59734. /**
  59735. * Creates a new instance of the component for the given scene
  59736. * @param scene Defines the scene to register the component in
  59737. */
  59738. constructor(scene: Scene);
  59739. /**
  59740. * Registers the component in a given scene
  59741. */
  59742. register(): void;
  59743. /**
  59744. * Rebuilds the elements related to this component in case of
  59745. * context lost for instance.
  59746. */
  59747. rebuild(): void;
  59748. /**
  59749. * Disposes the component and the associated ressources
  59750. */
  59751. dispose(): void;
  59752. private _beforeCameraUpdate;
  59753. }
  59754. }
  59755. declare module "babylonjs/Meshes/Builders/index" {
  59756. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59757. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59758. export * from "babylonjs/Meshes/Builders/discBuilder";
  59759. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59760. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59761. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59762. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59763. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59764. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59765. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59766. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59767. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59768. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59769. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59770. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59771. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59772. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59773. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59774. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59775. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59776. }
  59777. declare module "babylonjs/Meshes/index" {
  59778. export * from "babylonjs/Meshes/abstractMesh";
  59779. export * from "babylonjs/Meshes/buffer";
  59780. export * from "babylonjs/Meshes/Compression/index";
  59781. export * from "babylonjs/Meshes/csg";
  59782. export * from "babylonjs/Meshes/geometry";
  59783. export * from "babylonjs/Meshes/groundMesh";
  59784. export * from "babylonjs/Meshes/trailMesh";
  59785. export * from "babylonjs/Meshes/instancedMesh";
  59786. export * from "babylonjs/Meshes/linesMesh";
  59787. export * from "babylonjs/Meshes/mesh";
  59788. export * from "babylonjs/Meshes/mesh.vertexData";
  59789. export * from "babylonjs/Meshes/meshBuilder";
  59790. export * from "babylonjs/Meshes/meshSimplification";
  59791. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59792. export * from "babylonjs/Meshes/polygonMesh";
  59793. export * from "babylonjs/Meshes/subMesh";
  59794. export * from "babylonjs/Meshes/meshLODLevel";
  59795. export * from "babylonjs/Meshes/transformNode";
  59796. export * from "babylonjs/Meshes/Builders/index";
  59797. export * from "babylonjs/Meshes/dataBuffer";
  59798. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59799. }
  59800. declare module "babylonjs/Morph/index" {
  59801. export * from "babylonjs/Morph/morphTarget";
  59802. export * from "babylonjs/Morph/morphTargetManager";
  59803. }
  59804. declare module "babylonjs/Navigation/INavigationEngine" {
  59805. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59806. import { Vector3 } from "babylonjs/Maths/math";
  59807. import { Mesh } from "babylonjs/Meshes/mesh";
  59808. import { Scene } from "babylonjs/scene";
  59809. /**
  59810. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59811. */
  59812. export interface INavigationEnginePlugin {
  59813. /**
  59814. * plugin name
  59815. */
  59816. name: string;
  59817. /**
  59818. * Creates a navigation mesh
  59819. * @param meshes array of all the geometry used to compute the navigatio mesh
  59820. * @param parameters bunch of parameters used to filter geometry
  59821. */
  59822. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59823. /**
  59824. * Create a navigation mesh debug mesh
  59825. * @param scene is where the mesh will be added
  59826. * @returns debug display mesh
  59827. */
  59828. createDebugNavMesh(scene: Scene): Mesh;
  59829. /**
  59830. * Get a navigation mesh constrained position, closest to the parameter position
  59831. * @param position world position
  59832. * @returns the closest point to position constrained by the navigation mesh
  59833. */
  59834. getClosestPoint(position: Vector3): Vector3;
  59835. /**
  59836. * Get a navigation mesh constrained position, within a particular radius
  59837. * @param position world position
  59838. * @param maxRadius the maximum distance to the constrained world position
  59839. * @returns the closest point to position constrained by the navigation mesh
  59840. */
  59841. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59842. /**
  59843. * Compute the final position from a segment made of destination-position
  59844. * @param position world position
  59845. * @param destination world position
  59846. * @returns the resulting point along the navmesh
  59847. */
  59848. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59849. /**
  59850. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59851. * @param start world position
  59852. * @param end world position
  59853. * @returns array containing world position composing the path
  59854. */
  59855. computePath(start: Vector3, end: Vector3): Vector3[];
  59856. /**
  59857. * If this plugin is supported
  59858. * @returns true if plugin is supported
  59859. */
  59860. isSupported(): boolean;
  59861. /**
  59862. * Create a new Crowd so you can add agents
  59863. * @param maxAgents the maximum agent count in the crowd
  59864. * @param maxAgentRadius the maximum radius an agent can have
  59865. * @param scene to attach the crowd to
  59866. * @returns the crowd you can add agents to
  59867. */
  59868. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59869. /**
  59870. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59871. * The queries will try to find a solution within those bounds
  59872. * default is (1,1,1)
  59873. * @param extent x,y,z value that define the extent around the queries point of reference
  59874. */
  59875. setDefaultQueryExtent(extent: Vector3): void;
  59876. /**
  59877. * Get the Bounding box extent specified by setDefaultQueryExtent
  59878. * @returns the box extent values
  59879. */
  59880. getDefaultQueryExtent(): Vector3;
  59881. /**
  59882. * Release all resources
  59883. */
  59884. dispose(): void;
  59885. }
  59886. /**
  59887. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59888. */
  59889. export interface ICrowd {
  59890. /**
  59891. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59892. * You can attach anything to that node. The node position is updated in the scene update tick.
  59893. * @param pos world position that will be constrained by the navigation mesh
  59894. * @param parameters agent parameters
  59895. * @param transform hooked to the agent that will be update by the scene
  59896. * @returns agent index
  59897. */
  59898. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59899. /**
  59900. * Returns the agent position in world space
  59901. * @param index agent index returned by addAgent
  59902. * @returns world space position
  59903. */
  59904. getAgentPosition(index: number): Vector3;
  59905. /**
  59906. * Gets the agent velocity in world space
  59907. * @param index agent index returned by addAgent
  59908. * @returns world space velocity
  59909. */
  59910. getAgentVelocity(index: number): Vector3;
  59911. /**
  59912. * remove a particular agent previously created
  59913. * @param index agent index returned by addAgent
  59914. */
  59915. removeAgent(index: number): void;
  59916. /**
  59917. * get the list of all agents attached to this crowd
  59918. * @returns list of agent indices
  59919. */
  59920. getAgents(): number[];
  59921. /**
  59922. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59923. * @param deltaTime in seconds
  59924. */
  59925. update(deltaTime: number): void;
  59926. /**
  59927. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59928. * @param index agent index returned by addAgent
  59929. * @param destination targeted world position
  59930. */
  59931. agentGoto(index: number, destination: Vector3): void;
  59932. /**
  59933. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59934. * The queries will try to find a solution within those bounds
  59935. * default is (1,1,1)
  59936. * @param extent x,y,z value that define the extent around the queries point of reference
  59937. */
  59938. setDefaultQueryExtent(extent: Vector3): void;
  59939. /**
  59940. * Get the Bounding box extent specified by setDefaultQueryExtent
  59941. * @returns the box extent values
  59942. */
  59943. getDefaultQueryExtent(): Vector3;
  59944. /**
  59945. * Release all resources
  59946. */
  59947. dispose(): void;
  59948. }
  59949. /**
  59950. * Configures an agent
  59951. */
  59952. export interface IAgentParameters {
  59953. /**
  59954. * Agent radius. [Limit: >= 0]
  59955. */
  59956. radius: number;
  59957. /**
  59958. * Agent height. [Limit: > 0]
  59959. */
  59960. height: number;
  59961. /**
  59962. * Maximum allowed acceleration. [Limit: >= 0]
  59963. */
  59964. maxAcceleration: number;
  59965. /**
  59966. * Maximum allowed speed. [Limit: >= 0]
  59967. */
  59968. maxSpeed: number;
  59969. /**
  59970. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59971. */
  59972. collisionQueryRange: number;
  59973. /**
  59974. * The path visibility optimization range. [Limit: > 0]
  59975. */
  59976. pathOptimizationRange: number;
  59977. /**
  59978. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59979. */
  59980. separationWeight: number;
  59981. }
  59982. /**
  59983. * Configures the navigation mesh creation
  59984. */
  59985. export interface INavMeshParameters {
  59986. /**
  59987. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59988. */
  59989. cs: number;
  59990. /**
  59991. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59992. */
  59993. ch: number;
  59994. /**
  59995. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59996. */
  59997. walkableSlopeAngle: number;
  59998. /**
  59999. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60000. * be considered walkable. [Limit: >= 3] [Units: vx]
  60001. */
  60002. walkableHeight: number;
  60003. /**
  60004. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60005. */
  60006. walkableClimb: number;
  60007. /**
  60008. * The distance to erode/shrink the walkable area of the heightfield away from
  60009. * obstructions. [Limit: >=0] [Units: vx]
  60010. */
  60011. walkableRadius: number;
  60012. /**
  60013. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60014. */
  60015. maxEdgeLen: number;
  60016. /**
  60017. * The maximum distance a simplfied contour's border edges should deviate
  60018. * the original raw contour. [Limit: >=0] [Units: vx]
  60019. */
  60020. maxSimplificationError: number;
  60021. /**
  60022. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60023. */
  60024. minRegionArea: number;
  60025. /**
  60026. * Any regions with a span count smaller than this value will, if possible,
  60027. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60028. */
  60029. mergeRegionArea: number;
  60030. /**
  60031. * The maximum number of vertices allowed for polygons generated during the
  60032. * contour to polygon conversion process. [Limit: >= 3]
  60033. */
  60034. maxVertsPerPoly: number;
  60035. /**
  60036. * Sets the sampling distance to use when generating the detail mesh.
  60037. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60038. */
  60039. detailSampleDist: number;
  60040. /**
  60041. * The maximum distance the detail mesh surface should deviate from heightfield
  60042. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60043. */
  60044. detailSampleMaxError: number;
  60045. }
  60046. }
  60047. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60048. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60049. import { Mesh } from "babylonjs/Meshes/mesh";
  60050. import { Scene } from "babylonjs/scene";
  60051. import { Vector3 } from "babylonjs/Maths/math";
  60052. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60053. /**
  60054. * RecastJS navigation plugin
  60055. */
  60056. export class RecastJSPlugin implements INavigationEnginePlugin {
  60057. /**
  60058. * Reference to the Recast library
  60059. */
  60060. bjsRECAST: any;
  60061. /**
  60062. * plugin name
  60063. */
  60064. name: string;
  60065. /**
  60066. * the first navmesh created. We might extend this to support multiple navmeshes
  60067. */
  60068. navMesh: any;
  60069. /**
  60070. * Initializes the recastJS plugin
  60071. * @param recastInjection can be used to inject your own recast reference
  60072. */
  60073. constructor(recastInjection?: any);
  60074. /**
  60075. * Creates a navigation mesh
  60076. * @param meshes array of all the geometry used to compute the navigatio mesh
  60077. * @param parameters bunch of parameters used to filter geometry
  60078. */
  60079. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60080. /**
  60081. * Create a navigation mesh debug mesh
  60082. * @param scene is where the mesh will be added
  60083. * @returns debug display mesh
  60084. */
  60085. createDebugNavMesh(scene: Scene): Mesh;
  60086. /**
  60087. * Get a navigation mesh constrained position, closest to the parameter position
  60088. * @param position world position
  60089. * @returns the closest point to position constrained by the navigation mesh
  60090. */
  60091. getClosestPoint(position: Vector3): Vector3;
  60092. /**
  60093. * Get a navigation mesh constrained position, within a particular radius
  60094. * @param position world position
  60095. * @param maxRadius the maximum distance to the constrained world position
  60096. * @returns the closest point to position constrained by the navigation mesh
  60097. */
  60098. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60099. /**
  60100. * Compute the final position from a segment made of destination-position
  60101. * @param position world position
  60102. * @param destination world position
  60103. * @returns the resulting point along the navmesh
  60104. */
  60105. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60106. /**
  60107. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60108. * @param start world position
  60109. * @param end world position
  60110. * @returns array containing world position composing the path
  60111. */
  60112. computePath(start: Vector3, end: Vector3): Vector3[];
  60113. /**
  60114. * Create a new Crowd so you can add agents
  60115. * @param maxAgents the maximum agent count in the crowd
  60116. * @param maxAgentRadius the maximum radius an agent can have
  60117. * @param scene to attach the crowd to
  60118. * @returns the crowd you can add agents to
  60119. */
  60120. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60121. /**
  60122. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60123. * The queries will try to find a solution within those bounds
  60124. * default is (1,1,1)
  60125. * @param extent x,y,z value that define the extent around the queries point of reference
  60126. */
  60127. setDefaultQueryExtent(extent: Vector3): void;
  60128. /**
  60129. * Get the Bounding box extent specified by setDefaultQueryExtent
  60130. * @returns the box extent values
  60131. */
  60132. getDefaultQueryExtent(): Vector3;
  60133. /**
  60134. * Disposes
  60135. */
  60136. dispose(): void;
  60137. /**
  60138. * If this plugin is supported
  60139. * @returns true if plugin is supported
  60140. */
  60141. isSupported(): boolean;
  60142. }
  60143. /**
  60144. * Recast detour crowd implementation
  60145. */
  60146. export class RecastJSCrowd implements ICrowd {
  60147. /**
  60148. * Recast/detour plugin
  60149. */
  60150. bjsRECASTPlugin: RecastJSPlugin;
  60151. /**
  60152. * Link to the detour crowd
  60153. */
  60154. recastCrowd: any;
  60155. /**
  60156. * One transform per agent
  60157. */
  60158. transforms: TransformNode[];
  60159. /**
  60160. * All agents created
  60161. */
  60162. agents: number[];
  60163. /**
  60164. * Link to the scene is kept to unregister the crowd from the scene
  60165. */
  60166. private _scene;
  60167. /**
  60168. * Observer for crowd updates
  60169. */
  60170. private _onBeforeAnimationsObserver;
  60171. /**
  60172. * Constructor
  60173. * @param plugin recastJS plugin
  60174. * @param maxAgents the maximum agent count in the crowd
  60175. * @param maxAgentRadius the maximum radius an agent can have
  60176. * @param scene to attach the crowd to
  60177. * @returns the crowd you can add agents to
  60178. */
  60179. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60180. /**
  60181. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60182. * You can attach anything to that node. The node position is updated in the scene update tick.
  60183. * @param pos world position that will be constrained by the navigation mesh
  60184. * @param parameters agent parameters
  60185. * @param transform hooked to the agent that will be update by the scene
  60186. * @returns agent index
  60187. */
  60188. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60189. /**
  60190. * Returns the agent position in world space
  60191. * @param index agent index returned by addAgent
  60192. * @returns world space position
  60193. */
  60194. getAgentPosition(index: number): Vector3;
  60195. /**
  60196. * Returns the agent velocity in world space
  60197. * @param index agent index returned by addAgent
  60198. * @returns world space velocity
  60199. */
  60200. getAgentVelocity(index: number): Vector3;
  60201. /**
  60202. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60203. * @param index agent index returned by addAgent
  60204. * @param destination targeted world position
  60205. */
  60206. agentGoto(index: number, destination: Vector3): void;
  60207. /**
  60208. * remove a particular agent previously created
  60209. * @param index agent index returned by addAgent
  60210. */
  60211. removeAgent(index: number): void;
  60212. /**
  60213. * get the list of all agents attached to this crowd
  60214. * @returns list of agent indices
  60215. */
  60216. getAgents(): number[];
  60217. /**
  60218. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60219. * @param deltaTime in seconds
  60220. */
  60221. update(deltaTime: number): void;
  60222. /**
  60223. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60224. * The queries will try to find a solution within those bounds
  60225. * default is (1,1,1)
  60226. * @param extent x,y,z value that define the extent around the queries point of reference
  60227. */
  60228. setDefaultQueryExtent(extent: Vector3): void;
  60229. /**
  60230. * Get the Bounding box extent specified by setDefaultQueryExtent
  60231. * @returns the box extent values
  60232. */
  60233. getDefaultQueryExtent(): Vector3;
  60234. /**
  60235. * Release all resources
  60236. */
  60237. dispose(): void;
  60238. }
  60239. }
  60240. declare module "babylonjs/Navigation/Plugins/index" {
  60241. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60242. }
  60243. declare module "babylonjs/Navigation/index" {
  60244. export * from "babylonjs/Navigation/INavigationEngine";
  60245. export * from "babylonjs/Navigation/Plugins/index";
  60246. }
  60247. declare module "babylonjs/Offline/database" {
  60248. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60249. /**
  60250. * Class used to enable access to IndexedDB
  60251. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60252. */
  60253. export class Database implements IOfflineProvider {
  60254. private _callbackManifestChecked;
  60255. private _currentSceneUrl;
  60256. private _db;
  60257. private _enableSceneOffline;
  60258. private _enableTexturesOffline;
  60259. private _manifestVersionFound;
  60260. private _mustUpdateRessources;
  60261. private _hasReachedQuota;
  60262. private _isSupported;
  60263. private _idbFactory;
  60264. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60265. private static IsUASupportingBlobStorage;
  60266. /**
  60267. * Gets a boolean indicating if Database storate is enabled (off by default)
  60268. */
  60269. static IDBStorageEnabled: boolean;
  60270. /**
  60271. * Gets a boolean indicating if scene must be saved in the database
  60272. */
  60273. readonly enableSceneOffline: boolean;
  60274. /**
  60275. * Gets a boolean indicating if textures must be saved in the database
  60276. */
  60277. readonly enableTexturesOffline: boolean;
  60278. /**
  60279. * Creates a new Database
  60280. * @param urlToScene defines the url to load the scene
  60281. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60282. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60283. */
  60284. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60285. private static _ParseURL;
  60286. private static _ReturnFullUrlLocation;
  60287. private _checkManifestFile;
  60288. /**
  60289. * Open the database and make it available
  60290. * @param successCallback defines the callback to call on success
  60291. * @param errorCallback defines the callback to call on error
  60292. */
  60293. open(successCallback: () => void, errorCallback: () => void): void;
  60294. /**
  60295. * Loads an image from the database
  60296. * @param url defines the url to load from
  60297. * @param image defines the target DOM image
  60298. */
  60299. loadImage(url: string, image: HTMLImageElement): void;
  60300. private _loadImageFromDBAsync;
  60301. private _saveImageIntoDBAsync;
  60302. private _checkVersionFromDB;
  60303. private _loadVersionFromDBAsync;
  60304. private _saveVersionIntoDBAsync;
  60305. /**
  60306. * Loads a file from database
  60307. * @param url defines the URL to load from
  60308. * @param sceneLoaded defines a callback to call on success
  60309. * @param progressCallBack defines a callback to call when progress changed
  60310. * @param errorCallback defines a callback to call on error
  60311. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60312. */
  60313. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60314. private _loadFileAsync;
  60315. private _saveFileAsync;
  60316. /**
  60317. * Validates if xhr data is correct
  60318. * @param xhr defines the request to validate
  60319. * @param dataType defines the expected data type
  60320. * @returns true if data is correct
  60321. */
  60322. private static _ValidateXHRData;
  60323. }
  60324. }
  60325. declare module "babylonjs/Offline/index" {
  60326. export * from "babylonjs/Offline/database";
  60327. export * from "babylonjs/Offline/IOfflineProvider";
  60328. }
  60329. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60330. /** @hidden */
  60331. export var gpuUpdateParticlesPixelShader: {
  60332. name: string;
  60333. shader: string;
  60334. };
  60335. }
  60336. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60337. /** @hidden */
  60338. export var gpuUpdateParticlesVertexShader: {
  60339. name: string;
  60340. shader: string;
  60341. };
  60342. }
  60343. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60344. /** @hidden */
  60345. export var clipPlaneFragmentDeclaration2: {
  60346. name: string;
  60347. shader: string;
  60348. };
  60349. }
  60350. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60351. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60352. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60353. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60354. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60355. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60356. /** @hidden */
  60357. export var gpuRenderParticlesPixelShader: {
  60358. name: string;
  60359. shader: string;
  60360. };
  60361. }
  60362. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60363. /** @hidden */
  60364. export var clipPlaneVertexDeclaration2: {
  60365. name: string;
  60366. shader: string;
  60367. };
  60368. }
  60369. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60370. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60371. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60372. /** @hidden */
  60373. export var gpuRenderParticlesVertexShader: {
  60374. name: string;
  60375. shader: string;
  60376. };
  60377. }
  60378. declare module "babylonjs/Particles/gpuParticleSystem" {
  60379. import { Nullable } from "babylonjs/types";
  60380. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60381. import { Observable } from "babylonjs/Misc/observable";
  60382. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60384. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60385. import { Scene, IDisposable } from "babylonjs/scene";
  60386. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60387. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60388. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60389. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60390. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60391. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60392. /**
  60393. * This represents a GPU particle system in Babylon
  60394. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60395. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60396. */
  60397. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60398. /**
  60399. * The layer mask we are rendering the particles through.
  60400. */
  60401. layerMask: number;
  60402. private _capacity;
  60403. private _activeCount;
  60404. private _currentActiveCount;
  60405. private _accumulatedCount;
  60406. private _renderEffect;
  60407. private _updateEffect;
  60408. private _buffer0;
  60409. private _buffer1;
  60410. private _spriteBuffer;
  60411. private _updateVAO;
  60412. private _renderVAO;
  60413. private _targetIndex;
  60414. private _sourceBuffer;
  60415. private _targetBuffer;
  60416. private _engine;
  60417. private _currentRenderId;
  60418. private _started;
  60419. private _stopped;
  60420. private _timeDelta;
  60421. private _randomTexture;
  60422. private _randomTexture2;
  60423. private _attributesStrideSize;
  60424. private _updateEffectOptions;
  60425. private _randomTextureSize;
  60426. private _actualFrame;
  60427. private readonly _rawTextureWidth;
  60428. /**
  60429. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60430. */
  60431. static readonly IsSupported: boolean;
  60432. /**
  60433. * An event triggered when the system is disposed.
  60434. */
  60435. onDisposeObservable: Observable<GPUParticleSystem>;
  60436. /**
  60437. * Gets the maximum number of particles active at the same time.
  60438. * @returns The max number of active particles.
  60439. */
  60440. getCapacity(): number;
  60441. /**
  60442. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60443. * to override the particles.
  60444. */
  60445. forceDepthWrite: boolean;
  60446. /**
  60447. * Gets or set the number of active particles
  60448. */
  60449. activeParticleCount: number;
  60450. private _preWarmDone;
  60451. /**
  60452. * Is this system ready to be used/rendered
  60453. * @return true if the system is ready
  60454. */
  60455. isReady(): boolean;
  60456. /**
  60457. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60458. * @returns True if it has been started, otherwise false.
  60459. */
  60460. isStarted(): boolean;
  60461. /**
  60462. * Starts the particle system and begins to emit
  60463. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60464. */
  60465. start(delay?: number): void;
  60466. /**
  60467. * Stops the particle system.
  60468. */
  60469. stop(): void;
  60470. /**
  60471. * Remove all active particles
  60472. */
  60473. reset(): void;
  60474. /**
  60475. * Returns the string "GPUParticleSystem"
  60476. * @returns a string containing the class name
  60477. */
  60478. getClassName(): string;
  60479. private _colorGradientsTexture;
  60480. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60481. /**
  60482. * Adds a new color gradient
  60483. * @param gradient defines the gradient to use (between 0 and 1)
  60484. * @param color1 defines the color to affect to the specified gradient
  60485. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60486. * @returns the current particle system
  60487. */
  60488. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60489. /**
  60490. * Remove a specific color gradient
  60491. * @param gradient defines the gradient to remove
  60492. * @returns the current particle system
  60493. */
  60494. removeColorGradient(gradient: number): GPUParticleSystem;
  60495. private _angularSpeedGradientsTexture;
  60496. private _sizeGradientsTexture;
  60497. private _velocityGradientsTexture;
  60498. private _limitVelocityGradientsTexture;
  60499. private _dragGradientsTexture;
  60500. private _addFactorGradient;
  60501. /**
  60502. * Adds a new size gradient
  60503. * @param gradient defines the gradient to use (between 0 and 1)
  60504. * @param factor defines the size factor to affect to the specified gradient
  60505. * @returns the current particle system
  60506. */
  60507. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60508. /**
  60509. * Remove a specific size gradient
  60510. * @param gradient defines the gradient to remove
  60511. * @returns the current particle system
  60512. */
  60513. removeSizeGradient(gradient: number): GPUParticleSystem;
  60514. /**
  60515. * Adds a new angular speed gradient
  60516. * @param gradient defines the gradient to use (between 0 and 1)
  60517. * @param factor defines the angular speed to affect to the specified gradient
  60518. * @returns the current particle system
  60519. */
  60520. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60521. /**
  60522. * Remove a specific angular speed gradient
  60523. * @param gradient defines the gradient to remove
  60524. * @returns the current particle system
  60525. */
  60526. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60527. /**
  60528. * Adds a new velocity gradient
  60529. * @param gradient defines the gradient to use (between 0 and 1)
  60530. * @param factor defines the velocity to affect to the specified gradient
  60531. * @returns the current particle system
  60532. */
  60533. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60534. /**
  60535. * Remove a specific velocity gradient
  60536. * @param gradient defines the gradient to remove
  60537. * @returns the current particle system
  60538. */
  60539. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60540. /**
  60541. * Adds a new limit velocity gradient
  60542. * @param gradient defines the gradient to use (between 0 and 1)
  60543. * @param factor defines the limit velocity value to affect to the specified gradient
  60544. * @returns the current particle system
  60545. */
  60546. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60547. /**
  60548. * Remove a specific limit velocity gradient
  60549. * @param gradient defines the gradient to remove
  60550. * @returns the current particle system
  60551. */
  60552. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60553. /**
  60554. * Adds a new drag gradient
  60555. * @param gradient defines the gradient to use (between 0 and 1)
  60556. * @param factor defines the drag value to affect to the specified gradient
  60557. * @returns the current particle system
  60558. */
  60559. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60560. /**
  60561. * Remove a specific drag gradient
  60562. * @param gradient defines the gradient to remove
  60563. * @returns the current particle system
  60564. */
  60565. removeDragGradient(gradient: number): GPUParticleSystem;
  60566. /**
  60567. * Not supported by GPUParticleSystem
  60568. * @param gradient defines the gradient to use (between 0 and 1)
  60569. * @param factor defines the emit rate value to affect to the specified gradient
  60570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60571. * @returns the current particle system
  60572. */
  60573. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60574. /**
  60575. * Not supported by GPUParticleSystem
  60576. * @param gradient defines the gradient to remove
  60577. * @returns the current particle system
  60578. */
  60579. removeEmitRateGradient(gradient: number): IParticleSystem;
  60580. /**
  60581. * Not supported by GPUParticleSystem
  60582. * @param gradient defines the gradient to use (between 0 and 1)
  60583. * @param factor defines the start size value to affect to the specified gradient
  60584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60585. * @returns the current particle system
  60586. */
  60587. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60588. /**
  60589. * Not supported by GPUParticleSystem
  60590. * @param gradient defines the gradient to remove
  60591. * @returns the current particle system
  60592. */
  60593. removeStartSizeGradient(gradient: number): IParticleSystem;
  60594. /**
  60595. * Not supported by GPUParticleSystem
  60596. * @param gradient defines the gradient to use (between 0 and 1)
  60597. * @param min defines the color remap minimal range
  60598. * @param max defines the color remap maximal range
  60599. * @returns the current particle system
  60600. */
  60601. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60602. /**
  60603. * Not supported by GPUParticleSystem
  60604. * @param gradient defines the gradient to remove
  60605. * @returns the current particle system
  60606. */
  60607. removeColorRemapGradient(): IParticleSystem;
  60608. /**
  60609. * Not supported by GPUParticleSystem
  60610. * @param gradient defines the gradient to use (between 0 and 1)
  60611. * @param min defines the alpha remap minimal range
  60612. * @param max defines the alpha remap maximal range
  60613. * @returns the current particle system
  60614. */
  60615. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60616. /**
  60617. * Not supported by GPUParticleSystem
  60618. * @param gradient defines the gradient to remove
  60619. * @returns the current particle system
  60620. */
  60621. removeAlphaRemapGradient(): IParticleSystem;
  60622. /**
  60623. * Not supported by GPUParticleSystem
  60624. * @param gradient defines the gradient to use (between 0 and 1)
  60625. * @param color defines the color to affect to the specified gradient
  60626. * @returns the current particle system
  60627. */
  60628. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60629. /**
  60630. * Not supported by GPUParticleSystem
  60631. * @param gradient defines the gradient to remove
  60632. * @returns the current particle system
  60633. */
  60634. removeRampGradient(): IParticleSystem;
  60635. /**
  60636. * Not supported by GPUParticleSystem
  60637. * @returns the list of ramp gradients
  60638. */
  60639. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60640. /**
  60641. * Not supported by GPUParticleSystem
  60642. * Gets or sets a boolean indicating that ramp gradients must be used
  60643. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60644. */
  60645. useRampGradients: boolean;
  60646. /**
  60647. * Not supported by GPUParticleSystem
  60648. * @param gradient defines the gradient to use (between 0 and 1)
  60649. * @param factor defines the life time factor to affect to the specified gradient
  60650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60651. * @returns the current particle system
  60652. */
  60653. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60654. /**
  60655. * Not supported by GPUParticleSystem
  60656. * @param gradient defines the gradient to remove
  60657. * @returns the current particle system
  60658. */
  60659. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60660. /**
  60661. * Instantiates a GPU particle system.
  60662. * 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.
  60663. * @param name The name of the particle system
  60664. * @param options The options used to create the system
  60665. * @param scene The scene the particle system belongs to
  60666. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60667. */
  60668. constructor(name: string, options: Partial<{
  60669. capacity: number;
  60670. randomTextureSize: number;
  60671. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60672. protected _reset(): void;
  60673. private _createUpdateVAO;
  60674. private _createRenderVAO;
  60675. private _initialize;
  60676. /** @hidden */
  60677. _recreateUpdateEffect(): void;
  60678. /** @hidden */
  60679. _recreateRenderEffect(): void;
  60680. /**
  60681. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60682. * @param preWarm defines if we are in the pre-warmimg phase
  60683. */
  60684. animate(preWarm?: boolean): void;
  60685. private _createFactorGradientTexture;
  60686. private _createSizeGradientTexture;
  60687. private _createAngularSpeedGradientTexture;
  60688. private _createVelocityGradientTexture;
  60689. private _createLimitVelocityGradientTexture;
  60690. private _createDragGradientTexture;
  60691. private _createColorGradientTexture;
  60692. /**
  60693. * Renders the particle system in its current state
  60694. * @param preWarm defines if the system should only update the particles but not render them
  60695. * @returns the current number of particles
  60696. */
  60697. render(preWarm?: boolean): number;
  60698. /**
  60699. * Rebuilds the particle system
  60700. */
  60701. rebuild(): void;
  60702. private _releaseBuffers;
  60703. private _releaseVAOs;
  60704. /**
  60705. * Disposes the particle system and free the associated resources
  60706. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60707. */
  60708. dispose(disposeTexture?: boolean): void;
  60709. /**
  60710. * Clones the particle system.
  60711. * @param name The name of the cloned object
  60712. * @param newEmitter The new emitter to use
  60713. * @returns the cloned particle system
  60714. */
  60715. clone(name: string, newEmitter: any): GPUParticleSystem;
  60716. /**
  60717. * Serializes the particle system to a JSON object.
  60718. * @returns the JSON object
  60719. */
  60720. serialize(): any;
  60721. /**
  60722. * Parses a JSON object to create a GPU particle system.
  60723. * @param parsedParticleSystem The JSON object to parse
  60724. * @param scene The scene to create the particle system in
  60725. * @param rootUrl The root url to use to load external dependencies like texture
  60726. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60727. * @returns the parsed GPU particle system
  60728. */
  60729. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60730. }
  60731. }
  60732. declare module "babylonjs/Particles/particleSystemSet" {
  60733. import { Nullable } from "babylonjs/types";
  60734. import { Color3 } from "babylonjs/Maths/math.color";
  60735. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60737. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60738. import { Scene, IDisposable } from "babylonjs/scene";
  60739. /**
  60740. * Represents a set of particle systems working together to create a specific effect
  60741. */
  60742. export class ParticleSystemSet implements IDisposable {
  60743. private _emitterCreationOptions;
  60744. private _emitterNode;
  60745. /**
  60746. * Gets the particle system list
  60747. */
  60748. systems: IParticleSystem[];
  60749. /**
  60750. * Gets the emitter node used with this set
  60751. */
  60752. readonly emitterNode: Nullable<TransformNode>;
  60753. /**
  60754. * Creates a new emitter mesh as a sphere
  60755. * @param options defines the options used to create the sphere
  60756. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60757. * @param scene defines the hosting scene
  60758. */
  60759. setEmitterAsSphere(options: {
  60760. diameter: number;
  60761. segments: number;
  60762. color: Color3;
  60763. }, renderingGroupId: number, scene: Scene): void;
  60764. /**
  60765. * Starts all particle systems of the set
  60766. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60767. */
  60768. start(emitter?: AbstractMesh): void;
  60769. /**
  60770. * Release all associated resources
  60771. */
  60772. dispose(): void;
  60773. /**
  60774. * Serialize the set into a JSON compatible object
  60775. * @returns a JSON compatible representation of the set
  60776. */
  60777. serialize(): any;
  60778. /**
  60779. * Parse a new ParticleSystemSet from a serialized source
  60780. * @param data defines a JSON compatible representation of the set
  60781. * @param scene defines the hosting scene
  60782. * @param gpu defines if we want GPU particles or CPU particles
  60783. * @returns a new ParticleSystemSet
  60784. */
  60785. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60786. }
  60787. }
  60788. declare module "babylonjs/Particles/particleHelper" {
  60789. import { Nullable } from "babylonjs/types";
  60790. import { Scene } from "babylonjs/scene";
  60791. import { Vector3 } from "babylonjs/Maths/math.vector";
  60792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60793. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60794. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60795. /**
  60796. * This class is made for on one-liner static method to help creating particle system set.
  60797. */
  60798. export class ParticleHelper {
  60799. /**
  60800. * Gets or sets base Assets URL
  60801. */
  60802. static BaseAssetsUrl: string;
  60803. /**
  60804. * Create a default particle system that you can tweak
  60805. * @param emitter defines the emitter to use
  60806. * @param capacity defines the system capacity (default is 500 particles)
  60807. * @param scene defines the hosting scene
  60808. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60809. * @returns the new Particle system
  60810. */
  60811. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60812. /**
  60813. * This is the main static method (one-liner) of this helper to create different particle systems
  60814. * @param type This string represents the type to the particle system to create
  60815. * @param scene The scene where the particle system should live
  60816. * @param gpu If the system will use gpu
  60817. * @returns the ParticleSystemSet created
  60818. */
  60819. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60820. /**
  60821. * Static function used to export a particle system to a ParticleSystemSet variable.
  60822. * Please note that the emitter shape is not exported
  60823. * @param systems defines the particle systems to export
  60824. * @returns the created particle system set
  60825. */
  60826. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60827. }
  60828. }
  60829. declare module "babylonjs/Particles/particleSystemComponent" {
  60830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60831. import { Effect } from "babylonjs/Materials/effect";
  60832. import "babylonjs/Shaders/particles.vertex";
  60833. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60834. module "babylonjs/Engines/engine" {
  60835. interface Engine {
  60836. /**
  60837. * Create an effect to use with particle systems.
  60838. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60839. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60840. * @param uniformsNames defines a list of attribute names
  60841. * @param samplers defines an array of string used to represent textures
  60842. * @param defines defines the string containing the defines to use to compile the shaders
  60843. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60844. * @param onCompiled defines a function to call when the effect creation is successful
  60845. * @param onError defines a function to call when the effect creation has failed
  60846. * @returns the new Effect
  60847. */
  60848. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60849. }
  60850. }
  60851. module "babylonjs/Meshes/mesh" {
  60852. interface Mesh {
  60853. /**
  60854. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60855. * @returns an array of IParticleSystem
  60856. */
  60857. getEmittedParticleSystems(): IParticleSystem[];
  60858. /**
  60859. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60860. * @returns an array of IParticleSystem
  60861. */
  60862. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60863. }
  60864. }
  60865. /**
  60866. * @hidden
  60867. */
  60868. export var _IDoNeedToBeInTheBuild: number;
  60869. }
  60870. declare module "babylonjs/Particles/index" {
  60871. export * from "babylonjs/Particles/baseParticleSystem";
  60872. export * from "babylonjs/Particles/EmitterTypes/index";
  60873. export * from "babylonjs/Particles/gpuParticleSystem";
  60874. export * from "babylonjs/Particles/IParticleSystem";
  60875. export * from "babylonjs/Particles/particle";
  60876. export * from "babylonjs/Particles/particleHelper";
  60877. export * from "babylonjs/Particles/particleSystem";
  60878. export * from "babylonjs/Particles/particleSystemComponent";
  60879. export * from "babylonjs/Particles/particleSystemSet";
  60880. export * from "babylonjs/Particles/solidParticle";
  60881. export * from "babylonjs/Particles/solidParticleSystem";
  60882. export * from "babylonjs/Particles/subEmitter";
  60883. }
  60884. declare module "babylonjs/Physics/physicsEngineComponent" {
  60885. import { Nullable } from "babylonjs/types";
  60886. import { Observable, Observer } from "babylonjs/Misc/observable";
  60887. import { Vector3 } from "babylonjs/Maths/math.vector";
  60888. import { Mesh } from "babylonjs/Meshes/mesh";
  60889. import { ISceneComponent } from "babylonjs/sceneComponent";
  60890. import { Scene } from "babylonjs/scene";
  60891. import { Node } from "babylonjs/node";
  60892. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60893. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60894. module "babylonjs/scene" {
  60895. interface Scene {
  60896. /** @hidden (Backing field) */
  60897. _physicsEngine: Nullable<IPhysicsEngine>;
  60898. /**
  60899. * Gets the current physics engine
  60900. * @returns a IPhysicsEngine or null if none attached
  60901. */
  60902. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60903. /**
  60904. * Enables physics to the current scene
  60905. * @param gravity defines the scene's gravity for the physics engine
  60906. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60907. * @return a boolean indicating if the physics engine was initialized
  60908. */
  60909. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60910. /**
  60911. * Disables and disposes the physics engine associated with the scene
  60912. */
  60913. disablePhysicsEngine(): void;
  60914. /**
  60915. * Gets a boolean indicating if there is an active physics engine
  60916. * @returns a boolean indicating if there is an active physics engine
  60917. */
  60918. isPhysicsEnabled(): boolean;
  60919. /**
  60920. * Deletes a physics compound impostor
  60921. * @param compound defines the compound to delete
  60922. */
  60923. deleteCompoundImpostor(compound: any): void;
  60924. /**
  60925. * An event triggered when physic simulation is about to be run
  60926. */
  60927. onBeforePhysicsObservable: Observable<Scene>;
  60928. /**
  60929. * An event triggered when physic simulation has been done
  60930. */
  60931. onAfterPhysicsObservable: Observable<Scene>;
  60932. }
  60933. }
  60934. module "babylonjs/Meshes/abstractMesh" {
  60935. interface AbstractMesh {
  60936. /** @hidden */
  60937. _physicsImpostor: Nullable<PhysicsImpostor>;
  60938. /**
  60939. * Gets or sets impostor used for physic simulation
  60940. * @see http://doc.babylonjs.com/features/physics_engine
  60941. */
  60942. physicsImpostor: Nullable<PhysicsImpostor>;
  60943. /**
  60944. * Gets the current physics impostor
  60945. * @see http://doc.babylonjs.com/features/physics_engine
  60946. * @returns a physics impostor or null
  60947. */
  60948. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60949. /** Apply a physic impulse to the mesh
  60950. * @param force defines the force to apply
  60951. * @param contactPoint defines where to apply the force
  60952. * @returns the current mesh
  60953. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60954. */
  60955. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60956. /**
  60957. * Creates a physic joint between two meshes
  60958. * @param otherMesh defines the other mesh to use
  60959. * @param pivot1 defines the pivot to use on this mesh
  60960. * @param pivot2 defines the pivot to use on the other mesh
  60961. * @param options defines additional options (can be plugin dependent)
  60962. * @returns the current mesh
  60963. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60964. */
  60965. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60966. /** @hidden */
  60967. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60968. }
  60969. }
  60970. /**
  60971. * Defines the physics engine scene component responsible to manage a physics engine
  60972. */
  60973. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60974. /**
  60975. * The component name helpful to identify the component in the list of scene components.
  60976. */
  60977. readonly name: string;
  60978. /**
  60979. * The scene the component belongs to.
  60980. */
  60981. scene: Scene;
  60982. /**
  60983. * Creates a new instance of the component for the given scene
  60984. * @param scene Defines the scene to register the component in
  60985. */
  60986. constructor(scene: Scene);
  60987. /**
  60988. * Registers the component in a given scene
  60989. */
  60990. register(): void;
  60991. /**
  60992. * Rebuilds the elements related to this component in case of
  60993. * context lost for instance.
  60994. */
  60995. rebuild(): void;
  60996. /**
  60997. * Disposes the component and the associated ressources
  60998. */
  60999. dispose(): void;
  61000. }
  61001. }
  61002. declare module "babylonjs/Physics/physicsHelper" {
  61003. import { Nullable } from "babylonjs/types";
  61004. import { Vector3 } from "babylonjs/Maths/math.vector";
  61005. import { Mesh } from "babylonjs/Meshes/mesh";
  61006. import { Scene } from "babylonjs/scene";
  61007. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61008. /**
  61009. * A helper for physics simulations
  61010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61011. */
  61012. export class PhysicsHelper {
  61013. private _scene;
  61014. private _physicsEngine;
  61015. /**
  61016. * Initializes the Physics helper
  61017. * @param scene Babylon.js scene
  61018. */
  61019. constructor(scene: Scene);
  61020. /**
  61021. * Applies a radial explosion impulse
  61022. * @param origin the origin of the explosion
  61023. * @param radiusOrEventOptions the radius or the options of radial explosion
  61024. * @param strength the explosion strength
  61025. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61026. * @returns A physics radial explosion event, or null
  61027. */
  61028. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61029. /**
  61030. * Applies a radial explosion force
  61031. * @param origin the origin of the explosion
  61032. * @param radiusOrEventOptions the radius or the options of radial explosion
  61033. * @param strength the explosion strength
  61034. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61035. * @returns A physics radial explosion event, or null
  61036. */
  61037. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61038. /**
  61039. * Creates a gravitational field
  61040. * @param origin the origin of the explosion
  61041. * @param radiusOrEventOptions the radius or the options of radial explosion
  61042. * @param strength the explosion strength
  61043. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61044. * @returns A physics gravitational field event, or null
  61045. */
  61046. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61047. /**
  61048. * Creates a physics updraft event
  61049. * @param origin the origin of the updraft
  61050. * @param radiusOrEventOptions the radius or the options of the updraft
  61051. * @param strength the strength of the updraft
  61052. * @param height the height of the updraft
  61053. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61054. * @returns A physics updraft event, or null
  61055. */
  61056. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61057. /**
  61058. * Creates a physics vortex event
  61059. * @param origin the of the vortex
  61060. * @param radiusOrEventOptions the radius or the options of the vortex
  61061. * @param strength the strength of the vortex
  61062. * @param height the height of the vortex
  61063. * @returns a Physics vortex event, or null
  61064. * A physics vortex event or null
  61065. */
  61066. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61067. }
  61068. /**
  61069. * Represents a physics radial explosion event
  61070. */
  61071. class PhysicsRadialExplosionEvent {
  61072. private _scene;
  61073. private _options;
  61074. private _sphere;
  61075. private _dataFetched;
  61076. /**
  61077. * Initializes a radial explosioin event
  61078. * @param _scene BabylonJS scene
  61079. * @param _options The options for the vortex event
  61080. */
  61081. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61082. /**
  61083. * Returns the data related to the radial explosion event (sphere).
  61084. * @returns The radial explosion event data
  61085. */
  61086. getData(): PhysicsRadialExplosionEventData;
  61087. /**
  61088. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61089. * @param impostor A physics imposter
  61090. * @param origin the origin of the explosion
  61091. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61092. */
  61093. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61094. /**
  61095. * Triggers affecterd impostors callbacks
  61096. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61097. */
  61098. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61099. /**
  61100. * Disposes the sphere.
  61101. * @param force Specifies if the sphere should be disposed by force
  61102. */
  61103. dispose(force?: boolean): void;
  61104. /*** Helpers ***/
  61105. private _prepareSphere;
  61106. private _intersectsWithSphere;
  61107. }
  61108. /**
  61109. * Represents a gravitational field event
  61110. */
  61111. class PhysicsGravitationalFieldEvent {
  61112. private _physicsHelper;
  61113. private _scene;
  61114. private _origin;
  61115. private _options;
  61116. private _tickCallback;
  61117. private _sphere;
  61118. private _dataFetched;
  61119. /**
  61120. * Initializes the physics gravitational field event
  61121. * @param _physicsHelper A physics helper
  61122. * @param _scene BabylonJS scene
  61123. * @param _origin The origin position of the gravitational field event
  61124. * @param _options The options for the vortex event
  61125. */
  61126. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61127. /**
  61128. * Returns the data related to the gravitational field event (sphere).
  61129. * @returns A gravitational field event
  61130. */
  61131. getData(): PhysicsGravitationalFieldEventData;
  61132. /**
  61133. * Enables the gravitational field.
  61134. */
  61135. enable(): void;
  61136. /**
  61137. * Disables the gravitational field.
  61138. */
  61139. disable(): void;
  61140. /**
  61141. * Disposes the sphere.
  61142. * @param force The force to dispose from the gravitational field event
  61143. */
  61144. dispose(force?: boolean): void;
  61145. private _tick;
  61146. }
  61147. /**
  61148. * Represents a physics updraft event
  61149. */
  61150. class PhysicsUpdraftEvent {
  61151. private _scene;
  61152. private _origin;
  61153. private _options;
  61154. private _physicsEngine;
  61155. private _originTop;
  61156. private _originDirection;
  61157. private _tickCallback;
  61158. private _cylinder;
  61159. private _cylinderPosition;
  61160. private _dataFetched;
  61161. /**
  61162. * Initializes the physics updraft event
  61163. * @param _scene BabylonJS scene
  61164. * @param _origin The origin position of the updraft
  61165. * @param _options The options for the updraft event
  61166. */
  61167. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61168. /**
  61169. * Returns the data related to the updraft event (cylinder).
  61170. * @returns A physics updraft event
  61171. */
  61172. getData(): PhysicsUpdraftEventData;
  61173. /**
  61174. * Enables the updraft.
  61175. */
  61176. enable(): void;
  61177. /**
  61178. * Disables the updraft.
  61179. */
  61180. disable(): void;
  61181. /**
  61182. * Disposes the cylinder.
  61183. * @param force Specifies if the updraft should be disposed by force
  61184. */
  61185. dispose(force?: boolean): void;
  61186. private getImpostorHitData;
  61187. private _tick;
  61188. /*** Helpers ***/
  61189. private _prepareCylinder;
  61190. private _intersectsWithCylinder;
  61191. }
  61192. /**
  61193. * Represents a physics vortex event
  61194. */
  61195. class PhysicsVortexEvent {
  61196. private _scene;
  61197. private _origin;
  61198. private _options;
  61199. private _physicsEngine;
  61200. private _originTop;
  61201. private _tickCallback;
  61202. private _cylinder;
  61203. private _cylinderPosition;
  61204. private _dataFetched;
  61205. /**
  61206. * Initializes the physics vortex event
  61207. * @param _scene The BabylonJS scene
  61208. * @param _origin The origin position of the vortex
  61209. * @param _options The options for the vortex event
  61210. */
  61211. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61212. /**
  61213. * Returns the data related to the vortex event (cylinder).
  61214. * @returns The physics vortex event data
  61215. */
  61216. getData(): PhysicsVortexEventData;
  61217. /**
  61218. * Enables the vortex.
  61219. */
  61220. enable(): void;
  61221. /**
  61222. * Disables the cortex.
  61223. */
  61224. disable(): void;
  61225. /**
  61226. * Disposes the sphere.
  61227. * @param force
  61228. */
  61229. dispose(force?: boolean): void;
  61230. private getImpostorHitData;
  61231. private _tick;
  61232. /*** Helpers ***/
  61233. private _prepareCylinder;
  61234. private _intersectsWithCylinder;
  61235. }
  61236. /**
  61237. * Options fot the radial explosion event
  61238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61239. */
  61240. export class PhysicsRadialExplosionEventOptions {
  61241. /**
  61242. * The radius of the sphere for the radial explosion.
  61243. */
  61244. radius: number;
  61245. /**
  61246. * The strenth of the explosion.
  61247. */
  61248. strength: number;
  61249. /**
  61250. * The strenght of the force in correspondence to the distance of the affected object
  61251. */
  61252. falloff: PhysicsRadialImpulseFalloff;
  61253. /**
  61254. * Sphere options for the radial explosion.
  61255. */
  61256. sphere: {
  61257. segments: number;
  61258. diameter: number;
  61259. };
  61260. /**
  61261. * Sphere options for the radial explosion.
  61262. */
  61263. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61264. }
  61265. /**
  61266. * Options fot the updraft event
  61267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61268. */
  61269. export class PhysicsUpdraftEventOptions {
  61270. /**
  61271. * The radius of the cylinder for the vortex
  61272. */
  61273. radius: number;
  61274. /**
  61275. * The strenth of the updraft.
  61276. */
  61277. strength: number;
  61278. /**
  61279. * The height of the cylinder for the updraft.
  61280. */
  61281. height: number;
  61282. /**
  61283. * The mode for the the updraft.
  61284. */
  61285. updraftMode: PhysicsUpdraftMode;
  61286. }
  61287. /**
  61288. * Options fot the vortex event
  61289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61290. */
  61291. export class PhysicsVortexEventOptions {
  61292. /**
  61293. * The radius of the cylinder for the vortex
  61294. */
  61295. radius: number;
  61296. /**
  61297. * The strenth of the vortex.
  61298. */
  61299. strength: number;
  61300. /**
  61301. * The height of the cylinder for the vortex.
  61302. */
  61303. height: number;
  61304. /**
  61305. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61306. */
  61307. centripetalForceThreshold: number;
  61308. /**
  61309. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61310. */
  61311. centripetalForceMultiplier: number;
  61312. /**
  61313. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61314. */
  61315. centrifugalForceMultiplier: number;
  61316. /**
  61317. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61318. */
  61319. updraftForceMultiplier: number;
  61320. }
  61321. /**
  61322. * The strenght of the force in correspondence to the distance of the affected object
  61323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61324. */
  61325. export enum PhysicsRadialImpulseFalloff {
  61326. /** Defines that impulse is constant in strength across it's whole radius */
  61327. Constant = 0,
  61328. /** Defines that impulse gets weaker if it's further from the origin */
  61329. Linear = 1
  61330. }
  61331. /**
  61332. * The strength of the force in correspondence to the distance of the affected object
  61333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61334. */
  61335. export enum PhysicsUpdraftMode {
  61336. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61337. Center = 0,
  61338. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61339. Perpendicular = 1
  61340. }
  61341. /**
  61342. * Interface for a physics hit data
  61343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61344. */
  61345. export interface PhysicsHitData {
  61346. /**
  61347. * The force applied at the contact point
  61348. */
  61349. force: Vector3;
  61350. /**
  61351. * The contact point
  61352. */
  61353. contactPoint: Vector3;
  61354. /**
  61355. * The distance from the origin to the contact point
  61356. */
  61357. distanceFromOrigin: number;
  61358. }
  61359. /**
  61360. * Interface for radial explosion event data
  61361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61362. */
  61363. export interface PhysicsRadialExplosionEventData {
  61364. /**
  61365. * A sphere used for the radial explosion event
  61366. */
  61367. sphere: Mesh;
  61368. }
  61369. /**
  61370. * Interface for gravitational field event data
  61371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61372. */
  61373. export interface PhysicsGravitationalFieldEventData {
  61374. /**
  61375. * A sphere mesh used for the gravitational field event
  61376. */
  61377. sphere: Mesh;
  61378. }
  61379. /**
  61380. * Interface for updraft event data
  61381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61382. */
  61383. export interface PhysicsUpdraftEventData {
  61384. /**
  61385. * A cylinder used for the updraft event
  61386. */
  61387. cylinder: Mesh;
  61388. }
  61389. /**
  61390. * Interface for vortex event data
  61391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61392. */
  61393. export interface PhysicsVortexEventData {
  61394. /**
  61395. * A cylinder used for the vortex event
  61396. */
  61397. cylinder: Mesh;
  61398. }
  61399. /**
  61400. * Interface for an affected physics impostor
  61401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61402. */
  61403. export interface PhysicsAffectedImpostorWithData {
  61404. /**
  61405. * The impostor affected by the effect
  61406. */
  61407. impostor: PhysicsImpostor;
  61408. /**
  61409. * The data about the hit/horce from the explosion
  61410. */
  61411. hitData: PhysicsHitData;
  61412. }
  61413. }
  61414. declare module "babylonjs/Physics/Plugins/index" {
  61415. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61416. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61417. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61418. }
  61419. declare module "babylonjs/Physics/index" {
  61420. export * from "babylonjs/Physics/IPhysicsEngine";
  61421. export * from "babylonjs/Physics/physicsEngine";
  61422. export * from "babylonjs/Physics/physicsEngineComponent";
  61423. export * from "babylonjs/Physics/physicsHelper";
  61424. export * from "babylonjs/Physics/physicsImpostor";
  61425. export * from "babylonjs/Physics/physicsJoint";
  61426. export * from "babylonjs/Physics/Plugins/index";
  61427. }
  61428. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61429. /** @hidden */
  61430. export var blackAndWhitePixelShader: {
  61431. name: string;
  61432. shader: string;
  61433. };
  61434. }
  61435. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61436. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61437. import { Camera } from "babylonjs/Cameras/camera";
  61438. import { Engine } from "babylonjs/Engines/engine";
  61439. import "babylonjs/Shaders/blackAndWhite.fragment";
  61440. /**
  61441. * Post process used to render in black and white
  61442. */
  61443. export class BlackAndWhitePostProcess extends PostProcess {
  61444. /**
  61445. * Linear about to convert he result to black and white (default: 1)
  61446. */
  61447. degree: number;
  61448. /**
  61449. * Creates a black and white post process
  61450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61451. * @param name The name of the effect.
  61452. * @param options The required width/height ratio to downsize to before computing the render pass.
  61453. * @param camera The camera to apply the render pass to.
  61454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61455. * @param engine The engine which the post process will be applied. (default: current engine)
  61456. * @param reusable If the post process can be reused on the same frame. (default: false)
  61457. */
  61458. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61459. }
  61460. }
  61461. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61462. import { Nullable } from "babylonjs/types";
  61463. import { Camera } from "babylonjs/Cameras/camera";
  61464. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61465. import { Engine } from "babylonjs/Engines/engine";
  61466. /**
  61467. * This represents a set of one or more post processes in Babylon.
  61468. * A post process can be used to apply a shader to a texture after it is rendered.
  61469. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61470. */
  61471. export class PostProcessRenderEffect {
  61472. private _postProcesses;
  61473. private _getPostProcesses;
  61474. private _singleInstance;
  61475. private _cameras;
  61476. private _indicesForCamera;
  61477. /**
  61478. * Name of the effect
  61479. * @hidden
  61480. */
  61481. _name: string;
  61482. /**
  61483. * Instantiates a post process render effect.
  61484. * A post process can be used to apply a shader to a texture after it is rendered.
  61485. * @param engine The engine the effect is tied to
  61486. * @param name The name of the effect
  61487. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61488. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61489. */
  61490. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61491. /**
  61492. * Checks if all the post processes in the effect are supported.
  61493. */
  61494. readonly isSupported: boolean;
  61495. /**
  61496. * Updates the current state of the effect
  61497. * @hidden
  61498. */
  61499. _update(): void;
  61500. /**
  61501. * Attaches the effect on cameras
  61502. * @param cameras The camera to attach to.
  61503. * @hidden
  61504. */
  61505. _attachCameras(cameras: Camera): void;
  61506. /**
  61507. * Attaches the effect on cameras
  61508. * @param cameras The camera to attach to.
  61509. * @hidden
  61510. */
  61511. _attachCameras(cameras: Camera[]): void;
  61512. /**
  61513. * Detaches the effect on cameras
  61514. * @param cameras The camera to detatch from.
  61515. * @hidden
  61516. */
  61517. _detachCameras(cameras: Camera): void;
  61518. /**
  61519. * Detatches the effect on cameras
  61520. * @param cameras The camera to detatch from.
  61521. * @hidden
  61522. */
  61523. _detachCameras(cameras: Camera[]): void;
  61524. /**
  61525. * Enables the effect on given cameras
  61526. * @param cameras The camera to enable.
  61527. * @hidden
  61528. */
  61529. _enable(cameras: Camera): void;
  61530. /**
  61531. * Enables the effect on given cameras
  61532. * @param cameras The camera to enable.
  61533. * @hidden
  61534. */
  61535. _enable(cameras: Nullable<Camera[]>): void;
  61536. /**
  61537. * Disables the effect on the given cameras
  61538. * @param cameras The camera to disable.
  61539. * @hidden
  61540. */
  61541. _disable(cameras: Camera): void;
  61542. /**
  61543. * Disables the effect on the given cameras
  61544. * @param cameras The camera to disable.
  61545. * @hidden
  61546. */
  61547. _disable(cameras: Nullable<Camera[]>): void;
  61548. /**
  61549. * Gets a list of the post processes contained in the effect.
  61550. * @param camera The camera to get the post processes on.
  61551. * @returns The list of the post processes in the effect.
  61552. */
  61553. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61554. }
  61555. }
  61556. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61557. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61558. /** @hidden */
  61559. export var extractHighlightsPixelShader: {
  61560. name: string;
  61561. shader: string;
  61562. };
  61563. }
  61564. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61565. import { Nullable } from "babylonjs/types";
  61566. import { Camera } from "babylonjs/Cameras/camera";
  61567. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61568. import { Engine } from "babylonjs/Engines/engine";
  61569. import "babylonjs/Shaders/extractHighlights.fragment";
  61570. /**
  61571. * 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.
  61572. */
  61573. export class ExtractHighlightsPostProcess extends PostProcess {
  61574. /**
  61575. * The luminance threshold, pixels below this value will be set to black.
  61576. */
  61577. threshold: number;
  61578. /** @hidden */
  61579. _exposure: number;
  61580. /**
  61581. * Post process which has the input texture to be used when performing highlight extraction
  61582. * @hidden
  61583. */
  61584. _inputPostProcess: Nullable<PostProcess>;
  61585. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61586. }
  61587. }
  61588. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61589. /** @hidden */
  61590. export var bloomMergePixelShader: {
  61591. name: string;
  61592. shader: string;
  61593. };
  61594. }
  61595. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61596. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61597. import { Nullable } from "babylonjs/types";
  61598. import { Engine } from "babylonjs/Engines/engine";
  61599. import { Camera } from "babylonjs/Cameras/camera";
  61600. import "babylonjs/Shaders/bloomMerge.fragment";
  61601. /**
  61602. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61603. */
  61604. export class BloomMergePostProcess extends PostProcess {
  61605. /** Weight of the bloom to be added to the original input. */
  61606. weight: number;
  61607. /**
  61608. * Creates a new instance of @see BloomMergePostProcess
  61609. * @param name The name of the effect.
  61610. * @param originalFromInput Post process which's input will be used for the merge.
  61611. * @param blurred Blurred highlights post process which's output will be used.
  61612. * @param weight Weight of the bloom to be added to the original input.
  61613. * @param options The required width/height ratio to downsize to before computing the render pass.
  61614. * @param camera The camera to apply the render pass to.
  61615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61616. * @param engine The engine which the post process will be applied. (default: current engine)
  61617. * @param reusable If the post process can be reused on the same frame. (default: false)
  61618. * @param textureType Type of textures used when performing the post process. (default: 0)
  61619. * @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)
  61620. */
  61621. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61622. /** Weight of the bloom to be added to the original input. */
  61623. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61624. }
  61625. }
  61626. declare module "babylonjs/PostProcesses/bloomEffect" {
  61627. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61628. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61629. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61630. import { Camera } from "babylonjs/Cameras/camera";
  61631. import { Scene } from "babylonjs/scene";
  61632. /**
  61633. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61634. */
  61635. export class BloomEffect extends PostProcessRenderEffect {
  61636. private bloomScale;
  61637. /**
  61638. * @hidden Internal
  61639. */
  61640. _effects: Array<PostProcess>;
  61641. /**
  61642. * @hidden Internal
  61643. */
  61644. _downscale: ExtractHighlightsPostProcess;
  61645. private _blurX;
  61646. private _blurY;
  61647. private _merge;
  61648. /**
  61649. * The luminance threshold to find bright areas of the image to bloom.
  61650. */
  61651. threshold: number;
  61652. /**
  61653. * The strength of the bloom.
  61654. */
  61655. weight: number;
  61656. /**
  61657. * Specifies the size of the bloom blur kernel, relative to the final output size
  61658. */
  61659. kernel: number;
  61660. /**
  61661. * Creates a new instance of @see BloomEffect
  61662. * @param scene The scene the effect belongs to.
  61663. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61664. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61665. * @param bloomWeight The the strength of bloom.
  61666. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61667. * @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)
  61668. */
  61669. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61670. /**
  61671. * Disposes each of the internal effects for a given camera.
  61672. * @param camera The camera to dispose the effect on.
  61673. */
  61674. disposeEffects(camera: Camera): void;
  61675. /**
  61676. * @hidden Internal
  61677. */
  61678. _updateEffects(): void;
  61679. /**
  61680. * Internal
  61681. * @returns if all the contained post processes are ready.
  61682. * @hidden
  61683. */
  61684. _isReady(): boolean;
  61685. }
  61686. }
  61687. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61688. /** @hidden */
  61689. export var chromaticAberrationPixelShader: {
  61690. name: string;
  61691. shader: string;
  61692. };
  61693. }
  61694. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61695. import { Vector2 } from "babylonjs/Maths/math.vector";
  61696. import { Nullable } from "babylonjs/types";
  61697. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61698. import { Camera } from "babylonjs/Cameras/camera";
  61699. import { Engine } from "babylonjs/Engines/engine";
  61700. import "babylonjs/Shaders/chromaticAberration.fragment";
  61701. /**
  61702. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61703. */
  61704. export class ChromaticAberrationPostProcess extends PostProcess {
  61705. /**
  61706. * The amount of seperation of rgb channels (default: 30)
  61707. */
  61708. aberrationAmount: number;
  61709. /**
  61710. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61711. */
  61712. radialIntensity: number;
  61713. /**
  61714. * 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))
  61715. */
  61716. direction: Vector2;
  61717. /**
  61718. * 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))
  61719. */
  61720. centerPosition: Vector2;
  61721. /**
  61722. * Creates a new instance ChromaticAberrationPostProcess
  61723. * @param name The name of the effect.
  61724. * @param screenWidth The width of the screen to apply the effect on.
  61725. * @param screenHeight The height of the screen to apply the effect on.
  61726. * @param options The required width/height ratio to downsize to before computing the render pass.
  61727. * @param camera The camera to apply the render pass to.
  61728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61729. * @param engine The engine which the post process will be applied. (default: current engine)
  61730. * @param reusable If the post process can be reused on the same frame. (default: false)
  61731. * @param textureType Type of textures used when performing the post process. (default: 0)
  61732. * @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)
  61733. */
  61734. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61735. }
  61736. }
  61737. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61738. /** @hidden */
  61739. export var circleOfConfusionPixelShader: {
  61740. name: string;
  61741. shader: string;
  61742. };
  61743. }
  61744. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61745. import { Nullable } from "babylonjs/types";
  61746. import { Engine } from "babylonjs/Engines/engine";
  61747. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61748. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61749. import { Camera } from "babylonjs/Cameras/camera";
  61750. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61751. /**
  61752. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61753. */
  61754. export class CircleOfConfusionPostProcess extends PostProcess {
  61755. /**
  61756. * 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.
  61757. */
  61758. lensSize: number;
  61759. /**
  61760. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61761. */
  61762. fStop: number;
  61763. /**
  61764. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61765. */
  61766. focusDistance: number;
  61767. /**
  61768. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61769. */
  61770. focalLength: number;
  61771. private _depthTexture;
  61772. /**
  61773. * Creates a new instance CircleOfConfusionPostProcess
  61774. * @param name The name of the effect.
  61775. * @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.
  61776. * @param options The required width/height ratio to downsize to before computing the render pass.
  61777. * @param camera The camera to apply the render pass to.
  61778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61779. * @param engine The engine which the post process will be applied. (default: current engine)
  61780. * @param reusable If the post process can be reused on the same frame. (default: false)
  61781. * @param textureType Type of textures used when performing the post process. (default: 0)
  61782. * @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)
  61783. */
  61784. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61785. /**
  61786. * 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.
  61787. */
  61788. depthTexture: RenderTargetTexture;
  61789. }
  61790. }
  61791. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61792. /** @hidden */
  61793. export var colorCorrectionPixelShader: {
  61794. name: string;
  61795. shader: string;
  61796. };
  61797. }
  61798. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61799. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61800. import { Engine } from "babylonjs/Engines/engine";
  61801. import { Camera } from "babylonjs/Cameras/camera";
  61802. import "babylonjs/Shaders/colorCorrection.fragment";
  61803. /**
  61804. *
  61805. * This post-process allows the modification of rendered colors by using
  61806. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61807. *
  61808. * The object needs to be provided an url to a texture containing the color
  61809. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61810. * Use an image editing software to tweak the LUT to match your needs.
  61811. *
  61812. * For an example of a color LUT, see here:
  61813. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61814. * For explanations on color grading, see here:
  61815. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61816. *
  61817. */
  61818. export class ColorCorrectionPostProcess extends PostProcess {
  61819. private _colorTableTexture;
  61820. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61821. }
  61822. }
  61823. declare module "babylonjs/Shaders/convolution.fragment" {
  61824. /** @hidden */
  61825. export var convolutionPixelShader: {
  61826. name: string;
  61827. shader: string;
  61828. };
  61829. }
  61830. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61831. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61832. import { Nullable } from "babylonjs/types";
  61833. import { Camera } from "babylonjs/Cameras/camera";
  61834. import { Engine } from "babylonjs/Engines/engine";
  61835. import "babylonjs/Shaders/convolution.fragment";
  61836. /**
  61837. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61838. * input texture to perform effects such as edge detection or sharpening
  61839. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61840. */
  61841. export class ConvolutionPostProcess extends PostProcess {
  61842. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61843. kernel: number[];
  61844. /**
  61845. * Creates a new instance ConvolutionPostProcess
  61846. * @param name The name of the effect.
  61847. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61848. * @param options The required width/height ratio to downsize to before computing the render pass.
  61849. * @param camera The camera to apply the render pass to.
  61850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61851. * @param engine The engine which the post process will be applied. (default: current engine)
  61852. * @param reusable If the post process can be reused on the same frame. (default: false)
  61853. * @param textureType Type of textures used when performing the post process. (default: 0)
  61854. */
  61855. constructor(name: string,
  61856. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61857. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61858. /**
  61859. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61860. */
  61861. static EdgeDetect0Kernel: number[];
  61862. /**
  61863. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61864. */
  61865. static EdgeDetect1Kernel: number[];
  61866. /**
  61867. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61868. */
  61869. static EdgeDetect2Kernel: number[];
  61870. /**
  61871. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61872. */
  61873. static SharpenKernel: number[];
  61874. /**
  61875. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61876. */
  61877. static EmbossKernel: number[];
  61878. /**
  61879. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61880. */
  61881. static GaussianKernel: number[];
  61882. }
  61883. }
  61884. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61885. import { Nullable } from "babylonjs/types";
  61886. import { Vector2 } from "babylonjs/Maths/math.vector";
  61887. import { Camera } from "babylonjs/Cameras/camera";
  61888. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61889. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61890. import { Engine } from "babylonjs/Engines/engine";
  61891. import { Scene } from "babylonjs/scene";
  61892. /**
  61893. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61894. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61895. * based on samples that have a large difference in distance than the center pixel.
  61896. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61897. */
  61898. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61899. direction: Vector2;
  61900. /**
  61901. * Creates a new instance CircleOfConfusionPostProcess
  61902. * @param name The name of the effect.
  61903. * @param scene The scene the effect belongs to.
  61904. * @param direction The direction the blur should be applied.
  61905. * @param kernel The size of the kernel used to blur.
  61906. * @param options The required width/height ratio to downsize to before computing the render pass.
  61907. * @param camera The camera to apply the render pass to.
  61908. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61909. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61911. * @param engine The engine which the post process will be applied. (default: current engine)
  61912. * @param reusable If the post process can be reused on the same frame. (default: false)
  61913. * @param textureType Type of textures used when performing the post process. (default: 0)
  61914. * @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)
  61915. */
  61916. 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);
  61917. }
  61918. }
  61919. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61920. /** @hidden */
  61921. export var depthOfFieldMergePixelShader: {
  61922. name: string;
  61923. shader: string;
  61924. };
  61925. }
  61926. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61927. import { Nullable } from "babylonjs/types";
  61928. import { Camera } from "babylonjs/Cameras/camera";
  61929. import { Effect } from "babylonjs/Materials/effect";
  61930. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61931. import { Engine } from "babylonjs/Engines/engine";
  61932. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61933. /**
  61934. * Options to be set when merging outputs from the default pipeline.
  61935. */
  61936. export class DepthOfFieldMergePostProcessOptions {
  61937. /**
  61938. * The original image to merge on top of
  61939. */
  61940. originalFromInput: PostProcess;
  61941. /**
  61942. * Parameters to perform the merge of the depth of field effect
  61943. */
  61944. depthOfField?: {
  61945. circleOfConfusion: PostProcess;
  61946. blurSteps: Array<PostProcess>;
  61947. };
  61948. /**
  61949. * Parameters to perform the merge of bloom effect
  61950. */
  61951. bloom?: {
  61952. blurred: PostProcess;
  61953. weight: number;
  61954. };
  61955. }
  61956. /**
  61957. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61958. */
  61959. export class DepthOfFieldMergePostProcess extends PostProcess {
  61960. private blurSteps;
  61961. /**
  61962. * Creates a new instance of DepthOfFieldMergePostProcess
  61963. * @param name The name of the effect.
  61964. * @param originalFromInput Post process which's input will be used for the merge.
  61965. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61966. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61967. * @param options The required width/height ratio to downsize to before computing the render pass.
  61968. * @param camera The camera to apply the render pass to.
  61969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61970. * @param engine The engine which the post process will be applied. (default: current engine)
  61971. * @param reusable If the post process can be reused on the same frame. (default: false)
  61972. * @param textureType Type of textures used when performing the post process. (default: 0)
  61973. * @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)
  61974. */
  61975. 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);
  61976. /**
  61977. * Updates the effect with the current post process compile time values and recompiles the shader.
  61978. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61979. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61980. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61981. * @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
  61982. * @param onCompiled Called when the shader has been compiled.
  61983. * @param onError Called if there is an error when compiling a shader.
  61984. */
  61985. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61986. }
  61987. }
  61988. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61989. import { Nullable } from "babylonjs/types";
  61990. import { Camera } from "babylonjs/Cameras/camera";
  61991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61992. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61993. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61994. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61995. import { Scene } from "babylonjs/scene";
  61996. /**
  61997. * Specifies the level of max blur that should be applied when using the depth of field effect
  61998. */
  61999. export enum DepthOfFieldEffectBlurLevel {
  62000. /**
  62001. * Subtle blur
  62002. */
  62003. Low = 0,
  62004. /**
  62005. * Medium blur
  62006. */
  62007. Medium = 1,
  62008. /**
  62009. * Large blur
  62010. */
  62011. High = 2
  62012. }
  62013. /**
  62014. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62015. */
  62016. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62017. private _circleOfConfusion;
  62018. /**
  62019. * @hidden Internal, blurs from high to low
  62020. */
  62021. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62022. private _depthOfFieldBlurY;
  62023. private _dofMerge;
  62024. /**
  62025. * @hidden Internal post processes in depth of field effect
  62026. */
  62027. _effects: Array<PostProcess>;
  62028. /**
  62029. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62030. */
  62031. focalLength: number;
  62032. /**
  62033. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62034. */
  62035. fStop: number;
  62036. /**
  62037. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62038. */
  62039. focusDistance: number;
  62040. /**
  62041. * 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.
  62042. */
  62043. lensSize: number;
  62044. /**
  62045. * Creates a new instance DepthOfFieldEffect
  62046. * @param scene The scene the effect belongs to.
  62047. * @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.
  62048. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62049. * @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)
  62050. */
  62051. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62052. /**
  62053. * Get the current class name of the current effet
  62054. * @returns "DepthOfFieldEffect"
  62055. */
  62056. getClassName(): string;
  62057. /**
  62058. * 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.
  62059. */
  62060. depthTexture: RenderTargetTexture;
  62061. /**
  62062. * Disposes each of the internal effects for a given camera.
  62063. * @param camera The camera to dispose the effect on.
  62064. */
  62065. disposeEffects(camera: Camera): void;
  62066. /**
  62067. * @hidden Internal
  62068. */
  62069. _updateEffects(): void;
  62070. /**
  62071. * Internal
  62072. * @returns if all the contained post processes are ready.
  62073. * @hidden
  62074. */
  62075. _isReady(): boolean;
  62076. }
  62077. }
  62078. declare module "babylonjs/Shaders/displayPass.fragment" {
  62079. /** @hidden */
  62080. export var displayPassPixelShader: {
  62081. name: string;
  62082. shader: string;
  62083. };
  62084. }
  62085. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62086. import { Nullable } from "babylonjs/types";
  62087. import { Camera } from "babylonjs/Cameras/camera";
  62088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62089. import { Engine } from "babylonjs/Engines/engine";
  62090. import "babylonjs/Shaders/displayPass.fragment";
  62091. /**
  62092. * DisplayPassPostProcess which produces an output the same as it's input
  62093. */
  62094. export class DisplayPassPostProcess extends PostProcess {
  62095. /**
  62096. * Creates the DisplayPassPostProcess
  62097. * @param name The name of the effect.
  62098. * @param options The required width/height ratio to downsize to before computing the render pass.
  62099. * @param camera The camera to apply the render pass to.
  62100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62101. * @param engine The engine which the post process will be applied. (default: current engine)
  62102. * @param reusable If the post process can be reused on the same frame. (default: false)
  62103. */
  62104. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62105. }
  62106. }
  62107. declare module "babylonjs/Shaders/filter.fragment" {
  62108. /** @hidden */
  62109. export var filterPixelShader: {
  62110. name: string;
  62111. shader: string;
  62112. };
  62113. }
  62114. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62115. import { Nullable } from "babylonjs/types";
  62116. import { Matrix } from "babylonjs/Maths/math.vector";
  62117. import { Camera } from "babylonjs/Cameras/camera";
  62118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62119. import { Engine } from "babylonjs/Engines/engine";
  62120. import "babylonjs/Shaders/filter.fragment";
  62121. /**
  62122. * Applies a kernel filter to the image
  62123. */
  62124. export class FilterPostProcess extends PostProcess {
  62125. /** The matrix to be applied to the image */
  62126. kernelMatrix: Matrix;
  62127. /**
  62128. *
  62129. * @param name The name of the effect.
  62130. * @param kernelMatrix The matrix to be applied to the image
  62131. * @param options The required width/height ratio to downsize to before computing the render pass.
  62132. * @param camera The camera to apply the render pass to.
  62133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62134. * @param engine The engine which the post process will be applied. (default: current engine)
  62135. * @param reusable If the post process can be reused on the same frame. (default: false)
  62136. */
  62137. constructor(name: string,
  62138. /** The matrix to be applied to the image */
  62139. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62140. }
  62141. }
  62142. declare module "babylonjs/Shaders/fxaa.fragment" {
  62143. /** @hidden */
  62144. export var fxaaPixelShader: {
  62145. name: string;
  62146. shader: string;
  62147. };
  62148. }
  62149. declare module "babylonjs/Shaders/fxaa.vertex" {
  62150. /** @hidden */
  62151. export var fxaaVertexShader: {
  62152. name: string;
  62153. shader: string;
  62154. };
  62155. }
  62156. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62157. import { Nullable } from "babylonjs/types";
  62158. import { Camera } from "babylonjs/Cameras/camera";
  62159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62160. import { Engine } from "babylonjs/Engines/engine";
  62161. import "babylonjs/Shaders/fxaa.fragment";
  62162. import "babylonjs/Shaders/fxaa.vertex";
  62163. /**
  62164. * Fxaa post process
  62165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62166. */
  62167. export class FxaaPostProcess extends PostProcess {
  62168. /** @hidden */
  62169. texelWidth: number;
  62170. /** @hidden */
  62171. texelHeight: number;
  62172. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62173. private _getDefines;
  62174. }
  62175. }
  62176. declare module "babylonjs/Shaders/grain.fragment" {
  62177. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62178. /** @hidden */
  62179. export var grainPixelShader: {
  62180. name: string;
  62181. shader: string;
  62182. };
  62183. }
  62184. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62185. import { Nullable } from "babylonjs/types";
  62186. import { Camera } from "babylonjs/Cameras/camera";
  62187. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62188. import { Engine } from "babylonjs/Engines/engine";
  62189. import "babylonjs/Shaders/grain.fragment";
  62190. /**
  62191. * The GrainPostProcess adds noise to the image at mid luminance levels
  62192. */
  62193. export class GrainPostProcess extends PostProcess {
  62194. /**
  62195. * The intensity of the grain added (default: 30)
  62196. */
  62197. intensity: number;
  62198. /**
  62199. * If the grain should be randomized on every frame
  62200. */
  62201. animated: boolean;
  62202. /**
  62203. * Creates a new instance of @see GrainPostProcess
  62204. * @param name The name of the effect.
  62205. * @param options The required width/height ratio to downsize to before computing the render pass.
  62206. * @param camera The camera to apply the render pass to.
  62207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62208. * @param engine The engine which the post process will be applied. (default: current engine)
  62209. * @param reusable If the post process can be reused on the same frame. (default: false)
  62210. * @param textureType Type of textures used when performing the post process. (default: 0)
  62211. * @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)
  62212. */
  62213. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62214. }
  62215. }
  62216. declare module "babylonjs/Shaders/highlights.fragment" {
  62217. /** @hidden */
  62218. export var highlightsPixelShader: {
  62219. name: string;
  62220. shader: string;
  62221. };
  62222. }
  62223. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62224. import { Nullable } from "babylonjs/types";
  62225. import { Camera } from "babylonjs/Cameras/camera";
  62226. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62227. import { Engine } from "babylonjs/Engines/engine";
  62228. import "babylonjs/Shaders/highlights.fragment";
  62229. /**
  62230. * Extracts highlights from the image
  62231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62232. */
  62233. export class HighlightsPostProcess extends PostProcess {
  62234. /**
  62235. * Extracts highlights from the image
  62236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62237. * @param name The name of the effect.
  62238. * @param options The required width/height ratio to downsize to before computing the render pass.
  62239. * @param camera The camera to apply the render pass to.
  62240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62241. * @param engine The engine which the post process will be applied. (default: current engine)
  62242. * @param reusable If the post process can be reused on the same frame. (default: false)
  62243. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62244. */
  62245. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62246. }
  62247. }
  62248. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62249. /** @hidden */
  62250. export var mrtFragmentDeclaration: {
  62251. name: string;
  62252. shader: string;
  62253. };
  62254. }
  62255. declare module "babylonjs/Shaders/geometry.fragment" {
  62256. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62257. /** @hidden */
  62258. export var geometryPixelShader: {
  62259. name: string;
  62260. shader: string;
  62261. };
  62262. }
  62263. declare module "babylonjs/Shaders/geometry.vertex" {
  62264. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62266. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62267. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62268. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62269. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62270. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62271. /** @hidden */
  62272. export var geometryVertexShader: {
  62273. name: string;
  62274. shader: string;
  62275. };
  62276. }
  62277. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62278. import { Matrix } from "babylonjs/Maths/math.vector";
  62279. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62280. import { Mesh } from "babylonjs/Meshes/mesh";
  62281. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62282. import { Effect } from "babylonjs/Materials/effect";
  62283. import { Scene } from "babylonjs/scene";
  62284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62285. import "babylonjs/Shaders/geometry.fragment";
  62286. import "babylonjs/Shaders/geometry.vertex";
  62287. /** @hidden */
  62288. interface ISavedTransformationMatrix {
  62289. world: Matrix;
  62290. viewProjection: Matrix;
  62291. }
  62292. /**
  62293. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62294. */
  62295. export class GeometryBufferRenderer {
  62296. /**
  62297. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62298. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62299. */
  62300. static readonly POSITION_TEXTURE_TYPE: number;
  62301. /**
  62302. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62303. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62304. */
  62305. static readonly VELOCITY_TEXTURE_TYPE: number;
  62306. /**
  62307. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62308. * in order to compute objects velocities when enableVelocity is set to "true"
  62309. * @hidden
  62310. */
  62311. _previousTransformationMatrices: {
  62312. [index: number]: ISavedTransformationMatrix;
  62313. };
  62314. /**
  62315. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62316. * in order to compute objects velocities when enableVelocity is set to "true"
  62317. * @hidden
  62318. */
  62319. _previousBonesTransformationMatrices: {
  62320. [index: number]: Float32Array;
  62321. };
  62322. /**
  62323. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62324. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62325. */
  62326. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62327. private _scene;
  62328. private _multiRenderTarget;
  62329. private _ratio;
  62330. private _enablePosition;
  62331. private _enableVelocity;
  62332. private _positionIndex;
  62333. private _velocityIndex;
  62334. protected _effect: Effect;
  62335. protected _cachedDefines: string;
  62336. /**
  62337. * Set the render list (meshes to be rendered) used in the G buffer.
  62338. */
  62339. renderList: Mesh[];
  62340. /**
  62341. * Gets wether or not G buffer are supported by the running hardware.
  62342. * This requires draw buffer supports
  62343. */
  62344. readonly isSupported: boolean;
  62345. /**
  62346. * Returns the index of the given texture type in the G-Buffer textures array
  62347. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62348. * @returns the index of the given texture type in the G-Buffer textures array
  62349. */
  62350. getTextureIndex(textureType: number): number;
  62351. /**
  62352. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62353. */
  62354. /**
  62355. * Sets whether or not objects positions are enabled for the G buffer.
  62356. */
  62357. enablePosition: boolean;
  62358. /**
  62359. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62360. */
  62361. /**
  62362. * Sets wether or not objects velocities are enabled for the G buffer.
  62363. */
  62364. enableVelocity: boolean;
  62365. /**
  62366. * Gets the scene associated with the buffer.
  62367. */
  62368. readonly scene: Scene;
  62369. /**
  62370. * Gets the ratio used by the buffer during its creation.
  62371. * How big is the buffer related to the main canvas.
  62372. */
  62373. readonly ratio: number;
  62374. /** @hidden */
  62375. static _SceneComponentInitialization: (scene: Scene) => void;
  62376. /**
  62377. * Creates a new G Buffer for the scene
  62378. * @param scene The scene the buffer belongs to
  62379. * @param ratio How big is the buffer related to the main canvas.
  62380. */
  62381. constructor(scene: Scene, ratio?: number);
  62382. /**
  62383. * Checks wether everything is ready to render a submesh to the G buffer.
  62384. * @param subMesh the submesh to check readiness for
  62385. * @param useInstances is the mesh drawn using instance or not
  62386. * @returns true if ready otherwise false
  62387. */
  62388. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62389. /**
  62390. * Gets the current underlying G Buffer.
  62391. * @returns the buffer
  62392. */
  62393. getGBuffer(): MultiRenderTarget;
  62394. /**
  62395. * Gets the number of samples used to render the buffer (anti aliasing).
  62396. */
  62397. /**
  62398. * Sets the number of samples used to render the buffer (anti aliasing).
  62399. */
  62400. samples: number;
  62401. /**
  62402. * Disposes the renderer and frees up associated resources.
  62403. */
  62404. dispose(): void;
  62405. protected _createRenderTargets(): void;
  62406. private _copyBonesTransformationMatrices;
  62407. }
  62408. }
  62409. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62410. import { Nullable } from "babylonjs/types";
  62411. import { Scene } from "babylonjs/scene";
  62412. import { ISceneComponent } from "babylonjs/sceneComponent";
  62413. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62414. module "babylonjs/scene" {
  62415. interface Scene {
  62416. /** @hidden (Backing field) */
  62417. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62418. /**
  62419. * Gets or Sets the current geometry buffer associated to the scene.
  62420. */
  62421. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62422. /**
  62423. * Enables a GeometryBufferRender and associates it with the scene
  62424. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62425. * @returns the GeometryBufferRenderer
  62426. */
  62427. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62428. /**
  62429. * Disables the GeometryBufferRender associated with the scene
  62430. */
  62431. disableGeometryBufferRenderer(): void;
  62432. }
  62433. }
  62434. /**
  62435. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62436. * in several rendering techniques.
  62437. */
  62438. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62439. /**
  62440. * The component name helpful to identify the component in the list of scene components.
  62441. */
  62442. readonly name: string;
  62443. /**
  62444. * The scene the component belongs to.
  62445. */
  62446. scene: Scene;
  62447. /**
  62448. * Creates a new instance of the component for the given scene
  62449. * @param scene Defines the scene to register the component in
  62450. */
  62451. constructor(scene: Scene);
  62452. /**
  62453. * Registers the component in a given scene
  62454. */
  62455. register(): void;
  62456. /**
  62457. * Rebuilds the elements related to this component in case of
  62458. * context lost for instance.
  62459. */
  62460. rebuild(): void;
  62461. /**
  62462. * Disposes the component and the associated ressources
  62463. */
  62464. dispose(): void;
  62465. private _gatherRenderTargets;
  62466. }
  62467. }
  62468. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62469. /** @hidden */
  62470. export var motionBlurPixelShader: {
  62471. name: string;
  62472. shader: string;
  62473. };
  62474. }
  62475. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62476. import { Nullable } from "babylonjs/types";
  62477. import { Camera } from "babylonjs/Cameras/camera";
  62478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62479. import { Scene } from "babylonjs/scene";
  62480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62481. import "babylonjs/Animations/animatable";
  62482. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62483. import "babylonjs/Shaders/motionBlur.fragment";
  62484. import { Engine } from "babylonjs/Engines/engine";
  62485. /**
  62486. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62487. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62488. * As an example, all you have to do is to create the post-process:
  62489. * var mb = new BABYLON.MotionBlurPostProcess(
  62490. * 'mb', // The name of the effect.
  62491. * scene, // The scene containing the objects to blur according to their velocity.
  62492. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62493. * camera // The camera to apply the render pass to.
  62494. * );
  62495. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62496. */
  62497. export class MotionBlurPostProcess extends PostProcess {
  62498. /**
  62499. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62500. */
  62501. motionStrength: number;
  62502. /**
  62503. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62504. */
  62505. /**
  62506. * Sets the number of iterations to be used for motion blur quality
  62507. */
  62508. motionBlurSamples: number;
  62509. private _motionBlurSamples;
  62510. private _geometryBufferRenderer;
  62511. /**
  62512. * Creates a new instance MotionBlurPostProcess
  62513. * @param name The name of the effect.
  62514. * @param scene The scene containing the objects to blur according to their velocity.
  62515. * @param options The required width/height ratio to downsize to before computing the render pass.
  62516. * @param camera The camera to apply the render pass to.
  62517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62518. * @param engine The engine which the post process will be applied. (default: current engine)
  62519. * @param reusable If the post process can be reused on the same frame. (default: false)
  62520. * @param textureType Type of textures used when performing the post process. (default: 0)
  62521. * @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)
  62522. */
  62523. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62524. /**
  62525. * Excludes the given skinned mesh from computing bones velocities.
  62526. * 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.
  62527. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62528. */
  62529. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62530. /**
  62531. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62532. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62533. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62534. */
  62535. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62536. /**
  62537. * Disposes the post process.
  62538. * @param camera The camera to dispose the post process on.
  62539. */
  62540. dispose(camera?: Camera): void;
  62541. }
  62542. }
  62543. declare module "babylonjs/Shaders/refraction.fragment" {
  62544. /** @hidden */
  62545. export var refractionPixelShader: {
  62546. name: string;
  62547. shader: string;
  62548. };
  62549. }
  62550. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62551. import { Color3 } from "babylonjs/Maths/math.color";
  62552. import { Camera } from "babylonjs/Cameras/camera";
  62553. import { Texture } from "babylonjs/Materials/Textures/texture";
  62554. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62555. import { Engine } from "babylonjs/Engines/engine";
  62556. import "babylonjs/Shaders/refraction.fragment";
  62557. /**
  62558. * Post process which applies a refractin texture
  62559. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62560. */
  62561. export class RefractionPostProcess extends PostProcess {
  62562. /** the base color of the refraction (used to taint the rendering) */
  62563. color: Color3;
  62564. /** simulated refraction depth */
  62565. depth: number;
  62566. /** the coefficient of the base color (0 to remove base color tainting) */
  62567. colorLevel: number;
  62568. private _refTexture;
  62569. private _ownRefractionTexture;
  62570. /**
  62571. * Gets or sets the refraction texture
  62572. * Please note that you are responsible for disposing the texture if you set it manually
  62573. */
  62574. refractionTexture: Texture;
  62575. /**
  62576. * Initializes the RefractionPostProcess
  62577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62578. * @param name The name of the effect.
  62579. * @param refractionTextureUrl Url of the refraction texture to use
  62580. * @param color the base color of the refraction (used to taint the rendering)
  62581. * @param depth simulated refraction depth
  62582. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62583. * @param camera The camera to apply the render pass to.
  62584. * @param options The required width/height ratio to downsize to before computing the render pass.
  62585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62586. * @param engine The engine which the post process will be applied. (default: current engine)
  62587. * @param reusable If the post process can be reused on the same frame. (default: false)
  62588. */
  62589. constructor(name: string, refractionTextureUrl: string,
  62590. /** the base color of the refraction (used to taint the rendering) */
  62591. color: Color3,
  62592. /** simulated refraction depth */
  62593. depth: number,
  62594. /** the coefficient of the base color (0 to remove base color tainting) */
  62595. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62596. /**
  62597. * Disposes of the post process
  62598. * @param camera Camera to dispose post process on
  62599. */
  62600. dispose(camera: Camera): void;
  62601. }
  62602. }
  62603. declare module "babylonjs/Shaders/sharpen.fragment" {
  62604. /** @hidden */
  62605. export var sharpenPixelShader: {
  62606. name: string;
  62607. shader: string;
  62608. };
  62609. }
  62610. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62611. import { Nullable } from "babylonjs/types";
  62612. import { Camera } from "babylonjs/Cameras/camera";
  62613. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62614. import "babylonjs/Shaders/sharpen.fragment";
  62615. import { Engine } from "babylonjs/Engines/engine";
  62616. /**
  62617. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62618. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62619. */
  62620. export class SharpenPostProcess extends PostProcess {
  62621. /**
  62622. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62623. */
  62624. colorAmount: number;
  62625. /**
  62626. * How much sharpness should be applied (default: 0.3)
  62627. */
  62628. edgeAmount: number;
  62629. /**
  62630. * Creates a new instance ConvolutionPostProcess
  62631. * @param name The name of the effect.
  62632. * @param options The required width/height ratio to downsize to before computing the render pass.
  62633. * @param camera The camera to apply the render pass to.
  62634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62635. * @param engine The engine which the post process will be applied. (default: current engine)
  62636. * @param reusable If the post process can be reused on the same frame. (default: false)
  62637. * @param textureType Type of textures used when performing the post process. (default: 0)
  62638. * @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)
  62639. */
  62640. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62641. }
  62642. }
  62643. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62644. import { Nullable } from "babylonjs/types";
  62645. import { Camera } from "babylonjs/Cameras/camera";
  62646. import { Engine } from "babylonjs/Engines/engine";
  62647. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62648. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62649. /**
  62650. * PostProcessRenderPipeline
  62651. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62652. */
  62653. export class PostProcessRenderPipeline {
  62654. private engine;
  62655. private _renderEffects;
  62656. private _renderEffectsForIsolatedPass;
  62657. /**
  62658. * List of inspectable custom properties (used by the Inspector)
  62659. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62660. */
  62661. inspectableCustomProperties: IInspectable[];
  62662. /**
  62663. * @hidden
  62664. */
  62665. protected _cameras: Camera[];
  62666. /** @hidden */
  62667. _name: string;
  62668. /**
  62669. * Gets pipeline name
  62670. */
  62671. readonly name: string;
  62672. /**
  62673. * Initializes a PostProcessRenderPipeline
  62674. * @param engine engine to add the pipeline to
  62675. * @param name name of the pipeline
  62676. */
  62677. constructor(engine: Engine, name: string);
  62678. /**
  62679. * Gets the class name
  62680. * @returns "PostProcessRenderPipeline"
  62681. */
  62682. getClassName(): string;
  62683. /**
  62684. * If all the render effects in the pipeline are supported
  62685. */
  62686. readonly isSupported: boolean;
  62687. /**
  62688. * Adds an effect to the pipeline
  62689. * @param renderEffect the effect to add
  62690. */
  62691. addEffect(renderEffect: PostProcessRenderEffect): void;
  62692. /** @hidden */
  62693. _rebuild(): void;
  62694. /** @hidden */
  62695. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62696. /** @hidden */
  62697. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62698. /** @hidden */
  62699. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62700. /** @hidden */
  62701. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62702. /** @hidden */
  62703. _attachCameras(cameras: Camera, unique: boolean): void;
  62704. /** @hidden */
  62705. _attachCameras(cameras: Camera[], unique: boolean): void;
  62706. /** @hidden */
  62707. _detachCameras(cameras: Camera): void;
  62708. /** @hidden */
  62709. _detachCameras(cameras: Nullable<Camera[]>): void;
  62710. /** @hidden */
  62711. _update(): void;
  62712. /** @hidden */
  62713. _reset(): void;
  62714. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62715. /**
  62716. * Disposes of the pipeline
  62717. */
  62718. dispose(): void;
  62719. }
  62720. }
  62721. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62722. import { Camera } from "babylonjs/Cameras/camera";
  62723. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62724. /**
  62725. * PostProcessRenderPipelineManager class
  62726. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62727. */
  62728. export class PostProcessRenderPipelineManager {
  62729. private _renderPipelines;
  62730. /**
  62731. * Initializes a PostProcessRenderPipelineManager
  62732. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62733. */
  62734. constructor();
  62735. /**
  62736. * Gets the list of supported render pipelines
  62737. */
  62738. readonly supportedPipelines: PostProcessRenderPipeline[];
  62739. /**
  62740. * Adds a pipeline to the manager
  62741. * @param renderPipeline The pipeline to add
  62742. */
  62743. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62744. /**
  62745. * Attaches a camera to the pipeline
  62746. * @param renderPipelineName The name of the pipeline to attach to
  62747. * @param cameras the camera to attach
  62748. * @param unique if the camera can be attached multiple times to the pipeline
  62749. */
  62750. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62751. /**
  62752. * Detaches a camera from the pipeline
  62753. * @param renderPipelineName The name of the pipeline to detach from
  62754. * @param cameras the camera to detach
  62755. */
  62756. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62757. /**
  62758. * Enables an effect by name on a pipeline
  62759. * @param renderPipelineName the name of the pipeline to enable the effect in
  62760. * @param renderEffectName the name of the effect to enable
  62761. * @param cameras the cameras that the effect should be enabled on
  62762. */
  62763. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62764. /**
  62765. * Disables an effect by name on a pipeline
  62766. * @param renderPipelineName the name of the pipeline to disable the effect in
  62767. * @param renderEffectName the name of the effect to disable
  62768. * @param cameras the cameras that the effect should be disabled on
  62769. */
  62770. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62771. /**
  62772. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62773. */
  62774. update(): void;
  62775. /** @hidden */
  62776. _rebuild(): void;
  62777. /**
  62778. * Disposes of the manager and pipelines
  62779. */
  62780. dispose(): void;
  62781. }
  62782. }
  62783. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62784. import { ISceneComponent } from "babylonjs/sceneComponent";
  62785. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62786. import { Scene } from "babylonjs/scene";
  62787. module "babylonjs/scene" {
  62788. interface Scene {
  62789. /** @hidden (Backing field) */
  62790. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62791. /**
  62792. * Gets the postprocess render pipeline manager
  62793. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62794. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62795. */
  62796. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62797. }
  62798. }
  62799. /**
  62800. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62801. */
  62802. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62803. /**
  62804. * The component name helpfull to identify the component in the list of scene components.
  62805. */
  62806. readonly name: string;
  62807. /**
  62808. * The scene the component belongs to.
  62809. */
  62810. scene: Scene;
  62811. /**
  62812. * Creates a new instance of the component for the given scene
  62813. * @param scene Defines the scene to register the component in
  62814. */
  62815. constructor(scene: Scene);
  62816. /**
  62817. * Registers the component in a given scene
  62818. */
  62819. register(): void;
  62820. /**
  62821. * Rebuilds the elements related to this component in case of
  62822. * context lost for instance.
  62823. */
  62824. rebuild(): void;
  62825. /**
  62826. * Disposes the component and the associated ressources
  62827. */
  62828. dispose(): void;
  62829. private _gatherRenderTargets;
  62830. }
  62831. }
  62832. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62833. import { Nullable } from "babylonjs/types";
  62834. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62835. import { Camera } from "babylonjs/Cameras/camera";
  62836. import { IDisposable } from "babylonjs/scene";
  62837. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62838. import { Scene } from "babylonjs/scene";
  62839. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62840. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62841. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62842. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62843. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62844. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62845. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62846. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62847. import { Animation } from "babylonjs/Animations/animation";
  62848. /**
  62849. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62850. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62851. */
  62852. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62853. private _scene;
  62854. private _camerasToBeAttached;
  62855. /**
  62856. * ID of the sharpen post process,
  62857. */
  62858. private readonly SharpenPostProcessId;
  62859. /**
  62860. * @ignore
  62861. * ID of the image processing post process;
  62862. */
  62863. readonly ImageProcessingPostProcessId: string;
  62864. /**
  62865. * @ignore
  62866. * ID of the Fast Approximate Anti-Aliasing post process;
  62867. */
  62868. readonly FxaaPostProcessId: string;
  62869. /**
  62870. * ID of the chromatic aberration post process,
  62871. */
  62872. private readonly ChromaticAberrationPostProcessId;
  62873. /**
  62874. * ID of the grain post process
  62875. */
  62876. private readonly GrainPostProcessId;
  62877. /**
  62878. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62879. */
  62880. sharpen: SharpenPostProcess;
  62881. private _sharpenEffect;
  62882. private bloom;
  62883. /**
  62884. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62885. */
  62886. depthOfField: DepthOfFieldEffect;
  62887. /**
  62888. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62889. */
  62890. fxaa: FxaaPostProcess;
  62891. /**
  62892. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62893. */
  62894. imageProcessing: ImageProcessingPostProcess;
  62895. /**
  62896. * Chromatic aberration post process which will shift rgb colors in the image
  62897. */
  62898. chromaticAberration: ChromaticAberrationPostProcess;
  62899. private _chromaticAberrationEffect;
  62900. /**
  62901. * Grain post process which add noise to the image
  62902. */
  62903. grain: GrainPostProcess;
  62904. private _grainEffect;
  62905. /**
  62906. * Glow post process which adds a glow to emissive areas of the image
  62907. */
  62908. private _glowLayer;
  62909. /**
  62910. * Animations which can be used to tweak settings over a period of time
  62911. */
  62912. animations: Animation[];
  62913. private _imageProcessingConfigurationObserver;
  62914. private _sharpenEnabled;
  62915. private _bloomEnabled;
  62916. private _depthOfFieldEnabled;
  62917. private _depthOfFieldBlurLevel;
  62918. private _fxaaEnabled;
  62919. private _imageProcessingEnabled;
  62920. private _defaultPipelineTextureType;
  62921. private _bloomScale;
  62922. private _chromaticAberrationEnabled;
  62923. private _grainEnabled;
  62924. private _buildAllowed;
  62925. /**
  62926. * Gets active scene
  62927. */
  62928. readonly scene: Scene;
  62929. /**
  62930. * Enable or disable the sharpen process from the pipeline
  62931. */
  62932. sharpenEnabled: boolean;
  62933. private _resizeObserver;
  62934. private _hardwareScaleLevel;
  62935. private _bloomKernel;
  62936. /**
  62937. * Specifies the size of the bloom blur kernel, relative to the final output size
  62938. */
  62939. bloomKernel: number;
  62940. /**
  62941. * Specifies the weight of the bloom in the final rendering
  62942. */
  62943. private _bloomWeight;
  62944. /**
  62945. * Specifies the luma threshold for the area that will be blurred by the bloom
  62946. */
  62947. private _bloomThreshold;
  62948. private _hdr;
  62949. /**
  62950. * The strength of the bloom.
  62951. */
  62952. bloomWeight: number;
  62953. /**
  62954. * The strength of the bloom.
  62955. */
  62956. bloomThreshold: number;
  62957. /**
  62958. * The scale of the bloom, lower value will provide better performance.
  62959. */
  62960. bloomScale: number;
  62961. /**
  62962. * Enable or disable the bloom from the pipeline
  62963. */
  62964. bloomEnabled: boolean;
  62965. private _rebuildBloom;
  62966. /**
  62967. * If the depth of field is enabled.
  62968. */
  62969. depthOfFieldEnabled: boolean;
  62970. /**
  62971. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62972. */
  62973. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62974. /**
  62975. * If the anti aliasing is enabled.
  62976. */
  62977. fxaaEnabled: boolean;
  62978. private _samples;
  62979. /**
  62980. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62981. */
  62982. samples: number;
  62983. /**
  62984. * If image processing is enabled.
  62985. */
  62986. imageProcessingEnabled: boolean;
  62987. /**
  62988. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62989. */
  62990. glowLayerEnabled: boolean;
  62991. /**
  62992. * Gets the glow layer (or null if not defined)
  62993. */
  62994. readonly glowLayer: Nullable<GlowLayer>;
  62995. /**
  62996. * Enable or disable the chromaticAberration process from the pipeline
  62997. */
  62998. chromaticAberrationEnabled: boolean;
  62999. /**
  63000. * Enable or disable the grain process from the pipeline
  63001. */
  63002. grainEnabled: boolean;
  63003. /**
  63004. * @constructor
  63005. * @param name - The rendering pipeline name (default: "")
  63006. * @param hdr - If high dynamic range textures should be used (default: true)
  63007. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63008. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63009. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63010. */
  63011. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63012. /**
  63013. * Get the class name
  63014. * @returns "DefaultRenderingPipeline"
  63015. */
  63016. getClassName(): string;
  63017. /**
  63018. * Force the compilation of the entire pipeline.
  63019. */
  63020. prepare(): void;
  63021. private _hasCleared;
  63022. private _prevPostProcess;
  63023. private _prevPrevPostProcess;
  63024. private _setAutoClearAndTextureSharing;
  63025. private _depthOfFieldSceneObserver;
  63026. private _buildPipeline;
  63027. private _disposePostProcesses;
  63028. /**
  63029. * Adds a camera to the pipeline
  63030. * @param camera the camera to be added
  63031. */
  63032. addCamera(camera: Camera): void;
  63033. /**
  63034. * Removes a camera from the pipeline
  63035. * @param camera the camera to remove
  63036. */
  63037. removeCamera(camera: Camera): void;
  63038. /**
  63039. * Dispose of the pipeline and stop all post processes
  63040. */
  63041. dispose(): void;
  63042. /**
  63043. * Serialize the rendering pipeline (Used when exporting)
  63044. * @returns the serialized object
  63045. */
  63046. serialize(): any;
  63047. /**
  63048. * Parse the serialized pipeline
  63049. * @param source Source pipeline.
  63050. * @param scene The scene to load the pipeline to.
  63051. * @param rootUrl The URL of the serialized pipeline.
  63052. * @returns An instantiated pipeline from the serialized object.
  63053. */
  63054. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63055. }
  63056. }
  63057. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63058. /** @hidden */
  63059. export var lensHighlightsPixelShader: {
  63060. name: string;
  63061. shader: string;
  63062. };
  63063. }
  63064. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63065. /** @hidden */
  63066. export var depthOfFieldPixelShader: {
  63067. name: string;
  63068. shader: string;
  63069. };
  63070. }
  63071. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63072. import { Camera } from "babylonjs/Cameras/camera";
  63073. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63074. import { Scene } from "babylonjs/scene";
  63075. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63076. import "babylonjs/Shaders/chromaticAberration.fragment";
  63077. import "babylonjs/Shaders/lensHighlights.fragment";
  63078. import "babylonjs/Shaders/depthOfField.fragment";
  63079. /**
  63080. * BABYLON.JS Chromatic Aberration GLSL Shader
  63081. * Author: Olivier Guyot
  63082. * Separates very slightly R, G and B colors on the edges of the screen
  63083. * Inspired by Francois Tarlier & Martins Upitis
  63084. */
  63085. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63086. /**
  63087. * @ignore
  63088. * The chromatic aberration PostProcess id in the pipeline
  63089. */
  63090. LensChromaticAberrationEffect: string;
  63091. /**
  63092. * @ignore
  63093. * The highlights enhancing PostProcess id in the pipeline
  63094. */
  63095. HighlightsEnhancingEffect: string;
  63096. /**
  63097. * @ignore
  63098. * The depth-of-field PostProcess id in the pipeline
  63099. */
  63100. LensDepthOfFieldEffect: string;
  63101. private _scene;
  63102. private _depthTexture;
  63103. private _grainTexture;
  63104. private _chromaticAberrationPostProcess;
  63105. private _highlightsPostProcess;
  63106. private _depthOfFieldPostProcess;
  63107. private _edgeBlur;
  63108. private _grainAmount;
  63109. private _chromaticAberration;
  63110. private _distortion;
  63111. private _highlightsGain;
  63112. private _highlightsThreshold;
  63113. private _dofDistance;
  63114. private _dofAperture;
  63115. private _dofDarken;
  63116. private _dofPentagon;
  63117. private _blurNoise;
  63118. /**
  63119. * @constructor
  63120. *
  63121. * Effect parameters are as follow:
  63122. * {
  63123. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63124. * edge_blur: number; // from 0 to x (1 for realism)
  63125. * distortion: number; // from 0 to x (1 for realism)
  63126. * grain_amount: number; // from 0 to 1
  63127. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63128. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63129. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63130. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63131. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63132. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63133. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63134. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63135. * }
  63136. * Note: if an effect parameter is unset, effect is disabled
  63137. *
  63138. * @param name The rendering pipeline name
  63139. * @param parameters - An object containing all parameters (see above)
  63140. * @param scene The scene linked to this pipeline
  63141. * @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)
  63142. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63143. */
  63144. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63145. /**
  63146. * Get the class name
  63147. * @returns "LensRenderingPipeline"
  63148. */
  63149. getClassName(): string;
  63150. /**
  63151. * Gets associated scene
  63152. */
  63153. readonly scene: Scene;
  63154. /**
  63155. * Gets or sets the edge blur
  63156. */
  63157. edgeBlur: number;
  63158. /**
  63159. * Gets or sets the grain amount
  63160. */
  63161. grainAmount: number;
  63162. /**
  63163. * Gets or sets the chromatic aberration amount
  63164. */
  63165. chromaticAberration: number;
  63166. /**
  63167. * Gets or sets the depth of field aperture
  63168. */
  63169. dofAperture: number;
  63170. /**
  63171. * Gets or sets the edge distortion
  63172. */
  63173. edgeDistortion: number;
  63174. /**
  63175. * Gets or sets the depth of field distortion
  63176. */
  63177. dofDistortion: number;
  63178. /**
  63179. * Gets or sets the darken out of focus amount
  63180. */
  63181. darkenOutOfFocus: number;
  63182. /**
  63183. * Gets or sets a boolean indicating if blur noise is enabled
  63184. */
  63185. blurNoise: boolean;
  63186. /**
  63187. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63188. */
  63189. pentagonBokeh: boolean;
  63190. /**
  63191. * Gets or sets the highlight grain amount
  63192. */
  63193. highlightsGain: number;
  63194. /**
  63195. * Gets or sets the highlight threshold
  63196. */
  63197. highlightsThreshold: number;
  63198. /**
  63199. * Sets the amount of blur at the edges
  63200. * @param amount blur amount
  63201. */
  63202. setEdgeBlur(amount: number): void;
  63203. /**
  63204. * Sets edge blur to 0
  63205. */
  63206. disableEdgeBlur(): void;
  63207. /**
  63208. * Sets the amout of grain
  63209. * @param amount Amount of grain
  63210. */
  63211. setGrainAmount(amount: number): void;
  63212. /**
  63213. * Set grain amount to 0
  63214. */
  63215. disableGrain(): void;
  63216. /**
  63217. * Sets the chromatic aberration amount
  63218. * @param amount amount of chromatic aberration
  63219. */
  63220. setChromaticAberration(amount: number): void;
  63221. /**
  63222. * Sets chromatic aberration amount to 0
  63223. */
  63224. disableChromaticAberration(): void;
  63225. /**
  63226. * Sets the EdgeDistortion amount
  63227. * @param amount amount of EdgeDistortion
  63228. */
  63229. setEdgeDistortion(amount: number): void;
  63230. /**
  63231. * Sets edge distortion to 0
  63232. */
  63233. disableEdgeDistortion(): void;
  63234. /**
  63235. * Sets the FocusDistance amount
  63236. * @param amount amount of FocusDistance
  63237. */
  63238. setFocusDistance(amount: number): void;
  63239. /**
  63240. * Disables depth of field
  63241. */
  63242. disableDepthOfField(): void;
  63243. /**
  63244. * Sets the Aperture amount
  63245. * @param amount amount of Aperture
  63246. */
  63247. setAperture(amount: number): void;
  63248. /**
  63249. * Sets the DarkenOutOfFocus amount
  63250. * @param amount amount of DarkenOutOfFocus
  63251. */
  63252. setDarkenOutOfFocus(amount: number): void;
  63253. private _pentagonBokehIsEnabled;
  63254. /**
  63255. * Creates a pentagon bokeh effect
  63256. */
  63257. enablePentagonBokeh(): void;
  63258. /**
  63259. * Disables the pentagon bokeh effect
  63260. */
  63261. disablePentagonBokeh(): void;
  63262. /**
  63263. * Enables noise blur
  63264. */
  63265. enableNoiseBlur(): void;
  63266. /**
  63267. * Disables noise blur
  63268. */
  63269. disableNoiseBlur(): void;
  63270. /**
  63271. * Sets the HighlightsGain amount
  63272. * @param amount amount of HighlightsGain
  63273. */
  63274. setHighlightsGain(amount: number): void;
  63275. /**
  63276. * Sets the HighlightsThreshold amount
  63277. * @param amount amount of HighlightsThreshold
  63278. */
  63279. setHighlightsThreshold(amount: number): void;
  63280. /**
  63281. * Disables highlights
  63282. */
  63283. disableHighlights(): void;
  63284. /**
  63285. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63286. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63287. */
  63288. dispose(disableDepthRender?: boolean): void;
  63289. private _createChromaticAberrationPostProcess;
  63290. private _createHighlightsPostProcess;
  63291. private _createDepthOfFieldPostProcess;
  63292. private _createGrainTexture;
  63293. }
  63294. }
  63295. declare module "babylonjs/Shaders/ssao2.fragment" {
  63296. /** @hidden */
  63297. export var ssao2PixelShader: {
  63298. name: string;
  63299. shader: string;
  63300. };
  63301. }
  63302. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63303. /** @hidden */
  63304. export var ssaoCombinePixelShader: {
  63305. name: string;
  63306. shader: string;
  63307. };
  63308. }
  63309. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63310. import { Camera } from "babylonjs/Cameras/camera";
  63311. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63312. import { Scene } from "babylonjs/scene";
  63313. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63314. import "babylonjs/Shaders/ssao2.fragment";
  63315. import "babylonjs/Shaders/ssaoCombine.fragment";
  63316. /**
  63317. * Render pipeline to produce ssao effect
  63318. */
  63319. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63320. /**
  63321. * @ignore
  63322. * The PassPostProcess id in the pipeline that contains the original scene color
  63323. */
  63324. SSAOOriginalSceneColorEffect: string;
  63325. /**
  63326. * @ignore
  63327. * The SSAO PostProcess id in the pipeline
  63328. */
  63329. SSAORenderEffect: string;
  63330. /**
  63331. * @ignore
  63332. * The horizontal blur PostProcess id in the pipeline
  63333. */
  63334. SSAOBlurHRenderEffect: string;
  63335. /**
  63336. * @ignore
  63337. * The vertical blur PostProcess id in the pipeline
  63338. */
  63339. SSAOBlurVRenderEffect: string;
  63340. /**
  63341. * @ignore
  63342. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63343. */
  63344. SSAOCombineRenderEffect: string;
  63345. /**
  63346. * The output strength of the SSAO post-process. Default value is 1.0.
  63347. */
  63348. totalStrength: number;
  63349. /**
  63350. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63351. */
  63352. maxZ: number;
  63353. /**
  63354. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63355. */
  63356. minZAspect: number;
  63357. private _samples;
  63358. /**
  63359. * Number of samples used for the SSAO calculations. Default value is 8
  63360. */
  63361. samples: number;
  63362. private _textureSamples;
  63363. /**
  63364. * Number of samples to use for antialiasing
  63365. */
  63366. textureSamples: number;
  63367. /**
  63368. * Ratio object used for SSAO ratio and blur ratio
  63369. */
  63370. private _ratio;
  63371. /**
  63372. * Dynamically generated sphere sampler.
  63373. */
  63374. private _sampleSphere;
  63375. /**
  63376. * Blur filter offsets
  63377. */
  63378. private _samplerOffsets;
  63379. private _expensiveBlur;
  63380. /**
  63381. * If bilateral blur should be used
  63382. */
  63383. expensiveBlur: boolean;
  63384. /**
  63385. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63386. */
  63387. radius: number;
  63388. /**
  63389. * The base color of the SSAO post-process
  63390. * The final result is "base + ssao" between [0, 1]
  63391. */
  63392. base: number;
  63393. /**
  63394. * Support test.
  63395. */
  63396. static readonly IsSupported: boolean;
  63397. private _scene;
  63398. private _depthTexture;
  63399. private _normalTexture;
  63400. private _randomTexture;
  63401. private _originalColorPostProcess;
  63402. private _ssaoPostProcess;
  63403. private _blurHPostProcess;
  63404. private _blurVPostProcess;
  63405. private _ssaoCombinePostProcess;
  63406. private _firstUpdate;
  63407. /**
  63408. * Gets active scene
  63409. */
  63410. readonly scene: Scene;
  63411. /**
  63412. * @constructor
  63413. * @param name The rendering pipeline name
  63414. * @param scene The scene linked to this pipeline
  63415. * @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 }
  63416. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63417. */
  63418. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63419. /**
  63420. * Get the class name
  63421. * @returns "SSAO2RenderingPipeline"
  63422. */
  63423. getClassName(): string;
  63424. /**
  63425. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63426. */
  63427. dispose(disableGeometryBufferRenderer?: boolean): void;
  63428. private _createBlurPostProcess;
  63429. /** @hidden */
  63430. _rebuild(): void;
  63431. private _bits;
  63432. private _radicalInverse_VdC;
  63433. private _hammersley;
  63434. private _hemisphereSample_uniform;
  63435. private _generateHemisphere;
  63436. private _createSSAOPostProcess;
  63437. private _createSSAOCombinePostProcess;
  63438. private _createRandomTexture;
  63439. /**
  63440. * Serialize the rendering pipeline (Used when exporting)
  63441. * @returns the serialized object
  63442. */
  63443. serialize(): any;
  63444. /**
  63445. * Parse the serialized pipeline
  63446. * @param source Source pipeline.
  63447. * @param scene The scene to load the pipeline to.
  63448. * @param rootUrl The URL of the serialized pipeline.
  63449. * @returns An instantiated pipeline from the serialized object.
  63450. */
  63451. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63452. }
  63453. }
  63454. declare module "babylonjs/Shaders/ssao.fragment" {
  63455. /** @hidden */
  63456. export var ssaoPixelShader: {
  63457. name: string;
  63458. shader: string;
  63459. };
  63460. }
  63461. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63462. import { Camera } from "babylonjs/Cameras/camera";
  63463. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63464. import { Scene } from "babylonjs/scene";
  63465. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63466. import "babylonjs/Shaders/ssao.fragment";
  63467. import "babylonjs/Shaders/ssaoCombine.fragment";
  63468. /**
  63469. * Render pipeline to produce ssao effect
  63470. */
  63471. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63472. /**
  63473. * @ignore
  63474. * The PassPostProcess id in the pipeline that contains the original scene color
  63475. */
  63476. SSAOOriginalSceneColorEffect: string;
  63477. /**
  63478. * @ignore
  63479. * The SSAO PostProcess id in the pipeline
  63480. */
  63481. SSAORenderEffect: string;
  63482. /**
  63483. * @ignore
  63484. * The horizontal blur PostProcess id in the pipeline
  63485. */
  63486. SSAOBlurHRenderEffect: string;
  63487. /**
  63488. * @ignore
  63489. * The vertical blur PostProcess id in the pipeline
  63490. */
  63491. SSAOBlurVRenderEffect: string;
  63492. /**
  63493. * @ignore
  63494. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63495. */
  63496. SSAOCombineRenderEffect: string;
  63497. /**
  63498. * The output strength of the SSAO post-process. Default value is 1.0.
  63499. */
  63500. totalStrength: number;
  63501. /**
  63502. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63503. */
  63504. radius: number;
  63505. /**
  63506. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63507. * Must not be equal to fallOff and superior to fallOff.
  63508. * Default value is 0.0075
  63509. */
  63510. area: number;
  63511. /**
  63512. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63513. * Must not be equal to area and inferior to area.
  63514. * Default value is 0.000001
  63515. */
  63516. fallOff: number;
  63517. /**
  63518. * The base color of the SSAO post-process
  63519. * The final result is "base + ssao" between [0, 1]
  63520. */
  63521. base: number;
  63522. private _scene;
  63523. private _depthTexture;
  63524. private _randomTexture;
  63525. private _originalColorPostProcess;
  63526. private _ssaoPostProcess;
  63527. private _blurHPostProcess;
  63528. private _blurVPostProcess;
  63529. private _ssaoCombinePostProcess;
  63530. private _firstUpdate;
  63531. /**
  63532. * Gets active scene
  63533. */
  63534. readonly scene: Scene;
  63535. /**
  63536. * @constructor
  63537. * @param name - The rendering pipeline name
  63538. * @param scene - The scene linked to this pipeline
  63539. * @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 }
  63540. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63541. */
  63542. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63543. /**
  63544. * Get the class name
  63545. * @returns "SSAORenderingPipeline"
  63546. */
  63547. getClassName(): string;
  63548. /**
  63549. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63550. */
  63551. dispose(disableDepthRender?: boolean): void;
  63552. private _createBlurPostProcess;
  63553. /** @hidden */
  63554. _rebuild(): void;
  63555. private _createSSAOPostProcess;
  63556. private _createSSAOCombinePostProcess;
  63557. private _createRandomTexture;
  63558. }
  63559. }
  63560. declare module "babylonjs/Shaders/standard.fragment" {
  63561. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63562. /** @hidden */
  63563. export var standardPixelShader: {
  63564. name: string;
  63565. shader: string;
  63566. };
  63567. }
  63568. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63569. import { Nullable } from "babylonjs/types";
  63570. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63571. import { Camera } from "babylonjs/Cameras/camera";
  63572. import { Texture } from "babylonjs/Materials/Textures/texture";
  63573. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63574. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63575. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63576. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63577. import { IDisposable } from "babylonjs/scene";
  63578. import { SpotLight } from "babylonjs/Lights/spotLight";
  63579. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63580. import { Scene } from "babylonjs/scene";
  63581. import { Animation } from "babylonjs/Animations/animation";
  63582. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63583. import "babylonjs/Shaders/standard.fragment";
  63584. /**
  63585. * Standard rendering pipeline
  63586. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63587. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63588. */
  63589. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63590. /**
  63591. * Public members
  63592. */
  63593. /**
  63594. * Post-process which contains the original scene color before the pipeline applies all the effects
  63595. */
  63596. originalPostProcess: Nullable<PostProcess>;
  63597. /**
  63598. * Post-process used to down scale an image x4
  63599. */
  63600. downSampleX4PostProcess: Nullable<PostProcess>;
  63601. /**
  63602. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63603. */
  63604. brightPassPostProcess: Nullable<PostProcess>;
  63605. /**
  63606. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63607. */
  63608. blurHPostProcesses: PostProcess[];
  63609. /**
  63610. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63611. */
  63612. blurVPostProcesses: PostProcess[];
  63613. /**
  63614. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63615. */
  63616. textureAdderPostProcess: Nullable<PostProcess>;
  63617. /**
  63618. * Post-process used to create volumetric lighting effect
  63619. */
  63620. volumetricLightPostProcess: Nullable<PostProcess>;
  63621. /**
  63622. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63623. */
  63624. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63625. /**
  63626. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63627. */
  63628. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63629. /**
  63630. * Post-process used to merge the volumetric light effect and the real scene color
  63631. */
  63632. volumetricLightMergePostProces: Nullable<PostProcess>;
  63633. /**
  63634. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63635. */
  63636. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63637. /**
  63638. * Base post-process used to calculate the average luminance of the final image for HDR
  63639. */
  63640. luminancePostProcess: Nullable<PostProcess>;
  63641. /**
  63642. * Post-processes used to create down sample post-processes in order to get
  63643. * the average luminance of the final image for HDR
  63644. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63645. */
  63646. luminanceDownSamplePostProcesses: PostProcess[];
  63647. /**
  63648. * Post-process used to create a HDR effect (light adaptation)
  63649. */
  63650. hdrPostProcess: Nullable<PostProcess>;
  63651. /**
  63652. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63653. */
  63654. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63655. /**
  63656. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63657. */
  63658. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63659. /**
  63660. * Post-process used to merge the final HDR post-process and the real scene color
  63661. */
  63662. hdrFinalPostProcess: Nullable<PostProcess>;
  63663. /**
  63664. * Post-process used to create a lens flare effect
  63665. */
  63666. lensFlarePostProcess: Nullable<PostProcess>;
  63667. /**
  63668. * Post-process that merges the result of the lens flare post-process and the real scene color
  63669. */
  63670. lensFlareComposePostProcess: Nullable<PostProcess>;
  63671. /**
  63672. * Post-process used to create a motion blur effect
  63673. */
  63674. motionBlurPostProcess: Nullable<PostProcess>;
  63675. /**
  63676. * Post-process used to create a depth of field effect
  63677. */
  63678. depthOfFieldPostProcess: Nullable<PostProcess>;
  63679. /**
  63680. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63681. */
  63682. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63683. /**
  63684. * Represents the brightness threshold in order to configure the illuminated surfaces
  63685. */
  63686. brightThreshold: number;
  63687. /**
  63688. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63689. */
  63690. blurWidth: number;
  63691. /**
  63692. * Sets if the blur for highlighted surfaces must be only horizontal
  63693. */
  63694. horizontalBlur: boolean;
  63695. /**
  63696. * Gets the overall exposure used by the pipeline
  63697. */
  63698. /**
  63699. * Sets the overall exposure used by the pipeline
  63700. */
  63701. exposure: number;
  63702. /**
  63703. * Texture used typically to simulate "dirty" on camera lens
  63704. */
  63705. lensTexture: Nullable<Texture>;
  63706. /**
  63707. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63708. */
  63709. volumetricLightCoefficient: number;
  63710. /**
  63711. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63712. */
  63713. volumetricLightPower: number;
  63714. /**
  63715. * Used the set the blur intensity to smooth the volumetric lights
  63716. */
  63717. volumetricLightBlurScale: number;
  63718. /**
  63719. * Light (spot or directional) used to generate the volumetric lights rays
  63720. * The source light must have a shadow generate so the pipeline can get its
  63721. * depth map
  63722. */
  63723. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63724. /**
  63725. * For eye adaptation, represents the minimum luminance the eye can see
  63726. */
  63727. hdrMinimumLuminance: number;
  63728. /**
  63729. * For eye adaptation, represents the decrease luminance speed
  63730. */
  63731. hdrDecreaseRate: number;
  63732. /**
  63733. * For eye adaptation, represents the increase luminance speed
  63734. */
  63735. hdrIncreaseRate: number;
  63736. /**
  63737. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63738. */
  63739. /**
  63740. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63741. */
  63742. hdrAutoExposure: boolean;
  63743. /**
  63744. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63745. */
  63746. lensColorTexture: Nullable<Texture>;
  63747. /**
  63748. * The overall strengh for the lens flare effect
  63749. */
  63750. lensFlareStrength: number;
  63751. /**
  63752. * Dispersion coefficient for lens flare ghosts
  63753. */
  63754. lensFlareGhostDispersal: number;
  63755. /**
  63756. * Main lens flare halo width
  63757. */
  63758. lensFlareHaloWidth: number;
  63759. /**
  63760. * Based on the lens distortion effect, defines how much the lens flare result
  63761. * is distorted
  63762. */
  63763. lensFlareDistortionStrength: number;
  63764. /**
  63765. * Configures the blur intensity used for for lens flare (halo)
  63766. */
  63767. lensFlareBlurWidth: number;
  63768. /**
  63769. * Lens star texture must be used to simulate rays on the flares and is available
  63770. * in the documentation
  63771. */
  63772. lensStarTexture: Nullable<Texture>;
  63773. /**
  63774. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63775. * flare effect by taking account of the dirt texture
  63776. */
  63777. lensFlareDirtTexture: Nullable<Texture>;
  63778. /**
  63779. * Represents the focal length for the depth of field effect
  63780. */
  63781. depthOfFieldDistance: number;
  63782. /**
  63783. * Represents the blur intensity for the blurred part of the depth of field effect
  63784. */
  63785. depthOfFieldBlurWidth: number;
  63786. /**
  63787. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63788. */
  63789. /**
  63790. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63791. */
  63792. motionStrength: number;
  63793. /**
  63794. * Gets wether or not the motion blur post-process is object based or screen based.
  63795. */
  63796. /**
  63797. * Sets wether or not the motion blur post-process should be object based or screen based
  63798. */
  63799. objectBasedMotionBlur: boolean;
  63800. /**
  63801. * List of animations for the pipeline (IAnimatable implementation)
  63802. */
  63803. animations: Animation[];
  63804. /**
  63805. * Private members
  63806. */
  63807. private _scene;
  63808. private _currentDepthOfFieldSource;
  63809. private _basePostProcess;
  63810. private _fixedExposure;
  63811. private _currentExposure;
  63812. private _hdrAutoExposure;
  63813. private _hdrCurrentLuminance;
  63814. private _motionStrength;
  63815. private _isObjectBasedMotionBlur;
  63816. private _floatTextureType;
  63817. private _camerasToBeAttached;
  63818. private _ratio;
  63819. private _bloomEnabled;
  63820. private _depthOfFieldEnabled;
  63821. private _vlsEnabled;
  63822. private _lensFlareEnabled;
  63823. private _hdrEnabled;
  63824. private _motionBlurEnabled;
  63825. private _fxaaEnabled;
  63826. private _motionBlurSamples;
  63827. private _volumetricLightStepsCount;
  63828. private _samples;
  63829. /**
  63830. * @ignore
  63831. * Specifies if the bloom pipeline is enabled
  63832. */
  63833. BloomEnabled: boolean;
  63834. /**
  63835. * @ignore
  63836. * Specifies if the depth of field pipeline is enabed
  63837. */
  63838. DepthOfFieldEnabled: boolean;
  63839. /**
  63840. * @ignore
  63841. * Specifies if the lens flare pipeline is enabed
  63842. */
  63843. LensFlareEnabled: boolean;
  63844. /**
  63845. * @ignore
  63846. * Specifies if the HDR pipeline is enabled
  63847. */
  63848. HDREnabled: boolean;
  63849. /**
  63850. * @ignore
  63851. * Specifies if the volumetric lights scattering effect is enabled
  63852. */
  63853. VLSEnabled: boolean;
  63854. /**
  63855. * @ignore
  63856. * Specifies if the motion blur effect is enabled
  63857. */
  63858. MotionBlurEnabled: boolean;
  63859. /**
  63860. * Specifies if anti-aliasing is enabled
  63861. */
  63862. fxaaEnabled: boolean;
  63863. /**
  63864. * Specifies the number of steps used to calculate the volumetric lights
  63865. * Typically in interval [50, 200]
  63866. */
  63867. volumetricLightStepsCount: number;
  63868. /**
  63869. * Specifies the number of samples used for the motion blur effect
  63870. * Typically in interval [16, 64]
  63871. */
  63872. motionBlurSamples: number;
  63873. /**
  63874. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63875. */
  63876. samples: number;
  63877. /**
  63878. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63879. * @constructor
  63880. * @param name The rendering pipeline name
  63881. * @param scene The scene linked to this pipeline
  63882. * @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)
  63883. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63884. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63885. */
  63886. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63887. private _buildPipeline;
  63888. private _createDownSampleX4PostProcess;
  63889. private _createBrightPassPostProcess;
  63890. private _createBlurPostProcesses;
  63891. private _createTextureAdderPostProcess;
  63892. private _createVolumetricLightPostProcess;
  63893. private _createLuminancePostProcesses;
  63894. private _createHdrPostProcess;
  63895. private _createLensFlarePostProcess;
  63896. private _createDepthOfFieldPostProcess;
  63897. private _createMotionBlurPostProcess;
  63898. private _getDepthTexture;
  63899. private _disposePostProcesses;
  63900. /**
  63901. * Dispose of the pipeline and stop all post processes
  63902. */
  63903. dispose(): void;
  63904. /**
  63905. * Serialize the rendering pipeline (Used when exporting)
  63906. * @returns the serialized object
  63907. */
  63908. serialize(): any;
  63909. /**
  63910. * Parse the serialized pipeline
  63911. * @param source Source pipeline.
  63912. * @param scene The scene to load the pipeline to.
  63913. * @param rootUrl The URL of the serialized pipeline.
  63914. * @returns An instantiated pipeline from the serialized object.
  63915. */
  63916. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63917. /**
  63918. * Luminance steps
  63919. */
  63920. static LuminanceSteps: number;
  63921. }
  63922. }
  63923. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63924. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63925. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63926. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63927. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63928. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63929. }
  63930. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63931. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63932. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63933. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63934. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63935. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63936. }
  63937. declare module "babylonjs/Shaders/tonemap.fragment" {
  63938. /** @hidden */
  63939. export var tonemapPixelShader: {
  63940. name: string;
  63941. shader: string;
  63942. };
  63943. }
  63944. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63945. import { Camera } from "babylonjs/Cameras/camera";
  63946. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63947. import "babylonjs/Shaders/tonemap.fragment";
  63948. import { Engine } from "babylonjs/Engines/engine";
  63949. /** Defines operator used for tonemapping */
  63950. export enum TonemappingOperator {
  63951. /** Hable */
  63952. Hable = 0,
  63953. /** Reinhard */
  63954. Reinhard = 1,
  63955. /** HejiDawson */
  63956. HejiDawson = 2,
  63957. /** Photographic */
  63958. Photographic = 3
  63959. }
  63960. /**
  63961. * Defines a post process to apply tone mapping
  63962. */
  63963. export class TonemapPostProcess extends PostProcess {
  63964. private _operator;
  63965. /** Defines the required exposure adjustement */
  63966. exposureAdjustment: number;
  63967. /**
  63968. * Creates a new TonemapPostProcess
  63969. * @param name defines the name of the postprocess
  63970. * @param _operator defines the operator to use
  63971. * @param exposureAdjustment defines the required exposure adjustement
  63972. * @param camera defines the camera to use (can be null)
  63973. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63974. * @param engine defines the hosting engine (can be ignore if camera is set)
  63975. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63976. */
  63977. constructor(name: string, _operator: TonemappingOperator,
  63978. /** Defines the required exposure adjustement */
  63979. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63980. }
  63981. }
  63982. declare module "babylonjs/Shaders/depth.vertex" {
  63983. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63984. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63985. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63986. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63987. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63988. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63989. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63990. /** @hidden */
  63991. export var depthVertexShader: {
  63992. name: string;
  63993. shader: string;
  63994. };
  63995. }
  63996. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63997. /** @hidden */
  63998. export var volumetricLightScatteringPixelShader: {
  63999. name: string;
  64000. shader: string;
  64001. };
  64002. }
  64003. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64004. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64005. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64006. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64007. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64009. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64010. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64011. /** @hidden */
  64012. export var volumetricLightScatteringPassVertexShader: {
  64013. name: string;
  64014. shader: string;
  64015. };
  64016. }
  64017. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64018. /** @hidden */
  64019. export var volumetricLightScatteringPassPixelShader: {
  64020. name: string;
  64021. shader: string;
  64022. };
  64023. }
  64024. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64025. import { Vector3 } from "babylonjs/Maths/math.vector";
  64026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64027. import { Mesh } from "babylonjs/Meshes/mesh";
  64028. import { Camera } from "babylonjs/Cameras/camera";
  64029. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64030. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64031. import { Scene } from "babylonjs/scene";
  64032. import "babylonjs/Meshes/Builders/planeBuilder";
  64033. import "babylonjs/Shaders/depth.vertex";
  64034. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64035. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64036. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64037. import { Engine } from "babylonjs/Engines/engine";
  64038. /**
  64039. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64040. */
  64041. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64042. private _volumetricLightScatteringPass;
  64043. private _volumetricLightScatteringRTT;
  64044. private _viewPort;
  64045. private _screenCoordinates;
  64046. private _cachedDefines;
  64047. /**
  64048. * If not undefined, the mesh position is computed from the attached node position
  64049. */
  64050. attachedNode: {
  64051. position: Vector3;
  64052. };
  64053. /**
  64054. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64055. */
  64056. customMeshPosition: Vector3;
  64057. /**
  64058. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64059. */
  64060. useCustomMeshPosition: boolean;
  64061. /**
  64062. * If the post-process should inverse the light scattering direction
  64063. */
  64064. invert: boolean;
  64065. /**
  64066. * The internal mesh used by the post-process
  64067. */
  64068. mesh: Mesh;
  64069. /**
  64070. * @hidden
  64071. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64072. */
  64073. useDiffuseColor: boolean;
  64074. /**
  64075. * Array containing the excluded meshes not rendered in the internal pass
  64076. */
  64077. excludedMeshes: AbstractMesh[];
  64078. /**
  64079. * Controls the overall intensity of the post-process
  64080. */
  64081. exposure: number;
  64082. /**
  64083. * Dissipates each sample's contribution in range [0, 1]
  64084. */
  64085. decay: number;
  64086. /**
  64087. * Controls the overall intensity of each sample
  64088. */
  64089. weight: number;
  64090. /**
  64091. * Controls the density of each sample
  64092. */
  64093. density: number;
  64094. /**
  64095. * @constructor
  64096. * @param name The post-process name
  64097. * @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)
  64098. * @param camera The camera that the post-process will be attached to
  64099. * @param mesh The mesh used to create the light scattering
  64100. * @param samples The post-process quality, default 100
  64101. * @param samplingModeThe post-process filtering mode
  64102. * @param engine The babylon engine
  64103. * @param reusable If the post-process is reusable
  64104. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64105. */
  64106. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64107. /**
  64108. * Returns the string "VolumetricLightScatteringPostProcess"
  64109. * @returns "VolumetricLightScatteringPostProcess"
  64110. */
  64111. getClassName(): string;
  64112. private _isReady;
  64113. /**
  64114. * Sets the new light position for light scattering effect
  64115. * @param position The new custom light position
  64116. */
  64117. setCustomMeshPosition(position: Vector3): void;
  64118. /**
  64119. * Returns the light position for light scattering effect
  64120. * @return Vector3 The custom light position
  64121. */
  64122. getCustomMeshPosition(): Vector3;
  64123. /**
  64124. * Disposes the internal assets and detaches the post-process from the camera
  64125. */
  64126. dispose(camera: Camera): void;
  64127. /**
  64128. * Returns the render target texture used by the post-process
  64129. * @return the render target texture used by the post-process
  64130. */
  64131. getPass(): RenderTargetTexture;
  64132. private _meshExcluded;
  64133. private _createPass;
  64134. private _updateMeshScreenCoordinates;
  64135. /**
  64136. * Creates a default mesh for the Volumeric Light Scattering post-process
  64137. * @param name The mesh name
  64138. * @param scene The scene where to create the mesh
  64139. * @return the default mesh
  64140. */
  64141. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64142. }
  64143. }
  64144. declare module "babylonjs/PostProcesses/index" {
  64145. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64146. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64147. export * from "babylonjs/PostProcesses/bloomEffect";
  64148. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64149. export * from "babylonjs/PostProcesses/blurPostProcess";
  64150. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64151. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64152. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64153. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64154. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64155. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64156. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64157. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64158. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64159. export * from "babylonjs/PostProcesses/filterPostProcess";
  64160. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64161. export * from "babylonjs/PostProcesses/grainPostProcess";
  64162. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64163. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64164. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64165. export * from "babylonjs/PostProcesses/passPostProcess";
  64166. export * from "babylonjs/PostProcesses/postProcess";
  64167. export * from "babylonjs/PostProcesses/postProcessManager";
  64168. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64169. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64170. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64171. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64172. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64173. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64174. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64175. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64176. }
  64177. declare module "babylonjs/Probes/index" {
  64178. export * from "babylonjs/Probes/reflectionProbe";
  64179. }
  64180. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64181. import { Scene } from "babylonjs/scene";
  64182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64183. import { SmartArray } from "babylonjs/Misc/smartArray";
  64184. import { ISceneComponent } from "babylonjs/sceneComponent";
  64185. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64186. import "babylonjs/Meshes/Builders/boxBuilder";
  64187. import "babylonjs/Shaders/color.fragment";
  64188. import "babylonjs/Shaders/color.vertex";
  64189. import { Color3 } from "babylonjs/Maths/math.color";
  64190. module "babylonjs/scene" {
  64191. interface Scene {
  64192. /** @hidden (Backing field) */
  64193. _boundingBoxRenderer: BoundingBoxRenderer;
  64194. /** @hidden (Backing field) */
  64195. _forceShowBoundingBoxes: boolean;
  64196. /**
  64197. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64198. */
  64199. forceShowBoundingBoxes: boolean;
  64200. /**
  64201. * Gets the bounding box renderer associated with the scene
  64202. * @returns a BoundingBoxRenderer
  64203. */
  64204. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64205. }
  64206. }
  64207. module "babylonjs/Meshes/abstractMesh" {
  64208. interface AbstractMesh {
  64209. /** @hidden (Backing field) */
  64210. _showBoundingBox: boolean;
  64211. /**
  64212. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64213. */
  64214. showBoundingBox: boolean;
  64215. }
  64216. }
  64217. /**
  64218. * Component responsible of rendering the bounding box of the meshes in a scene.
  64219. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64220. */
  64221. export class BoundingBoxRenderer implements ISceneComponent {
  64222. /**
  64223. * The component name helpfull to identify the component in the list of scene components.
  64224. */
  64225. readonly name: string;
  64226. /**
  64227. * The scene the component belongs to.
  64228. */
  64229. scene: Scene;
  64230. /**
  64231. * Color of the bounding box lines placed in front of an object
  64232. */
  64233. frontColor: Color3;
  64234. /**
  64235. * Color of the bounding box lines placed behind an object
  64236. */
  64237. backColor: Color3;
  64238. /**
  64239. * Defines if the renderer should show the back lines or not
  64240. */
  64241. showBackLines: boolean;
  64242. /**
  64243. * @hidden
  64244. */
  64245. renderList: SmartArray<BoundingBox>;
  64246. private _colorShader;
  64247. private _vertexBuffers;
  64248. private _indexBuffer;
  64249. private _fillIndexBuffer;
  64250. private _fillIndexData;
  64251. /**
  64252. * Instantiates a new bounding box renderer in a scene.
  64253. * @param scene the scene the renderer renders in
  64254. */
  64255. constructor(scene: Scene);
  64256. /**
  64257. * Registers the component in a given scene
  64258. */
  64259. register(): void;
  64260. private _evaluateSubMesh;
  64261. private _activeMesh;
  64262. private _prepareRessources;
  64263. private _createIndexBuffer;
  64264. /**
  64265. * Rebuilds the elements related to this component in case of
  64266. * context lost for instance.
  64267. */
  64268. rebuild(): void;
  64269. /**
  64270. * @hidden
  64271. */
  64272. reset(): void;
  64273. /**
  64274. * Render the bounding boxes of a specific rendering group
  64275. * @param renderingGroupId defines the rendering group to render
  64276. */
  64277. render(renderingGroupId: number): void;
  64278. /**
  64279. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64280. * @param mesh Define the mesh to render the occlusion bounding box for
  64281. */
  64282. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64283. /**
  64284. * Dispose and release the resources attached to this renderer.
  64285. */
  64286. dispose(): void;
  64287. }
  64288. }
  64289. declare module "babylonjs/Shaders/depth.fragment" {
  64290. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64291. /** @hidden */
  64292. export var depthPixelShader: {
  64293. name: string;
  64294. shader: string;
  64295. };
  64296. }
  64297. declare module "babylonjs/Rendering/depthRenderer" {
  64298. import { Nullable } from "babylonjs/types";
  64299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64300. import { Scene } from "babylonjs/scene";
  64301. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64302. import { Camera } from "babylonjs/Cameras/camera";
  64303. import "babylonjs/Shaders/depth.fragment";
  64304. import "babylonjs/Shaders/depth.vertex";
  64305. /**
  64306. * This represents a depth renderer in Babylon.
  64307. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64308. */
  64309. export class DepthRenderer {
  64310. private _scene;
  64311. private _depthMap;
  64312. private _effect;
  64313. private readonly _storeNonLinearDepth;
  64314. private readonly _clearColor;
  64315. /** Get if the depth renderer is using packed depth or not */
  64316. readonly isPacked: boolean;
  64317. private _cachedDefines;
  64318. private _camera;
  64319. /**
  64320. * Specifiess that the depth renderer will only be used within
  64321. * the camera it is created for.
  64322. * This can help forcing its rendering during the camera processing.
  64323. */
  64324. useOnlyInActiveCamera: boolean;
  64325. /** @hidden */
  64326. static _SceneComponentInitialization: (scene: Scene) => void;
  64327. /**
  64328. * Instantiates a depth renderer
  64329. * @param scene The scene the renderer belongs to
  64330. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64331. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64332. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64333. */
  64334. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64335. /**
  64336. * Creates the depth rendering effect and checks if the effect is ready.
  64337. * @param subMesh The submesh to be used to render the depth map of
  64338. * @param useInstances If multiple world instances should be used
  64339. * @returns if the depth renderer is ready to render the depth map
  64340. */
  64341. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64342. /**
  64343. * Gets the texture which the depth map will be written to.
  64344. * @returns The depth map texture
  64345. */
  64346. getDepthMap(): RenderTargetTexture;
  64347. /**
  64348. * Disposes of the depth renderer.
  64349. */
  64350. dispose(): void;
  64351. }
  64352. }
  64353. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64354. import { Nullable } from "babylonjs/types";
  64355. import { Scene } from "babylonjs/scene";
  64356. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64357. import { Camera } from "babylonjs/Cameras/camera";
  64358. import { ISceneComponent } from "babylonjs/sceneComponent";
  64359. module "babylonjs/scene" {
  64360. interface Scene {
  64361. /** @hidden (Backing field) */
  64362. _depthRenderer: {
  64363. [id: string]: DepthRenderer;
  64364. };
  64365. /**
  64366. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64367. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64368. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64369. * @returns the created depth renderer
  64370. */
  64371. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64372. /**
  64373. * Disables a depth renderer for a given camera
  64374. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64375. */
  64376. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64377. }
  64378. }
  64379. /**
  64380. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64381. * in several rendering techniques.
  64382. */
  64383. export class DepthRendererSceneComponent implements ISceneComponent {
  64384. /**
  64385. * The component name helpfull to identify the component in the list of scene components.
  64386. */
  64387. readonly name: string;
  64388. /**
  64389. * The scene the component belongs to.
  64390. */
  64391. scene: Scene;
  64392. /**
  64393. * Creates a new instance of the component for the given scene
  64394. * @param scene Defines the scene to register the component in
  64395. */
  64396. constructor(scene: Scene);
  64397. /**
  64398. * Registers the component in a given scene
  64399. */
  64400. register(): void;
  64401. /**
  64402. * Rebuilds the elements related to this component in case of
  64403. * context lost for instance.
  64404. */
  64405. rebuild(): void;
  64406. /**
  64407. * Disposes the component and the associated ressources
  64408. */
  64409. dispose(): void;
  64410. private _gatherRenderTargets;
  64411. private _gatherActiveCameraRenderTargets;
  64412. }
  64413. }
  64414. declare module "babylonjs/Shaders/outline.fragment" {
  64415. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64416. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64417. /** @hidden */
  64418. export var outlinePixelShader: {
  64419. name: string;
  64420. shader: string;
  64421. };
  64422. }
  64423. declare module "babylonjs/Shaders/outline.vertex" {
  64424. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64427. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64428. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64429. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64430. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64431. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64432. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64433. /** @hidden */
  64434. export var outlineVertexShader: {
  64435. name: string;
  64436. shader: string;
  64437. };
  64438. }
  64439. declare module "babylonjs/Rendering/outlineRenderer" {
  64440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64441. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64442. import { Scene } from "babylonjs/scene";
  64443. import { ISceneComponent } from "babylonjs/sceneComponent";
  64444. import "babylonjs/Shaders/outline.fragment";
  64445. import "babylonjs/Shaders/outline.vertex";
  64446. module "babylonjs/scene" {
  64447. interface Scene {
  64448. /** @hidden */
  64449. _outlineRenderer: OutlineRenderer;
  64450. /**
  64451. * Gets the outline renderer associated with the scene
  64452. * @returns a OutlineRenderer
  64453. */
  64454. getOutlineRenderer(): OutlineRenderer;
  64455. }
  64456. }
  64457. module "babylonjs/Meshes/abstractMesh" {
  64458. interface AbstractMesh {
  64459. /** @hidden (Backing field) */
  64460. _renderOutline: boolean;
  64461. /**
  64462. * Gets or sets a boolean indicating if the outline must be rendered as well
  64463. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64464. */
  64465. renderOutline: boolean;
  64466. /** @hidden (Backing field) */
  64467. _renderOverlay: boolean;
  64468. /**
  64469. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64470. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64471. */
  64472. renderOverlay: boolean;
  64473. }
  64474. }
  64475. /**
  64476. * This class is responsible to draw bothe outline/overlay of meshes.
  64477. * It should not be used directly but through the available method on mesh.
  64478. */
  64479. export class OutlineRenderer implements ISceneComponent {
  64480. /**
  64481. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64482. */
  64483. private static _StencilReference;
  64484. /**
  64485. * The name of the component. Each component must have a unique name.
  64486. */
  64487. name: string;
  64488. /**
  64489. * The scene the component belongs to.
  64490. */
  64491. scene: Scene;
  64492. /**
  64493. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64494. */
  64495. zOffset: number;
  64496. private _engine;
  64497. private _effect;
  64498. private _cachedDefines;
  64499. private _savedDepthWrite;
  64500. /**
  64501. * Instantiates a new outline renderer. (There could be only one per scene).
  64502. * @param scene Defines the scene it belongs to
  64503. */
  64504. constructor(scene: Scene);
  64505. /**
  64506. * Register the component to one instance of a scene.
  64507. */
  64508. register(): void;
  64509. /**
  64510. * Rebuilds the elements related to this component in case of
  64511. * context lost for instance.
  64512. */
  64513. rebuild(): void;
  64514. /**
  64515. * Disposes the component and the associated ressources.
  64516. */
  64517. dispose(): void;
  64518. /**
  64519. * Renders the outline in the canvas.
  64520. * @param subMesh Defines the sumesh to render
  64521. * @param batch Defines the batch of meshes in case of instances
  64522. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64523. */
  64524. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64525. /**
  64526. * Returns whether or not the outline renderer is ready for a given submesh.
  64527. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64528. * @param subMesh Defines the submesh to check readyness for
  64529. * @param useInstances Defines wheter wee are trying to render instances or not
  64530. * @returns true if ready otherwise false
  64531. */
  64532. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64533. private _beforeRenderingMesh;
  64534. private _afterRenderingMesh;
  64535. }
  64536. }
  64537. declare module "babylonjs/Rendering/index" {
  64538. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64539. export * from "babylonjs/Rendering/depthRenderer";
  64540. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64541. export * from "babylonjs/Rendering/edgesRenderer";
  64542. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64543. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64544. export * from "babylonjs/Rendering/outlineRenderer";
  64545. export * from "babylonjs/Rendering/renderingGroup";
  64546. export * from "babylonjs/Rendering/renderingManager";
  64547. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64548. }
  64549. declare module "babylonjs/Sprites/spritePackedManager" {
  64550. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64551. import { Scene } from "babylonjs/scene";
  64552. /**
  64553. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64554. * @see http://doc.babylonjs.com/babylon101/sprites
  64555. */
  64556. export class SpritePackedManager extends SpriteManager {
  64557. /** defines the packed manager's name */
  64558. name: string;
  64559. /**
  64560. * Creates a new sprite manager from a packed sprite sheet
  64561. * @param name defines the manager's name
  64562. * @param imgUrl defines the sprite sheet url
  64563. * @param capacity defines the maximum allowed number of sprites
  64564. * @param scene defines the hosting scene
  64565. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64566. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64567. * @param samplingMode defines the smapling mode to use with spritesheet
  64568. * @param fromPacked set to true; do not alter
  64569. */
  64570. constructor(
  64571. /** defines the packed manager's name */
  64572. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64573. }
  64574. }
  64575. declare module "babylonjs/Sprites/index" {
  64576. export * from "babylonjs/Sprites/sprite";
  64577. export * from "babylonjs/Sprites/spriteManager";
  64578. export * from "babylonjs/Sprites/spritePackedManager";
  64579. export * from "babylonjs/Sprites/spriteSceneComponent";
  64580. }
  64581. declare module "babylonjs/States/index" {
  64582. export * from "babylonjs/States/alphaCullingState";
  64583. export * from "babylonjs/States/depthCullingState";
  64584. export * from "babylonjs/States/stencilState";
  64585. }
  64586. declare module "babylonjs/Misc/assetsManager" {
  64587. import { Scene } from "babylonjs/scene";
  64588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64589. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64590. import { Skeleton } from "babylonjs/Bones/skeleton";
  64591. import { Observable } from "babylonjs/Misc/observable";
  64592. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64593. import { Texture } from "babylonjs/Materials/Textures/texture";
  64594. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64595. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64596. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64597. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64598. /**
  64599. * Defines the list of states available for a task inside a AssetsManager
  64600. */
  64601. export enum AssetTaskState {
  64602. /**
  64603. * Initialization
  64604. */
  64605. INIT = 0,
  64606. /**
  64607. * Running
  64608. */
  64609. RUNNING = 1,
  64610. /**
  64611. * Done
  64612. */
  64613. DONE = 2,
  64614. /**
  64615. * Error
  64616. */
  64617. ERROR = 3
  64618. }
  64619. /**
  64620. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64621. */
  64622. export abstract class AbstractAssetTask {
  64623. /**
  64624. * Task name
  64625. */ name: string;
  64626. /**
  64627. * Callback called when the task is successful
  64628. */
  64629. onSuccess: (task: any) => void;
  64630. /**
  64631. * Callback called when the task is not successful
  64632. */
  64633. onError: (task: any, message?: string, exception?: any) => void;
  64634. /**
  64635. * Creates a new AssetsManager
  64636. * @param name defines the name of the task
  64637. */
  64638. constructor(
  64639. /**
  64640. * Task name
  64641. */ name: string);
  64642. private _isCompleted;
  64643. private _taskState;
  64644. private _errorObject;
  64645. /**
  64646. * Get if the task is completed
  64647. */
  64648. readonly isCompleted: boolean;
  64649. /**
  64650. * Gets the current state of the task
  64651. */
  64652. readonly taskState: AssetTaskState;
  64653. /**
  64654. * Gets the current error object (if task is in error)
  64655. */
  64656. readonly errorObject: {
  64657. message?: string;
  64658. exception?: any;
  64659. };
  64660. /**
  64661. * Internal only
  64662. * @hidden
  64663. */
  64664. _setErrorObject(message?: string, exception?: any): void;
  64665. /**
  64666. * Execute the current task
  64667. * @param scene defines the scene where you want your assets to be loaded
  64668. * @param onSuccess is a callback called when the task is successfully executed
  64669. * @param onError is a callback called if an error occurs
  64670. */
  64671. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64672. /**
  64673. * Execute the current task
  64674. * @param scene defines the scene where you want your assets to be loaded
  64675. * @param onSuccess is a callback called when the task is successfully executed
  64676. * @param onError is a callback called if an error occurs
  64677. */
  64678. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64679. /**
  64680. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64681. * This can be used with failed tasks that have the reason for failure fixed.
  64682. */
  64683. reset(): void;
  64684. private onErrorCallback;
  64685. private onDoneCallback;
  64686. }
  64687. /**
  64688. * Define the interface used by progress events raised during assets loading
  64689. */
  64690. export interface IAssetsProgressEvent {
  64691. /**
  64692. * Defines the number of remaining tasks to process
  64693. */
  64694. remainingCount: number;
  64695. /**
  64696. * Defines the total number of tasks
  64697. */
  64698. totalCount: number;
  64699. /**
  64700. * Defines the task that was just processed
  64701. */
  64702. task: AbstractAssetTask;
  64703. }
  64704. /**
  64705. * Class used to share progress information about assets loading
  64706. */
  64707. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64708. /**
  64709. * Defines the number of remaining tasks to process
  64710. */
  64711. remainingCount: number;
  64712. /**
  64713. * Defines the total number of tasks
  64714. */
  64715. totalCount: number;
  64716. /**
  64717. * Defines the task that was just processed
  64718. */
  64719. task: AbstractAssetTask;
  64720. /**
  64721. * Creates a AssetsProgressEvent
  64722. * @param remainingCount defines the number of remaining tasks to process
  64723. * @param totalCount defines the total number of tasks
  64724. * @param task defines the task that was just processed
  64725. */
  64726. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64727. }
  64728. /**
  64729. * Define a task used by AssetsManager to load meshes
  64730. */
  64731. export class MeshAssetTask extends AbstractAssetTask {
  64732. /**
  64733. * Defines the name of the task
  64734. */
  64735. name: string;
  64736. /**
  64737. * Defines the list of mesh's names you want to load
  64738. */
  64739. meshesNames: any;
  64740. /**
  64741. * Defines the root url to use as a base to load your meshes and associated resources
  64742. */
  64743. rootUrl: string;
  64744. /**
  64745. * Defines the filename of the scene to load from
  64746. */
  64747. sceneFilename: string;
  64748. /**
  64749. * Gets the list of loaded meshes
  64750. */
  64751. loadedMeshes: Array<AbstractMesh>;
  64752. /**
  64753. * Gets the list of loaded particle systems
  64754. */
  64755. loadedParticleSystems: Array<IParticleSystem>;
  64756. /**
  64757. * Gets the list of loaded skeletons
  64758. */
  64759. loadedSkeletons: Array<Skeleton>;
  64760. /**
  64761. * Gets the list of loaded animation groups
  64762. */
  64763. loadedAnimationGroups: Array<AnimationGroup>;
  64764. /**
  64765. * Callback called when the task is successful
  64766. */
  64767. onSuccess: (task: MeshAssetTask) => void;
  64768. /**
  64769. * Callback called when the task is successful
  64770. */
  64771. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64772. /**
  64773. * Creates a new MeshAssetTask
  64774. * @param name defines the name of the task
  64775. * @param meshesNames defines the list of mesh's names you want to load
  64776. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64777. * @param sceneFilename defines the filename of the scene to load from
  64778. */
  64779. constructor(
  64780. /**
  64781. * Defines the name of the task
  64782. */
  64783. name: string,
  64784. /**
  64785. * Defines the list of mesh's names you want to load
  64786. */
  64787. meshesNames: any,
  64788. /**
  64789. * Defines the root url to use as a base to load your meshes and associated resources
  64790. */
  64791. rootUrl: string,
  64792. /**
  64793. * Defines the filename of the scene to load from
  64794. */
  64795. sceneFilename: string);
  64796. /**
  64797. * Execute the current task
  64798. * @param scene defines the scene where you want your assets to be loaded
  64799. * @param onSuccess is a callback called when the task is successfully executed
  64800. * @param onError is a callback called if an error occurs
  64801. */
  64802. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64803. }
  64804. /**
  64805. * Define a task used by AssetsManager to load text content
  64806. */
  64807. export class TextFileAssetTask extends AbstractAssetTask {
  64808. /**
  64809. * Defines the name of the task
  64810. */
  64811. name: string;
  64812. /**
  64813. * Defines the location of the file to load
  64814. */
  64815. url: string;
  64816. /**
  64817. * Gets the loaded text string
  64818. */
  64819. text: string;
  64820. /**
  64821. * Callback called when the task is successful
  64822. */
  64823. onSuccess: (task: TextFileAssetTask) => void;
  64824. /**
  64825. * Callback called when the task is successful
  64826. */
  64827. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64828. /**
  64829. * Creates a new TextFileAssetTask object
  64830. * @param name defines the name of the task
  64831. * @param url defines the location of the file to load
  64832. */
  64833. constructor(
  64834. /**
  64835. * Defines the name of the task
  64836. */
  64837. name: string,
  64838. /**
  64839. * Defines the location of the file to load
  64840. */
  64841. url: string);
  64842. /**
  64843. * Execute the current task
  64844. * @param scene defines the scene where you want your assets to be loaded
  64845. * @param onSuccess is a callback called when the task is successfully executed
  64846. * @param onError is a callback called if an error occurs
  64847. */
  64848. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64849. }
  64850. /**
  64851. * Define a task used by AssetsManager to load binary data
  64852. */
  64853. export class BinaryFileAssetTask extends AbstractAssetTask {
  64854. /**
  64855. * Defines the name of the task
  64856. */
  64857. name: string;
  64858. /**
  64859. * Defines the location of the file to load
  64860. */
  64861. url: string;
  64862. /**
  64863. * Gets the lodaded data (as an array buffer)
  64864. */
  64865. data: ArrayBuffer;
  64866. /**
  64867. * Callback called when the task is successful
  64868. */
  64869. onSuccess: (task: BinaryFileAssetTask) => void;
  64870. /**
  64871. * Callback called when the task is successful
  64872. */
  64873. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64874. /**
  64875. * Creates a new BinaryFileAssetTask object
  64876. * @param name defines the name of the new task
  64877. * @param url defines the location of the file to load
  64878. */
  64879. constructor(
  64880. /**
  64881. * Defines the name of the task
  64882. */
  64883. name: string,
  64884. /**
  64885. * Defines the location of the file to load
  64886. */
  64887. url: string);
  64888. /**
  64889. * Execute the current task
  64890. * @param scene defines the scene where you want your assets to be loaded
  64891. * @param onSuccess is a callback called when the task is successfully executed
  64892. * @param onError is a callback called if an error occurs
  64893. */
  64894. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64895. }
  64896. /**
  64897. * Define a task used by AssetsManager to load images
  64898. */
  64899. export class ImageAssetTask extends AbstractAssetTask {
  64900. /**
  64901. * Defines the name of the task
  64902. */
  64903. name: string;
  64904. /**
  64905. * Defines the location of the image to load
  64906. */
  64907. url: string;
  64908. /**
  64909. * Gets the loaded images
  64910. */
  64911. image: HTMLImageElement;
  64912. /**
  64913. * Callback called when the task is successful
  64914. */
  64915. onSuccess: (task: ImageAssetTask) => void;
  64916. /**
  64917. * Callback called when the task is successful
  64918. */
  64919. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64920. /**
  64921. * Creates a new ImageAssetTask
  64922. * @param name defines the name of the task
  64923. * @param url defines the location of the image to load
  64924. */
  64925. constructor(
  64926. /**
  64927. * Defines the name of the task
  64928. */
  64929. name: string,
  64930. /**
  64931. * Defines the location of the image to load
  64932. */
  64933. url: string);
  64934. /**
  64935. * Execute the current task
  64936. * @param scene defines the scene where you want your assets to be loaded
  64937. * @param onSuccess is a callback called when the task is successfully executed
  64938. * @param onError is a callback called if an error occurs
  64939. */
  64940. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64941. }
  64942. /**
  64943. * Defines the interface used by texture loading tasks
  64944. */
  64945. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64946. /**
  64947. * Gets the loaded texture
  64948. */
  64949. texture: TEX;
  64950. }
  64951. /**
  64952. * Define a task used by AssetsManager to load 2D textures
  64953. */
  64954. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64955. /**
  64956. * Defines the name of the task
  64957. */
  64958. name: string;
  64959. /**
  64960. * Defines the location of the file to load
  64961. */
  64962. url: string;
  64963. /**
  64964. * Defines if mipmap should not be generated (default is false)
  64965. */
  64966. noMipmap?: boolean | undefined;
  64967. /**
  64968. * Defines if texture must be inverted on Y axis (default is false)
  64969. */
  64970. invertY?: boolean | undefined;
  64971. /**
  64972. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64973. */
  64974. samplingMode: number;
  64975. /**
  64976. * Gets the loaded texture
  64977. */
  64978. texture: Texture;
  64979. /**
  64980. * Callback called when the task is successful
  64981. */
  64982. onSuccess: (task: TextureAssetTask) => void;
  64983. /**
  64984. * Callback called when the task is successful
  64985. */
  64986. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64987. /**
  64988. * Creates a new TextureAssetTask object
  64989. * @param name defines the name of the task
  64990. * @param url defines the location of the file to load
  64991. * @param noMipmap defines if mipmap should not be generated (default is false)
  64992. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64993. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64994. */
  64995. constructor(
  64996. /**
  64997. * Defines the name of the task
  64998. */
  64999. name: string,
  65000. /**
  65001. * Defines the location of the file to load
  65002. */
  65003. url: string,
  65004. /**
  65005. * Defines if mipmap should not be generated (default is false)
  65006. */
  65007. noMipmap?: boolean | undefined,
  65008. /**
  65009. * Defines if texture must be inverted on Y axis (default is false)
  65010. */
  65011. invertY?: boolean | undefined,
  65012. /**
  65013. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65014. */
  65015. samplingMode?: number);
  65016. /**
  65017. * Execute the current task
  65018. * @param scene defines the scene where you want your assets to be loaded
  65019. * @param onSuccess is a callback called when the task is successfully executed
  65020. * @param onError is a callback called if an error occurs
  65021. */
  65022. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65023. }
  65024. /**
  65025. * Define a task used by AssetsManager to load cube textures
  65026. */
  65027. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65028. /**
  65029. * Defines the name of the task
  65030. */
  65031. name: string;
  65032. /**
  65033. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65034. */
  65035. url: string;
  65036. /**
  65037. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65038. */
  65039. extensions?: string[] | undefined;
  65040. /**
  65041. * Defines if mipmaps should not be generated (default is false)
  65042. */
  65043. noMipmap?: boolean | undefined;
  65044. /**
  65045. * Defines the explicit list of files (undefined by default)
  65046. */
  65047. files?: string[] | undefined;
  65048. /**
  65049. * Gets the loaded texture
  65050. */
  65051. texture: CubeTexture;
  65052. /**
  65053. * Callback called when the task is successful
  65054. */
  65055. onSuccess: (task: CubeTextureAssetTask) => void;
  65056. /**
  65057. * Callback called when the task is successful
  65058. */
  65059. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65060. /**
  65061. * Creates a new CubeTextureAssetTask
  65062. * @param name defines the name of the task
  65063. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65064. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65065. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65066. * @param files defines the explicit list of files (undefined by default)
  65067. */
  65068. constructor(
  65069. /**
  65070. * Defines the name of the task
  65071. */
  65072. name: string,
  65073. /**
  65074. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65075. */
  65076. url: string,
  65077. /**
  65078. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65079. */
  65080. extensions?: string[] | undefined,
  65081. /**
  65082. * Defines if mipmaps should not be generated (default is false)
  65083. */
  65084. noMipmap?: boolean | undefined,
  65085. /**
  65086. * Defines the explicit list of files (undefined by default)
  65087. */
  65088. files?: string[] | undefined);
  65089. /**
  65090. * Execute the current task
  65091. * @param scene defines the scene where you want your assets to be loaded
  65092. * @param onSuccess is a callback called when the task is successfully executed
  65093. * @param onError is a callback called if an error occurs
  65094. */
  65095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65096. }
  65097. /**
  65098. * Define a task used by AssetsManager to load HDR cube textures
  65099. */
  65100. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65101. /**
  65102. * Defines the name of the task
  65103. */
  65104. name: string;
  65105. /**
  65106. * Defines the location of the file to load
  65107. */
  65108. url: string;
  65109. /**
  65110. * Defines the desired size (the more it increases the longer the generation will be)
  65111. */
  65112. size: number;
  65113. /**
  65114. * Defines if mipmaps should not be generated (default is false)
  65115. */
  65116. noMipmap: boolean;
  65117. /**
  65118. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65119. */
  65120. generateHarmonics: boolean;
  65121. /**
  65122. * 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)
  65123. */
  65124. gammaSpace: boolean;
  65125. /**
  65126. * Internal Use Only
  65127. */
  65128. reserved: boolean;
  65129. /**
  65130. * Gets the loaded texture
  65131. */
  65132. texture: HDRCubeTexture;
  65133. /**
  65134. * Callback called when the task is successful
  65135. */
  65136. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65137. /**
  65138. * Callback called when the task is successful
  65139. */
  65140. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65141. /**
  65142. * Creates a new HDRCubeTextureAssetTask object
  65143. * @param name defines the name of the task
  65144. * @param url defines the location of the file to load
  65145. * @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.
  65146. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65147. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65148. * @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)
  65149. * @param reserved Internal use only
  65150. */
  65151. constructor(
  65152. /**
  65153. * Defines the name of the task
  65154. */
  65155. name: string,
  65156. /**
  65157. * Defines the location of the file to load
  65158. */
  65159. url: string,
  65160. /**
  65161. * Defines the desired size (the more it increases the longer the generation will be)
  65162. */
  65163. size: number,
  65164. /**
  65165. * Defines if mipmaps should not be generated (default is false)
  65166. */
  65167. noMipmap?: boolean,
  65168. /**
  65169. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65170. */
  65171. generateHarmonics?: boolean,
  65172. /**
  65173. * 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)
  65174. */
  65175. gammaSpace?: boolean,
  65176. /**
  65177. * Internal Use Only
  65178. */
  65179. reserved?: boolean);
  65180. /**
  65181. * Execute the current task
  65182. * @param scene defines the scene where you want your assets to be loaded
  65183. * @param onSuccess is a callback called when the task is successfully executed
  65184. * @param onError is a callback called if an error occurs
  65185. */
  65186. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65187. }
  65188. /**
  65189. * Define a task used by AssetsManager to load Equirectangular cube textures
  65190. */
  65191. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65192. /**
  65193. * Defines the name of the task
  65194. */
  65195. name: string;
  65196. /**
  65197. * Defines the location of the file to load
  65198. */
  65199. url: string;
  65200. /**
  65201. * Defines the desired size (the more it increases the longer the generation will be)
  65202. */
  65203. size: number;
  65204. /**
  65205. * Defines if mipmaps should not be generated (default is false)
  65206. */
  65207. noMipmap: boolean;
  65208. /**
  65209. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65210. * but the standard material would require them in Gamma space) (default is true)
  65211. */
  65212. gammaSpace: boolean;
  65213. /**
  65214. * Gets the loaded texture
  65215. */
  65216. texture: EquiRectangularCubeTexture;
  65217. /**
  65218. * Callback called when the task is successful
  65219. */
  65220. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65221. /**
  65222. * Callback called when the task is successful
  65223. */
  65224. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65225. /**
  65226. * Creates a new EquiRectangularCubeTextureAssetTask object
  65227. * @param name defines the name of the task
  65228. * @param url defines the location of the file to load
  65229. * @param size defines the desired size (the more it increases the longer the generation will be)
  65230. * If the size is omitted this implies you are using a preprocessed cubemap.
  65231. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65232. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65233. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65234. * (default is true)
  65235. */
  65236. constructor(
  65237. /**
  65238. * Defines the name of the task
  65239. */
  65240. name: string,
  65241. /**
  65242. * Defines the location of the file to load
  65243. */
  65244. url: string,
  65245. /**
  65246. * Defines the desired size (the more it increases the longer the generation will be)
  65247. */
  65248. size: number,
  65249. /**
  65250. * Defines if mipmaps should not be generated (default is false)
  65251. */
  65252. noMipmap?: boolean,
  65253. /**
  65254. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65255. * but the standard material would require them in Gamma space) (default is true)
  65256. */
  65257. gammaSpace?: boolean);
  65258. /**
  65259. * Execute the current task
  65260. * @param scene defines the scene where you want your assets to be loaded
  65261. * @param onSuccess is a callback called when the task is successfully executed
  65262. * @param onError is a callback called if an error occurs
  65263. */
  65264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65265. }
  65266. /**
  65267. * This class can be used to easily import assets into a scene
  65268. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65269. */
  65270. export class AssetsManager {
  65271. private _scene;
  65272. private _isLoading;
  65273. protected _tasks: AbstractAssetTask[];
  65274. protected _waitingTasksCount: number;
  65275. protected _totalTasksCount: number;
  65276. /**
  65277. * Callback called when all tasks are processed
  65278. */
  65279. onFinish: (tasks: AbstractAssetTask[]) => void;
  65280. /**
  65281. * Callback called when a task is successful
  65282. */
  65283. onTaskSuccess: (task: AbstractAssetTask) => void;
  65284. /**
  65285. * Callback called when a task had an error
  65286. */
  65287. onTaskError: (task: AbstractAssetTask) => void;
  65288. /**
  65289. * Callback called when a task is done (whatever the result is)
  65290. */
  65291. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65292. /**
  65293. * Observable called when all tasks are processed
  65294. */
  65295. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65296. /**
  65297. * Observable called when a task had an error
  65298. */
  65299. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65300. /**
  65301. * Observable called when all tasks were executed
  65302. */
  65303. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65304. /**
  65305. * Observable called when a task is done (whatever the result is)
  65306. */
  65307. onProgressObservable: Observable<IAssetsProgressEvent>;
  65308. /**
  65309. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65310. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65311. */
  65312. useDefaultLoadingScreen: boolean;
  65313. /**
  65314. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65315. * when all assets have been downloaded.
  65316. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65317. */
  65318. autoHideLoadingUI: boolean;
  65319. /**
  65320. * Creates a new AssetsManager
  65321. * @param scene defines the scene to work on
  65322. */
  65323. constructor(scene: Scene);
  65324. /**
  65325. * Add a MeshAssetTask to the list of active tasks
  65326. * @param taskName defines the name of the new task
  65327. * @param meshesNames defines the name of meshes to load
  65328. * @param rootUrl defines the root url to use to locate files
  65329. * @param sceneFilename defines the filename of the scene file
  65330. * @returns a new MeshAssetTask object
  65331. */
  65332. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65333. /**
  65334. * Add a TextFileAssetTask to the list of active tasks
  65335. * @param taskName defines the name of the new task
  65336. * @param url defines the url of the file to load
  65337. * @returns a new TextFileAssetTask object
  65338. */
  65339. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65340. /**
  65341. * Add a BinaryFileAssetTask to the list of active tasks
  65342. * @param taskName defines the name of the new task
  65343. * @param url defines the url of the file to load
  65344. * @returns a new BinaryFileAssetTask object
  65345. */
  65346. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65347. /**
  65348. * Add a ImageAssetTask to the list of active tasks
  65349. * @param taskName defines the name of the new task
  65350. * @param url defines the url of the file to load
  65351. * @returns a new ImageAssetTask object
  65352. */
  65353. addImageTask(taskName: string, url: string): ImageAssetTask;
  65354. /**
  65355. * Add a TextureAssetTask to the list of active tasks
  65356. * @param taskName defines the name of the new task
  65357. * @param url defines the url of the file to load
  65358. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65359. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65360. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65361. * @returns a new TextureAssetTask object
  65362. */
  65363. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65364. /**
  65365. * Add a CubeTextureAssetTask to the list of active tasks
  65366. * @param taskName defines the name of the new task
  65367. * @param url defines the url of the file to load
  65368. * @param extensions defines the extension to use to load the cube map (can be null)
  65369. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65370. * @param files defines the list of files to load (can be null)
  65371. * @returns a new CubeTextureAssetTask object
  65372. */
  65373. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65374. /**
  65375. *
  65376. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65377. * @param taskName defines the name of the new task
  65378. * @param url defines the url of the file to load
  65379. * @param size defines the size you want for the cubemap (can be null)
  65380. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65381. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65382. * @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)
  65383. * @param reserved Internal use only
  65384. * @returns a new HDRCubeTextureAssetTask object
  65385. */
  65386. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65387. /**
  65388. *
  65389. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65390. * @param taskName defines the name of the new task
  65391. * @param url defines the url of the file to load
  65392. * @param size defines the size you want for the cubemap (can be null)
  65393. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65394. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65395. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65396. * @returns a new EquiRectangularCubeTextureAssetTask object
  65397. */
  65398. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65399. /**
  65400. * Remove a task from the assets manager.
  65401. * @param task the task to remove
  65402. */
  65403. removeTask(task: AbstractAssetTask): void;
  65404. private _decreaseWaitingTasksCount;
  65405. private _runTask;
  65406. /**
  65407. * Reset the AssetsManager and remove all tasks
  65408. * @return the current instance of the AssetsManager
  65409. */
  65410. reset(): AssetsManager;
  65411. /**
  65412. * Start the loading process
  65413. * @return the current instance of the AssetsManager
  65414. */
  65415. load(): AssetsManager;
  65416. /**
  65417. * Start the loading process as an async operation
  65418. * @return a promise returning the list of failed tasks
  65419. */
  65420. loadAsync(): Promise<void>;
  65421. }
  65422. }
  65423. declare module "babylonjs/Misc/deferred" {
  65424. /**
  65425. * Wrapper class for promise with external resolve and reject.
  65426. */
  65427. export class Deferred<T> {
  65428. /**
  65429. * The promise associated with this deferred object.
  65430. */
  65431. readonly promise: Promise<T>;
  65432. private _resolve;
  65433. private _reject;
  65434. /**
  65435. * The resolve method of the promise associated with this deferred object.
  65436. */
  65437. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65438. /**
  65439. * The reject method of the promise associated with this deferred object.
  65440. */
  65441. readonly reject: (reason?: any) => void;
  65442. /**
  65443. * Constructor for this deferred object.
  65444. */
  65445. constructor();
  65446. }
  65447. }
  65448. declare module "babylonjs/Misc/meshExploder" {
  65449. import { Mesh } from "babylonjs/Meshes/mesh";
  65450. /**
  65451. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65452. */
  65453. export class MeshExploder {
  65454. private _centerMesh;
  65455. private _meshes;
  65456. private _meshesOrigins;
  65457. private _toCenterVectors;
  65458. private _scaledDirection;
  65459. private _newPosition;
  65460. private _centerPosition;
  65461. /**
  65462. * Explodes meshes from a center mesh.
  65463. * @param meshes The meshes to explode.
  65464. * @param centerMesh The mesh to be center of explosion.
  65465. */
  65466. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65467. private _setCenterMesh;
  65468. /**
  65469. * Get class name
  65470. * @returns "MeshExploder"
  65471. */
  65472. getClassName(): string;
  65473. /**
  65474. * "Exploded meshes"
  65475. * @returns Array of meshes with the centerMesh at index 0.
  65476. */
  65477. getMeshes(): Array<Mesh>;
  65478. /**
  65479. * Explodes meshes giving a specific direction
  65480. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65481. */
  65482. explode(direction?: number): void;
  65483. }
  65484. }
  65485. declare module "babylonjs/Misc/filesInput" {
  65486. import { Engine } from "babylonjs/Engines/engine";
  65487. import { Scene } from "babylonjs/scene";
  65488. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65489. /**
  65490. * Class used to help managing file picking and drag'n'drop
  65491. */
  65492. export class FilesInput {
  65493. /**
  65494. * List of files ready to be loaded
  65495. */
  65496. static readonly FilesToLoad: {
  65497. [key: string]: File;
  65498. };
  65499. /**
  65500. * Callback called when a file is processed
  65501. */
  65502. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65503. private _engine;
  65504. private _currentScene;
  65505. private _sceneLoadedCallback;
  65506. private _progressCallback;
  65507. private _additionalRenderLoopLogicCallback;
  65508. private _textureLoadingCallback;
  65509. private _startingProcessingFilesCallback;
  65510. private _onReloadCallback;
  65511. private _errorCallback;
  65512. private _elementToMonitor;
  65513. private _sceneFileToLoad;
  65514. private _filesToLoad;
  65515. /**
  65516. * Creates a new FilesInput
  65517. * @param engine defines the rendering engine
  65518. * @param scene defines the hosting scene
  65519. * @param sceneLoadedCallback callback called when scene is loaded
  65520. * @param progressCallback callback called to track progress
  65521. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65522. * @param textureLoadingCallback callback called when a texture is loading
  65523. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65524. * @param onReloadCallback callback called when a reload is requested
  65525. * @param errorCallback callback call if an error occurs
  65526. */
  65527. 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);
  65528. private _dragEnterHandler;
  65529. private _dragOverHandler;
  65530. private _dropHandler;
  65531. /**
  65532. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65533. * @param elementToMonitor defines the DOM element to track
  65534. */
  65535. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65536. /**
  65537. * Release all associated resources
  65538. */
  65539. dispose(): void;
  65540. private renderFunction;
  65541. private drag;
  65542. private drop;
  65543. private _traverseFolder;
  65544. private _processFiles;
  65545. /**
  65546. * Load files from a drop event
  65547. * @param event defines the drop event to use as source
  65548. */
  65549. loadFiles(event: any): void;
  65550. private _processReload;
  65551. /**
  65552. * Reload the current scene from the loaded files
  65553. */
  65554. reload(): void;
  65555. }
  65556. }
  65557. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65558. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65559. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65560. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65561. }
  65562. declare module "babylonjs/Misc/sceneOptimizer" {
  65563. import { Scene, IDisposable } from "babylonjs/scene";
  65564. import { Observable } from "babylonjs/Misc/observable";
  65565. /**
  65566. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65568. */
  65569. export class SceneOptimization {
  65570. /**
  65571. * Defines the priority of this optimization (0 by default which means first in the list)
  65572. */
  65573. priority: number;
  65574. /**
  65575. * Gets a string describing the action executed by the current optimization
  65576. * @returns description string
  65577. */
  65578. getDescription(): string;
  65579. /**
  65580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65581. * @param scene defines the current scene where to apply this optimization
  65582. * @param optimizer defines the current optimizer
  65583. * @returns true if everything that can be done was applied
  65584. */
  65585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65586. /**
  65587. * Creates the SceneOptimization object
  65588. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65589. * @param desc defines the description associated with the optimization
  65590. */
  65591. constructor(
  65592. /**
  65593. * Defines the priority of this optimization (0 by default which means first in the list)
  65594. */
  65595. priority?: number);
  65596. }
  65597. /**
  65598. * Defines an optimization used to reduce the size of render target textures
  65599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65600. */
  65601. export class TextureOptimization extends SceneOptimization {
  65602. /**
  65603. * Defines the priority of this optimization (0 by default which means first in the list)
  65604. */
  65605. priority: number;
  65606. /**
  65607. * 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
  65608. */
  65609. maximumSize: number;
  65610. /**
  65611. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65612. */
  65613. step: number;
  65614. /**
  65615. * Gets a string describing the action executed by the current optimization
  65616. * @returns description string
  65617. */
  65618. getDescription(): string;
  65619. /**
  65620. * Creates the TextureOptimization object
  65621. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65622. * @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
  65623. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65624. */
  65625. constructor(
  65626. /**
  65627. * Defines the priority of this optimization (0 by default which means first in the list)
  65628. */
  65629. priority?: number,
  65630. /**
  65631. * 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
  65632. */
  65633. maximumSize?: number,
  65634. /**
  65635. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65636. */
  65637. step?: number);
  65638. /**
  65639. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65640. * @param scene defines the current scene where to apply this optimization
  65641. * @param optimizer defines the current optimizer
  65642. * @returns true if everything that can be done was applied
  65643. */
  65644. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65645. }
  65646. /**
  65647. * Defines an optimization used to increase or decrease the rendering resolution
  65648. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65649. */
  65650. export class HardwareScalingOptimization extends SceneOptimization {
  65651. /**
  65652. * Defines the priority of this optimization (0 by default which means first in the list)
  65653. */
  65654. priority: number;
  65655. /**
  65656. * Defines the maximum scale to use (2 by default)
  65657. */
  65658. maximumScale: number;
  65659. /**
  65660. * Defines the step to use between two passes (0.5 by default)
  65661. */
  65662. step: number;
  65663. private _currentScale;
  65664. private _directionOffset;
  65665. /**
  65666. * Gets a string describing the action executed by the current optimization
  65667. * @return description string
  65668. */
  65669. getDescription(): string;
  65670. /**
  65671. * Creates the HardwareScalingOptimization object
  65672. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65673. * @param maximumScale defines the maximum scale to use (2 by default)
  65674. * @param step defines the step to use between two passes (0.5 by default)
  65675. */
  65676. constructor(
  65677. /**
  65678. * Defines the priority of this optimization (0 by default which means first in the list)
  65679. */
  65680. priority?: number,
  65681. /**
  65682. * Defines the maximum scale to use (2 by default)
  65683. */
  65684. maximumScale?: number,
  65685. /**
  65686. * Defines the step to use between two passes (0.5 by default)
  65687. */
  65688. step?: number);
  65689. /**
  65690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65691. * @param scene defines the current scene where to apply this optimization
  65692. * @param optimizer defines the current optimizer
  65693. * @returns true if everything that can be done was applied
  65694. */
  65695. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65696. }
  65697. /**
  65698. * Defines an optimization used to remove shadows
  65699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65700. */
  65701. export class ShadowsOptimization extends SceneOptimization {
  65702. /**
  65703. * Gets a string describing the action executed by the current optimization
  65704. * @return description string
  65705. */
  65706. getDescription(): string;
  65707. /**
  65708. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65709. * @param scene defines the current scene where to apply this optimization
  65710. * @param optimizer defines the current optimizer
  65711. * @returns true if everything that can be done was applied
  65712. */
  65713. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65714. }
  65715. /**
  65716. * Defines an optimization used to turn post-processes off
  65717. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65718. */
  65719. export class PostProcessesOptimization extends SceneOptimization {
  65720. /**
  65721. * Gets a string describing the action executed by the current optimization
  65722. * @return description string
  65723. */
  65724. getDescription(): string;
  65725. /**
  65726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65727. * @param scene defines the current scene where to apply this optimization
  65728. * @param optimizer defines the current optimizer
  65729. * @returns true if everything that can be done was applied
  65730. */
  65731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65732. }
  65733. /**
  65734. * Defines an optimization used to turn lens flares off
  65735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65736. */
  65737. export class LensFlaresOptimization extends SceneOptimization {
  65738. /**
  65739. * Gets a string describing the action executed by the current optimization
  65740. * @return description string
  65741. */
  65742. getDescription(): string;
  65743. /**
  65744. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65745. * @param scene defines the current scene where to apply this optimization
  65746. * @param optimizer defines the current optimizer
  65747. * @returns true if everything that can be done was applied
  65748. */
  65749. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65750. }
  65751. /**
  65752. * Defines an optimization based on user defined callback.
  65753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65754. */
  65755. export class CustomOptimization extends SceneOptimization {
  65756. /**
  65757. * Callback called to apply the custom optimization.
  65758. */
  65759. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65760. /**
  65761. * Callback called to get custom description
  65762. */
  65763. onGetDescription: () => string;
  65764. /**
  65765. * Gets a string describing the action executed by the current optimization
  65766. * @returns description string
  65767. */
  65768. getDescription(): string;
  65769. /**
  65770. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65771. * @param scene defines the current scene where to apply this optimization
  65772. * @param optimizer defines the current optimizer
  65773. * @returns true if everything that can be done was applied
  65774. */
  65775. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65776. }
  65777. /**
  65778. * Defines an optimization used to turn particles off
  65779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65780. */
  65781. export class ParticlesOptimization extends SceneOptimization {
  65782. /**
  65783. * Gets a string describing the action executed by the current optimization
  65784. * @return description string
  65785. */
  65786. getDescription(): string;
  65787. /**
  65788. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65789. * @param scene defines the current scene where to apply this optimization
  65790. * @param optimizer defines the current optimizer
  65791. * @returns true if everything that can be done was applied
  65792. */
  65793. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65794. }
  65795. /**
  65796. * Defines an optimization used to turn render targets off
  65797. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65798. */
  65799. export class RenderTargetsOptimization extends SceneOptimization {
  65800. /**
  65801. * Gets a string describing the action executed by the current optimization
  65802. * @return description string
  65803. */
  65804. getDescription(): string;
  65805. /**
  65806. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65807. * @param scene defines the current scene where to apply this optimization
  65808. * @param optimizer defines the current optimizer
  65809. * @returns true if everything that can be done was applied
  65810. */
  65811. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65812. }
  65813. /**
  65814. * Defines an optimization used to merge meshes with compatible materials
  65815. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65816. */
  65817. export class MergeMeshesOptimization extends SceneOptimization {
  65818. private static _UpdateSelectionTree;
  65819. /**
  65820. * Gets or sets a boolean which defines if optimization octree has to be updated
  65821. */
  65822. /**
  65823. * Gets or sets a boolean which defines if optimization octree has to be updated
  65824. */
  65825. static UpdateSelectionTree: boolean;
  65826. /**
  65827. * Gets a string describing the action executed by the current optimization
  65828. * @return description string
  65829. */
  65830. getDescription(): string;
  65831. private _canBeMerged;
  65832. /**
  65833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65834. * @param scene defines the current scene where to apply this optimization
  65835. * @param optimizer defines the current optimizer
  65836. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65837. * @returns true if everything that can be done was applied
  65838. */
  65839. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65840. }
  65841. /**
  65842. * Defines a list of options used by SceneOptimizer
  65843. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65844. */
  65845. export class SceneOptimizerOptions {
  65846. /**
  65847. * Defines the target frame rate to reach (60 by default)
  65848. */
  65849. targetFrameRate: number;
  65850. /**
  65851. * Defines the interval between two checkes (2000ms by default)
  65852. */
  65853. trackerDuration: number;
  65854. /**
  65855. * Gets the list of optimizations to apply
  65856. */
  65857. optimizations: SceneOptimization[];
  65858. /**
  65859. * Creates a new list of options used by SceneOptimizer
  65860. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65861. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65862. */
  65863. constructor(
  65864. /**
  65865. * Defines the target frame rate to reach (60 by default)
  65866. */
  65867. targetFrameRate?: number,
  65868. /**
  65869. * Defines the interval between two checkes (2000ms by default)
  65870. */
  65871. trackerDuration?: number);
  65872. /**
  65873. * Add a new optimization
  65874. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65875. * @returns the current SceneOptimizerOptions
  65876. */
  65877. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65878. /**
  65879. * Add a new custom optimization
  65880. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65881. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65882. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65883. * @returns the current SceneOptimizerOptions
  65884. */
  65885. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65886. /**
  65887. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65888. * @param targetFrameRate defines the target frame rate (60 by default)
  65889. * @returns a SceneOptimizerOptions object
  65890. */
  65891. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65892. /**
  65893. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65894. * @param targetFrameRate defines the target frame rate (60 by default)
  65895. * @returns a SceneOptimizerOptions object
  65896. */
  65897. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65898. /**
  65899. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65900. * @param targetFrameRate defines the target frame rate (60 by default)
  65901. * @returns a SceneOptimizerOptions object
  65902. */
  65903. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65904. }
  65905. /**
  65906. * Class used to run optimizations in order to reach a target frame rate
  65907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65908. */
  65909. export class SceneOptimizer implements IDisposable {
  65910. private _isRunning;
  65911. private _options;
  65912. private _scene;
  65913. private _currentPriorityLevel;
  65914. private _targetFrameRate;
  65915. private _trackerDuration;
  65916. private _currentFrameRate;
  65917. private _sceneDisposeObserver;
  65918. private _improvementMode;
  65919. /**
  65920. * Defines an observable called when the optimizer reaches the target frame rate
  65921. */
  65922. onSuccessObservable: Observable<SceneOptimizer>;
  65923. /**
  65924. * Defines an observable called when the optimizer enables an optimization
  65925. */
  65926. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65927. /**
  65928. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65929. */
  65930. onFailureObservable: Observable<SceneOptimizer>;
  65931. /**
  65932. * Gets a boolean indicating if the optimizer is in improvement mode
  65933. */
  65934. readonly isInImprovementMode: boolean;
  65935. /**
  65936. * Gets the current priority level (0 at start)
  65937. */
  65938. readonly currentPriorityLevel: number;
  65939. /**
  65940. * Gets the current frame rate checked by the SceneOptimizer
  65941. */
  65942. readonly currentFrameRate: number;
  65943. /**
  65944. * Gets or sets the current target frame rate (60 by default)
  65945. */
  65946. /**
  65947. * Gets or sets the current target frame rate (60 by default)
  65948. */
  65949. targetFrameRate: number;
  65950. /**
  65951. * Gets or sets the current interval between two checks (every 2000ms by default)
  65952. */
  65953. /**
  65954. * Gets or sets the current interval between two checks (every 2000ms by default)
  65955. */
  65956. trackerDuration: number;
  65957. /**
  65958. * Gets the list of active optimizations
  65959. */
  65960. readonly optimizations: SceneOptimization[];
  65961. /**
  65962. * Creates a new SceneOptimizer
  65963. * @param scene defines the scene to work on
  65964. * @param options defines the options to use with the SceneOptimizer
  65965. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65966. * @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)
  65967. */
  65968. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65969. /**
  65970. * Stops the current optimizer
  65971. */
  65972. stop(): void;
  65973. /**
  65974. * Reset the optimizer to initial step (current priority level = 0)
  65975. */
  65976. reset(): void;
  65977. /**
  65978. * Start the optimizer. By default it will try to reach a specific framerate
  65979. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65980. */
  65981. start(): void;
  65982. private _checkCurrentState;
  65983. /**
  65984. * Release all resources
  65985. */
  65986. dispose(): void;
  65987. /**
  65988. * Helper function to create a SceneOptimizer with one single line of code
  65989. * @param scene defines the scene to work on
  65990. * @param options defines the options to use with the SceneOptimizer
  65991. * @param onSuccess defines a callback to call on success
  65992. * @param onFailure defines a callback to call on failure
  65993. * @returns the new SceneOptimizer object
  65994. */
  65995. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65996. }
  65997. }
  65998. declare module "babylonjs/Misc/sceneSerializer" {
  65999. import { Scene } from "babylonjs/scene";
  66000. /**
  66001. * Class used to serialize a scene into a string
  66002. */
  66003. export class SceneSerializer {
  66004. /**
  66005. * Clear cache used by a previous serialization
  66006. */
  66007. static ClearCache(): void;
  66008. /**
  66009. * Serialize a scene into a JSON compatible object
  66010. * @param scene defines the scene to serialize
  66011. * @returns a JSON compatible object
  66012. */
  66013. static Serialize(scene: Scene): any;
  66014. /**
  66015. * Serialize a mesh into a JSON compatible object
  66016. * @param toSerialize defines the mesh to serialize
  66017. * @param withParents defines if parents must be serialized as well
  66018. * @param withChildren defines if children must be serialized as well
  66019. * @returns a JSON compatible object
  66020. */
  66021. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66022. }
  66023. }
  66024. declare module "babylonjs/Misc/textureTools" {
  66025. import { Texture } from "babylonjs/Materials/Textures/texture";
  66026. /**
  66027. * Class used to host texture specific utilities
  66028. */
  66029. export class TextureTools {
  66030. /**
  66031. * Uses the GPU to create a copy texture rescaled at a given size
  66032. * @param texture Texture to copy from
  66033. * @param width defines the desired width
  66034. * @param height defines the desired height
  66035. * @param useBilinearMode defines if bilinear mode has to be used
  66036. * @return the generated texture
  66037. */
  66038. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66039. }
  66040. }
  66041. declare module "babylonjs/Misc/videoRecorder" {
  66042. import { Nullable } from "babylonjs/types";
  66043. import { Engine } from "babylonjs/Engines/engine";
  66044. /**
  66045. * This represents the different options available for the video capture.
  66046. */
  66047. export interface VideoRecorderOptions {
  66048. /** Defines the mime type of the video. */
  66049. mimeType: string;
  66050. /** Defines the FPS the video should be recorded at. */
  66051. fps: number;
  66052. /** Defines the chunk size for the recording data. */
  66053. recordChunckSize: number;
  66054. /** The audio tracks to attach to the recording. */
  66055. audioTracks?: MediaStreamTrack[];
  66056. }
  66057. /**
  66058. * This can help with recording videos from BabylonJS.
  66059. * This is based on the available WebRTC functionalities of the browser.
  66060. *
  66061. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66062. */
  66063. export class VideoRecorder {
  66064. private static readonly _defaultOptions;
  66065. /**
  66066. * Returns whether or not the VideoRecorder is available in your browser.
  66067. * @param engine Defines the Babylon Engine.
  66068. * @returns true if supported otherwise false.
  66069. */
  66070. static IsSupported(engine: Engine): boolean;
  66071. private readonly _options;
  66072. private _canvas;
  66073. private _mediaRecorder;
  66074. private _recordedChunks;
  66075. private _fileName;
  66076. private _resolve;
  66077. private _reject;
  66078. /**
  66079. * True when a recording is already in progress.
  66080. */
  66081. readonly isRecording: boolean;
  66082. /**
  66083. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66084. * @param engine Defines the BabylonJS Engine you wish to record.
  66085. * @param options Defines options that can be used to customize the capture.
  66086. */
  66087. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66088. /**
  66089. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66090. */
  66091. stopRecording(): void;
  66092. /**
  66093. * Starts recording the canvas for a max duration specified in parameters.
  66094. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66095. * If null no automatic download will start and you can rely on the promise to get the data back.
  66096. * @param maxDuration Defines the maximum recording time in seconds.
  66097. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66098. * @return A promise callback at the end of the recording with the video data in Blob.
  66099. */
  66100. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66101. /**
  66102. * Releases internal resources used during the recording.
  66103. */
  66104. dispose(): void;
  66105. private _handleDataAvailable;
  66106. private _handleError;
  66107. private _handleStop;
  66108. }
  66109. }
  66110. declare module "babylonjs/Misc/screenshotTools" {
  66111. import { Camera } from "babylonjs/Cameras/camera";
  66112. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66113. import { Engine } from "babylonjs/Engines/engine";
  66114. /**
  66115. * Class containing a set of static utilities functions for screenshots
  66116. */
  66117. export class ScreenshotTools {
  66118. /**
  66119. * Captures a screenshot of the current rendering
  66120. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66121. * @param engine defines the rendering engine
  66122. * @param camera defines the source camera
  66123. * @param size This parameter can be set to a single number or to an object with the
  66124. * following (optional) properties: precision, width, height. If a single number is passed,
  66125. * it will be used for both width and height. If an object is passed, the screenshot size
  66126. * will be derived from the parameters. The precision property is a multiplier allowing
  66127. * rendering at a higher or lower resolution
  66128. * @param successCallback defines the callback receives a single parameter which contains the
  66129. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66130. * src parameter of an <img> to display it
  66131. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66132. * Check your browser for supported MIME types
  66133. */
  66134. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66135. /**
  66136. * Captures a screenshot of the current rendering
  66137. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66138. * @param engine defines the rendering engine
  66139. * @param camera defines the source camera
  66140. * @param size This parameter can be set to a single number or to an object with the
  66141. * following (optional) properties: precision, width, height. If a single number is passed,
  66142. * it will be used for both width and height. If an object is passed, the screenshot size
  66143. * will be derived from the parameters. The precision property is a multiplier allowing
  66144. * rendering at a higher or lower resolution
  66145. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66146. * Check your browser for supported MIME types
  66147. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66148. * to the src parameter of an <img> to display it
  66149. */
  66150. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66151. /**
  66152. * Generates an image screenshot from the specified camera.
  66153. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66154. * @param engine The engine to use for rendering
  66155. * @param camera The camera to use for rendering
  66156. * @param size This parameter can be set to a single number or to an object with the
  66157. * following (optional) properties: precision, width, height. If a single number is passed,
  66158. * it will be used for both width and height. If an object is passed, the screenshot size
  66159. * will be derived from the parameters. The precision property is a multiplier allowing
  66160. * rendering at a higher or lower resolution
  66161. * @param successCallback The callback receives a single parameter which contains the
  66162. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66163. * src parameter of an <img> to display it
  66164. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66165. * Check your browser for supported MIME types
  66166. * @param samples Texture samples (default: 1)
  66167. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66168. * @param fileName A name for for the downloaded file.
  66169. */
  66170. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66171. /**
  66172. * Generates an image screenshot from the specified camera.
  66173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66174. * @param engine The engine to use for rendering
  66175. * @param camera The camera to use for rendering
  66176. * @param size This parameter can be set to a single number or to an object with the
  66177. * following (optional) properties: precision, width, height. If a single number is passed,
  66178. * it will be used for both width and height. If an object is passed, the screenshot size
  66179. * will be derived from the parameters. The precision property is a multiplier allowing
  66180. * rendering at a higher or lower resolution
  66181. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66182. * Check your browser for supported MIME types
  66183. * @param samples Texture samples (default: 1)
  66184. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66185. * @param fileName A name for for the downloaded file.
  66186. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66187. * to the src parameter of an <img> to display it
  66188. */
  66189. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66190. /**
  66191. * Gets height and width for screenshot size
  66192. * @private
  66193. */
  66194. private static _getScreenshotSize;
  66195. }
  66196. }
  66197. declare module "babylonjs/Misc/index" {
  66198. export * from "babylonjs/Misc/andOrNotEvaluator";
  66199. export * from "babylonjs/Misc/assetsManager";
  66200. export * from "babylonjs/Misc/dds";
  66201. export * from "babylonjs/Misc/decorators";
  66202. export * from "babylonjs/Misc/deferred";
  66203. export * from "babylonjs/Misc/environmentTextureTools";
  66204. export * from "babylonjs/Misc/meshExploder";
  66205. export * from "babylonjs/Misc/filesInput";
  66206. export * from "babylonjs/Misc/HighDynamicRange/index";
  66207. export * from "babylonjs/Misc/khronosTextureContainer";
  66208. export * from "babylonjs/Misc/observable";
  66209. export * from "babylonjs/Misc/performanceMonitor";
  66210. export * from "babylonjs/Misc/promise";
  66211. export * from "babylonjs/Misc/sceneOptimizer";
  66212. export * from "babylonjs/Misc/sceneSerializer";
  66213. export * from "babylonjs/Misc/smartArray";
  66214. export * from "babylonjs/Misc/stringDictionary";
  66215. export * from "babylonjs/Misc/tags";
  66216. export * from "babylonjs/Misc/textureTools";
  66217. export * from "babylonjs/Misc/tga";
  66218. export * from "babylonjs/Misc/tools";
  66219. export * from "babylonjs/Misc/videoRecorder";
  66220. export * from "babylonjs/Misc/virtualJoystick";
  66221. export * from "babylonjs/Misc/workerPool";
  66222. export * from "babylonjs/Misc/logger";
  66223. export * from "babylonjs/Misc/typeStore";
  66224. export * from "babylonjs/Misc/filesInputStore";
  66225. export * from "babylonjs/Misc/deepCopier";
  66226. export * from "babylonjs/Misc/pivotTools";
  66227. export * from "babylonjs/Misc/precisionDate";
  66228. export * from "babylonjs/Misc/screenshotTools";
  66229. export * from "babylonjs/Misc/typeStore";
  66230. export * from "babylonjs/Misc/webRequest";
  66231. export * from "babylonjs/Misc/iInspectable";
  66232. export * from "babylonjs/Misc/brdfTextureTools";
  66233. export * from "babylonjs/Misc/rgbdTextureTools";
  66234. export * from "babylonjs/Misc/gradients";
  66235. export * from "babylonjs/Misc/perfCounter";
  66236. export * from "babylonjs/Misc/fileRequest";
  66237. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66238. export * from "babylonjs/Misc/retryStrategy";
  66239. export * from "babylonjs/Misc/loadFileError";
  66240. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66241. }
  66242. declare module "babylonjs/index" {
  66243. export * from "babylonjs/abstractScene";
  66244. export * from "babylonjs/Actions/index";
  66245. export * from "babylonjs/Animations/index";
  66246. export * from "babylonjs/assetContainer";
  66247. export * from "babylonjs/Audio/index";
  66248. export * from "babylonjs/Behaviors/index";
  66249. export * from "babylonjs/Bones/index";
  66250. export * from "babylonjs/Cameras/index";
  66251. export * from "babylonjs/Collisions/index";
  66252. export * from "babylonjs/Culling/index";
  66253. export * from "babylonjs/Debug/index";
  66254. export * from "babylonjs/Engines/index";
  66255. export * from "babylonjs/Events/index";
  66256. export * from "babylonjs/Gamepads/index";
  66257. export * from "babylonjs/Gizmos/index";
  66258. export * from "babylonjs/Helpers/index";
  66259. export * from "babylonjs/Instrumentation/index";
  66260. export * from "babylonjs/Layers/index";
  66261. export * from "babylonjs/LensFlares/index";
  66262. export * from "babylonjs/Lights/index";
  66263. export * from "babylonjs/Loading/index";
  66264. export * from "babylonjs/Materials/index";
  66265. export * from "babylonjs/Maths/index";
  66266. export * from "babylonjs/Meshes/index";
  66267. export * from "babylonjs/Morph/index";
  66268. export * from "babylonjs/Navigation/index";
  66269. export * from "babylonjs/node";
  66270. export * from "babylonjs/Offline/index";
  66271. export * from "babylonjs/Particles/index";
  66272. export * from "babylonjs/Physics/index";
  66273. export * from "babylonjs/PostProcesses/index";
  66274. export * from "babylonjs/Probes/index";
  66275. export * from "babylonjs/Rendering/index";
  66276. export * from "babylonjs/scene";
  66277. export * from "babylonjs/sceneComponent";
  66278. export * from "babylonjs/Sprites/index";
  66279. export * from "babylonjs/States/index";
  66280. export * from "babylonjs/Misc/index";
  66281. export * from "babylonjs/types";
  66282. }
  66283. declare module "babylonjs/Animations/pathCursor" {
  66284. import { Vector3 } from "babylonjs/Maths/math.vector";
  66285. import { Path2 } from "babylonjs/Maths/math.path";
  66286. /**
  66287. * A cursor which tracks a point on a path
  66288. */
  66289. export class PathCursor {
  66290. private path;
  66291. /**
  66292. * Stores path cursor callbacks for when an onchange event is triggered
  66293. */
  66294. private _onchange;
  66295. /**
  66296. * The value of the path cursor
  66297. */
  66298. value: number;
  66299. /**
  66300. * The animation array of the path cursor
  66301. */
  66302. animations: Animation[];
  66303. /**
  66304. * Initializes the path cursor
  66305. * @param path The path to track
  66306. */
  66307. constructor(path: Path2);
  66308. /**
  66309. * Gets the cursor point on the path
  66310. * @returns A point on the path cursor at the cursor location
  66311. */
  66312. getPoint(): Vector3;
  66313. /**
  66314. * Moves the cursor ahead by the step amount
  66315. * @param step The amount to move the cursor forward
  66316. * @returns This path cursor
  66317. */
  66318. moveAhead(step?: number): PathCursor;
  66319. /**
  66320. * Moves the cursor behind by the step amount
  66321. * @param step The amount to move the cursor back
  66322. * @returns This path cursor
  66323. */
  66324. moveBack(step?: number): PathCursor;
  66325. /**
  66326. * Moves the cursor by the step amount
  66327. * If the step amount is greater than one, an exception is thrown
  66328. * @param step The amount to move the cursor
  66329. * @returns This path cursor
  66330. */
  66331. move(step: number): PathCursor;
  66332. /**
  66333. * Ensures that the value is limited between zero and one
  66334. * @returns This path cursor
  66335. */
  66336. private ensureLimits;
  66337. /**
  66338. * Runs onchange callbacks on change (used by the animation engine)
  66339. * @returns This path cursor
  66340. */
  66341. private raiseOnChange;
  66342. /**
  66343. * Executes a function on change
  66344. * @param f A path cursor onchange callback
  66345. * @returns This path cursor
  66346. */
  66347. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66348. }
  66349. }
  66350. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66351. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66352. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66353. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66354. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66355. }
  66356. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66357. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66358. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66359. }
  66360. declare module "babylonjs/Engines/Processors/index" {
  66361. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66362. export * from "babylonjs/Engines/Processors/Expressions/index";
  66363. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66364. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66365. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66366. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66367. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66368. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66369. }
  66370. declare module "babylonjs/Legacy/legacy" {
  66371. import * as Babylon from "babylonjs/index";
  66372. export * from "babylonjs/index";
  66373. }
  66374. declare module "babylonjs/Shaders/blur.fragment" {
  66375. /** @hidden */
  66376. export var blurPixelShader: {
  66377. name: string;
  66378. shader: string;
  66379. };
  66380. }
  66381. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66382. /** @hidden */
  66383. export var pointCloudVertexDeclaration: {
  66384. name: string;
  66385. shader: string;
  66386. };
  66387. }
  66388. declare module "babylonjs" {
  66389. export * from "babylonjs/Legacy/legacy";
  66390. }
  66391. declare module BABYLON {
  66392. /** Alias type for value that can be null */
  66393. export type Nullable<T> = T | null;
  66394. /**
  66395. * Alias type for number that are floats
  66396. * @ignorenaming
  66397. */
  66398. export type float = number;
  66399. /**
  66400. * Alias type for number that are doubles.
  66401. * @ignorenaming
  66402. */
  66403. export type double = number;
  66404. /**
  66405. * Alias type for number that are integer
  66406. * @ignorenaming
  66407. */
  66408. export type int = number;
  66409. /** Alias type for number array or Float32Array */
  66410. export type FloatArray = number[] | Float32Array;
  66411. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66412. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66413. /**
  66414. * Alias for types that can be used by a Buffer or VertexBuffer.
  66415. */
  66416. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66417. /**
  66418. * Alias type for primitive types
  66419. * @ignorenaming
  66420. */
  66421. type Primitive = undefined | null | boolean | string | number | Function;
  66422. /**
  66423. * Type modifier to make all the properties of an object Readonly
  66424. */
  66425. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66426. /**
  66427. * Type modifier to make all the properties of an object Readonly recursively
  66428. */
  66429. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66430. /**
  66431. * Type modifier to make object properties readonly.
  66432. */
  66433. export type DeepImmutableObject<T> = {
  66434. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66435. };
  66436. /** @hidden */
  66437. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66438. }
  66439. }
  66440. declare module BABYLON {
  66441. /**
  66442. * A class serves as a medium between the observable and its observers
  66443. */
  66444. export class EventState {
  66445. /**
  66446. * Create a new EventState
  66447. * @param mask defines the mask associated with this state
  66448. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66449. * @param target defines the original target of the state
  66450. * @param currentTarget defines the current target of the state
  66451. */
  66452. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66453. /**
  66454. * Initialize the current event state
  66455. * @param mask defines the mask associated with this state
  66456. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66457. * @param target defines the original target of the state
  66458. * @param currentTarget defines the current target of the state
  66459. * @returns the current event state
  66460. */
  66461. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66462. /**
  66463. * An Observer can set this property to true to prevent subsequent observers of being notified
  66464. */
  66465. skipNextObservers: boolean;
  66466. /**
  66467. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66468. */
  66469. mask: number;
  66470. /**
  66471. * The object that originally notified the event
  66472. */
  66473. target?: any;
  66474. /**
  66475. * The current object in the bubbling phase
  66476. */
  66477. currentTarget?: any;
  66478. /**
  66479. * This will be populated with the return value of the last function that was executed.
  66480. * If it is the first function in the callback chain it will be the event data.
  66481. */
  66482. lastReturnValue?: any;
  66483. }
  66484. /**
  66485. * Represent an Observer registered to a given Observable object.
  66486. */
  66487. export class Observer<T> {
  66488. /**
  66489. * Defines the callback to call when the observer is notified
  66490. */
  66491. callback: (eventData: T, eventState: EventState) => void;
  66492. /**
  66493. * Defines the mask of the observer (used to filter notifications)
  66494. */
  66495. mask: number;
  66496. /**
  66497. * Defines the current scope used to restore the JS context
  66498. */
  66499. scope: any;
  66500. /** @hidden */
  66501. _willBeUnregistered: boolean;
  66502. /**
  66503. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66504. */
  66505. unregisterOnNextCall: boolean;
  66506. /**
  66507. * Creates a new observer
  66508. * @param callback defines the callback to call when the observer is notified
  66509. * @param mask defines the mask of the observer (used to filter notifications)
  66510. * @param scope defines the current scope used to restore the JS context
  66511. */
  66512. constructor(
  66513. /**
  66514. * Defines the callback to call when the observer is notified
  66515. */
  66516. callback: (eventData: T, eventState: EventState) => void,
  66517. /**
  66518. * Defines the mask of the observer (used to filter notifications)
  66519. */
  66520. mask: number,
  66521. /**
  66522. * Defines the current scope used to restore the JS context
  66523. */
  66524. scope?: any);
  66525. }
  66526. /**
  66527. * Represent a list of observers registered to multiple Observables object.
  66528. */
  66529. export class MultiObserver<T> {
  66530. private _observers;
  66531. private _observables;
  66532. /**
  66533. * Release associated resources
  66534. */
  66535. dispose(): void;
  66536. /**
  66537. * Raise a callback when one of the observable will notify
  66538. * @param observables defines a list of observables to watch
  66539. * @param callback defines the callback to call on notification
  66540. * @param mask defines the mask used to filter notifications
  66541. * @param scope defines the current scope used to restore the JS context
  66542. * @returns the new MultiObserver
  66543. */
  66544. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66545. }
  66546. /**
  66547. * The Observable class is a simple implementation of the Observable pattern.
  66548. *
  66549. * 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.
  66550. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66551. * 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).
  66552. * 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.
  66553. */
  66554. export class Observable<T> {
  66555. private _observers;
  66556. private _eventState;
  66557. private _onObserverAdded;
  66558. /**
  66559. * Gets the list of observers
  66560. */
  66561. readonly observers: Array<Observer<T>>;
  66562. /**
  66563. * Creates a new observable
  66564. * @param onObserverAdded defines a callback to call when a new observer is added
  66565. */
  66566. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66567. /**
  66568. * Create a new Observer with the specified callback
  66569. * @param callback the callback that will be executed for that Observer
  66570. * @param mask the mask used to filter observers
  66571. * @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.
  66572. * @param scope optional scope for the callback to be called from
  66573. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66574. * @returns the new observer created for the callback
  66575. */
  66576. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66577. /**
  66578. * Create a new Observer with the specified callback and unregisters after the next notification
  66579. * @param callback the callback that will be executed for that Observer
  66580. * @returns the new observer created for the callback
  66581. */
  66582. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66583. /**
  66584. * Remove an Observer from the Observable object
  66585. * @param observer the instance of the Observer to remove
  66586. * @returns false if it doesn't belong to this Observable
  66587. */
  66588. remove(observer: Nullable<Observer<T>>): boolean;
  66589. /**
  66590. * Remove a callback from the Observable object
  66591. * @param callback the callback to remove
  66592. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66593. * @returns false if it doesn't belong to this Observable
  66594. */
  66595. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66596. private _deferUnregister;
  66597. private _remove;
  66598. /**
  66599. * Moves the observable to the top of the observer list making it get called first when notified
  66600. * @param observer the observer to move
  66601. */
  66602. makeObserverTopPriority(observer: Observer<T>): void;
  66603. /**
  66604. * Moves the observable to the bottom of the observer list making it get called last when notified
  66605. * @param observer the observer to move
  66606. */
  66607. makeObserverBottomPriority(observer: Observer<T>): void;
  66608. /**
  66609. * Notify all Observers by calling their respective callback with the given data
  66610. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66611. * @param eventData defines the data to send to all observers
  66612. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66613. * @param target defines the original target of the state
  66614. * @param currentTarget defines the current target of the state
  66615. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66616. */
  66617. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66618. /**
  66619. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66620. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66621. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66622. * and it is crucial that all callbacks will be executed.
  66623. * The order of the callbacks is kept, callbacks are not executed parallel.
  66624. *
  66625. * @param eventData The data to be sent to each callback
  66626. * @param mask is used to filter observers defaults to -1
  66627. * @param target defines the callback target (see EventState)
  66628. * @param currentTarget defines he current object in the bubbling phase
  66629. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66630. */
  66631. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66632. /**
  66633. * Notify a specific observer
  66634. * @param observer defines the observer to notify
  66635. * @param eventData defines the data to be sent to each callback
  66636. * @param mask is used to filter observers defaults to -1
  66637. */
  66638. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66639. /**
  66640. * Gets a boolean indicating if the observable has at least one observer
  66641. * @returns true is the Observable has at least one Observer registered
  66642. */
  66643. hasObservers(): boolean;
  66644. /**
  66645. * Clear the list of observers
  66646. */
  66647. clear(): void;
  66648. /**
  66649. * Clone the current observable
  66650. * @returns a new observable
  66651. */
  66652. clone(): Observable<T>;
  66653. /**
  66654. * Does this observable handles observer registered with a given mask
  66655. * @param mask defines the mask to be tested
  66656. * @return whether or not one observer registered with the given mask is handeled
  66657. **/
  66658. hasSpecificMask(mask?: number): boolean;
  66659. }
  66660. }
  66661. declare module BABYLON {
  66662. /**
  66663. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66664. * Babylon.js
  66665. */
  66666. export class DomManagement {
  66667. /**
  66668. * Checks if the window object exists
  66669. * @returns true if the window object exists
  66670. */
  66671. static IsWindowObjectExist(): boolean;
  66672. /**
  66673. * Checks if the navigator object exists
  66674. * @returns true if the navigator object exists
  66675. */
  66676. static IsNavigatorAvailable(): boolean;
  66677. /**
  66678. * Extracts text content from a DOM element hierarchy
  66679. * @param element defines the root element
  66680. * @returns a string
  66681. */
  66682. static GetDOMTextContent(element: HTMLElement): string;
  66683. }
  66684. }
  66685. declare module BABYLON {
  66686. /**
  66687. * Logger used througouht the application to allow configuration of
  66688. * the log level required for the messages.
  66689. */
  66690. export class Logger {
  66691. /**
  66692. * No log
  66693. */
  66694. static readonly NoneLogLevel: number;
  66695. /**
  66696. * Only message logs
  66697. */
  66698. static readonly MessageLogLevel: number;
  66699. /**
  66700. * Only warning logs
  66701. */
  66702. static readonly WarningLogLevel: number;
  66703. /**
  66704. * Only error logs
  66705. */
  66706. static readonly ErrorLogLevel: number;
  66707. /**
  66708. * All logs
  66709. */
  66710. static readonly AllLogLevel: number;
  66711. private static _LogCache;
  66712. /**
  66713. * Gets a value indicating the number of loading errors
  66714. * @ignorenaming
  66715. */
  66716. static errorsCount: number;
  66717. /**
  66718. * Callback called when a new log is added
  66719. */
  66720. static OnNewCacheEntry: (entry: string) => void;
  66721. private static _AddLogEntry;
  66722. private static _FormatMessage;
  66723. private static _LogDisabled;
  66724. private static _LogEnabled;
  66725. private static _WarnDisabled;
  66726. private static _WarnEnabled;
  66727. private static _ErrorDisabled;
  66728. private static _ErrorEnabled;
  66729. /**
  66730. * Log a message to the console
  66731. */
  66732. static Log: (message: string) => void;
  66733. /**
  66734. * Write a warning message to the console
  66735. */
  66736. static Warn: (message: string) => void;
  66737. /**
  66738. * Write an error message to the console
  66739. */
  66740. static Error: (message: string) => void;
  66741. /**
  66742. * Gets current log cache (list of logs)
  66743. */
  66744. static readonly LogCache: string;
  66745. /**
  66746. * Clears the log cache
  66747. */
  66748. static ClearLogCache(): void;
  66749. /**
  66750. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66751. */
  66752. static LogLevels: number;
  66753. }
  66754. }
  66755. declare module BABYLON {
  66756. /** @hidden */
  66757. export class _TypeStore {
  66758. /** @hidden */
  66759. static RegisteredTypes: {
  66760. [key: string]: Object;
  66761. };
  66762. /** @hidden */
  66763. static GetClass(fqdn: string): any;
  66764. }
  66765. }
  66766. declare module BABYLON {
  66767. /**
  66768. * Class containing a set of static utilities functions for deep copy.
  66769. */
  66770. export class DeepCopier {
  66771. /**
  66772. * Tries to copy an object by duplicating every property
  66773. * @param source defines the source object
  66774. * @param destination defines the target object
  66775. * @param doNotCopyList defines a list of properties to avoid
  66776. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66777. */
  66778. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66779. }
  66780. }
  66781. declare module BABYLON {
  66782. /**
  66783. * Class containing a set of static utilities functions for precision date
  66784. */
  66785. export class PrecisionDate {
  66786. /**
  66787. * Gets either window.performance.now() if supported or Date.now() else
  66788. */
  66789. static readonly Now: number;
  66790. }
  66791. }
  66792. declare module BABYLON {
  66793. /** @hidden */
  66794. export class _DevTools {
  66795. static WarnImport(name: string): string;
  66796. }
  66797. }
  66798. declare module BABYLON {
  66799. /**
  66800. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66801. */
  66802. export class WebRequest {
  66803. private _xhr;
  66804. /**
  66805. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66806. * i.e. when loading files, where the server/service expects an Authorization header
  66807. */
  66808. static CustomRequestHeaders: {
  66809. [key: string]: string;
  66810. };
  66811. /**
  66812. * Add callback functions in this array to update all the requests before they get sent to the network
  66813. */
  66814. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66815. private _injectCustomRequestHeaders;
  66816. /**
  66817. * Gets or sets a function to be called when loading progress changes
  66818. */
  66819. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66820. /**
  66821. * Returns client's state
  66822. */
  66823. readonly readyState: number;
  66824. /**
  66825. * Returns client's status
  66826. */
  66827. readonly status: number;
  66828. /**
  66829. * Returns client's status as a text
  66830. */
  66831. readonly statusText: string;
  66832. /**
  66833. * Returns client's response
  66834. */
  66835. readonly response: any;
  66836. /**
  66837. * Returns client's response url
  66838. */
  66839. readonly responseURL: string;
  66840. /**
  66841. * Returns client's response as text
  66842. */
  66843. readonly responseText: string;
  66844. /**
  66845. * Gets or sets the expected response type
  66846. */
  66847. responseType: XMLHttpRequestResponseType;
  66848. /** @hidden */
  66849. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66850. /** @hidden */
  66851. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66852. /**
  66853. * Cancels any network activity
  66854. */
  66855. abort(): void;
  66856. /**
  66857. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66858. * @param body defines an optional request body
  66859. */
  66860. send(body?: Document | BodyInit | null): void;
  66861. /**
  66862. * Sets the request method, request URL
  66863. * @param method defines the method to use (GET, POST, etc..)
  66864. * @param url defines the url to connect with
  66865. */
  66866. open(method: string, url: string): void;
  66867. }
  66868. }
  66869. declare module BABYLON {
  66870. /**
  66871. * File request interface
  66872. */
  66873. export interface IFileRequest {
  66874. /**
  66875. * Raised when the request is complete (success or error).
  66876. */
  66877. onCompleteObservable: Observable<IFileRequest>;
  66878. /**
  66879. * Aborts the request for a file.
  66880. */
  66881. abort: () => void;
  66882. }
  66883. }
  66884. declare module BABYLON {
  66885. /**
  66886. * Scalar computation library
  66887. */
  66888. export class Scalar {
  66889. /**
  66890. * Two pi constants convenient for computation.
  66891. */
  66892. static TwoPi: number;
  66893. /**
  66894. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66895. * @param a number
  66896. * @param b number
  66897. * @param epsilon (default = 1.401298E-45)
  66898. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66899. */
  66900. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66901. /**
  66902. * Returns a string : the upper case translation of the number i to hexadecimal.
  66903. * @param i number
  66904. * @returns the upper case translation of the number i to hexadecimal.
  66905. */
  66906. static ToHex(i: number): string;
  66907. /**
  66908. * Returns -1 if value is negative and +1 is value is positive.
  66909. * @param value the value
  66910. * @returns the value itself if it's equal to zero.
  66911. */
  66912. static Sign(value: number): number;
  66913. /**
  66914. * Returns the value itself if it's between min and max.
  66915. * Returns min if the value is lower than min.
  66916. * Returns max if the value is greater than max.
  66917. * @param value the value to clmap
  66918. * @param min the min value to clamp to (default: 0)
  66919. * @param max the max value to clamp to (default: 1)
  66920. * @returns the clamped value
  66921. */
  66922. static Clamp(value: number, min?: number, max?: number): number;
  66923. /**
  66924. * the log2 of value.
  66925. * @param value the value to compute log2 of
  66926. * @returns the log2 of value.
  66927. */
  66928. static Log2(value: number): number;
  66929. /**
  66930. * Loops the value, so that it is never larger than length and never smaller than 0.
  66931. *
  66932. * This is similar to the modulo operator but it works with floating point numbers.
  66933. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66934. * With t = 5 and length = 2.5, the result would be 0.0.
  66935. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66936. * @param value the value
  66937. * @param length the length
  66938. * @returns the looped value
  66939. */
  66940. static Repeat(value: number, length: number): number;
  66941. /**
  66942. * Normalize the value between 0.0 and 1.0 using min and max values
  66943. * @param value value to normalize
  66944. * @param min max to normalize between
  66945. * @param max min to normalize between
  66946. * @returns the normalized value
  66947. */
  66948. static Normalize(value: number, min: number, max: number): number;
  66949. /**
  66950. * Denormalize the value from 0.0 and 1.0 using min and max values
  66951. * @param normalized value to denormalize
  66952. * @param min max to denormalize between
  66953. * @param max min to denormalize between
  66954. * @returns the denormalized value
  66955. */
  66956. static Denormalize(normalized: number, min: number, max: number): number;
  66957. /**
  66958. * Calculates the shortest difference between two given angles given in degrees.
  66959. * @param current current angle in degrees
  66960. * @param target target angle in degrees
  66961. * @returns the delta
  66962. */
  66963. static DeltaAngle(current: number, target: number): number;
  66964. /**
  66965. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66966. * @param tx value
  66967. * @param length length
  66968. * @returns The returned value will move back and forth between 0 and length
  66969. */
  66970. static PingPong(tx: number, length: number): number;
  66971. /**
  66972. * Interpolates between min and max with smoothing at the limits.
  66973. *
  66974. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66975. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66976. * @param from from
  66977. * @param to to
  66978. * @param tx value
  66979. * @returns the smooth stepped value
  66980. */
  66981. static SmoothStep(from: number, to: number, tx: number): number;
  66982. /**
  66983. * Moves a value current towards target.
  66984. *
  66985. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66986. * Negative values of maxDelta pushes the value away from target.
  66987. * @param current current value
  66988. * @param target target value
  66989. * @param maxDelta max distance to move
  66990. * @returns resulting value
  66991. */
  66992. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66993. /**
  66994. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66995. *
  66996. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66997. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66998. * @param current current value
  66999. * @param target target value
  67000. * @param maxDelta max distance to move
  67001. * @returns resulting angle
  67002. */
  67003. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67004. /**
  67005. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67006. * @param start start value
  67007. * @param end target value
  67008. * @param amount amount to lerp between
  67009. * @returns the lerped value
  67010. */
  67011. static Lerp(start: number, end: number, amount: number): number;
  67012. /**
  67013. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67014. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67015. * @param start start value
  67016. * @param end target value
  67017. * @param amount amount to lerp between
  67018. * @returns the lerped value
  67019. */
  67020. static LerpAngle(start: number, end: number, amount: number): number;
  67021. /**
  67022. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67023. * @param a start value
  67024. * @param b target value
  67025. * @param value value between a and b
  67026. * @returns the inverseLerp value
  67027. */
  67028. static InverseLerp(a: number, b: number, value: number): number;
  67029. /**
  67030. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67031. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67032. * @param value1 spline value
  67033. * @param tangent1 spline value
  67034. * @param value2 spline value
  67035. * @param tangent2 spline value
  67036. * @param amount input value
  67037. * @returns hermite result
  67038. */
  67039. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67040. /**
  67041. * Returns a random float number between and min and max values
  67042. * @param min min value of random
  67043. * @param max max value of random
  67044. * @returns random value
  67045. */
  67046. static RandomRange(min: number, max: number): number;
  67047. /**
  67048. * This function returns percentage of a number in a given range.
  67049. *
  67050. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67051. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67052. * @param number to convert to percentage
  67053. * @param min min range
  67054. * @param max max range
  67055. * @returns the percentage
  67056. */
  67057. static RangeToPercent(number: number, min: number, max: number): number;
  67058. /**
  67059. * This function returns number that corresponds to the percentage in a given range.
  67060. *
  67061. * PercentToRange(0.34,0,100) will return 34.
  67062. * @param percent to convert to number
  67063. * @param min min range
  67064. * @param max max range
  67065. * @returns the number
  67066. */
  67067. static PercentToRange(percent: number, min: number, max: number): number;
  67068. /**
  67069. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67070. * @param angle The angle to normalize in radian.
  67071. * @return The converted angle.
  67072. */
  67073. static NormalizeRadians(angle: number): number;
  67074. }
  67075. }
  67076. declare module BABYLON {
  67077. /**
  67078. * Constant used to convert a value to gamma space
  67079. * @ignorenaming
  67080. */
  67081. export const ToGammaSpace: number;
  67082. /**
  67083. * Constant used to convert a value to linear space
  67084. * @ignorenaming
  67085. */
  67086. export const ToLinearSpace = 2.2;
  67087. /**
  67088. * Constant used to define the minimal number value in Babylon.js
  67089. * @ignorenaming
  67090. */
  67091. let Epsilon: number;
  67092. }
  67093. declare module BABYLON {
  67094. /**
  67095. * Class used to represent a viewport on screen
  67096. */
  67097. export class Viewport {
  67098. /** viewport left coordinate */
  67099. x: number;
  67100. /** viewport top coordinate */
  67101. y: number;
  67102. /**viewport width */
  67103. width: number;
  67104. /** viewport height */
  67105. height: number;
  67106. /**
  67107. * Creates a Viewport object located at (x, y) and sized (width, height)
  67108. * @param x defines viewport left coordinate
  67109. * @param y defines viewport top coordinate
  67110. * @param width defines the viewport width
  67111. * @param height defines the viewport height
  67112. */
  67113. constructor(
  67114. /** viewport left coordinate */
  67115. x: number,
  67116. /** viewport top coordinate */
  67117. y: number,
  67118. /**viewport width */
  67119. width: number,
  67120. /** viewport height */
  67121. height: number);
  67122. /**
  67123. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67124. * @param renderWidth defines the rendering width
  67125. * @param renderHeight defines the rendering height
  67126. * @returns a new Viewport
  67127. */
  67128. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67129. /**
  67130. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67131. * @param renderWidth defines the rendering width
  67132. * @param renderHeight defines the rendering height
  67133. * @param ref defines the target viewport
  67134. * @returns the current viewport
  67135. */
  67136. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67137. /**
  67138. * Returns a new Viewport copied from the current one
  67139. * @returns a new Viewport
  67140. */
  67141. clone(): Viewport;
  67142. }
  67143. }
  67144. declare module BABYLON {
  67145. /**
  67146. * Class containing a set of static utilities functions for arrays.
  67147. */
  67148. export class ArrayTools {
  67149. /**
  67150. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67151. * @param size the number of element to construct and put in the array
  67152. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67153. * @returns a new array filled with new objects
  67154. */
  67155. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67156. }
  67157. }
  67158. declare module BABYLON {
  67159. /**
  67160. * @hidden
  67161. */
  67162. export interface IColor4Like {
  67163. r: float;
  67164. g: float;
  67165. b: float;
  67166. a: float;
  67167. }
  67168. /**
  67169. * @hidden
  67170. */
  67171. export interface IColor3Like {
  67172. r: float;
  67173. g: float;
  67174. b: float;
  67175. }
  67176. /**
  67177. * @hidden
  67178. */
  67179. export interface IVector4Like {
  67180. x: float;
  67181. y: float;
  67182. z: float;
  67183. w: float;
  67184. }
  67185. /**
  67186. * @hidden
  67187. */
  67188. export interface IVector3Like {
  67189. x: float;
  67190. y: float;
  67191. z: float;
  67192. }
  67193. /**
  67194. * @hidden
  67195. */
  67196. export interface IVector2Like {
  67197. x: float;
  67198. y: float;
  67199. }
  67200. /**
  67201. * @hidden
  67202. */
  67203. export interface IMatrixLike {
  67204. toArray(): DeepImmutable<Float32Array>;
  67205. updateFlag: int;
  67206. }
  67207. /**
  67208. * @hidden
  67209. */
  67210. export interface IViewportLike {
  67211. x: float;
  67212. y: float;
  67213. width: float;
  67214. height: float;
  67215. }
  67216. /**
  67217. * @hidden
  67218. */
  67219. export interface IPlaneLike {
  67220. normal: IVector3Like;
  67221. d: float;
  67222. normalize(): void;
  67223. }
  67224. }
  67225. declare module BABYLON {
  67226. /**
  67227. * Class representing a vector containing 2 coordinates
  67228. */
  67229. export class Vector2 {
  67230. /** defines the first coordinate */
  67231. x: number;
  67232. /** defines the second coordinate */
  67233. y: number;
  67234. /**
  67235. * Creates a new Vector2 from the given x and y coordinates
  67236. * @param x defines the first coordinate
  67237. * @param y defines the second coordinate
  67238. */
  67239. constructor(
  67240. /** defines the first coordinate */
  67241. x?: number,
  67242. /** defines the second coordinate */
  67243. y?: number);
  67244. /**
  67245. * Gets a string with the Vector2 coordinates
  67246. * @returns a string with the Vector2 coordinates
  67247. */
  67248. toString(): string;
  67249. /**
  67250. * Gets class name
  67251. * @returns the string "Vector2"
  67252. */
  67253. getClassName(): string;
  67254. /**
  67255. * Gets current vector hash code
  67256. * @returns the Vector2 hash code as a number
  67257. */
  67258. getHashCode(): number;
  67259. /**
  67260. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67261. * @param array defines the source array
  67262. * @param index defines the offset in source array
  67263. * @returns the current Vector2
  67264. */
  67265. toArray(array: FloatArray, index?: number): Vector2;
  67266. /**
  67267. * Copy the current vector to an array
  67268. * @returns a new array with 2 elements: the Vector2 coordinates.
  67269. */
  67270. asArray(): number[];
  67271. /**
  67272. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67273. * @param source defines the source Vector2
  67274. * @returns the current updated Vector2
  67275. */
  67276. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67277. /**
  67278. * Sets the Vector2 coordinates with the given floats
  67279. * @param x defines the first coordinate
  67280. * @param y defines the second coordinate
  67281. * @returns the current updated Vector2
  67282. */
  67283. copyFromFloats(x: number, y: number): Vector2;
  67284. /**
  67285. * Sets the Vector2 coordinates with the given floats
  67286. * @param x defines the first coordinate
  67287. * @param y defines the second coordinate
  67288. * @returns the current updated Vector2
  67289. */
  67290. set(x: number, y: number): Vector2;
  67291. /**
  67292. * Add another vector with the current one
  67293. * @param otherVector defines the other vector
  67294. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67295. */
  67296. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67297. /**
  67298. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67299. * @param otherVector defines the other vector
  67300. * @param result defines the target vector
  67301. * @returns the unmodified current Vector2
  67302. */
  67303. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67304. /**
  67305. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67306. * @param otherVector defines the other vector
  67307. * @returns the current updated Vector2
  67308. */
  67309. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67310. /**
  67311. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67312. * @param otherVector defines the other vector
  67313. * @returns a new Vector2
  67314. */
  67315. addVector3(otherVector: Vector3): Vector2;
  67316. /**
  67317. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67318. * @param otherVector defines the other vector
  67319. * @returns a new Vector2
  67320. */
  67321. subtract(otherVector: Vector2): Vector2;
  67322. /**
  67323. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67324. * @param otherVector defines the other vector
  67325. * @param result defines the target vector
  67326. * @returns the unmodified current Vector2
  67327. */
  67328. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67329. /**
  67330. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67331. * @param otherVector defines the other vector
  67332. * @returns the current updated Vector2
  67333. */
  67334. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67335. /**
  67336. * Multiplies in place the current Vector2 coordinates by the given ones
  67337. * @param otherVector defines the other vector
  67338. * @returns the current updated Vector2
  67339. */
  67340. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67341. /**
  67342. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67343. * @param otherVector defines the other vector
  67344. * @returns a new Vector2
  67345. */
  67346. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67347. /**
  67348. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67349. * @param otherVector defines the other vector
  67350. * @param result defines the target vector
  67351. * @returns the unmodified current Vector2
  67352. */
  67353. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67354. /**
  67355. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67356. * @param x defines the first coordinate
  67357. * @param y defines the second coordinate
  67358. * @returns a new Vector2
  67359. */
  67360. multiplyByFloats(x: number, y: number): Vector2;
  67361. /**
  67362. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67363. * @param otherVector defines the other vector
  67364. * @returns a new Vector2
  67365. */
  67366. divide(otherVector: Vector2): Vector2;
  67367. /**
  67368. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67369. * @param otherVector defines the other vector
  67370. * @param result defines the target vector
  67371. * @returns the unmodified current Vector2
  67372. */
  67373. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67374. /**
  67375. * Divides the current Vector2 coordinates by the given ones
  67376. * @param otherVector defines the other vector
  67377. * @returns the current updated Vector2
  67378. */
  67379. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67380. /**
  67381. * Gets a new Vector2 with current Vector2 negated coordinates
  67382. * @returns a new Vector2
  67383. */
  67384. negate(): Vector2;
  67385. /**
  67386. * Multiply the Vector2 coordinates by scale
  67387. * @param scale defines the scaling factor
  67388. * @returns the current updated Vector2
  67389. */
  67390. scaleInPlace(scale: number): Vector2;
  67391. /**
  67392. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67393. * @param scale defines the scaling factor
  67394. * @returns a new Vector2
  67395. */
  67396. scale(scale: number): Vector2;
  67397. /**
  67398. * Scale the current Vector2 values by a factor to a given Vector2
  67399. * @param scale defines the scale factor
  67400. * @param result defines the Vector2 object where to store the result
  67401. * @returns the unmodified current Vector2
  67402. */
  67403. scaleToRef(scale: number, result: Vector2): Vector2;
  67404. /**
  67405. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67406. * @param scale defines the scale factor
  67407. * @param result defines the Vector2 object where to store the result
  67408. * @returns the unmodified current Vector2
  67409. */
  67410. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67411. /**
  67412. * Gets a boolean if two vectors are equals
  67413. * @param otherVector defines the other vector
  67414. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67415. */
  67416. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67417. /**
  67418. * Gets a boolean if two vectors are equals (using an epsilon value)
  67419. * @param otherVector defines the other vector
  67420. * @param epsilon defines the minimal distance to consider equality
  67421. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67422. */
  67423. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67424. /**
  67425. * Gets a new Vector2 from current Vector2 floored values
  67426. * @returns a new Vector2
  67427. */
  67428. floor(): Vector2;
  67429. /**
  67430. * Gets a new Vector2 from current Vector2 floored values
  67431. * @returns a new Vector2
  67432. */
  67433. fract(): Vector2;
  67434. /**
  67435. * Gets the length of the vector
  67436. * @returns the vector length (float)
  67437. */
  67438. length(): number;
  67439. /**
  67440. * Gets the vector squared length
  67441. * @returns the vector squared length (float)
  67442. */
  67443. lengthSquared(): number;
  67444. /**
  67445. * Normalize the vector
  67446. * @returns the current updated Vector2
  67447. */
  67448. normalize(): Vector2;
  67449. /**
  67450. * Gets a new Vector2 copied from the Vector2
  67451. * @returns a new Vector2
  67452. */
  67453. clone(): Vector2;
  67454. /**
  67455. * Gets a new Vector2(0, 0)
  67456. * @returns a new Vector2
  67457. */
  67458. static Zero(): Vector2;
  67459. /**
  67460. * Gets a new Vector2(1, 1)
  67461. * @returns a new Vector2
  67462. */
  67463. static One(): Vector2;
  67464. /**
  67465. * Gets a new Vector2 set from the given index element of the given array
  67466. * @param array defines the data source
  67467. * @param offset defines the offset in the data source
  67468. * @returns a new Vector2
  67469. */
  67470. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67471. /**
  67472. * Sets "result" from the given index element of the given array
  67473. * @param array defines the data source
  67474. * @param offset defines the offset in the data source
  67475. * @param result defines the target vector
  67476. */
  67477. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67478. /**
  67479. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67480. * @param value1 defines 1st point of control
  67481. * @param value2 defines 2nd point of control
  67482. * @param value3 defines 3rd point of control
  67483. * @param value4 defines 4th point of control
  67484. * @param amount defines the interpolation factor
  67485. * @returns a new Vector2
  67486. */
  67487. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67488. /**
  67489. * 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".
  67490. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67491. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67492. * @param value defines the value to clamp
  67493. * @param min defines the lower limit
  67494. * @param max defines the upper limit
  67495. * @returns a new Vector2
  67496. */
  67497. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67498. /**
  67499. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67500. * @param value1 defines the 1st control point
  67501. * @param tangent1 defines the outgoing tangent
  67502. * @param value2 defines the 2nd control point
  67503. * @param tangent2 defines the incoming tangent
  67504. * @param amount defines the interpolation factor
  67505. * @returns a new Vector2
  67506. */
  67507. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67508. /**
  67509. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67510. * @param start defines the start vector
  67511. * @param end defines the end vector
  67512. * @param amount defines the interpolation factor
  67513. * @returns a new Vector2
  67514. */
  67515. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67516. /**
  67517. * Gets the dot product of the vector "left" and the vector "right"
  67518. * @param left defines first vector
  67519. * @param right defines second vector
  67520. * @returns the dot product (float)
  67521. */
  67522. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67523. /**
  67524. * Returns a new Vector2 equal to the normalized given vector
  67525. * @param vector defines the vector to normalize
  67526. * @returns a new Vector2
  67527. */
  67528. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67529. /**
  67530. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67531. * @param left defines 1st vector
  67532. * @param right defines 2nd vector
  67533. * @returns a new Vector2
  67534. */
  67535. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67536. /**
  67537. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67538. * @param left defines 1st vector
  67539. * @param right defines 2nd vector
  67540. * @returns a new Vector2
  67541. */
  67542. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67543. /**
  67544. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67545. * @param vector defines the vector to transform
  67546. * @param transformation defines the matrix to apply
  67547. * @returns a new Vector2
  67548. */
  67549. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67550. /**
  67551. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67552. * @param vector defines the vector to transform
  67553. * @param transformation defines the matrix to apply
  67554. * @param result defines the target vector
  67555. */
  67556. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67557. /**
  67558. * Determines if a given vector is included in a triangle
  67559. * @param p defines the vector to test
  67560. * @param p0 defines 1st triangle point
  67561. * @param p1 defines 2nd triangle point
  67562. * @param p2 defines 3rd triangle point
  67563. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67564. */
  67565. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67566. /**
  67567. * Gets the distance between the vectors "value1" and "value2"
  67568. * @param value1 defines first vector
  67569. * @param value2 defines second vector
  67570. * @returns the distance between vectors
  67571. */
  67572. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67573. /**
  67574. * Returns the squared distance between the vectors "value1" and "value2"
  67575. * @param value1 defines first vector
  67576. * @param value2 defines second vector
  67577. * @returns the squared distance between vectors
  67578. */
  67579. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67580. /**
  67581. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67582. * @param value1 defines first vector
  67583. * @param value2 defines second vector
  67584. * @returns a new Vector2
  67585. */
  67586. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67587. /**
  67588. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67589. * @param p defines the middle point
  67590. * @param segA defines one point of the segment
  67591. * @param segB defines the other point of the segment
  67592. * @returns the shortest distance
  67593. */
  67594. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67595. }
  67596. /**
  67597. * Classed used to store (x,y,z) vector representation
  67598. * A Vector3 is the main object used in 3D geometry
  67599. * It can represent etiher the coordinates of a point the space, either a direction
  67600. * Reminder: js uses a left handed forward facing system
  67601. */
  67602. export class Vector3 {
  67603. /**
  67604. * Defines the first coordinates (on X axis)
  67605. */
  67606. x: number;
  67607. /**
  67608. * Defines the second coordinates (on Y axis)
  67609. */
  67610. y: number;
  67611. /**
  67612. * Defines the third coordinates (on Z axis)
  67613. */
  67614. z: number;
  67615. private static _UpReadOnly;
  67616. private static _ZeroReadOnly;
  67617. /**
  67618. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67619. * @param x defines the first coordinates (on X axis)
  67620. * @param y defines the second coordinates (on Y axis)
  67621. * @param z defines the third coordinates (on Z axis)
  67622. */
  67623. constructor(
  67624. /**
  67625. * Defines the first coordinates (on X axis)
  67626. */
  67627. x?: number,
  67628. /**
  67629. * Defines the second coordinates (on Y axis)
  67630. */
  67631. y?: number,
  67632. /**
  67633. * Defines the third coordinates (on Z axis)
  67634. */
  67635. z?: number);
  67636. /**
  67637. * Creates a string representation of the Vector3
  67638. * @returns a string with the Vector3 coordinates.
  67639. */
  67640. toString(): string;
  67641. /**
  67642. * Gets the class name
  67643. * @returns the string "Vector3"
  67644. */
  67645. getClassName(): string;
  67646. /**
  67647. * Creates the Vector3 hash code
  67648. * @returns a number which tends to be unique between Vector3 instances
  67649. */
  67650. getHashCode(): number;
  67651. /**
  67652. * Creates an array containing three elements : the coordinates of the Vector3
  67653. * @returns a new array of numbers
  67654. */
  67655. asArray(): number[];
  67656. /**
  67657. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67658. * @param array defines the destination array
  67659. * @param index defines the offset in the destination array
  67660. * @returns the current Vector3
  67661. */
  67662. toArray(array: FloatArray, index?: number): Vector3;
  67663. /**
  67664. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67665. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67666. */
  67667. toQuaternion(): Quaternion;
  67668. /**
  67669. * Adds the given vector to the current Vector3
  67670. * @param otherVector defines the second operand
  67671. * @returns the current updated Vector3
  67672. */
  67673. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67674. /**
  67675. * Adds the given coordinates to the current Vector3
  67676. * @param x defines the x coordinate of the operand
  67677. * @param y defines the y coordinate of the operand
  67678. * @param z defines the z coordinate of the operand
  67679. * @returns the current updated Vector3
  67680. */
  67681. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67682. /**
  67683. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67684. * @param otherVector defines the second operand
  67685. * @returns the resulting Vector3
  67686. */
  67687. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67688. /**
  67689. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67690. * @param otherVector defines the second operand
  67691. * @param result defines the Vector3 object where to store the result
  67692. * @returns the current Vector3
  67693. */
  67694. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67695. /**
  67696. * Subtract the given vector from the current Vector3
  67697. * @param otherVector defines the second operand
  67698. * @returns the current updated Vector3
  67699. */
  67700. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67701. /**
  67702. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67703. * @param otherVector defines the second operand
  67704. * @returns the resulting Vector3
  67705. */
  67706. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67707. /**
  67708. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67709. * @param otherVector defines the second operand
  67710. * @param result defines the Vector3 object where to store the result
  67711. * @returns the current Vector3
  67712. */
  67713. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67714. /**
  67715. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67716. * @param x defines the x coordinate of the operand
  67717. * @param y defines the y coordinate of the operand
  67718. * @param z defines the z coordinate of the operand
  67719. * @returns the resulting Vector3
  67720. */
  67721. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67722. /**
  67723. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67724. * @param x defines the x coordinate of the operand
  67725. * @param y defines the y coordinate of the operand
  67726. * @param z defines the z coordinate of the operand
  67727. * @param result defines the Vector3 object where to store the result
  67728. * @returns the current Vector3
  67729. */
  67730. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67731. /**
  67732. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67733. * @returns a new Vector3
  67734. */
  67735. negate(): Vector3;
  67736. /**
  67737. * Multiplies the Vector3 coordinates by the float "scale"
  67738. * @param scale defines the multiplier factor
  67739. * @returns the current updated Vector3
  67740. */
  67741. scaleInPlace(scale: number): Vector3;
  67742. /**
  67743. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67744. * @param scale defines the multiplier factor
  67745. * @returns a new Vector3
  67746. */
  67747. scale(scale: number): Vector3;
  67748. /**
  67749. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67750. * @param scale defines the multiplier factor
  67751. * @param result defines the Vector3 object where to store the result
  67752. * @returns the current Vector3
  67753. */
  67754. scaleToRef(scale: number, result: Vector3): Vector3;
  67755. /**
  67756. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67757. * @param scale defines the scale factor
  67758. * @param result defines the Vector3 object where to store the result
  67759. * @returns the unmodified current Vector3
  67760. */
  67761. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67762. /**
  67763. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67764. * @param otherVector defines the second operand
  67765. * @returns true if both vectors are equals
  67766. */
  67767. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67768. /**
  67769. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67770. * @param otherVector defines the second operand
  67771. * @param epsilon defines the minimal distance to define values as equals
  67772. * @returns true if both vectors are distant less than epsilon
  67773. */
  67774. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67775. /**
  67776. * Returns true if the current Vector3 coordinates equals the given floats
  67777. * @param x defines the x coordinate of the operand
  67778. * @param y defines the y coordinate of the operand
  67779. * @param z defines the z coordinate of the operand
  67780. * @returns true if both vectors are equals
  67781. */
  67782. equalsToFloats(x: number, y: number, z: number): boolean;
  67783. /**
  67784. * Multiplies the current Vector3 coordinates by the given ones
  67785. * @param otherVector defines the second operand
  67786. * @returns the current updated Vector3
  67787. */
  67788. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67789. /**
  67790. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67791. * @param otherVector defines the second operand
  67792. * @returns the new Vector3
  67793. */
  67794. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67795. /**
  67796. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67797. * @param otherVector defines the second operand
  67798. * @param result defines the Vector3 object where to store the result
  67799. * @returns the current Vector3
  67800. */
  67801. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67802. /**
  67803. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67804. * @param x defines the x coordinate of the operand
  67805. * @param y defines the y coordinate of the operand
  67806. * @param z defines the z coordinate of the operand
  67807. * @returns the new Vector3
  67808. */
  67809. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67810. /**
  67811. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67812. * @param otherVector defines the second operand
  67813. * @returns the new Vector3
  67814. */
  67815. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67816. /**
  67817. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67818. * @param otherVector defines the second operand
  67819. * @param result defines the Vector3 object where to store the result
  67820. * @returns the current Vector3
  67821. */
  67822. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67823. /**
  67824. * Divides the current Vector3 coordinates by the given ones.
  67825. * @param otherVector defines the second operand
  67826. * @returns the current updated Vector3
  67827. */
  67828. divideInPlace(otherVector: Vector3): Vector3;
  67829. /**
  67830. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67831. * @param other defines the second operand
  67832. * @returns the current updated Vector3
  67833. */
  67834. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67835. /**
  67836. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67837. * @param other defines the second operand
  67838. * @returns the current updated Vector3
  67839. */
  67840. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67841. /**
  67842. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67843. * @param x defines the x coordinate of the operand
  67844. * @param y defines the y coordinate of the operand
  67845. * @param z defines the z coordinate of the operand
  67846. * @returns the current updated Vector3
  67847. */
  67848. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67849. /**
  67850. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67851. * @param x defines the x coordinate of the operand
  67852. * @param y defines the y coordinate of the operand
  67853. * @param z defines the z coordinate of the operand
  67854. * @returns the current updated Vector3
  67855. */
  67856. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67857. /**
  67858. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67859. * Check if is non uniform within a certain amount of decimal places to account for this
  67860. * @param epsilon the amount the values can differ
  67861. * @returns if the the vector is non uniform to a certain number of decimal places
  67862. */
  67863. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67864. /**
  67865. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67866. */
  67867. readonly isNonUniform: boolean;
  67868. /**
  67869. * Gets a new Vector3 from current Vector3 floored values
  67870. * @returns a new Vector3
  67871. */
  67872. floor(): Vector3;
  67873. /**
  67874. * Gets a new Vector3 from current Vector3 floored values
  67875. * @returns a new Vector3
  67876. */
  67877. fract(): Vector3;
  67878. /**
  67879. * Gets the length of the Vector3
  67880. * @returns the length of the Vector3
  67881. */
  67882. length(): number;
  67883. /**
  67884. * Gets the squared length of the Vector3
  67885. * @returns squared length of the Vector3
  67886. */
  67887. lengthSquared(): number;
  67888. /**
  67889. * Normalize the current Vector3.
  67890. * Please note that this is an in place operation.
  67891. * @returns the current updated Vector3
  67892. */
  67893. normalize(): Vector3;
  67894. /**
  67895. * Reorders the x y z properties of the vector in place
  67896. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67897. * @returns the current updated vector
  67898. */
  67899. reorderInPlace(order: string): this;
  67900. /**
  67901. * Rotates the vector around 0,0,0 by a quaternion
  67902. * @param quaternion the rotation quaternion
  67903. * @param result vector to store the result
  67904. * @returns the resulting vector
  67905. */
  67906. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67907. /**
  67908. * Rotates a vector around a given point
  67909. * @param quaternion the rotation quaternion
  67910. * @param point the point to rotate around
  67911. * @param result vector to store the result
  67912. * @returns the resulting vector
  67913. */
  67914. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67915. /**
  67916. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67917. * The cross product is then orthogonal to both current and "other"
  67918. * @param other defines the right operand
  67919. * @returns the cross product
  67920. */
  67921. cross(other: Vector3): Vector3;
  67922. /**
  67923. * Normalize the current Vector3 with the given input length.
  67924. * Please note that this is an in place operation.
  67925. * @param len the length of the vector
  67926. * @returns the current updated Vector3
  67927. */
  67928. normalizeFromLength(len: number): Vector3;
  67929. /**
  67930. * Normalize the current Vector3 to a new vector
  67931. * @returns the new Vector3
  67932. */
  67933. normalizeToNew(): Vector3;
  67934. /**
  67935. * Normalize the current Vector3 to the reference
  67936. * @param reference define the Vector3 to update
  67937. * @returns the updated Vector3
  67938. */
  67939. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67940. /**
  67941. * Creates a new Vector3 copied from the current Vector3
  67942. * @returns the new Vector3
  67943. */
  67944. clone(): Vector3;
  67945. /**
  67946. * Copies the given vector coordinates to the current Vector3 ones
  67947. * @param source defines the source Vector3
  67948. * @returns the current updated Vector3
  67949. */
  67950. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67951. /**
  67952. * Copies the given floats to the current Vector3 coordinates
  67953. * @param x defines the x coordinate of the operand
  67954. * @param y defines the y coordinate of the operand
  67955. * @param z defines the z coordinate of the operand
  67956. * @returns the current updated Vector3
  67957. */
  67958. copyFromFloats(x: number, y: number, z: number): Vector3;
  67959. /**
  67960. * Copies the given floats to the current Vector3 coordinates
  67961. * @param x defines the x coordinate of the operand
  67962. * @param y defines the y coordinate of the operand
  67963. * @param z defines the z coordinate of the operand
  67964. * @returns the current updated Vector3
  67965. */
  67966. set(x: number, y: number, z: number): Vector3;
  67967. /**
  67968. * Copies the given float to the current Vector3 coordinates
  67969. * @param v defines the x, y and z coordinates of the operand
  67970. * @returns the current updated Vector3
  67971. */
  67972. setAll(v: number): Vector3;
  67973. /**
  67974. * Get the clip factor between two vectors
  67975. * @param vector0 defines the first operand
  67976. * @param vector1 defines the second operand
  67977. * @param axis defines the axis to use
  67978. * @param size defines the size along the axis
  67979. * @returns the clip factor
  67980. */
  67981. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67982. /**
  67983. * Get angle between two vectors
  67984. * @param vector0 angle between vector0 and vector1
  67985. * @param vector1 angle between vector0 and vector1
  67986. * @param normal direction of the normal
  67987. * @return the angle between vector0 and vector1
  67988. */
  67989. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67990. /**
  67991. * Returns a new Vector3 set from the index "offset" of the given array
  67992. * @param array defines the source array
  67993. * @param offset defines the offset in the source array
  67994. * @returns the new Vector3
  67995. */
  67996. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67997. /**
  67998. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67999. * This function is deprecated. Use FromArray instead
  68000. * @param array defines the source array
  68001. * @param offset defines the offset in the source array
  68002. * @returns the new Vector3
  68003. */
  68004. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68005. /**
  68006. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68007. * @param array defines the source array
  68008. * @param offset defines the offset in the source array
  68009. * @param result defines the Vector3 where to store the result
  68010. */
  68011. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68012. /**
  68013. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68014. * This function is deprecated. Use FromArrayToRef instead.
  68015. * @param array defines the source array
  68016. * @param offset defines the offset in the source array
  68017. * @param result defines the Vector3 where to store the result
  68018. */
  68019. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68020. /**
  68021. * Sets the given vector "result" with the given floats.
  68022. * @param x defines the x coordinate of the source
  68023. * @param y defines the y coordinate of the source
  68024. * @param z defines the z coordinate of the source
  68025. * @param result defines the Vector3 where to store the result
  68026. */
  68027. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68028. /**
  68029. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68030. * @returns a new empty Vector3
  68031. */
  68032. static Zero(): Vector3;
  68033. /**
  68034. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68035. * @returns a new unit Vector3
  68036. */
  68037. static One(): Vector3;
  68038. /**
  68039. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68040. * @returns a new up Vector3
  68041. */
  68042. static Up(): Vector3;
  68043. /**
  68044. * Gets a up Vector3 that must not be updated
  68045. */
  68046. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68047. /**
  68048. * Gets a zero Vector3 that must not be updated
  68049. */
  68050. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68051. /**
  68052. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68053. * @returns a new down Vector3
  68054. */
  68055. static Down(): Vector3;
  68056. /**
  68057. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68058. * @returns a new forward Vector3
  68059. */
  68060. static Forward(): Vector3;
  68061. /**
  68062. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68063. * @returns a new forward Vector3
  68064. */
  68065. static Backward(): Vector3;
  68066. /**
  68067. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68068. * @returns a new right Vector3
  68069. */
  68070. static Right(): Vector3;
  68071. /**
  68072. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68073. * @returns a new left Vector3
  68074. */
  68075. static Left(): Vector3;
  68076. /**
  68077. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68078. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68079. * @param vector defines the Vector3 to transform
  68080. * @param transformation defines the transformation matrix
  68081. * @returns the transformed Vector3
  68082. */
  68083. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68084. /**
  68085. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68086. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68087. * @param vector defines the Vector3 to transform
  68088. * @param transformation defines the transformation matrix
  68089. * @param result defines the Vector3 where to store the result
  68090. */
  68091. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68092. /**
  68093. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68094. * This method computes tranformed coordinates only, not transformed direction vectors
  68095. * @param x define the x coordinate of the source vector
  68096. * @param y define the y coordinate of the source vector
  68097. * @param z define the z coordinate of the source vector
  68098. * @param transformation defines the transformation matrix
  68099. * @param result defines the Vector3 where to store the result
  68100. */
  68101. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68102. /**
  68103. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68104. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68105. * @param vector defines the Vector3 to transform
  68106. * @param transformation defines the transformation matrix
  68107. * @returns the new Vector3
  68108. */
  68109. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68110. /**
  68111. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68112. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68113. * @param vector defines the Vector3 to transform
  68114. * @param transformation defines the transformation matrix
  68115. * @param result defines the Vector3 where to store the result
  68116. */
  68117. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68118. /**
  68119. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68120. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68121. * @param x define the x coordinate of the source vector
  68122. * @param y define the y coordinate of the source vector
  68123. * @param z define the z coordinate of the source vector
  68124. * @param transformation defines the transformation matrix
  68125. * @param result defines the Vector3 where to store the result
  68126. */
  68127. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68128. /**
  68129. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68130. * @param value1 defines the first control point
  68131. * @param value2 defines the second control point
  68132. * @param value3 defines the third control point
  68133. * @param value4 defines the fourth control point
  68134. * @param amount defines the amount on the spline to use
  68135. * @returns the new Vector3
  68136. */
  68137. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68138. /**
  68139. * 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"
  68140. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68141. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68142. * @param value defines the current value
  68143. * @param min defines the lower range value
  68144. * @param max defines the upper range value
  68145. * @returns the new Vector3
  68146. */
  68147. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68148. /**
  68149. * 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"
  68150. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68151. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68152. * @param value defines the current value
  68153. * @param min defines the lower range value
  68154. * @param max defines the upper range value
  68155. * @param result defines the Vector3 where to store the result
  68156. */
  68157. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68158. /**
  68159. * Checks if a given vector is inside a specific range
  68160. * @param v defines the vector to test
  68161. * @param min defines the minimum range
  68162. * @param max defines the maximum range
  68163. */
  68164. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68165. /**
  68166. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68167. * @param value1 defines the first control point
  68168. * @param tangent1 defines the first tangent vector
  68169. * @param value2 defines the second control point
  68170. * @param tangent2 defines the second tangent vector
  68171. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68172. * @returns the new Vector3
  68173. */
  68174. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68175. /**
  68176. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68177. * @param start defines the start value
  68178. * @param end defines the end value
  68179. * @param amount max defines amount between both (between 0 and 1)
  68180. * @returns the new Vector3
  68181. */
  68182. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68183. /**
  68184. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68185. * @param start defines the start value
  68186. * @param end defines the end value
  68187. * @param amount max defines amount between both (between 0 and 1)
  68188. * @param result defines the Vector3 where to store the result
  68189. */
  68190. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68191. /**
  68192. * Returns the dot product (float) between the vectors "left" and "right"
  68193. * @param left defines the left operand
  68194. * @param right defines the right operand
  68195. * @returns the dot product
  68196. */
  68197. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68198. /**
  68199. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68200. * The cross product is then orthogonal to both "left" and "right"
  68201. * @param left defines the left operand
  68202. * @param right defines the right operand
  68203. * @returns the cross product
  68204. */
  68205. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68206. /**
  68207. * Sets the given vector "result" with the cross product of "left" and "right"
  68208. * The cross product is then orthogonal to both "left" and "right"
  68209. * @param left defines the left operand
  68210. * @param right defines the right operand
  68211. * @param result defines the Vector3 where to store the result
  68212. */
  68213. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68214. /**
  68215. * Returns a new Vector3 as the normalization of the given vector
  68216. * @param vector defines the Vector3 to normalize
  68217. * @returns the new Vector3
  68218. */
  68219. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68220. /**
  68221. * Sets the given vector "result" with the normalization of the given first vector
  68222. * @param vector defines the Vector3 to normalize
  68223. * @param result defines the Vector3 where to store the result
  68224. */
  68225. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68226. /**
  68227. * Project a Vector3 onto screen space
  68228. * @param vector defines the Vector3 to project
  68229. * @param world defines the world matrix to use
  68230. * @param transform defines the transform (view x projection) matrix to use
  68231. * @param viewport defines the screen viewport to use
  68232. * @returns the new Vector3
  68233. */
  68234. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68235. /** @hidden */
  68236. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68237. /**
  68238. * Unproject from screen space to object space
  68239. * @param source defines the screen space Vector3 to use
  68240. * @param viewportWidth defines the current width of the viewport
  68241. * @param viewportHeight defines the current height of the viewport
  68242. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68243. * @param transform defines the transform (view x projection) matrix to use
  68244. * @returns the new Vector3
  68245. */
  68246. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68247. /**
  68248. * Unproject from screen space to object space
  68249. * @param source defines the screen space Vector3 to use
  68250. * @param viewportWidth defines the current width of the viewport
  68251. * @param viewportHeight defines the current height of the viewport
  68252. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68253. * @param view defines the view matrix to use
  68254. * @param projection defines the projection matrix to use
  68255. * @returns the new Vector3
  68256. */
  68257. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68258. /**
  68259. * Unproject from screen space to object space
  68260. * @param source defines the screen space Vector3 to use
  68261. * @param viewportWidth defines the current width of the viewport
  68262. * @param viewportHeight defines the current height of the viewport
  68263. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68264. * @param view defines the view matrix to use
  68265. * @param projection defines the projection matrix to use
  68266. * @param result defines the Vector3 where to store the result
  68267. */
  68268. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68269. /**
  68270. * Unproject from screen space to object space
  68271. * @param sourceX defines the screen space x coordinate to use
  68272. * @param sourceY defines the screen space y coordinate to use
  68273. * @param sourceZ defines the screen space z coordinate to use
  68274. * @param viewportWidth defines the current width of the viewport
  68275. * @param viewportHeight defines the current height of the viewport
  68276. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68277. * @param view defines the view matrix to use
  68278. * @param projection defines the projection matrix to use
  68279. * @param result defines the Vector3 where to store the result
  68280. */
  68281. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68282. /**
  68283. * Gets the minimal coordinate values between two Vector3
  68284. * @param left defines the first operand
  68285. * @param right defines the second operand
  68286. * @returns the new Vector3
  68287. */
  68288. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68289. /**
  68290. * Gets the maximal coordinate values between two Vector3
  68291. * @param left defines the first operand
  68292. * @param right defines the second operand
  68293. * @returns the new Vector3
  68294. */
  68295. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68296. /**
  68297. * Returns the distance between the vectors "value1" and "value2"
  68298. * @param value1 defines the first operand
  68299. * @param value2 defines the second operand
  68300. * @returns the distance
  68301. */
  68302. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68303. /**
  68304. * Returns the squared distance between the vectors "value1" and "value2"
  68305. * @param value1 defines the first operand
  68306. * @param value2 defines the second operand
  68307. * @returns the squared distance
  68308. */
  68309. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68310. /**
  68311. * Returns a new Vector3 located at the center between "value1" and "value2"
  68312. * @param value1 defines the first operand
  68313. * @param value2 defines the second operand
  68314. * @returns the new Vector3
  68315. */
  68316. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68317. /**
  68318. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68319. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68320. * to something in order to rotate it from its local system to the given target system
  68321. * Note: axis1, axis2 and axis3 are normalized during this operation
  68322. * @param axis1 defines the first axis
  68323. * @param axis2 defines the second axis
  68324. * @param axis3 defines the third axis
  68325. * @returns a new Vector3
  68326. */
  68327. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68328. /**
  68329. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68330. * @param axis1 defines the first axis
  68331. * @param axis2 defines the second axis
  68332. * @param axis3 defines the third axis
  68333. * @param ref defines the Vector3 where to store the result
  68334. */
  68335. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68336. }
  68337. /**
  68338. * Vector4 class created for EulerAngle class conversion to Quaternion
  68339. */
  68340. export class Vector4 {
  68341. /** x value of the vector */
  68342. x: number;
  68343. /** y value of the vector */
  68344. y: number;
  68345. /** z value of the vector */
  68346. z: number;
  68347. /** w value of the vector */
  68348. w: number;
  68349. /**
  68350. * Creates a Vector4 object from the given floats.
  68351. * @param x x value of the vector
  68352. * @param y y value of the vector
  68353. * @param z z value of the vector
  68354. * @param w w value of the vector
  68355. */
  68356. constructor(
  68357. /** x value of the vector */
  68358. x: number,
  68359. /** y value of the vector */
  68360. y: number,
  68361. /** z value of the vector */
  68362. z: number,
  68363. /** w value of the vector */
  68364. w: number);
  68365. /**
  68366. * Returns the string with the Vector4 coordinates.
  68367. * @returns a string containing all the vector values
  68368. */
  68369. toString(): string;
  68370. /**
  68371. * Returns the string "Vector4".
  68372. * @returns "Vector4"
  68373. */
  68374. getClassName(): string;
  68375. /**
  68376. * Returns the Vector4 hash code.
  68377. * @returns a unique hash code
  68378. */
  68379. getHashCode(): number;
  68380. /**
  68381. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68382. * @returns the resulting array
  68383. */
  68384. asArray(): number[];
  68385. /**
  68386. * Populates the given array from the given index with the Vector4 coordinates.
  68387. * @param array array to populate
  68388. * @param index index of the array to start at (default: 0)
  68389. * @returns the Vector4.
  68390. */
  68391. toArray(array: FloatArray, index?: number): Vector4;
  68392. /**
  68393. * Adds the given vector to the current Vector4.
  68394. * @param otherVector the vector to add
  68395. * @returns the updated Vector4.
  68396. */
  68397. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68398. /**
  68399. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68400. * @param otherVector the vector to add
  68401. * @returns the resulting vector
  68402. */
  68403. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68404. /**
  68405. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68406. * @param otherVector the vector to add
  68407. * @param result the vector to store the result
  68408. * @returns the current Vector4.
  68409. */
  68410. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68411. /**
  68412. * Subtract in place the given vector from the current Vector4.
  68413. * @param otherVector the vector to subtract
  68414. * @returns the updated Vector4.
  68415. */
  68416. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68417. /**
  68418. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68419. * @param otherVector the vector to add
  68420. * @returns the new vector with the result
  68421. */
  68422. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68423. /**
  68424. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68425. * @param otherVector the vector to subtract
  68426. * @param result the vector to store the result
  68427. * @returns the current Vector4.
  68428. */
  68429. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68430. /**
  68431. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68432. */
  68433. /**
  68434. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68435. * @param x value to subtract
  68436. * @param y value to subtract
  68437. * @param z value to subtract
  68438. * @param w value to subtract
  68439. * @returns new vector containing the result
  68440. */
  68441. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68442. /**
  68443. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68444. * @param x value to subtract
  68445. * @param y value to subtract
  68446. * @param z value to subtract
  68447. * @param w value to subtract
  68448. * @param result the vector to store the result in
  68449. * @returns the current Vector4.
  68450. */
  68451. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68452. /**
  68453. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68454. * @returns a new vector with the negated values
  68455. */
  68456. negate(): Vector4;
  68457. /**
  68458. * Multiplies the current Vector4 coordinates by scale (float).
  68459. * @param scale the number to scale with
  68460. * @returns the updated Vector4.
  68461. */
  68462. scaleInPlace(scale: number): Vector4;
  68463. /**
  68464. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68465. * @param scale the number to scale with
  68466. * @returns a new vector with the result
  68467. */
  68468. scale(scale: number): Vector4;
  68469. /**
  68470. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68471. * @param scale the number to scale with
  68472. * @param result a vector to store the result in
  68473. * @returns the current Vector4.
  68474. */
  68475. scaleToRef(scale: number, result: Vector4): Vector4;
  68476. /**
  68477. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68478. * @param scale defines the scale factor
  68479. * @param result defines the Vector4 object where to store the result
  68480. * @returns the unmodified current Vector4
  68481. */
  68482. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68483. /**
  68484. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68485. * @param otherVector the vector to compare against
  68486. * @returns true if they are equal
  68487. */
  68488. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68489. /**
  68490. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68491. * @param otherVector vector to compare against
  68492. * @param epsilon (Default: very small number)
  68493. * @returns true if they are equal
  68494. */
  68495. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68496. /**
  68497. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68498. * @param x x value to compare against
  68499. * @param y y value to compare against
  68500. * @param z z value to compare against
  68501. * @param w w value to compare against
  68502. * @returns true if equal
  68503. */
  68504. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68505. /**
  68506. * Multiplies in place the current Vector4 by the given one.
  68507. * @param otherVector vector to multiple with
  68508. * @returns the updated Vector4.
  68509. */
  68510. multiplyInPlace(otherVector: Vector4): Vector4;
  68511. /**
  68512. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68513. * @param otherVector vector to multiple with
  68514. * @returns resulting new vector
  68515. */
  68516. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68517. /**
  68518. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68519. * @param otherVector vector to multiple with
  68520. * @param result vector to store the result
  68521. * @returns the current Vector4.
  68522. */
  68523. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68524. /**
  68525. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68526. * @param x x value multiply with
  68527. * @param y y value multiply with
  68528. * @param z z value multiply with
  68529. * @param w w value multiply with
  68530. * @returns resulting new vector
  68531. */
  68532. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68533. /**
  68534. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68535. * @param otherVector vector to devide with
  68536. * @returns resulting new vector
  68537. */
  68538. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68539. /**
  68540. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68541. * @param otherVector vector to devide with
  68542. * @param result vector to store the result
  68543. * @returns the current Vector4.
  68544. */
  68545. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68546. /**
  68547. * Divides the current Vector3 coordinates by the given ones.
  68548. * @param otherVector vector to devide with
  68549. * @returns the updated Vector3.
  68550. */
  68551. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68552. /**
  68553. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68554. * @param other defines the second operand
  68555. * @returns the current updated Vector4
  68556. */
  68557. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68558. /**
  68559. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68560. * @param other defines the second operand
  68561. * @returns the current updated Vector4
  68562. */
  68563. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68564. /**
  68565. * Gets a new Vector4 from current Vector4 floored values
  68566. * @returns a new Vector4
  68567. */
  68568. floor(): Vector4;
  68569. /**
  68570. * Gets a new Vector4 from current Vector3 floored values
  68571. * @returns a new Vector4
  68572. */
  68573. fract(): Vector4;
  68574. /**
  68575. * Returns the Vector4 length (float).
  68576. * @returns the length
  68577. */
  68578. length(): number;
  68579. /**
  68580. * Returns the Vector4 squared length (float).
  68581. * @returns the length squared
  68582. */
  68583. lengthSquared(): number;
  68584. /**
  68585. * Normalizes in place the Vector4.
  68586. * @returns the updated Vector4.
  68587. */
  68588. normalize(): Vector4;
  68589. /**
  68590. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68591. * @returns this converted to a new vector3
  68592. */
  68593. toVector3(): Vector3;
  68594. /**
  68595. * Returns a new Vector4 copied from the current one.
  68596. * @returns the new cloned vector
  68597. */
  68598. clone(): Vector4;
  68599. /**
  68600. * Updates the current Vector4 with the given one coordinates.
  68601. * @param source the source vector to copy from
  68602. * @returns the updated Vector4.
  68603. */
  68604. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68605. /**
  68606. * Updates the current Vector4 coordinates with the given floats.
  68607. * @param x float to copy from
  68608. * @param y float to copy from
  68609. * @param z float to copy from
  68610. * @param w float to copy from
  68611. * @returns the updated Vector4.
  68612. */
  68613. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68614. /**
  68615. * Updates the current Vector4 coordinates with the given floats.
  68616. * @param x float to set from
  68617. * @param y float to set from
  68618. * @param z float to set from
  68619. * @param w float to set from
  68620. * @returns the updated Vector4.
  68621. */
  68622. set(x: number, y: number, z: number, w: number): Vector4;
  68623. /**
  68624. * Copies the given float to the current Vector3 coordinates
  68625. * @param v defines the x, y, z and w coordinates of the operand
  68626. * @returns the current updated Vector3
  68627. */
  68628. setAll(v: number): Vector4;
  68629. /**
  68630. * Returns a new Vector4 set from the starting index of the given array.
  68631. * @param array the array to pull values from
  68632. * @param offset the offset into the array to start at
  68633. * @returns the new vector
  68634. */
  68635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68636. /**
  68637. * Updates the given vector "result" from the starting index of the given array.
  68638. * @param array the array to pull values from
  68639. * @param offset the offset into the array to start at
  68640. * @param result the vector to store the result in
  68641. */
  68642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68643. /**
  68644. * Updates the given vector "result" from the starting index of the given Float32Array.
  68645. * @param array the array to pull values from
  68646. * @param offset the offset into the array to start at
  68647. * @param result the vector to store the result in
  68648. */
  68649. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68650. /**
  68651. * Updates the given vector "result" coordinates from the given floats.
  68652. * @param x float to set from
  68653. * @param y float to set from
  68654. * @param z float to set from
  68655. * @param w float to set from
  68656. * @param result the vector to the floats in
  68657. */
  68658. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68659. /**
  68660. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68661. * @returns the new vector
  68662. */
  68663. static Zero(): Vector4;
  68664. /**
  68665. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68666. * @returns the new vector
  68667. */
  68668. static One(): Vector4;
  68669. /**
  68670. * Returns a new normalized Vector4 from the given one.
  68671. * @param vector the vector to normalize
  68672. * @returns the vector
  68673. */
  68674. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68675. /**
  68676. * Updates the given vector "result" from the normalization of the given one.
  68677. * @param vector the vector to normalize
  68678. * @param result the vector to store the result in
  68679. */
  68680. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68681. /**
  68682. * Returns a vector with the minimum values from the left and right vectors
  68683. * @param left left vector to minimize
  68684. * @param right right vector to minimize
  68685. * @returns a new vector with the minimum of the left and right vector values
  68686. */
  68687. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68688. /**
  68689. * Returns a vector with the maximum values from the left and right vectors
  68690. * @param left left vector to maximize
  68691. * @param right right vector to maximize
  68692. * @returns a new vector with the maximum of the left and right vector values
  68693. */
  68694. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68695. /**
  68696. * Returns the distance (float) between the vectors "value1" and "value2".
  68697. * @param value1 value to calulate the distance between
  68698. * @param value2 value to calulate the distance between
  68699. * @return the distance between the two vectors
  68700. */
  68701. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68702. /**
  68703. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68704. * @param value1 value to calulate the distance between
  68705. * @param value2 value to calulate the distance between
  68706. * @return the distance between the two vectors squared
  68707. */
  68708. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68709. /**
  68710. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68711. * @param value1 value to calulate the center between
  68712. * @param value2 value to calulate the center between
  68713. * @return the center between the two vectors
  68714. */
  68715. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68716. /**
  68717. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68718. * This methods computes transformed normalized direction vectors only.
  68719. * @param vector the vector to transform
  68720. * @param transformation the transformation matrix to apply
  68721. * @returns the new vector
  68722. */
  68723. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68724. /**
  68725. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68726. * This methods computes transformed normalized direction vectors only.
  68727. * @param vector the vector to transform
  68728. * @param transformation the transformation matrix to apply
  68729. * @param result the vector to store the result in
  68730. */
  68731. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68732. /**
  68733. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68734. * This methods computes transformed normalized direction vectors only.
  68735. * @param x value to transform
  68736. * @param y value to transform
  68737. * @param z value to transform
  68738. * @param w value to transform
  68739. * @param transformation the transformation matrix to apply
  68740. * @param result the vector to store the results in
  68741. */
  68742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68743. /**
  68744. * Creates a new Vector4 from a Vector3
  68745. * @param source defines the source data
  68746. * @param w defines the 4th component (default is 0)
  68747. * @returns a new Vector4
  68748. */
  68749. static FromVector3(source: Vector3, w?: number): Vector4;
  68750. }
  68751. /**
  68752. * Class used to store quaternion data
  68753. * @see https://en.wikipedia.org/wiki/Quaternion
  68754. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68755. */
  68756. export class Quaternion {
  68757. /** defines the first component (0 by default) */
  68758. x: number;
  68759. /** defines the second component (0 by default) */
  68760. y: number;
  68761. /** defines the third component (0 by default) */
  68762. z: number;
  68763. /** defines the fourth component (1.0 by default) */
  68764. w: number;
  68765. /**
  68766. * Creates a new Quaternion from the given floats
  68767. * @param x defines the first component (0 by default)
  68768. * @param y defines the second component (0 by default)
  68769. * @param z defines the third component (0 by default)
  68770. * @param w defines the fourth component (1.0 by default)
  68771. */
  68772. constructor(
  68773. /** defines the first component (0 by default) */
  68774. x?: number,
  68775. /** defines the second component (0 by default) */
  68776. y?: number,
  68777. /** defines the third component (0 by default) */
  68778. z?: number,
  68779. /** defines the fourth component (1.0 by default) */
  68780. w?: number);
  68781. /**
  68782. * Gets a string representation for the current quaternion
  68783. * @returns a string with the Quaternion coordinates
  68784. */
  68785. toString(): string;
  68786. /**
  68787. * Gets the class name of the quaternion
  68788. * @returns the string "Quaternion"
  68789. */
  68790. getClassName(): string;
  68791. /**
  68792. * Gets a hash code for this quaternion
  68793. * @returns the quaternion hash code
  68794. */
  68795. getHashCode(): number;
  68796. /**
  68797. * Copy the quaternion to an array
  68798. * @returns a new array populated with 4 elements from the quaternion coordinates
  68799. */
  68800. asArray(): number[];
  68801. /**
  68802. * Check if two quaternions are equals
  68803. * @param otherQuaternion defines the second operand
  68804. * @return true if the current quaternion and the given one coordinates are strictly equals
  68805. */
  68806. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68807. /**
  68808. * Clone the current quaternion
  68809. * @returns a new quaternion copied from the current one
  68810. */
  68811. clone(): Quaternion;
  68812. /**
  68813. * Copy a quaternion to the current one
  68814. * @param other defines the other quaternion
  68815. * @returns the updated current quaternion
  68816. */
  68817. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68818. /**
  68819. * Updates the current quaternion with the given float coordinates
  68820. * @param x defines the x coordinate
  68821. * @param y defines the y coordinate
  68822. * @param z defines the z coordinate
  68823. * @param w defines the w coordinate
  68824. * @returns the updated current quaternion
  68825. */
  68826. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68827. /**
  68828. * Updates the current quaternion from the given float coordinates
  68829. * @param x defines the x coordinate
  68830. * @param y defines the y coordinate
  68831. * @param z defines the z coordinate
  68832. * @param w defines the w coordinate
  68833. * @returns the updated current quaternion
  68834. */
  68835. set(x: number, y: number, z: number, w: number): Quaternion;
  68836. /**
  68837. * Adds two quaternions
  68838. * @param other defines the second operand
  68839. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68840. */
  68841. add(other: DeepImmutable<Quaternion>): Quaternion;
  68842. /**
  68843. * Add a quaternion to the current one
  68844. * @param other defines the quaternion to add
  68845. * @returns the current quaternion
  68846. */
  68847. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68848. /**
  68849. * Subtract two quaternions
  68850. * @param other defines the second operand
  68851. * @returns a new quaternion as the subtraction result of the given one from the current one
  68852. */
  68853. subtract(other: Quaternion): Quaternion;
  68854. /**
  68855. * Multiplies the current quaternion by a scale factor
  68856. * @param value defines the scale factor
  68857. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68858. */
  68859. scale(value: number): Quaternion;
  68860. /**
  68861. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68862. * @param scale defines the scale factor
  68863. * @param result defines the Quaternion object where to store the result
  68864. * @returns the unmodified current quaternion
  68865. */
  68866. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68867. /**
  68868. * Multiplies in place the current quaternion by a scale factor
  68869. * @param value defines the scale factor
  68870. * @returns the current modified quaternion
  68871. */
  68872. scaleInPlace(value: number): Quaternion;
  68873. /**
  68874. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68875. * @param scale defines the scale factor
  68876. * @param result defines the Quaternion object where to store the result
  68877. * @returns the unmodified current quaternion
  68878. */
  68879. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68880. /**
  68881. * Multiplies two quaternions
  68882. * @param q1 defines the second operand
  68883. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68884. */
  68885. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68886. /**
  68887. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68888. * @param q1 defines the second operand
  68889. * @param result defines the target quaternion
  68890. * @returns the current quaternion
  68891. */
  68892. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68893. /**
  68894. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68895. * @param q1 defines the second operand
  68896. * @returns the currentupdated quaternion
  68897. */
  68898. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68899. /**
  68900. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68901. * @param ref defines the target quaternion
  68902. * @returns the current quaternion
  68903. */
  68904. conjugateToRef(ref: Quaternion): Quaternion;
  68905. /**
  68906. * Conjugates in place (1-q) the current quaternion
  68907. * @returns the current updated quaternion
  68908. */
  68909. conjugateInPlace(): Quaternion;
  68910. /**
  68911. * Conjugates in place (1-q) the current quaternion
  68912. * @returns a new quaternion
  68913. */
  68914. conjugate(): Quaternion;
  68915. /**
  68916. * Gets length of current quaternion
  68917. * @returns the quaternion length (float)
  68918. */
  68919. length(): number;
  68920. /**
  68921. * Normalize in place the current quaternion
  68922. * @returns the current updated quaternion
  68923. */
  68924. normalize(): Quaternion;
  68925. /**
  68926. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68927. * @param order is a reserved parameter and is ignore for now
  68928. * @returns a new Vector3 containing the Euler angles
  68929. */
  68930. toEulerAngles(order?: string): Vector3;
  68931. /**
  68932. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68933. * @param result defines the vector which will be filled with the Euler angles
  68934. * @param order is a reserved parameter and is ignore for now
  68935. * @returns the current unchanged quaternion
  68936. */
  68937. toEulerAnglesToRef(result: Vector3): Quaternion;
  68938. /**
  68939. * Updates the given rotation matrix with the current quaternion values
  68940. * @param result defines the target matrix
  68941. * @returns the current unchanged quaternion
  68942. */
  68943. toRotationMatrix(result: Matrix): Quaternion;
  68944. /**
  68945. * Updates the current quaternion from the given rotation matrix values
  68946. * @param matrix defines the source matrix
  68947. * @returns the current updated quaternion
  68948. */
  68949. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68950. /**
  68951. * Creates a new quaternion from a rotation matrix
  68952. * @param matrix defines the source matrix
  68953. * @returns a new quaternion created from the given rotation matrix values
  68954. */
  68955. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68956. /**
  68957. * Updates the given quaternion with the given rotation matrix values
  68958. * @param matrix defines the source matrix
  68959. * @param result defines the target quaternion
  68960. */
  68961. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68962. /**
  68963. * Returns the dot product (float) between the quaternions "left" and "right"
  68964. * @param left defines the left operand
  68965. * @param right defines the right operand
  68966. * @returns the dot product
  68967. */
  68968. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68969. /**
  68970. * Checks if the two quaternions are close to each other
  68971. * @param quat0 defines the first quaternion to check
  68972. * @param quat1 defines the second quaternion to check
  68973. * @returns true if the two quaternions are close to each other
  68974. */
  68975. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68976. /**
  68977. * Creates an empty quaternion
  68978. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68979. */
  68980. static Zero(): Quaternion;
  68981. /**
  68982. * Inverse a given quaternion
  68983. * @param q defines the source quaternion
  68984. * @returns a new quaternion as the inverted current quaternion
  68985. */
  68986. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68987. /**
  68988. * Inverse a given quaternion
  68989. * @param q defines the source quaternion
  68990. * @param result the quaternion the result will be stored in
  68991. * @returns the result quaternion
  68992. */
  68993. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68994. /**
  68995. * Creates an identity quaternion
  68996. * @returns the identity quaternion
  68997. */
  68998. static Identity(): Quaternion;
  68999. /**
  69000. * Gets a boolean indicating if the given quaternion is identity
  69001. * @param quaternion defines the quaternion to check
  69002. * @returns true if the quaternion is identity
  69003. */
  69004. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69005. /**
  69006. * Creates a quaternion from a rotation around an axis
  69007. * @param axis defines the axis to use
  69008. * @param angle defines the angle to use
  69009. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69010. */
  69011. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69012. /**
  69013. * Creates a rotation around an axis and stores it into the given quaternion
  69014. * @param axis defines the axis to use
  69015. * @param angle defines the angle to use
  69016. * @param result defines the target quaternion
  69017. * @returns the target quaternion
  69018. */
  69019. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69020. /**
  69021. * Creates a new quaternion from data stored into an array
  69022. * @param array defines the data source
  69023. * @param offset defines the offset in the source array where the data starts
  69024. * @returns a new quaternion
  69025. */
  69026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69027. /**
  69028. * Create a quaternion from Euler rotation angles
  69029. * @param x Pitch
  69030. * @param y Yaw
  69031. * @param z Roll
  69032. * @returns the new Quaternion
  69033. */
  69034. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69035. /**
  69036. * Updates a quaternion from Euler rotation angles
  69037. * @param x Pitch
  69038. * @param y Yaw
  69039. * @param z Roll
  69040. * @param result the quaternion to store the result
  69041. * @returns the updated quaternion
  69042. */
  69043. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69044. /**
  69045. * Create a quaternion from Euler rotation vector
  69046. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69047. * @returns the new Quaternion
  69048. */
  69049. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69050. /**
  69051. * Updates a quaternion from Euler rotation vector
  69052. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69053. * @param result the quaternion to store the result
  69054. * @returns the updated quaternion
  69055. */
  69056. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69057. /**
  69058. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69059. * @param yaw defines the rotation around Y axis
  69060. * @param pitch defines the rotation around X axis
  69061. * @param roll defines the rotation around Z axis
  69062. * @returns the new quaternion
  69063. */
  69064. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69065. /**
  69066. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69067. * @param yaw defines the rotation around Y axis
  69068. * @param pitch defines the rotation around X axis
  69069. * @param roll defines the rotation around Z axis
  69070. * @param result defines the target quaternion
  69071. */
  69072. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69073. /**
  69074. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69075. * @param alpha defines the rotation around first axis
  69076. * @param beta defines the rotation around second axis
  69077. * @param gamma defines the rotation around third axis
  69078. * @returns the new quaternion
  69079. */
  69080. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69081. /**
  69082. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69083. * @param alpha defines the rotation around first axis
  69084. * @param beta defines the rotation around second axis
  69085. * @param gamma defines the rotation around third axis
  69086. * @param result defines the target quaternion
  69087. */
  69088. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69089. /**
  69090. * 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)
  69091. * @param axis1 defines the first axis
  69092. * @param axis2 defines the second axis
  69093. * @param axis3 defines the third axis
  69094. * @returns the new quaternion
  69095. */
  69096. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69097. /**
  69098. * 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
  69099. * @param axis1 defines the first axis
  69100. * @param axis2 defines the second axis
  69101. * @param axis3 defines the third axis
  69102. * @param ref defines the target quaternion
  69103. */
  69104. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69105. /**
  69106. * Interpolates between two quaternions
  69107. * @param left defines first quaternion
  69108. * @param right defines second quaternion
  69109. * @param amount defines the gradient to use
  69110. * @returns the new interpolated quaternion
  69111. */
  69112. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69113. /**
  69114. * Interpolates between two quaternions and stores it into a target quaternion
  69115. * @param left defines first quaternion
  69116. * @param right defines second quaternion
  69117. * @param amount defines the gradient to use
  69118. * @param result defines the target quaternion
  69119. */
  69120. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69121. /**
  69122. * Interpolate between two quaternions using Hermite interpolation
  69123. * @param value1 defines first quaternion
  69124. * @param tangent1 defines the incoming tangent
  69125. * @param value2 defines second quaternion
  69126. * @param tangent2 defines the outgoing tangent
  69127. * @param amount defines the target quaternion
  69128. * @returns the new interpolated quaternion
  69129. */
  69130. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69131. }
  69132. /**
  69133. * Class used to store matrix data (4x4)
  69134. */
  69135. export class Matrix {
  69136. private static _updateFlagSeed;
  69137. private static _identityReadOnly;
  69138. private _isIdentity;
  69139. private _isIdentityDirty;
  69140. private _isIdentity3x2;
  69141. private _isIdentity3x2Dirty;
  69142. /**
  69143. * Gets the update flag of the matrix which is an unique number for the matrix.
  69144. * It will be incremented every time the matrix data change.
  69145. * You can use it to speed the comparison between two versions of the same matrix.
  69146. */
  69147. updateFlag: number;
  69148. private readonly _m;
  69149. /**
  69150. * Gets the internal data of the matrix
  69151. */
  69152. readonly m: DeepImmutable<Float32Array>;
  69153. /** @hidden */
  69154. _markAsUpdated(): void;
  69155. /** @hidden */
  69156. private _updateIdentityStatus;
  69157. /**
  69158. * Creates an empty matrix (filled with zeros)
  69159. */
  69160. constructor();
  69161. /**
  69162. * Check if the current matrix is identity
  69163. * @returns true is the matrix is the identity matrix
  69164. */
  69165. isIdentity(): boolean;
  69166. /**
  69167. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69168. * @returns true is the matrix is the identity matrix
  69169. */
  69170. isIdentityAs3x2(): boolean;
  69171. /**
  69172. * Gets the determinant of the matrix
  69173. * @returns the matrix determinant
  69174. */
  69175. determinant(): number;
  69176. /**
  69177. * Returns the matrix as a Float32Array
  69178. * @returns the matrix underlying array
  69179. */
  69180. toArray(): DeepImmutable<Float32Array>;
  69181. /**
  69182. * Returns the matrix as a Float32Array
  69183. * @returns the matrix underlying array.
  69184. */
  69185. asArray(): DeepImmutable<Float32Array>;
  69186. /**
  69187. * Inverts the current matrix in place
  69188. * @returns the current inverted matrix
  69189. */
  69190. invert(): Matrix;
  69191. /**
  69192. * Sets all the matrix elements to zero
  69193. * @returns the current matrix
  69194. */
  69195. reset(): Matrix;
  69196. /**
  69197. * Adds the current matrix with a second one
  69198. * @param other defines the matrix to add
  69199. * @returns a new matrix as the addition of the current matrix and the given one
  69200. */
  69201. add(other: DeepImmutable<Matrix>): Matrix;
  69202. /**
  69203. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69204. * @param other defines the matrix to add
  69205. * @param result defines the target matrix
  69206. * @returns the current matrix
  69207. */
  69208. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69209. /**
  69210. * Adds in place the given matrix to the current matrix
  69211. * @param other defines the second operand
  69212. * @returns the current updated matrix
  69213. */
  69214. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69215. /**
  69216. * Sets the given matrix to the current inverted Matrix
  69217. * @param other defines the target matrix
  69218. * @returns the unmodified current matrix
  69219. */
  69220. invertToRef(other: Matrix): Matrix;
  69221. /**
  69222. * add a value at the specified position in the current Matrix
  69223. * @param index the index of the value within the matrix. between 0 and 15.
  69224. * @param value the value to be added
  69225. * @returns the current updated matrix
  69226. */
  69227. addAtIndex(index: number, value: number): Matrix;
  69228. /**
  69229. * mutiply the specified position in the current Matrix by a value
  69230. * @param index the index of the value within the matrix. between 0 and 15.
  69231. * @param value the value to be added
  69232. * @returns the current updated matrix
  69233. */
  69234. multiplyAtIndex(index: number, value: number): Matrix;
  69235. /**
  69236. * Inserts the translation vector (using 3 floats) in the current matrix
  69237. * @param x defines the 1st component of the translation
  69238. * @param y defines the 2nd component of the translation
  69239. * @param z defines the 3rd component of the translation
  69240. * @returns the current updated matrix
  69241. */
  69242. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69243. /**
  69244. * Adds the translation vector (using 3 floats) in the current matrix
  69245. * @param x defines the 1st component of the translation
  69246. * @param y defines the 2nd component of the translation
  69247. * @param z defines the 3rd component of the translation
  69248. * @returns the current updated matrix
  69249. */
  69250. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69251. /**
  69252. * Inserts the translation vector in the current matrix
  69253. * @param vector3 defines the translation to insert
  69254. * @returns the current updated matrix
  69255. */
  69256. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69257. /**
  69258. * Gets the translation value of the current matrix
  69259. * @returns a new Vector3 as the extracted translation from the matrix
  69260. */
  69261. getTranslation(): Vector3;
  69262. /**
  69263. * Fill a Vector3 with the extracted translation from the matrix
  69264. * @param result defines the Vector3 where to store the translation
  69265. * @returns the current matrix
  69266. */
  69267. getTranslationToRef(result: Vector3): Matrix;
  69268. /**
  69269. * Remove rotation and scaling part from the matrix
  69270. * @returns the updated matrix
  69271. */
  69272. removeRotationAndScaling(): Matrix;
  69273. /**
  69274. * Multiply two matrices
  69275. * @param other defines the second operand
  69276. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69277. */
  69278. multiply(other: DeepImmutable<Matrix>): Matrix;
  69279. /**
  69280. * Copy the current matrix from the given one
  69281. * @param other defines the source matrix
  69282. * @returns the current updated matrix
  69283. */
  69284. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69285. /**
  69286. * Populates the given array from the starting index with the current matrix values
  69287. * @param array defines the target array
  69288. * @param offset defines the offset in the target array where to start storing values
  69289. * @returns the current matrix
  69290. */
  69291. copyToArray(array: Float32Array, offset?: number): Matrix;
  69292. /**
  69293. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69294. * @param other defines the second operand
  69295. * @param result defines the matrix where to store the multiplication
  69296. * @returns the current matrix
  69297. */
  69298. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69299. /**
  69300. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69301. * @param other defines the second operand
  69302. * @param result defines the array where to store the multiplication
  69303. * @param offset defines the offset in the target array where to start storing values
  69304. * @returns the current matrix
  69305. */
  69306. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69307. /**
  69308. * Check equality between this matrix and a second one
  69309. * @param value defines the second matrix to compare
  69310. * @returns true is the current matrix and the given one values are strictly equal
  69311. */
  69312. equals(value: DeepImmutable<Matrix>): boolean;
  69313. /**
  69314. * Clone the current matrix
  69315. * @returns a new matrix from the current matrix
  69316. */
  69317. clone(): Matrix;
  69318. /**
  69319. * Returns the name of the current matrix class
  69320. * @returns the string "Matrix"
  69321. */
  69322. getClassName(): string;
  69323. /**
  69324. * Gets the hash code of the current matrix
  69325. * @returns the hash code
  69326. */
  69327. getHashCode(): number;
  69328. /**
  69329. * Decomposes the current Matrix into a translation, rotation and scaling components
  69330. * @param scale defines the scale vector3 given as a reference to update
  69331. * @param rotation defines the rotation quaternion given as a reference to update
  69332. * @param translation defines the translation vector3 given as a reference to update
  69333. * @returns true if operation was successful
  69334. */
  69335. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69336. /**
  69337. * Gets specific row of the matrix
  69338. * @param index defines the number of the row to get
  69339. * @returns the index-th row of the current matrix as a new Vector4
  69340. */
  69341. getRow(index: number): Nullable<Vector4>;
  69342. /**
  69343. * Sets the index-th row of the current matrix to the vector4 values
  69344. * @param index defines the number of the row to set
  69345. * @param row defines the target vector4
  69346. * @returns the updated current matrix
  69347. */
  69348. setRow(index: number, row: Vector4): Matrix;
  69349. /**
  69350. * Compute the transpose of the matrix
  69351. * @returns the new transposed matrix
  69352. */
  69353. transpose(): Matrix;
  69354. /**
  69355. * Compute the transpose of the matrix and store it in a given matrix
  69356. * @param result defines the target matrix
  69357. * @returns the current matrix
  69358. */
  69359. transposeToRef(result: Matrix): Matrix;
  69360. /**
  69361. * Sets the index-th row of the current matrix with the given 4 x float values
  69362. * @param index defines the row index
  69363. * @param x defines the x component to set
  69364. * @param y defines the y component to set
  69365. * @param z defines the z component to set
  69366. * @param w defines the w component to set
  69367. * @returns the updated current matrix
  69368. */
  69369. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69370. /**
  69371. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69372. * @param scale defines the scale factor
  69373. * @returns a new matrix
  69374. */
  69375. scale(scale: number): Matrix;
  69376. /**
  69377. * Scale the current matrix values by a factor to a given result matrix
  69378. * @param scale defines the scale factor
  69379. * @param result defines the matrix to store the result
  69380. * @returns the current matrix
  69381. */
  69382. scaleToRef(scale: number, result: Matrix): Matrix;
  69383. /**
  69384. * Scale the current matrix values by a factor and add the result to a given matrix
  69385. * @param scale defines the scale factor
  69386. * @param result defines the Matrix to store the result
  69387. * @returns the current matrix
  69388. */
  69389. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69390. /**
  69391. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69392. * @param ref matrix to store the result
  69393. */
  69394. toNormalMatrix(ref: Matrix): void;
  69395. /**
  69396. * Gets only rotation part of the current matrix
  69397. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69398. */
  69399. getRotationMatrix(): Matrix;
  69400. /**
  69401. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69402. * @param result defines the target matrix to store data to
  69403. * @returns the current matrix
  69404. */
  69405. getRotationMatrixToRef(result: Matrix): Matrix;
  69406. /**
  69407. * Toggles model matrix from being right handed to left handed in place and vice versa
  69408. */
  69409. toggleModelMatrixHandInPlace(): void;
  69410. /**
  69411. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69412. */
  69413. toggleProjectionMatrixHandInPlace(): void;
  69414. /**
  69415. * Creates a matrix from an array
  69416. * @param array defines the source array
  69417. * @param offset defines an offset in the source array
  69418. * @returns a new Matrix set from the starting index of the given array
  69419. */
  69420. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69421. /**
  69422. * Copy the content of an array into a given matrix
  69423. * @param array defines the source array
  69424. * @param offset defines an offset in the source array
  69425. * @param result defines the target matrix
  69426. */
  69427. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69428. /**
  69429. * Stores an array into a matrix after having multiplied each component by a given factor
  69430. * @param array defines the source array
  69431. * @param offset defines the offset in the source array
  69432. * @param scale defines the scaling factor
  69433. * @param result defines the target matrix
  69434. */
  69435. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69436. /**
  69437. * Gets an identity matrix that must not be updated
  69438. */
  69439. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69440. /**
  69441. * Stores a list of values (16) inside a given matrix
  69442. * @param initialM11 defines 1st value of 1st row
  69443. * @param initialM12 defines 2nd value of 1st row
  69444. * @param initialM13 defines 3rd value of 1st row
  69445. * @param initialM14 defines 4th value of 1st row
  69446. * @param initialM21 defines 1st value of 2nd row
  69447. * @param initialM22 defines 2nd value of 2nd row
  69448. * @param initialM23 defines 3rd value of 2nd row
  69449. * @param initialM24 defines 4th value of 2nd row
  69450. * @param initialM31 defines 1st value of 3rd row
  69451. * @param initialM32 defines 2nd value of 3rd row
  69452. * @param initialM33 defines 3rd value of 3rd row
  69453. * @param initialM34 defines 4th value of 3rd row
  69454. * @param initialM41 defines 1st value of 4th row
  69455. * @param initialM42 defines 2nd value of 4th row
  69456. * @param initialM43 defines 3rd value of 4th row
  69457. * @param initialM44 defines 4th value of 4th row
  69458. * @param result defines the target matrix
  69459. */
  69460. 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;
  69461. /**
  69462. * Creates new matrix from a list of values (16)
  69463. * @param initialM11 defines 1st value of 1st row
  69464. * @param initialM12 defines 2nd value of 1st row
  69465. * @param initialM13 defines 3rd value of 1st row
  69466. * @param initialM14 defines 4th value of 1st row
  69467. * @param initialM21 defines 1st value of 2nd row
  69468. * @param initialM22 defines 2nd value of 2nd row
  69469. * @param initialM23 defines 3rd value of 2nd row
  69470. * @param initialM24 defines 4th value of 2nd row
  69471. * @param initialM31 defines 1st value of 3rd row
  69472. * @param initialM32 defines 2nd value of 3rd row
  69473. * @param initialM33 defines 3rd value of 3rd row
  69474. * @param initialM34 defines 4th value of 3rd row
  69475. * @param initialM41 defines 1st value of 4th row
  69476. * @param initialM42 defines 2nd value of 4th row
  69477. * @param initialM43 defines 3rd value of 4th row
  69478. * @param initialM44 defines 4th value of 4th row
  69479. * @returns the new matrix
  69480. */
  69481. 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;
  69482. /**
  69483. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69484. * @param scale defines the scale vector3
  69485. * @param rotation defines the rotation quaternion
  69486. * @param translation defines the translation vector3
  69487. * @returns a new matrix
  69488. */
  69489. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69490. /**
  69491. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69492. * @param scale defines the scale vector3
  69493. * @param rotation defines the rotation quaternion
  69494. * @param translation defines the translation vector3
  69495. * @param result defines the target matrix
  69496. */
  69497. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69498. /**
  69499. * Creates a new identity matrix
  69500. * @returns a new identity matrix
  69501. */
  69502. static Identity(): Matrix;
  69503. /**
  69504. * Creates a new identity matrix and stores the result in a given matrix
  69505. * @param result defines the target matrix
  69506. */
  69507. static IdentityToRef(result: Matrix): void;
  69508. /**
  69509. * Creates a new zero matrix
  69510. * @returns a new zero matrix
  69511. */
  69512. static Zero(): Matrix;
  69513. /**
  69514. * Creates a new rotation matrix for "angle" radians around the X axis
  69515. * @param angle defines the angle (in radians) to use
  69516. * @return the new matrix
  69517. */
  69518. static RotationX(angle: number): Matrix;
  69519. /**
  69520. * Creates a new matrix as the invert of a given matrix
  69521. * @param source defines the source matrix
  69522. * @returns the new matrix
  69523. */
  69524. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69525. /**
  69526. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69527. * @param angle defines the angle (in radians) to use
  69528. * @param result defines the target matrix
  69529. */
  69530. static RotationXToRef(angle: number, result: Matrix): void;
  69531. /**
  69532. * Creates a new rotation matrix for "angle" radians around the Y axis
  69533. * @param angle defines the angle (in radians) to use
  69534. * @return the new matrix
  69535. */
  69536. static RotationY(angle: number): Matrix;
  69537. /**
  69538. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69539. * @param angle defines the angle (in radians) to use
  69540. * @param result defines the target matrix
  69541. */
  69542. static RotationYToRef(angle: number, result: Matrix): void;
  69543. /**
  69544. * Creates a new rotation matrix for "angle" radians around the Z axis
  69545. * @param angle defines the angle (in radians) to use
  69546. * @return the new matrix
  69547. */
  69548. static RotationZ(angle: number): Matrix;
  69549. /**
  69550. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69551. * @param angle defines the angle (in radians) to use
  69552. * @param result defines the target matrix
  69553. */
  69554. static RotationZToRef(angle: number, result: Matrix): void;
  69555. /**
  69556. * Creates a new rotation matrix for "angle" radians around the given axis
  69557. * @param axis defines the axis to use
  69558. * @param angle defines the angle (in radians) to use
  69559. * @return the new matrix
  69560. */
  69561. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69562. /**
  69563. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69564. * @param axis defines the axis to use
  69565. * @param angle defines the angle (in radians) to use
  69566. * @param result defines the target matrix
  69567. */
  69568. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69569. /**
  69570. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69571. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69572. * @param from defines the vector to align
  69573. * @param to defines the vector to align to
  69574. * @param result defines the target matrix
  69575. */
  69576. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69577. /**
  69578. * Creates a rotation matrix
  69579. * @param yaw defines the yaw angle in radians (Y axis)
  69580. * @param pitch defines the pitch angle in radians (X axis)
  69581. * @param roll defines the roll angle in radians (X axis)
  69582. * @returns the new rotation matrix
  69583. */
  69584. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69585. /**
  69586. * Creates a rotation matrix and stores it in a given matrix
  69587. * @param yaw defines the yaw angle in radians (Y axis)
  69588. * @param pitch defines the pitch angle in radians (X axis)
  69589. * @param roll defines the roll angle in radians (X axis)
  69590. * @param result defines the target matrix
  69591. */
  69592. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69593. /**
  69594. * Creates a scaling matrix
  69595. * @param x defines the scale factor on X axis
  69596. * @param y defines the scale factor on Y axis
  69597. * @param z defines the scale factor on Z axis
  69598. * @returns the new matrix
  69599. */
  69600. static Scaling(x: number, y: number, z: number): Matrix;
  69601. /**
  69602. * Creates a scaling matrix and stores it in a given matrix
  69603. * @param x defines the scale factor on X axis
  69604. * @param y defines the scale factor on Y axis
  69605. * @param z defines the scale factor on Z axis
  69606. * @param result defines the target matrix
  69607. */
  69608. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69609. /**
  69610. * Creates a translation matrix
  69611. * @param x defines the translation on X axis
  69612. * @param y defines the translation on Y axis
  69613. * @param z defines the translationon Z axis
  69614. * @returns the new matrix
  69615. */
  69616. static Translation(x: number, y: number, z: number): Matrix;
  69617. /**
  69618. * Creates a translation matrix and stores it in a given matrix
  69619. * @param x defines the translation on X axis
  69620. * @param y defines the translation on Y axis
  69621. * @param z defines the translationon Z axis
  69622. * @param result defines the target matrix
  69623. */
  69624. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69625. /**
  69626. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69627. * @param startValue defines the start value
  69628. * @param endValue defines the end value
  69629. * @param gradient defines the gradient factor
  69630. * @returns the new matrix
  69631. */
  69632. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69633. /**
  69634. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69635. * @param startValue defines the start value
  69636. * @param endValue defines the end value
  69637. * @param gradient defines the gradient factor
  69638. * @param result defines the Matrix object where to store data
  69639. */
  69640. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69641. /**
  69642. * Builds a new matrix whose values are computed by:
  69643. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69644. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69645. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69646. * @param startValue defines the first matrix
  69647. * @param endValue defines the second matrix
  69648. * @param gradient defines the gradient between the two matrices
  69649. * @returns the new matrix
  69650. */
  69651. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69652. /**
  69653. * Update a matrix to values which are computed by:
  69654. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69655. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69656. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69657. * @param startValue defines the first matrix
  69658. * @param endValue defines the second matrix
  69659. * @param gradient defines the gradient between the two matrices
  69660. * @param result defines the target matrix
  69661. */
  69662. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69663. /**
  69664. * 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"
  69665. * This function works in left handed mode
  69666. * @param eye defines the final position of the entity
  69667. * @param target defines where the entity should look at
  69668. * @param up defines the up vector for the entity
  69669. * @returns the new matrix
  69670. */
  69671. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69672. /**
  69673. * 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".
  69674. * This function works in left handed mode
  69675. * @param eye defines the final position of the entity
  69676. * @param target defines where the entity should look at
  69677. * @param up defines the up vector for the entity
  69678. * @param result defines the target matrix
  69679. */
  69680. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69681. /**
  69682. * 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"
  69683. * This function works in right handed mode
  69684. * @param eye defines the final position of the entity
  69685. * @param target defines where the entity should look at
  69686. * @param up defines the up vector for the entity
  69687. * @returns the new matrix
  69688. */
  69689. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69690. /**
  69691. * 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".
  69692. * This function works in right handed mode
  69693. * @param eye defines the final position of the entity
  69694. * @param target defines where the entity should look at
  69695. * @param up defines the up vector for the entity
  69696. * @param result defines the target matrix
  69697. */
  69698. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69699. /**
  69700. * Create a left-handed orthographic projection matrix
  69701. * @param width defines the viewport width
  69702. * @param height defines the viewport height
  69703. * @param znear defines the near clip plane
  69704. * @param zfar defines the far clip plane
  69705. * @returns a new matrix as a left-handed orthographic projection matrix
  69706. */
  69707. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69708. /**
  69709. * Store a left-handed orthographic projection to a given matrix
  69710. * @param width defines the viewport width
  69711. * @param height defines the viewport height
  69712. * @param znear defines the near clip plane
  69713. * @param zfar defines the far clip plane
  69714. * @param result defines the target matrix
  69715. */
  69716. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69717. /**
  69718. * Create a left-handed orthographic projection matrix
  69719. * @param left defines the viewport left coordinate
  69720. * @param right defines the viewport right coordinate
  69721. * @param bottom defines the viewport bottom coordinate
  69722. * @param top defines the viewport top coordinate
  69723. * @param znear defines the near clip plane
  69724. * @param zfar defines the far clip plane
  69725. * @returns a new matrix as a left-handed orthographic projection matrix
  69726. */
  69727. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69728. /**
  69729. * Stores a left-handed orthographic projection into a given matrix
  69730. * @param left defines the viewport left coordinate
  69731. * @param right defines the viewport right coordinate
  69732. * @param bottom defines the viewport bottom coordinate
  69733. * @param top defines the viewport top coordinate
  69734. * @param znear defines the near clip plane
  69735. * @param zfar defines the far clip plane
  69736. * @param result defines the target matrix
  69737. */
  69738. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69739. /**
  69740. * Creates a right-handed orthographic projection matrix
  69741. * @param left defines the viewport left coordinate
  69742. * @param right defines the viewport right coordinate
  69743. * @param bottom defines the viewport bottom coordinate
  69744. * @param top defines the viewport top coordinate
  69745. * @param znear defines the near clip plane
  69746. * @param zfar defines the far clip plane
  69747. * @returns a new matrix as a right-handed orthographic projection matrix
  69748. */
  69749. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69750. /**
  69751. * Stores a right-handed orthographic projection into a given matrix
  69752. * @param left defines the viewport left coordinate
  69753. * @param right defines the viewport right coordinate
  69754. * @param bottom defines the viewport bottom coordinate
  69755. * @param top defines the viewport top coordinate
  69756. * @param znear defines the near clip plane
  69757. * @param zfar defines the far clip plane
  69758. * @param result defines the target matrix
  69759. */
  69760. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69761. /**
  69762. * Creates a left-handed perspective projection matrix
  69763. * @param width defines the viewport width
  69764. * @param height defines the viewport height
  69765. * @param znear defines the near clip plane
  69766. * @param zfar defines the far clip plane
  69767. * @returns a new matrix as a left-handed perspective projection matrix
  69768. */
  69769. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69770. /**
  69771. * Creates a left-handed perspective projection matrix
  69772. * @param fov defines the horizontal field of view
  69773. * @param aspect defines the aspect ratio
  69774. * @param znear defines the near clip plane
  69775. * @param zfar defines the far clip plane
  69776. * @returns a new matrix as a left-handed perspective projection matrix
  69777. */
  69778. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69779. /**
  69780. * Stores a left-handed perspective projection into a given matrix
  69781. * @param fov defines the horizontal field of view
  69782. * @param aspect defines the aspect ratio
  69783. * @param znear defines the near clip plane
  69784. * @param zfar defines the far clip plane
  69785. * @param result defines the target matrix
  69786. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69787. */
  69788. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69789. /**
  69790. * Creates a right-handed perspective projection matrix
  69791. * @param fov defines the horizontal field of view
  69792. * @param aspect defines the aspect ratio
  69793. * @param znear defines the near clip plane
  69794. * @param zfar defines the far clip plane
  69795. * @returns a new matrix as a right-handed perspective projection matrix
  69796. */
  69797. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69798. /**
  69799. * Stores a right-handed perspective projection into a given matrix
  69800. * @param fov defines the horizontal field of view
  69801. * @param aspect defines the aspect ratio
  69802. * @param znear defines the near clip plane
  69803. * @param zfar defines the far clip plane
  69804. * @param result defines the target matrix
  69805. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69806. */
  69807. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69808. /**
  69809. * Stores a perspective projection for WebVR info a given matrix
  69810. * @param fov defines the field of view
  69811. * @param znear defines the near clip plane
  69812. * @param zfar defines the far clip plane
  69813. * @param result defines the target matrix
  69814. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69815. */
  69816. static PerspectiveFovWebVRToRef(fov: {
  69817. upDegrees: number;
  69818. downDegrees: number;
  69819. leftDegrees: number;
  69820. rightDegrees: number;
  69821. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69822. /**
  69823. * Computes a complete transformation matrix
  69824. * @param viewport defines the viewport to use
  69825. * @param world defines the world matrix
  69826. * @param view defines the view matrix
  69827. * @param projection defines the projection matrix
  69828. * @param zmin defines the near clip plane
  69829. * @param zmax defines the far clip plane
  69830. * @returns the transformation matrix
  69831. */
  69832. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69833. /**
  69834. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69835. * @param matrix defines the matrix to use
  69836. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69837. */
  69838. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69839. /**
  69840. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69841. * @param matrix defines the matrix to use
  69842. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69843. */
  69844. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69845. /**
  69846. * Compute the transpose of a given matrix
  69847. * @param matrix defines the matrix to transpose
  69848. * @returns the new matrix
  69849. */
  69850. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69851. /**
  69852. * Compute the transpose of a matrix and store it in a target matrix
  69853. * @param matrix defines the matrix to transpose
  69854. * @param result defines the target matrix
  69855. */
  69856. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69857. /**
  69858. * Computes a reflection matrix from a plane
  69859. * @param plane defines the reflection plane
  69860. * @returns a new matrix
  69861. */
  69862. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69863. /**
  69864. * Computes a reflection matrix from a plane
  69865. * @param plane defines the reflection plane
  69866. * @param result defines the target matrix
  69867. */
  69868. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69869. /**
  69870. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69871. * @param xaxis defines the value of the 1st axis
  69872. * @param yaxis defines the value of the 2nd axis
  69873. * @param zaxis defines the value of the 3rd axis
  69874. * @param result defines the target matrix
  69875. */
  69876. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69877. /**
  69878. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69879. * @param quat defines the quaternion to use
  69880. * @param result defines the target matrix
  69881. */
  69882. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69883. }
  69884. /**
  69885. * @hidden
  69886. */
  69887. export class TmpVectors {
  69888. static Vector2: Vector2[];
  69889. static Vector3: Vector3[];
  69890. static Vector4: Vector4[];
  69891. static Quaternion: Quaternion[];
  69892. static Matrix: Matrix[];
  69893. }
  69894. }
  69895. declare module BABYLON {
  69896. /**
  69897. * Class used to hold a RBG color
  69898. */
  69899. export class Color3 {
  69900. /**
  69901. * Defines the red component (between 0 and 1, default is 0)
  69902. */
  69903. r: number;
  69904. /**
  69905. * Defines the green component (between 0 and 1, default is 0)
  69906. */
  69907. g: number;
  69908. /**
  69909. * Defines the blue component (between 0 and 1, default is 0)
  69910. */
  69911. b: number;
  69912. /**
  69913. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69914. * @param r defines the red component (between 0 and 1, default is 0)
  69915. * @param g defines the green component (between 0 and 1, default is 0)
  69916. * @param b defines the blue component (between 0 and 1, default is 0)
  69917. */
  69918. constructor(
  69919. /**
  69920. * Defines the red component (between 0 and 1, default is 0)
  69921. */
  69922. r?: number,
  69923. /**
  69924. * Defines the green component (between 0 and 1, default is 0)
  69925. */
  69926. g?: number,
  69927. /**
  69928. * Defines the blue component (between 0 and 1, default is 0)
  69929. */
  69930. b?: number);
  69931. /**
  69932. * Creates a string with the Color3 current values
  69933. * @returns the string representation of the Color3 object
  69934. */
  69935. toString(): string;
  69936. /**
  69937. * Returns the string "Color3"
  69938. * @returns "Color3"
  69939. */
  69940. getClassName(): string;
  69941. /**
  69942. * Compute the Color3 hash code
  69943. * @returns an unique number that can be used to hash Color3 objects
  69944. */
  69945. getHashCode(): number;
  69946. /**
  69947. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69948. * @param array defines the array where to store the r,g,b components
  69949. * @param index defines an optional index in the target array to define where to start storing values
  69950. * @returns the current Color3 object
  69951. */
  69952. toArray(array: FloatArray, index?: number): Color3;
  69953. /**
  69954. * Returns a new Color4 object from the current Color3 and the given alpha
  69955. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69956. * @returns a new Color4 object
  69957. */
  69958. toColor4(alpha?: number): Color4;
  69959. /**
  69960. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69961. * @returns the new array
  69962. */
  69963. asArray(): number[];
  69964. /**
  69965. * Returns the luminance value
  69966. * @returns a float value
  69967. */
  69968. toLuminance(): number;
  69969. /**
  69970. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69971. * @param otherColor defines the second operand
  69972. * @returns the new Color3 object
  69973. */
  69974. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69975. /**
  69976. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69977. * @param otherColor defines the second operand
  69978. * @param result defines the Color3 object where to store the result
  69979. * @returns the current Color3
  69980. */
  69981. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69982. /**
  69983. * Determines equality between Color3 objects
  69984. * @param otherColor defines the second operand
  69985. * @returns true if the rgb values are equal to the given ones
  69986. */
  69987. equals(otherColor: DeepImmutable<Color3>): boolean;
  69988. /**
  69989. * Determines equality between the current Color3 object and a set of r,b,g values
  69990. * @param r defines the red component to check
  69991. * @param g defines the green component to check
  69992. * @param b defines the blue component to check
  69993. * @returns true if the rgb values are equal to the given ones
  69994. */
  69995. equalsFloats(r: number, g: number, b: number): boolean;
  69996. /**
  69997. * Multiplies in place each rgb value by scale
  69998. * @param scale defines the scaling factor
  69999. * @returns the updated Color3
  70000. */
  70001. scale(scale: number): Color3;
  70002. /**
  70003. * Multiplies the rgb values by scale and stores the result into "result"
  70004. * @param scale defines the scaling factor
  70005. * @param result defines the Color3 object where to store the result
  70006. * @returns the unmodified current Color3
  70007. */
  70008. scaleToRef(scale: number, result: Color3): Color3;
  70009. /**
  70010. * Scale the current Color3 values by a factor and add the result to a given Color3
  70011. * @param scale defines the scale factor
  70012. * @param result defines color to store the result into
  70013. * @returns the unmodified current Color3
  70014. */
  70015. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70016. /**
  70017. * Clamps the rgb values by the min and max values and stores the result into "result"
  70018. * @param min defines minimum clamping value (default is 0)
  70019. * @param max defines maximum clamping value (default is 1)
  70020. * @param result defines color to store the result into
  70021. * @returns the original Color3
  70022. */
  70023. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70024. /**
  70025. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70026. * @param otherColor defines the second operand
  70027. * @returns the new Color3
  70028. */
  70029. add(otherColor: DeepImmutable<Color3>): Color3;
  70030. /**
  70031. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70032. * @param otherColor defines the second operand
  70033. * @param result defines Color3 object to store the result into
  70034. * @returns the unmodified current Color3
  70035. */
  70036. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70037. /**
  70038. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70039. * @param otherColor defines the second operand
  70040. * @returns the new Color3
  70041. */
  70042. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70043. /**
  70044. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70045. * @param otherColor defines the second operand
  70046. * @param result defines Color3 object to store the result into
  70047. * @returns the unmodified current Color3
  70048. */
  70049. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70050. /**
  70051. * Copy the current object
  70052. * @returns a new Color3 copied the current one
  70053. */
  70054. clone(): Color3;
  70055. /**
  70056. * Copies the rgb values from the source in the current Color3
  70057. * @param source defines the source Color3 object
  70058. * @returns the updated Color3 object
  70059. */
  70060. copyFrom(source: DeepImmutable<Color3>): Color3;
  70061. /**
  70062. * Updates the Color3 rgb values from the given floats
  70063. * @param r defines the red component to read from
  70064. * @param g defines the green component to read from
  70065. * @param b defines the blue component to read from
  70066. * @returns the current Color3 object
  70067. */
  70068. copyFromFloats(r: number, g: number, b: number): Color3;
  70069. /**
  70070. * Updates the Color3 rgb values from the given floats
  70071. * @param r defines the red component to read from
  70072. * @param g defines the green component to read from
  70073. * @param b defines the blue component to read from
  70074. * @returns the current Color3 object
  70075. */
  70076. set(r: number, g: number, b: number): Color3;
  70077. /**
  70078. * Compute the Color3 hexadecimal code as a string
  70079. * @returns a string containing the hexadecimal representation of the Color3 object
  70080. */
  70081. toHexString(): string;
  70082. /**
  70083. * Computes a new Color3 converted from the current one to linear space
  70084. * @returns a new Color3 object
  70085. */
  70086. toLinearSpace(): Color3;
  70087. /**
  70088. * Converts current color in rgb space to HSV values
  70089. * @returns a new color3 representing the HSV values
  70090. */
  70091. toHSV(): Color3;
  70092. /**
  70093. * Converts current color in rgb space to HSV values
  70094. * @param result defines the Color3 where to store the HSV values
  70095. */
  70096. toHSVToRef(result: Color3): void;
  70097. /**
  70098. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70099. * @param convertedColor defines the Color3 object where to store the linear space version
  70100. * @returns the unmodified Color3
  70101. */
  70102. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70103. /**
  70104. * Computes a new Color3 converted from the current one to gamma space
  70105. * @returns a new Color3 object
  70106. */
  70107. toGammaSpace(): Color3;
  70108. /**
  70109. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70110. * @param convertedColor defines the Color3 object where to store the gamma space version
  70111. * @returns the unmodified Color3
  70112. */
  70113. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70114. private static _BlackReadOnly;
  70115. /**
  70116. * Convert Hue, saturation and value to a Color3 (RGB)
  70117. * @param hue defines the hue
  70118. * @param saturation defines the saturation
  70119. * @param value defines the value
  70120. * @param result defines the Color3 where to store the RGB values
  70121. */
  70122. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70123. /**
  70124. * Creates a new Color3 from the string containing valid hexadecimal values
  70125. * @param hex defines a string containing valid hexadecimal values
  70126. * @returns a new Color3 object
  70127. */
  70128. static FromHexString(hex: string): Color3;
  70129. /**
  70130. * Creates a new Color3 from the starting index of the given array
  70131. * @param array defines the source array
  70132. * @param offset defines an offset in the source array
  70133. * @returns a new Color3 object
  70134. */
  70135. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70136. /**
  70137. * Creates a new Color3 from integer values (< 256)
  70138. * @param r defines the red component to read from (value between 0 and 255)
  70139. * @param g defines the green component to read from (value between 0 and 255)
  70140. * @param b defines the blue component to read from (value between 0 and 255)
  70141. * @returns a new Color3 object
  70142. */
  70143. static FromInts(r: number, g: number, b: number): Color3;
  70144. /**
  70145. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70146. * @param start defines the start Color3 value
  70147. * @param end defines the end Color3 value
  70148. * @param amount defines the gradient value between start and end
  70149. * @returns a new Color3 object
  70150. */
  70151. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70152. /**
  70153. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70154. * @param left defines the start value
  70155. * @param right defines the end value
  70156. * @param amount defines the gradient factor
  70157. * @param result defines the Color3 object where to store the result
  70158. */
  70159. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70160. /**
  70161. * Returns a Color3 value containing a red color
  70162. * @returns a new Color3 object
  70163. */
  70164. static Red(): Color3;
  70165. /**
  70166. * Returns a Color3 value containing a green color
  70167. * @returns a new Color3 object
  70168. */
  70169. static Green(): Color3;
  70170. /**
  70171. * Returns a Color3 value containing a blue color
  70172. * @returns a new Color3 object
  70173. */
  70174. static Blue(): Color3;
  70175. /**
  70176. * Returns a Color3 value containing a black color
  70177. * @returns a new Color3 object
  70178. */
  70179. static Black(): Color3;
  70180. /**
  70181. * Gets a Color3 value containing a black color that must not be updated
  70182. */
  70183. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70184. /**
  70185. * Returns a Color3 value containing a white color
  70186. * @returns a new Color3 object
  70187. */
  70188. static White(): Color3;
  70189. /**
  70190. * Returns a Color3 value containing a purple color
  70191. * @returns a new Color3 object
  70192. */
  70193. static Purple(): Color3;
  70194. /**
  70195. * Returns a Color3 value containing a magenta color
  70196. * @returns a new Color3 object
  70197. */
  70198. static Magenta(): Color3;
  70199. /**
  70200. * Returns a Color3 value containing a yellow color
  70201. * @returns a new Color3 object
  70202. */
  70203. static Yellow(): Color3;
  70204. /**
  70205. * Returns a Color3 value containing a gray color
  70206. * @returns a new Color3 object
  70207. */
  70208. static Gray(): Color3;
  70209. /**
  70210. * Returns a Color3 value containing a teal color
  70211. * @returns a new Color3 object
  70212. */
  70213. static Teal(): Color3;
  70214. /**
  70215. * Returns a Color3 value containing a random color
  70216. * @returns a new Color3 object
  70217. */
  70218. static Random(): Color3;
  70219. }
  70220. /**
  70221. * Class used to hold a RBGA color
  70222. */
  70223. export class Color4 {
  70224. /**
  70225. * Defines the red component (between 0 and 1, default is 0)
  70226. */
  70227. r: number;
  70228. /**
  70229. * Defines the green component (between 0 and 1, default is 0)
  70230. */
  70231. g: number;
  70232. /**
  70233. * Defines the blue component (between 0 and 1, default is 0)
  70234. */
  70235. b: number;
  70236. /**
  70237. * Defines the alpha component (between 0 and 1, default is 1)
  70238. */
  70239. a: number;
  70240. /**
  70241. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70242. * @param r defines the red component (between 0 and 1, default is 0)
  70243. * @param g defines the green component (between 0 and 1, default is 0)
  70244. * @param b defines the blue component (between 0 and 1, default is 0)
  70245. * @param a defines the alpha component (between 0 and 1, default is 1)
  70246. */
  70247. constructor(
  70248. /**
  70249. * Defines the red component (between 0 and 1, default is 0)
  70250. */
  70251. r?: number,
  70252. /**
  70253. * Defines the green component (between 0 and 1, default is 0)
  70254. */
  70255. g?: number,
  70256. /**
  70257. * Defines the blue component (between 0 and 1, default is 0)
  70258. */
  70259. b?: number,
  70260. /**
  70261. * Defines the alpha component (between 0 and 1, default is 1)
  70262. */
  70263. a?: number);
  70264. /**
  70265. * Adds in place the given Color4 values to the current Color4 object
  70266. * @param right defines the second operand
  70267. * @returns the current updated Color4 object
  70268. */
  70269. addInPlace(right: DeepImmutable<Color4>): Color4;
  70270. /**
  70271. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70272. * @returns the new array
  70273. */
  70274. asArray(): number[];
  70275. /**
  70276. * Stores from the starting index in the given array the Color4 successive values
  70277. * @param array defines the array where to store the r,g,b components
  70278. * @param index defines an optional index in the target array to define where to start storing values
  70279. * @returns the current Color4 object
  70280. */
  70281. toArray(array: number[], index?: number): Color4;
  70282. /**
  70283. * Determines equality between Color4 objects
  70284. * @param otherColor defines the second operand
  70285. * @returns true if the rgba values are equal to the given ones
  70286. */
  70287. equals(otherColor: DeepImmutable<Color4>): boolean;
  70288. /**
  70289. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70290. * @param right defines the second operand
  70291. * @returns a new Color4 object
  70292. */
  70293. add(right: DeepImmutable<Color4>): Color4;
  70294. /**
  70295. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70296. * @param right defines the second operand
  70297. * @returns a new Color4 object
  70298. */
  70299. subtract(right: DeepImmutable<Color4>): Color4;
  70300. /**
  70301. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70302. * @param right defines the second operand
  70303. * @param result defines the Color4 object where to store the result
  70304. * @returns the current Color4 object
  70305. */
  70306. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70307. /**
  70308. * Creates a new Color4 with the current Color4 values multiplied by scale
  70309. * @param scale defines the scaling factor to apply
  70310. * @returns a new Color4 object
  70311. */
  70312. scale(scale: number): Color4;
  70313. /**
  70314. * Multiplies the current Color4 values by scale and stores the result in "result"
  70315. * @param scale defines the scaling factor to apply
  70316. * @param result defines the Color4 object where to store the result
  70317. * @returns the current unmodified Color4
  70318. */
  70319. scaleToRef(scale: number, result: Color4): Color4;
  70320. /**
  70321. * Scale the current Color4 values by a factor and add the result to a given Color4
  70322. * @param scale defines the scale factor
  70323. * @param result defines the Color4 object where to store the result
  70324. * @returns the unmodified current Color4
  70325. */
  70326. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70327. /**
  70328. * Clamps the rgb values by the min and max values and stores the result into "result"
  70329. * @param min defines minimum clamping value (default is 0)
  70330. * @param max defines maximum clamping value (default is 1)
  70331. * @param result defines color to store the result into.
  70332. * @returns the cuurent Color4
  70333. */
  70334. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70335. /**
  70336. * Multipy an Color4 value by another and return a new Color4 object
  70337. * @param color defines the Color4 value to multiply by
  70338. * @returns a new Color4 object
  70339. */
  70340. multiply(color: Color4): Color4;
  70341. /**
  70342. * Multipy a Color4 value by another and push the result in a reference value
  70343. * @param color defines the Color4 value to multiply by
  70344. * @param result defines the Color4 to fill the result in
  70345. * @returns the result Color4
  70346. */
  70347. multiplyToRef(color: Color4, result: Color4): Color4;
  70348. /**
  70349. * Creates a string with the Color4 current values
  70350. * @returns the string representation of the Color4 object
  70351. */
  70352. toString(): string;
  70353. /**
  70354. * Returns the string "Color4"
  70355. * @returns "Color4"
  70356. */
  70357. getClassName(): string;
  70358. /**
  70359. * Compute the Color4 hash code
  70360. * @returns an unique number that can be used to hash Color4 objects
  70361. */
  70362. getHashCode(): number;
  70363. /**
  70364. * Creates a new Color4 copied from the current one
  70365. * @returns a new Color4 object
  70366. */
  70367. clone(): Color4;
  70368. /**
  70369. * Copies the given Color4 values into the current one
  70370. * @param source defines the source Color4 object
  70371. * @returns the current updated Color4 object
  70372. */
  70373. copyFrom(source: Color4): Color4;
  70374. /**
  70375. * Copies the given float values into the current one
  70376. * @param r defines the red component to read from
  70377. * @param g defines the green component to read from
  70378. * @param b defines the blue component to read from
  70379. * @param a defines the alpha component to read from
  70380. * @returns the current updated Color4 object
  70381. */
  70382. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70383. /**
  70384. * Copies the given float values into the current one
  70385. * @param r defines the red component to read from
  70386. * @param g defines the green component to read from
  70387. * @param b defines the blue component to read from
  70388. * @param a defines the alpha component to read from
  70389. * @returns the current updated Color4 object
  70390. */
  70391. set(r: number, g: number, b: number, a: number): Color4;
  70392. /**
  70393. * Compute the Color4 hexadecimal code as a string
  70394. * @returns a string containing the hexadecimal representation of the Color4 object
  70395. */
  70396. toHexString(): string;
  70397. /**
  70398. * Computes a new Color4 converted from the current one to linear space
  70399. * @returns a new Color4 object
  70400. */
  70401. toLinearSpace(): Color4;
  70402. /**
  70403. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70404. * @param convertedColor defines the Color4 object where to store the linear space version
  70405. * @returns the unmodified Color4
  70406. */
  70407. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70408. /**
  70409. * Computes a new Color4 converted from the current one to gamma space
  70410. * @returns a new Color4 object
  70411. */
  70412. toGammaSpace(): Color4;
  70413. /**
  70414. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70415. * @param convertedColor defines the Color4 object where to store the gamma space version
  70416. * @returns the unmodified Color4
  70417. */
  70418. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70419. /**
  70420. * Creates a new Color4 from the string containing valid hexadecimal values
  70421. * @param hex defines a string containing valid hexadecimal values
  70422. * @returns a new Color4 object
  70423. */
  70424. static FromHexString(hex: string): Color4;
  70425. /**
  70426. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70427. * @param left defines the start value
  70428. * @param right defines the end value
  70429. * @param amount defines the gradient factor
  70430. * @returns a new Color4 object
  70431. */
  70432. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70433. /**
  70434. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70435. * @param left defines the start value
  70436. * @param right defines the end value
  70437. * @param amount defines the gradient factor
  70438. * @param result defines the Color4 object where to store data
  70439. */
  70440. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70441. /**
  70442. * Creates a new Color4 from a Color3 and an alpha value
  70443. * @param color3 defines the source Color3 to read from
  70444. * @param alpha defines the alpha component (1.0 by default)
  70445. * @returns a new Color4 object
  70446. */
  70447. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70448. /**
  70449. * Creates a new Color4 from the starting index element of the given array
  70450. * @param array defines the source array to read from
  70451. * @param offset defines the offset in the source array
  70452. * @returns a new Color4 object
  70453. */
  70454. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70455. /**
  70456. * Creates a new Color3 from integer values (< 256)
  70457. * @param r defines the red component to read from (value between 0 and 255)
  70458. * @param g defines the green component to read from (value between 0 and 255)
  70459. * @param b defines the blue component to read from (value between 0 and 255)
  70460. * @param a defines the alpha component to read from (value between 0 and 255)
  70461. * @returns a new Color3 object
  70462. */
  70463. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70464. /**
  70465. * Check the content of a given array and convert it to an array containing RGBA data
  70466. * If the original array was already containing count * 4 values then it is returned directly
  70467. * @param colors defines the array to check
  70468. * @param count defines the number of RGBA data to expect
  70469. * @returns an array containing count * 4 values (RGBA)
  70470. */
  70471. static CheckColors4(colors: number[], count: number): number[];
  70472. }
  70473. /**
  70474. * @hidden
  70475. */
  70476. export class TmpColors {
  70477. static Color3: Color3[];
  70478. static Color4: Color4[];
  70479. }
  70480. }
  70481. declare module BABYLON {
  70482. /**
  70483. * Class representing spherical harmonics coefficients to the 3rd degree
  70484. */
  70485. export class SphericalHarmonics {
  70486. /**
  70487. * Defines whether or not the harmonics have been prescaled for rendering.
  70488. */
  70489. preScaled: boolean;
  70490. /**
  70491. * The l0,0 coefficients of the spherical harmonics
  70492. */
  70493. l00: Vector3;
  70494. /**
  70495. * The l1,-1 coefficients of the spherical harmonics
  70496. */
  70497. l1_1: Vector3;
  70498. /**
  70499. * The l1,0 coefficients of the spherical harmonics
  70500. */
  70501. l10: Vector3;
  70502. /**
  70503. * The l1,1 coefficients of the spherical harmonics
  70504. */
  70505. l11: Vector3;
  70506. /**
  70507. * The l2,-2 coefficients of the spherical harmonics
  70508. */
  70509. l2_2: Vector3;
  70510. /**
  70511. * The l2,-1 coefficients of the spherical harmonics
  70512. */
  70513. l2_1: Vector3;
  70514. /**
  70515. * The l2,0 coefficients of the spherical harmonics
  70516. */
  70517. l20: Vector3;
  70518. /**
  70519. * The l2,1 coefficients of the spherical harmonics
  70520. */
  70521. l21: Vector3;
  70522. /**
  70523. * The l2,2 coefficients of the spherical harmonics
  70524. */
  70525. l22: Vector3;
  70526. /**
  70527. * Adds a light to the spherical harmonics
  70528. * @param direction the direction of the light
  70529. * @param color the color of the light
  70530. * @param deltaSolidAngle the delta solid angle of the light
  70531. */
  70532. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70533. /**
  70534. * Scales the spherical harmonics by the given amount
  70535. * @param scale the amount to scale
  70536. */
  70537. scaleInPlace(scale: number): void;
  70538. /**
  70539. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70540. *
  70541. * ```
  70542. * E_lm = A_l * L_lm
  70543. * ```
  70544. *
  70545. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70546. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70547. * the scaling factors are given in equation 9.
  70548. */
  70549. convertIncidentRadianceToIrradiance(): void;
  70550. /**
  70551. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70552. *
  70553. * ```
  70554. * L = (1/pi) * E * rho
  70555. * ```
  70556. *
  70557. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70558. */
  70559. convertIrradianceToLambertianRadiance(): void;
  70560. /**
  70561. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70562. * required operations at run time.
  70563. *
  70564. * This is simply done by scaling back the SH with Ylm constants parameter.
  70565. * The trigonometric part being applied by the shader at run time.
  70566. */
  70567. preScaleForRendering(): void;
  70568. /**
  70569. * Constructs a spherical harmonics from an array.
  70570. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70571. * @returns the spherical harmonics
  70572. */
  70573. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70574. /**
  70575. * Gets the spherical harmonics from polynomial
  70576. * @param polynomial the spherical polynomial
  70577. * @returns the spherical harmonics
  70578. */
  70579. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70580. }
  70581. /**
  70582. * Class representing spherical polynomial coefficients to the 3rd degree
  70583. */
  70584. export class SphericalPolynomial {
  70585. private _harmonics;
  70586. /**
  70587. * The spherical harmonics used to create the polynomials.
  70588. */
  70589. readonly preScaledHarmonics: SphericalHarmonics;
  70590. /**
  70591. * The x coefficients of the spherical polynomial
  70592. */
  70593. x: Vector3;
  70594. /**
  70595. * The y coefficients of the spherical polynomial
  70596. */
  70597. y: Vector3;
  70598. /**
  70599. * The z coefficients of the spherical polynomial
  70600. */
  70601. z: Vector3;
  70602. /**
  70603. * The xx coefficients of the spherical polynomial
  70604. */
  70605. xx: Vector3;
  70606. /**
  70607. * The yy coefficients of the spherical polynomial
  70608. */
  70609. yy: Vector3;
  70610. /**
  70611. * The zz coefficients of the spherical polynomial
  70612. */
  70613. zz: Vector3;
  70614. /**
  70615. * The xy coefficients of the spherical polynomial
  70616. */
  70617. xy: Vector3;
  70618. /**
  70619. * The yz coefficients of the spherical polynomial
  70620. */
  70621. yz: Vector3;
  70622. /**
  70623. * The zx coefficients of the spherical polynomial
  70624. */
  70625. zx: Vector3;
  70626. /**
  70627. * Adds an ambient color to the spherical polynomial
  70628. * @param color the color to add
  70629. */
  70630. addAmbient(color: Color3): void;
  70631. /**
  70632. * Scales the spherical polynomial by the given amount
  70633. * @param scale the amount to scale
  70634. */
  70635. scaleInPlace(scale: number): void;
  70636. /**
  70637. * Gets the spherical polynomial from harmonics
  70638. * @param harmonics the spherical harmonics
  70639. * @returns the spherical polynomial
  70640. */
  70641. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70642. /**
  70643. * Constructs a spherical polynomial from an array.
  70644. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70645. * @returns the spherical polynomial
  70646. */
  70647. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70648. }
  70649. }
  70650. declare module BABYLON {
  70651. /**
  70652. * Define options used to create a render target texture
  70653. */
  70654. export class RenderTargetCreationOptions {
  70655. /**
  70656. * Specifies is mipmaps must be generated
  70657. */
  70658. generateMipMaps?: boolean;
  70659. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70660. generateDepthBuffer?: boolean;
  70661. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70662. generateStencilBuffer?: boolean;
  70663. /** Defines texture type (int by default) */
  70664. type?: number;
  70665. /** Defines sampling mode (trilinear by default) */
  70666. samplingMode?: number;
  70667. /** Defines format (RGBA by default) */
  70668. format?: number;
  70669. }
  70670. }
  70671. declare module BABYLON {
  70672. /**
  70673. * @hidden
  70674. **/
  70675. export class _TimeToken {
  70676. _startTimeQuery: Nullable<WebGLQuery>;
  70677. _endTimeQuery: Nullable<WebGLQuery>;
  70678. _timeElapsedQuery: Nullable<WebGLQuery>;
  70679. _timeElapsedQueryEnded: boolean;
  70680. }
  70681. }
  70682. declare module BABYLON {
  70683. /** Defines the cross module used constants to avoid circular dependncies */
  70684. export class Constants {
  70685. /** Defines that alpha blending is disabled */
  70686. static readonly ALPHA_DISABLE: number;
  70687. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  70688. static readonly ALPHA_ADD: number;
  70689. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  70690. static readonly ALPHA_COMBINE: number;
  70691. /** Defines that alpha blending to DEST - SRC * DEST */
  70692. static readonly ALPHA_SUBTRACT: number;
  70693. /** Defines that alpha blending to SRC * DEST */
  70694. static readonly ALPHA_MULTIPLY: number;
  70695. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  70696. static readonly ALPHA_MAXIMIZED: number;
  70697. /** Defines that alpha blending to SRC + DEST */
  70698. static readonly ALPHA_ONEONE: number;
  70699. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  70700. static readonly ALPHA_PREMULTIPLIED: number;
  70701. /**
  70702. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  70703. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  70704. */
  70705. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  70706. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  70707. static readonly ALPHA_INTERPOLATE: number;
  70708. /**
  70709. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  70710. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  70711. */
  70712. static readonly ALPHA_SCREENMODE: number;
  70713. /**
  70714. * Defines that alpha blending to SRC + DST
  70715. * Alpha will be set to SRC ALPHA + DST ALPHA
  70716. */
  70717. static readonly ALPHA_ONEONE_ONEONE: number;
  70718. /**
  70719. * Defines that alpha blending to SRC * DST ALPHA + DST
  70720. * Alpha will be set to 0
  70721. */
  70722. static readonly ALPHA_ALPHATOCOLOR: number;
  70723. /**
  70724. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  70725. */
  70726. static readonly ALPHA_REVERSEONEMINUS: number;
  70727. /**
  70728. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  70729. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  70730. */
  70731. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  70732. /**
  70733. * Defines that alpha blending to SRC + DST
  70734. * Alpha will be set to SRC ALPHA
  70735. */
  70736. static readonly ALPHA_ONEONE_ONEZERO: number;
  70737. /** Defines that alpha blending equation a SUM */
  70738. static readonly ALPHA_EQUATION_ADD: number;
  70739. /** Defines that alpha blending equation a SUBSTRACTION */
  70740. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  70741. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  70742. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70743. /** Defines that alpha blending equation a MAX operation */
  70744. static readonly ALPHA_EQUATION_MAX: number;
  70745. /** Defines that alpha blending equation a MIN operation */
  70746. static readonly ALPHA_EQUATION_MIN: number;
  70747. /**
  70748. * Defines that alpha blending equation a DARKEN operation:
  70749. * It takes the min of the src and sums the alpha channels.
  70750. */
  70751. static readonly ALPHA_EQUATION_DARKEN: number;
  70752. /** Defines that the ressource is not delayed*/
  70753. static readonly DELAYLOADSTATE_NONE: number;
  70754. /** Defines that the ressource was successfully delay loaded */
  70755. static readonly DELAYLOADSTATE_LOADED: number;
  70756. /** Defines that the ressource is currently delay loading */
  70757. static readonly DELAYLOADSTATE_LOADING: number;
  70758. /** Defines that the ressource is delayed and has not started loading */
  70759. static readonly DELAYLOADSTATE_NOTLOADED: number;
  70760. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  70761. static readonly NEVER: number;
  70762. /** 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 */
  70763. static readonly ALWAYS: number;
  70764. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  70765. static readonly LESS: number;
  70766. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  70767. static readonly EQUAL: number;
  70768. /** 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 */
  70769. static readonly LEQUAL: number;
  70770. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  70771. static readonly GREATER: number;
  70772. /** 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 */
  70773. static readonly GEQUAL: number;
  70774. /** 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 */
  70775. static readonly NOTEQUAL: number;
  70776. /** Passed to stencilOperation to specify that stencil value must be kept */
  70777. static readonly KEEP: number;
  70778. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70779. static readonly REPLACE: number;
  70780. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70781. static readonly INCR: number;
  70782. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70783. static readonly DECR: number;
  70784. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70785. static readonly INVERT: number;
  70786. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70787. static readonly INCR_WRAP: number;
  70788. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70789. static readonly DECR_WRAP: number;
  70790. /** Texture is not repeating outside of 0..1 UVs */
  70791. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70792. /** Texture is repeating outside of 0..1 UVs */
  70793. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70794. /** Texture is repeating and mirrored */
  70795. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70796. /** ALPHA */
  70797. static readonly TEXTUREFORMAT_ALPHA: number;
  70798. /** LUMINANCE */
  70799. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70800. /** LUMINANCE_ALPHA */
  70801. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70802. /** RGB */
  70803. static readonly TEXTUREFORMAT_RGB: number;
  70804. /** RGBA */
  70805. static readonly TEXTUREFORMAT_RGBA: number;
  70806. /** RED */
  70807. static readonly TEXTUREFORMAT_RED: number;
  70808. /** RED (2nd reference) */
  70809. static readonly TEXTUREFORMAT_R: number;
  70810. /** RG */
  70811. static readonly TEXTUREFORMAT_RG: number;
  70812. /** RED_INTEGER */
  70813. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70814. /** RED_INTEGER (2nd reference) */
  70815. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70816. /** RG_INTEGER */
  70817. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70818. /** RGB_INTEGER */
  70819. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70820. /** RGBA_INTEGER */
  70821. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70822. /** UNSIGNED_BYTE */
  70823. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70824. /** UNSIGNED_BYTE (2nd reference) */
  70825. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70826. /** FLOAT */
  70827. static readonly TEXTURETYPE_FLOAT: number;
  70828. /** HALF_FLOAT */
  70829. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70830. /** BYTE */
  70831. static readonly TEXTURETYPE_BYTE: number;
  70832. /** SHORT */
  70833. static readonly TEXTURETYPE_SHORT: number;
  70834. /** UNSIGNED_SHORT */
  70835. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70836. /** INT */
  70837. static readonly TEXTURETYPE_INT: number;
  70838. /** UNSIGNED_INT */
  70839. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70840. /** UNSIGNED_SHORT_4_4_4_4 */
  70841. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70842. /** UNSIGNED_SHORT_5_5_5_1 */
  70843. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70844. /** UNSIGNED_SHORT_5_6_5 */
  70845. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70846. /** UNSIGNED_INT_2_10_10_10_REV */
  70847. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70848. /** UNSIGNED_INT_24_8 */
  70849. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70850. /** UNSIGNED_INT_10F_11F_11F_REV */
  70851. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70852. /** UNSIGNED_INT_5_9_9_9_REV */
  70853. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70854. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70855. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70856. /** nearest is mag = nearest and min = nearest and mip = linear */
  70857. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70858. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70859. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70860. /** Trilinear is mag = linear and min = linear and mip = linear */
  70861. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70862. /** nearest is mag = nearest and min = nearest and mip = linear */
  70863. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70864. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70865. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70866. /** Trilinear is mag = linear and min = linear and mip = linear */
  70867. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70868. /** mag = nearest and min = nearest and mip = nearest */
  70869. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70870. /** mag = nearest and min = linear and mip = nearest */
  70871. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70872. /** mag = nearest and min = linear and mip = linear */
  70873. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70874. /** mag = nearest and min = linear and mip = none */
  70875. static readonly TEXTURE_NEAREST_LINEAR: number;
  70876. /** mag = nearest and min = nearest and mip = none */
  70877. static readonly TEXTURE_NEAREST_NEAREST: number;
  70878. /** mag = linear and min = nearest and mip = nearest */
  70879. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70880. /** mag = linear and min = nearest and mip = linear */
  70881. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70882. /** mag = linear and min = linear and mip = none */
  70883. static readonly TEXTURE_LINEAR_LINEAR: number;
  70884. /** mag = linear and min = nearest and mip = none */
  70885. static readonly TEXTURE_LINEAR_NEAREST: number;
  70886. /** Explicit coordinates mode */
  70887. static readonly TEXTURE_EXPLICIT_MODE: number;
  70888. /** Spherical coordinates mode */
  70889. static readonly TEXTURE_SPHERICAL_MODE: number;
  70890. /** Planar coordinates mode */
  70891. static readonly TEXTURE_PLANAR_MODE: number;
  70892. /** Cubic coordinates mode */
  70893. static readonly TEXTURE_CUBIC_MODE: number;
  70894. /** Projection coordinates mode */
  70895. static readonly TEXTURE_PROJECTION_MODE: number;
  70896. /** Skybox coordinates mode */
  70897. static readonly TEXTURE_SKYBOX_MODE: number;
  70898. /** Inverse Cubic coordinates mode */
  70899. static readonly TEXTURE_INVCUBIC_MODE: number;
  70900. /** Equirectangular coordinates mode */
  70901. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70902. /** Equirectangular Fixed coordinates mode */
  70903. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70904. /** Equirectangular Fixed Mirrored coordinates mode */
  70905. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70906. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70907. static readonly SCALEMODE_FLOOR: number;
  70908. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70909. static readonly SCALEMODE_NEAREST: number;
  70910. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70911. static readonly SCALEMODE_CEILING: number;
  70912. /**
  70913. * The dirty texture flag value
  70914. */
  70915. static readonly MATERIAL_TextureDirtyFlag: number;
  70916. /**
  70917. * The dirty light flag value
  70918. */
  70919. static readonly MATERIAL_LightDirtyFlag: number;
  70920. /**
  70921. * The dirty fresnel flag value
  70922. */
  70923. static readonly MATERIAL_FresnelDirtyFlag: number;
  70924. /**
  70925. * The dirty attribute flag value
  70926. */
  70927. static readonly MATERIAL_AttributesDirtyFlag: number;
  70928. /**
  70929. * The dirty misc flag value
  70930. */
  70931. static readonly MATERIAL_MiscDirtyFlag: number;
  70932. /**
  70933. * The all dirty flag value
  70934. */
  70935. static readonly MATERIAL_AllDirtyFlag: number;
  70936. /**
  70937. * Returns the triangle fill mode
  70938. */
  70939. static readonly MATERIAL_TriangleFillMode: number;
  70940. /**
  70941. * Returns the wireframe mode
  70942. */
  70943. static readonly MATERIAL_WireFrameFillMode: number;
  70944. /**
  70945. * Returns the point fill mode
  70946. */
  70947. static readonly MATERIAL_PointFillMode: number;
  70948. /**
  70949. * Returns the point list draw mode
  70950. */
  70951. static readonly MATERIAL_PointListDrawMode: number;
  70952. /**
  70953. * Returns the line list draw mode
  70954. */
  70955. static readonly MATERIAL_LineListDrawMode: number;
  70956. /**
  70957. * Returns the line loop draw mode
  70958. */
  70959. static readonly MATERIAL_LineLoopDrawMode: number;
  70960. /**
  70961. * Returns the line strip draw mode
  70962. */
  70963. static readonly MATERIAL_LineStripDrawMode: number;
  70964. /**
  70965. * Returns the triangle strip draw mode
  70966. */
  70967. static readonly MATERIAL_TriangleStripDrawMode: number;
  70968. /**
  70969. * Returns the triangle fan draw mode
  70970. */
  70971. static readonly MATERIAL_TriangleFanDrawMode: number;
  70972. /**
  70973. * Stores the clock-wise side orientation
  70974. */
  70975. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70976. /**
  70977. * Stores the counter clock-wise side orientation
  70978. */
  70979. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70980. /**
  70981. * Nothing
  70982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70983. */
  70984. static readonly ACTION_NothingTrigger: number;
  70985. /**
  70986. * On pick
  70987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70988. */
  70989. static readonly ACTION_OnPickTrigger: number;
  70990. /**
  70991. * On left pick
  70992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70993. */
  70994. static readonly ACTION_OnLeftPickTrigger: number;
  70995. /**
  70996. * On right pick
  70997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70998. */
  70999. static readonly ACTION_OnRightPickTrigger: number;
  71000. /**
  71001. * On center pick
  71002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71003. */
  71004. static readonly ACTION_OnCenterPickTrigger: number;
  71005. /**
  71006. * On pick down
  71007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71008. */
  71009. static readonly ACTION_OnPickDownTrigger: number;
  71010. /**
  71011. * On double pick
  71012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71013. */
  71014. static readonly ACTION_OnDoublePickTrigger: number;
  71015. /**
  71016. * On pick up
  71017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71018. */
  71019. static readonly ACTION_OnPickUpTrigger: number;
  71020. /**
  71021. * On pick out.
  71022. * This trigger will only be raised if you also declared a OnPickDown
  71023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71024. */
  71025. static readonly ACTION_OnPickOutTrigger: number;
  71026. /**
  71027. * On long press
  71028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71029. */
  71030. static readonly ACTION_OnLongPressTrigger: number;
  71031. /**
  71032. * On pointer over
  71033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71034. */
  71035. static readonly ACTION_OnPointerOverTrigger: number;
  71036. /**
  71037. * On pointer out
  71038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71039. */
  71040. static readonly ACTION_OnPointerOutTrigger: number;
  71041. /**
  71042. * On every frame
  71043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71044. */
  71045. static readonly ACTION_OnEveryFrameTrigger: number;
  71046. /**
  71047. * On intersection enter
  71048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71049. */
  71050. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71051. /**
  71052. * On intersection exit
  71053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71054. */
  71055. static readonly ACTION_OnIntersectionExitTrigger: number;
  71056. /**
  71057. * On key down
  71058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71059. */
  71060. static readonly ACTION_OnKeyDownTrigger: number;
  71061. /**
  71062. * On key up
  71063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71064. */
  71065. static readonly ACTION_OnKeyUpTrigger: number;
  71066. /**
  71067. * Billboard mode will only apply to Y axis
  71068. */
  71069. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71070. /**
  71071. * Billboard mode will apply to all axes
  71072. */
  71073. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71074. /**
  71075. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71076. */
  71077. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71078. /**
  71079. * Gets or sets base Assets URL
  71080. */
  71081. static PARTICLES_BaseAssetsUrl: string;
  71082. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71083. * Test order :
  71084. * Is the bounding sphere outside the frustum ?
  71085. * If not, are the bounding box vertices outside the frustum ?
  71086. * It not, then the cullable object is in the frustum.
  71087. */
  71088. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71089. /** Culling strategy : Bounding Sphere Only.
  71090. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71091. * It's also less accurate than the standard because some not visible objects can still be selected.
  71092. * Test : is the bounding sphere outside the frustum ?
  71093. * If not, then the cullable object is in the frustum.
  71094. */
  71095. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71096. /** Culling strategy : Optimistic Inclusion.
  71097. * This in an inclusion test first, then the standard exclusion test.
  71098. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71099. * 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.
  71100. * Anyway, it's as accurate as the standard strategy.
  71101. * Test :
  71102. * Is the cullable object bounding sphere center in the frustum ?
  71103. * If not, apply the default culling strategy.
  71104. */
  71105. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71106. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71107. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71108. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71109. * 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.
  71110. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71111. * Test :
  71112. * Is the cullable object bounding sphere center in the frustum ?
  71113. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71114. */
  71115. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71116. /**
  71117. * No logging while loading
  71118. */
  71119. static readonly SCENELOADER_NO_LOGGING: number;
  71120. /**
  71121. * Minimal logging while loading
  71122. */
  71123. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71124. /**
  71125. * Summary logging while loading
  71126. */
  71127. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71128. /**
  71129. * Detailled logging while loading
  71130. */
  71131. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71132. }
  71133. }
  71134. declare module BABYLON {
  71135. /**
  71136. * This represents the required contract to create a new type of texture loader.
  71137. */
  71138. export interface IInternalTextureLoader {
  71139. /**
  71140. * Defines wether the loader supports cascade loading the different faces.
  71141. */
  71142. supportCascades: boolean;
  71143. /**
  71144. * This returns if the loader support the current file information.
  71145. * @param extension defines the file extension of the file being loaded
  71146. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71147. * @param fallback defines the fallback internal texture if any
  71148. * @param isBase64 defines whether the texture is encoded as a base64
  71149. * @param isBuffer defines whether the texture data are stored as a buffer
  71150. * @returns true if the loader can load the specified file
  71151. */
  71152. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71153. /**
  71154. * Transform the url before loading if required.
  71155. * @param rootUrl the url of the texture
  71156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71157. * @returns the transformed texture
  71158. */
  71159. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71160. /**
  71161. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71162. * @param rootUrl the url of the texture
  71163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71164. * @returns the fallback texture
  71165. */
  71166. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71167. /**
  71168. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71169. * @param data contains the texture data
  71170. * @param texture defines the BabylonJS internal texture
  71171. * @param createPolynomials will be true if polynomials have been requested
  71172. * @param onLoad defines the callback to trigger once the texture is ready
  71173. * @param onError defines the callback to trigger in case of error
  71174. */
  71175. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71176. /**
  71177. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71178. * @param data contains the texture data
  71179. * @param texture defines the BabylonJS internal texture
  71180. * @param callback defines the method to call once ready to upload
  71181. */
  71182. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71183. }
  71184. }
  71185. declare module BABYLON {
  71186. /**
  71187. * Class used to store and describe the pipeline context associated with an effect
  71188. */
  71189. export interface IPipelineContext {
  71190. /**
  71191. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71192. */
  71193. isAsync: boolean;
  71194. /**
  71195. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71196. */
  71197. isReady: boolean;
  71198. /** @hidden */
  71199. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71200. }
  71201. }
  71202. declare module BABYLON {
  71203. /**
  71204. * Class used to store gfx data (like WebGLBuffer)
  71205. */
  71206. export class DataBuffer {
  71207. /**
  71208. * Gets or sets the number of objects referencing this buffer
  71209. */
  71210. references: number;
  71211. /** Gets or sets the size of the underlying buffer */
  71212. capacity: number;
  71213. /**
  71214. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71215. */
  71216. is32Bits: boolean;
  71217. /**
  71218. * Gets the underlying buffer
  71219. */
  71220. readonly underlyingResource: any;
  71221. }
  71222. }
  71223. declare module BABYLON {
  71224. /** @hidden */
  71225. export interface IShaderProcessor {
  71226. attributeProcessor?: (attribute: string) => string;
  71227. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71228. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71229. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71230. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71231. lineProcessor?: (line: string, isFragment: boolean) => string;
  71232. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71233. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71234. }
  71235. }
  71236. declare module BABYLON {
  71237. /** @hidden */
  71238. export interface ProcessingOptions {
  71239. defines: string[];
  71240. indexParameters: any;
  71241. isFragment: boolean;
  71242. shouldUseHighPrecisionShader: boolean;
  71243. supportsUniformBuffers: boolean;
  71244. shadersRepository: string;
  71245. includesShadersStore: {
  71246. [key: string]: string;
  71247. };
  71248. processor?: IShaderProcessor;
  71249. version: string;
  71250. platformName: string;
  71251. lookForClosingBracketForUniformBuffer?: boolean;
  71252. }
  71253. }
  71254. declare module BABYLON {
  71255. /**
  71256. * Helper to manipulate strings
  71257. */
  71258. export class StringTools {
  71259. /**
  71260. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71261. * @param str Source string
  71262. * @param suffix Suffix to search for in the source string
  71263. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71264. */
  71265. static EndsWith(str: string, suffix: string): boolean;
  71266. /**
  71267. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71268. * @param str Source string
  71269. * @param suffix Suffix to search for in the source string
  71270. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71271. */
  71272. static StartsWith(str: string, suffix: string): boolean;
  71273. }
  71274. }
  71275. declare module BABYLON {
  71276. /** @hidden */
  71277. export class ShaderCodeNode {
  71278. line: string;
  71279. children: ShaderCodeNode[];
  71280. additionalDefineKey?: string;
  71281. additionalDefineValue?: string;
  71282. isValid(preprocessors: {
  71283. [key: string]: string;
  71284. }): boolean;
  71285. process(preprocessors: {
  71286. [key: string]: string;
  71287. }, options: ProcessingOptions): string;
  71288. }
  71289. }
  71290. declare module BABYLON {
  71291. /** @hidden */
  71292. export class ShaderCodeCursor {
  71293. private _lines;
  71294. lineIndex: number;
  71295. readonly currentLine: string;
  71296. readonly canRead: boolean;
  71297. lines: string[];
  71298. }
  71299. }
  71300. declare module BABYLON {
  71301. /** @hidden */
  71302. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71303. process(preprocessors: {
  71304. [key: string]: string;
  71305. }, options: ProcessingOptions): string;
  71306. }
  71307. }
  71308. declare module BABYLON {
  71309. /** @hidden */
  71310. export class ShaderDefineExpression {
  71311. isTrue(preprocessors: {
  71312. [key: string]: string;
  71313. }): boolean;
  71314. }
  71315. }
  71316. declare module BABYLON {
  71317. /** @hidden */
  71318. export class ShaderCodeTestNode extends ShaderCodeNode {
  71319. testExpression: ShaderDefineExpression;
  71320. isValid(preprocessors: {
  71321. [key: string]: string;
  71322. }): boolean;
  71323. }
  71324. }
  71325. declare module BABYLON {
  71326. /** @hidden */
  71327. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71328. define: string;
  71329. not: boolean;
  71330. constructor(define: string, not?: boolean);
  71331. isTrue(preprocessors: {
  71332. [key: string]: string;
  71333. }): boolean;
  71334. }
  71335. }
  71336. declare module BABYLON {
  71337. /** @hidden */
  71338. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71339. leftOperand: ShaderDefineExpression;
  71340. rightOperand: ShaderDefineExpression;
  71341. isTrue(preprocessors: {
  71342. [key: string]: string;
  71343. }): boolean;
  71344. }
  71345. }
  71346. declare module BABYLON {
  71347. /** @hidden */
  71348. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71349. leftOperand: ShaderDefineExpression;
  71350. rightOperand: ShaderDefineExpression;
  71351. isTrue(preprocessors: {
  71352. [key: string]: string;
  71353. }): boolean;
  71354. }
  71355. }
  71356. declare module BABYLON {
  71357. /** @hidden */
  71358. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71359. define: string;
  71360. operand: string;
  71361. testValue: string;
  71362. constructor(define: string, operand: string, testValue: string);
  71363. isTrue(preprocessors: {
  71364. [key: string]: string;
  71365. }): boolean;
  71366. }
  71367. }
  71368. declare module BABYLON {
  71369. /**
  71370. * @ignore
  71371. * Application error to support additional information when loading a file
  71372. */
  71373. export class LoadFileError extends Error {
  71374. /** defines the optional web request */
  71375. request?: WebRequest | undefined;
  71376. private static _setPrototypeOf;
  71377. /**
  71378. * Creates a new LoadFileError
  71379. * @param message defines the message of the error
  71380. * @param request defines the optional web request
  71381. */
  71382. constructor(message: string,
  71383. /** defines the optional web request */
  71384. request?: WebRequest | undefined);
  71385. }
  71386. }
  71387. declare module BABYLON {
  71388. /**
  71389. * Class used to enable access to offline support
  71390. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71391. */
  71392. export interface IOfflineProvider {
  71393. /**
  71394. * Gets a boolean indicating if scene must be saved in the database
  71395. */
  71396. enableSceneOffline: boolean;
  71397. /**
  71398. * Gets a boolean indicating if textures must be saved in the database
  71399. */
  71400. enableTexturesOffline: boolean;
  71401. /**
  71402. * Open the offline support and make it available
  71403. * @param successCallback defines the callback to call on success
  71404. * @param errorCallback defines the callback to call on error
  71405. */
  71406. open(successCallback: () => void, errorCallback: () => void): void;
  71407. /**
  71408. * Loads an image from the offline support
  71409. * @param url defines the url to load from
  71410. * @param image defines the target DOM image
  71411. */
  71412. loadImage(url: string, image: HTMLImageElement): void;
  71413. /**
  71414. * Loads a file from offline support
  71415. * @param url defines the URL to load from
  71416. * @param sceneLoaded defines a callback to call on success
  71417. * @param progressCallBack defines a callback to call when progress changed
  71418. * @param errorCallback defines a callback to call on error
  71419. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71420. */
  71421. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71422. }
  71423. }
  71424. declare module BABYLON {
  71425. /**
  71426. * Class used to help managing file picking and drag'n'drop
  71427. * File Storage
  71428. */
  71429. export class FilesInputStore {
  71430. /**
  71431. * List of files ready to be loaded
  71432. */
  71433. static FilesToLoad: {
  71434. [key: string]: File;
  71435. };
  71436. }
  71437. }
  71438. declare module BABYLON {
  71439. /**
  71440. * Class used to define a retry strategy when error happens while loading assets
  71441. */
  71442. export class RetryStrategy {
  71443. /**
  71444. * Function used to defines an exponential back off strategy
  71445. * @param maxRetries defines the maximum number of retries (3 by default)
  71446. * @param baseInterval defines the interval between retries
  71447. * @returns the strategy function to use
  71448. */
  71449. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71450. }
  71451. }
  71452. declare module BABYLON {
  71453. /**
  71454. * @hidden
  71455. */
  71456. export class FileTools {
  71457. /**
  71458. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71459. */
  71460. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71461. /**
  71462. * Gets or sets the base URL to use to load assets
  71463. */
  71464. static BaseUrl: string;
  71465. /**
  71466. * Default behaviour for cors in the application.
  71467. * It can be a string if the expected behavior is identical in the entire app.
  71468. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71469. */
  71470. static CorsBehavior: string | ((url: string | string[]) => string);
  71471. /**
  71472. * Gets or sets a function used to pre-process url before using them to load assets
  71473. */
  71474. static PreprocessUrl: (url: string) => string;
  71475. /**
  71476. * Removes unwanted characters from an url
  71477. * @param url defines the url to clean
  71478. * @returns the cleaned url
  71479. */
  71480. private static _CleanUrl;
  71481. /**
  71482. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71483. * @param url define the url we are trying
  71484. * @param element define the dom element where to configure the cors policy
  71485. */
  71486. static SetCorsBehavior(url: string | string[], element: {
  71487. crossOrigin: string | null;
  71488. }): void;
  71489. /**
  71490. * Loads an image as an HTMLImageElement.
  71491. * @param input url string, ArrayBuffer, or Blob to load
  71492. * @param onLoad callback called when the image successfully loads
  71493. * @param onError callback called when the image fails to load
  71494. * @param offlineProvider offline provider for caching
  71495. * @returns the HTMLImageElement of the loaded image
  71496. */
  71497. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71498. /**
  71499. * Loads a file
  71500. * @param fileToLoad defines the file to load
  71501. * @param callback defines the callback to call when data is loaded
  71502. * @param progressCallBack defines the callback to call during loading process
  71503. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71504. * @returns a file request object
  71505. */
  71506. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71507. /**
  71508. * Loads a file
  71509. * @param url url string, ArrayBuffer, or Blob to load
  71510. * @param onSuccess callback called when the file successfully loads
  71511. * @param onProgress callback called while file is loading (if the server supports this mode)
  71512. * @param offlineProvider defines the offline provider for caching
  71513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71514. * @param onError callback called when the file fails to load
  71515. * @returns a file request object
  71516. */
  71517. 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;
  71518. /**
  71519. * Checks if the loaded document was accessed via `file:`-Protocol.
  71520. * @returns boolean
  71521. */
  71522. static IsFileURL(): boolean;
  71523. }
  71524. }
  71525. declare module BABYLON {
  71526. /** @hidden */
  71527. export class ShaderProcessor {
  71528. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71529. private static _ProcessPrecision;
  71530. private static _ExtractOperation;
  71531. private static _BuildSubExpression;
  71532. private static _BuildExpression;
  71533. private static _MoveCursorWithinIf;
  71534. private static _MoveCursor;
  71535. private static _EvaluatePreProcessors;
  71536. private static _PreparePreProcessors;
  71537. private static _ProcessShaderConversion;
  71538. private static _ProcessIncludes;
  71539. }
  71540. }
  71541. declare module BABYLON {
  71542. /**
  71543. * Interface used to define common properties for effect fallbacks
  71544. */
  71545. export interface IEffectFallbacks {
  71546. /**
  71547. * Removes the defines that should be removed when falling back.
  71548. * @param currentDefines defines the current define statements for the shader.
  71549. * @param effect defines the current effect we try to compile
  71550. * @returns The resulting defines with defines of the current rank removed.
  71551. */
  71552. reduce(currentDefines: string, effect: Effect): string;
  71553. /**
  71554. * Removes the fallback from the bound mesh.
  71555. */
  71556. unBindMesh(): void;
  71557. /**
  71558. * Checks to see if more fallbacks are still availible.
  71559. */
  71560. hasMoreFallbacks: boolean;
  71561. }
  71562. }
  71563. declare module BABYLON {
  71564. /**
  71565. * Class used to evalaute queries containing `and` and `or` operators
  71566. */
  71567. export class AndOrNotEvaluator {
  71568. /**
  71569. * Evaluate a query
  71570. * @param query defines the query to evaluate
  71571. * @param evaluateCallback defines the callback used to filter result
  71572. * @returns true if the query matches
  71573. */
  71574. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71575. private static _HandleParenthesisContent;
  71576. private static _SimplifyNegation;
  71577. }
  71578. }
  71579. declare module BABYLON {
  71580. /**
  71581. * Class used to store custom tags
  71582. */
  71583. export class Tags {
  71584. /**
  71585. * Adds support for tags on the given object
  71586. * @param obj defines the object to use
  71587. */
  71588. static EnableFor(obj: any): void;
  71589. /**
  71590. * Removes tags support
  71591. * @param obj defines the object to use
  71592. */
  71593. static DisableFor(obj: any): void;
  71594. /**
  71595. * Gets a boolean indicating if the given object has tags
  71596. * @param obj defines the object to use
  71597. * @returns a boolean
  71598. */
  71599. static HasTags(obj: any): boolean;
  71600. /**
  71601. * Gets the tags available on a given object
  71602. * @param obj defines the object to use
  71603. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71604. * @returns the tags
  71605. */
  71606. static GetTags(obj: any, asString?: boolean): any;
  71607. /**
  71608. * Adds tags to an object
  71609. * @param obj defines the object to use
  71610. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71611. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71612. */
  71613. static AddTagsTo(obj: any, tagsString: string): void;
  71614. /**
  71615. * @hidden
  71616. */
  71617. static _AddTagTo(obj: any, tag: string): void;
  71618. /**
  71619. * Removes specific tags from a specific object
  71620. * @param obj defines the object to use
  71621. * @param tagsString defines the tags to remove
  71622. */
  71623. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71624. /**
  71625. * @hidden
  71626. */
  71627. static _RemoveTagFrom(obj: any, tag: string): void;
  71628. /**
  71629. * Defines if tags hosted on an object match a given query
  71630. * @param obj defines the object to use
  71631. * @param tagsQuery defines the tag query
  71632. * @returns a boolean
  71633. */
  71634. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71635. }
  71636. }
  71637. declare module BABYLON {
  71638. /**
  71639. * Defines potential orientation for back face culling
  71640. */
  71641. export enum Orientation {
  71642. /**
  71643. * Clockwise
  71644. */
  71645. CW = 0,
  71646. /** Counter clockwise */
  71647. CCW = 1
  71648. }
  71649. /** Class used to represent a Bezier curve */
  71650. export class BezierCurve {
  71651. /**
  71652. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71653. * @param t defines the time
  71654. * @param x1 defines the left coordinate on X axis
  71655. * @param y1 defines the left coordinate on Y axis
  71656. * @param x2 defines the right coordinate on X axis
  71657. * @param y2 defines the right coordinate on Y axis
  71658. * @returns the interpolated value
  71659. */
  71660. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71661. }
  71662. /**
  71663. * Defines angle representation
  71664. */
  71665. export class Angle {
  71666. private _radians;
  71667. /**
  71668. * Creates an Angle object of "radians" radians (float).
  71669. * @param radians the angle in radians
  71670. */
  71671. constructor(radians: number);
  71672. /**
  71673. * Get value in degrees
  71674. * @returns the Angle value in degrees (float)
  71675. */
  71676. degrees(): number;
  71677. /**
  71678. * Get value in radians
  71679. * @returns the Angle value in radians (float)
  71680. */
  71681. radians(): number;
  71682. /**
  71683. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71684. * @param a defines first vector
  71685. * @param b defines second vector
  71686. * @returns a new Angle
  71687. */
  71688. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71689. /**
  71690. * Gets a new Angle object from the given float in radians
  71691. * @param radians defines the angle value in radians
  71692. * @returns a new Angle
  71693. */
  71694. static FromRadians(radians: number): Angle;
  71695. /**
  71696. * Gets a new Angle object from the given float in degrees
  71697. * @param degrees defines the angle value in degrees
  71698. * @returns a new Angle
  71699. */
  71700. static FromDegrees(degrees: number): Angle;
  71701. }
  71702. /**
  71703. * This represents an arc in a 2d space.
  71704. */
  71705. export class Arc2 {
  71706. /** Defines the start point of the arc */
  71707. startPoint: Vector2;
  71708. /** Defines the mid point of the arc */
  71709. midPoint: Vector2;
  71710. /** Defines the end point of the arc */
  71711. endPoint: Vector2;
  71712. /**
  71713. * Defines the center point of the arc.
  71714. */
  71715. centerPoint: Vector2;
  71716. /**
  71717. * Defines the radius of the arc.
  71718. */
  71719. radius: number;
  71720. /**
  71721. * Defines the angle of the arc (from mid point to end point).
  71722. */
  71723. angle: Angle;
  71724. /**
  71725. * Defines the start angle of the arc (from start point to middle point).
  71726. */
  71727. startAngle: Angle;
  71728. /**
  71729. * Defines the orientation of the arc (clock wise/counter clock wise).
  71730. */
  71731. orientation: Orientation;
  71732. /**
  71733. * Creates an Arc object from the three given points : start, middle and end.
  71734. * @param startPoint Defines the start point of the arc
  71735. * @param midPoint Defines the midlle point of the arc
  71736. * @param endPoint Defines the end point of the arc
  71737. */
  71738. constructor(
  71739. /** Defines the start point of the arc */
  71740. startPoint: Vector2,
  71741. /** Defines the mid point of the arc */
  71742. midPoint: Vector2,
  71743. /** Defines the end point of the arc */
  71744. endPoint: Vector2);
  71745. }
  71746. /**
  71747. * Represents a 2D path made up of multiple 2D points
  71748. */
  71749. export class Path2 {
  71750. private _points;
  71751. private _length;
  71752. /**
  71753. * If the path start and end point are the same
  71754. */
  71755. closed: boolean;
  71756. /**
  71757. * Creates a Path2 object from the starting 2D coordinates x and y.
  71758. * @param x the starting points x value
  71759. * @param y the starting points y value
  71760. */
  71761. constructor(x: number, y: number);
  71762. /**
  71763. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71764. * @param x the added points x value
  71765. * @param y the added points y value
  71766. * @returns the updated Path2.
  71767. */
  71768. addLineTo(x: number, y: number): Path2;
  71769. /**
  71770. * 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.
  71771. * @param midX middle point x value
  71772. * @param midY middle point y value
  71773. * @param endX end point x value
  71774. * @param endY end point y value
  71775. * @param numberOfSegments (default: 36)
  71776. * @returns the updated Path2.
  71777. */
  71778. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71779. /**
  71780. * Closes the Path2.
  71781. * @returns the Path2.
  71782. */
  71783. close(): Path2;
  71784. /**
  71785. * Gets the sum of the distance between each sequential point in the path
  71786. * @returns the Path2 total length (float).
  71787. */
  71788. length(): number;
  71789. /**
  71790. * Gets the points which construct the path
  71791. * @returns the Path2 internal array of points.
  71792. */
  71793. getPoints(): Vector2[];
  71794. /**
  71795. * Retreives the point at the distance aways from the starting point
  71796. * @param normalizedLengthPosition the length along the path to retreive the point from
  71797. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71798. */
  71799. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71800. /**
  71801. * Creates a new path starting from an x and y position
  71802. * @param x starting x value
  71803. * @param y starting y value
  71804. * @returns a new Path2 starting at the coordinates (x, y).
  71805. */
  71806. static StartingAt(x: number, y: number): Path2;
  71807. }
  71808. /**
  71809. * Represents a 3D path made up of multiple 3D points
  71810. */
  71811. export class Path3D {
  71812. /**
  71813. * an array of Vector3, the curve axis of the Path3D
  71814. */
  71815. path: Vector3[];
  71816. private _curve;
  71817. private _distances;
  71818. private _tangents;
  71819. private _normals;
  71820. private _binormals;
  71821. private _raw;
  71822. /**
  71823. * new Path3D(path, normal, raw)
  71824. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71825. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71826. * @param path an array of Vector3, the curve axis of the Path3D
  71827. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71828. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71829. */
  71830. constructor(
  71831. /**
  71832. * an array of Vector3, the curve axis of the Path3D
  71833. */
  71834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71835. /**
  71836. * Returns the Path3D array of successive Vector3 designing its curve.
  71837. * @returns the Path3D array of successive Vector3 designing its curve.
  71838. */
  71839. getCurve(): Vector3[];
  71840. /**
  71841. * Returns an array populated with tangent vectors on each Path3D curve point.
  71842. * @returns an array populated with tangent vectors on each Path3D curve point.
  71843. */
  71844. getTangents(): Vector3[];
  71845. /**
  71846. * Returns an array populated with normal vectors on each Path3D curve point.
  71847. * @returns an array populated with normal vectors on each Path3D curve point.
  71848. */
  71849. getNormals(): Vector3[];
  71850. /**
  71851. * Returns an array populated with binormal vectors on each Path3D curve point.
  71852. * @returns an array populated with binormal vectors on each Path3D curve point.
  71853. */
  71854. getBinormals(): Vector3[];
  71855. /**
  71856. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71857. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71858. */
  71859. getDistances(): number[];
  71860. /**
  71861. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71862. * @param path path which all values are copied into the curves points
  71863. * @param firstNormal which should be projected onto the curve
  71864. * @returns the same object updated.
  71865. */
  71866. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71867. private _compute;
  71868. private _getFirstNonNullVector;
  71869. private _getLastNonNullVector;
  71870. private _normalVector;
  71871. }
  71872. /**
  71873. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71874. * A Curve3 is designed from a series of successive Vector3.
  71875. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71876. */
  71877. export class Curve3 {
  71878. private _points;
  71879. private _length;
  71880. /**
  71881. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71882. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71883. * @param v1 (Vector3) the control point
  71884. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71885. * @param nbPoints (integer) the wanted number of points in the curve
  71886. * @returns the created Curve3
  71887. */
  71888. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71889. /**
  71890. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71891. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71892. * @param v1 (Vector3) the first control point
  71893. * @param v2 (Vector3) the second control point
  71894. * @param v3 (Vector3) the end point of the Cubic Bezier
  71895. * @param nbPoints (integer) the wanted number of points in the curve
  71896. * @returns the created Curve3
  71897. */
  71898. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71899. /**
  71900. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71901. * @param p1 (Vector3) the origin point of the Hermite Spline
  71902. * @param t1 (Vector3) the tangent vector at the origin point
  71903. * @param p2 (Vector3) the end point of the Hermite Spline
  71904. * @param t2 (Vector3) the tangent vector at the end point
  71905. * @param nbPoints (integer) the wanted number of points in the curve
  71906. * @returns the created Curve3
  71907. */
  71908. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71909. /**
  71910. * Returns a Curve3 object along a CatmullRom Spline curve :
  71911. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71912. * @param nbPoints (integer) the wanted number of points between each curve control points
  71913. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71914. * @returns the created Curve3
  71915. */
  71916. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71917. /**
  71918. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71919. * A Curve3 is designed from a series of successive Vector3.
  71920. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71921. * @param points points which make up the curve
  71922. */
  71923. constructor(points: Vector3[]);
  71924. /**
  71925. * @returns the Curve3 stored array of successive Vector3
  71926. */
  71927. getPoints(): Vector3[];
  71928. /**
  71929. * @returns the computed length (float) of the curve.
  71930. */
  71931. length(): number;
  71932. /**
  71933. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71934. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71935. * curveA and curveB keep unchanged.
  71936. * @param curve the curve to continue from this curve
  71937. * @returns the newly constructed curve
  71938. */
  71939. continue(curve: DeepImmutable<Curve3>): Curve3;
  71940. private _computeLength;
  71941. }
  71942. }
  71943. declare module BABYLON {
  71944. /**
  71945. * This represents the main contract an easing function should follow.
  71946. * Easing functions are used throughout the animation system.
  71947. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71948. */
  71949. export interface IEasingFunction {
  71950. /**
  71951. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71952. * of the easing function.
  71953. * The link below provides some of the most common examples of easing functions.
  71954. * @see https://easings.net/
  71955. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71956. * @returns the corresponding value on the curve defined by the easing function
  71957. */
  71958. ease(gradient: number): number;
  71959. }
  71960. /**
  71961. * Base class used for every default easing function.
  71962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71963. */
  71964. export class EasingFunction implements IEasingFunction {
  71965. /**
  71966. * Interpolation follows the mathematical formula associated with the easing function.
  71967. */
  71968. static readonly EASINGMODE_EASEIN: number;
  71969. /**
  71970. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71971. */
  71972. static readonly EASINGMODE_EASEOUT: number;
  71973. /**
  71974. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71975. */
  71976. static readonly EASINGMODE_EASEINOUT: number;
  71977. private _easingMode;
  71978. /**
  71979. * Sets the easing mode of the current function.
  71980. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71981. */
  71982. setEasingMode(easingMode: number): void;
  71983. /**
  71984. * Gets the current easing mode.
  71985. * @returns the easing mode
  71986. */
  71987. getEasingMode(): number;
  71988. /**
  71989. * @hidden
  71990. */
  71991. easeInCore(gradient: number): number;
  71992. /**
  71993. * Given an input gradient between 0 and 1, this returns the corresponding value
  71994. * of the easing function.
  71995. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71996. * @returns the corresponding value on the curve defined by the easing function
  71997. */
  71998. ease(gradient: number): number;
  71999. }
  72000. /**
  72001. * Easing function with a circle shape (see link below).
  72002. * @see https://easings.net/#easeInCirc
  72003. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72004. */
  72005. export class CircleEase extends EasingFunction implements IEasingFunction {
  72006. /** @hidden */
  72007. easeInCore(gradient: number): number;
  72008. }
  72009. /**
  72010. * Easing function with a ease back shape (see link below).
  72011. * @see https://easings.net/#easeInBack
  72012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72013. */
  72014. export class BackEase extends EasingFunction implements IEasingFunction {
  72015. /** Defines the amplitude of the function */
  72016. amplitude: number;
  72017. /**
  72018. * Instantiates a back ease easing
  72019. * @see https://easings.net/#easeInBack
  72020. * @param amplitude Defines the amplitude of the function
  72021. */
  72022. constructor(
  72023. /** Defines the amplitude of the function */
  72024. amplitude?: number);
  72025. /** @hidden */
  72026. easeInCore(gradient: number): number;
  72027. }
  72028. /**
  72029. * Easing function with a bouncing shape (see link below).
  72030. * @see https://easings.net/#easeInBounce
  72031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72032. */
  72033. export class BounceEase extends EasingFunction implements IEasingFunction {
  72034. /** Defines the number of bounces */
  72035. bounces: number;
  72036. /** Defines the amplitude of the bounce */
  72037. bounciness: number;
  72038. /**
  72039. * Instantiates a bounce easing
  72040. * @see https://easings.net/#easeInBounce
  72041. * @param bounces Defines the number of bounces
  72042. * @param bounciness Defines the amplitude of the bounce
  72043. */
  72044. constructor(
  72045. /** Defines the number of bounces */
  72046. bounces?: number,
  72047. /** Defines the amplitude of the bounce */
  72048. bounciness?: number);
  72049. /** @hidden */
  72050. easeInCore(gradient: number): number;
  72051. }
  72052. /**
  72053. * Easing function with a power of 3 shape (see link below).
  72054. * @see https://easings.net/#easeInCubic
  72055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72056. */
  72057. export class CubicEase extends EasingFunction implements IEasingFunction {
  72058. /** @hidden */
  72059. easeInCore(gradient: number): number;
  72060. }
  72061. /**
  72062. * Easing function with an elastic shape (see link below).
  72063. * @see https://easings.net/#easeInElastic
  72064. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72065. */
  72066. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72067. /** Defines the number of oscillations*/
  72068. oscillations: number;
  72069. /** Defines the amplitude of the oscillations*/
  72070. springiness: number;
  72071. /**
  72072. * Instantiates an elastic easing function
  72073. * @see https://easings.net/#easeInElastic
  72074. * @param oscillations Defines the number of oscillations
  72075. * @param springiness Defines the amplitude of the oscillations
  72076. */
  72077. constructor(
  72078. /** Defines the number of oscillations*/
  72079. oscillations?: number,
  72080. /** Defines the amplitude of the oscillations*/
  72081. springiness?: number);
  72082. /** @hidden */
  72083. easeInCore(gradient: number): number;
  72084. }
  72085. /**
  72086. * Easing function with an exponential shape (see link below).
  72087. * @see https://easings.net/#easeInExpo
  72088. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72089. */
  72090. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72091. /** Defines the exponent of the function */
  72092. exponent: number;
  72093. /**
  72094. * Instantiates an exponential easing function
  72095. * @see https://easings.net/#easeInExpo
  72096. * @param exponent Defines the exponent of the function
  72097. */
  72098. constructor(
  72099. /** Defines the exponent of the function */
  72100. exponent?: number);
  72101. /** @hidden */
  72102. easeInCore(gradient: number): number;
  72103. }
  72104. /**
  72105. * Easing function with a power shape (see link below).
  72106. * @see https://easings.net/#easeInQuad
  72107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72108. */
  72109. export class PowerEase extends EasingFunction implements IEasingFunction {
  72110. /** Defines the power of the function */
  72111. power: number;
  72112. /**
  72113. * Instantiates an power base easing function
  72114. * @see https://easings.net/#easeInQuad
  72115. * @param power Defines the power of the function
  72116. */
  72117. constructor(
  72118. /** Defines the power of the function */
  72119. power?: number);
  72120. /** @hidden */
  72121. easeInCore(gradient: number): number;
  72122. }
  72123. /**
  72124. * Easing function with a power of 2 shape (see link below).
  72125. * @see https://easings.net/#easeInQuad
  72126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72127. */
  72128. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72129. /** @hidden */
  72130. easeInCore(gradient: number): number;
  72131. }
  72132. /**
  72133. * Easing function with a power of 4 shape (see link below).
  72134. * @see https://easings.net/#easeInQuart
  72135. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72136. */
  72137. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72138. /** @hidden */
  72139. easeInCore(gradient: number): number;
  72140. }
  72141. /**
  72142. * Easing function with a power of 5 shape (see link below).
  72143. * @see https://easings.net/#easeInQuint
  72144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72145. */
  72146. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72147. /** @hidden */
  72148. easeInCore(gradient: number): number;
  72149. }
  72150. /**
  72151. * Easing function with a sin shape (see link below).
  72152. * @see https://easings.net/#easeInSine
  72153. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72154. */
  72155. export class SineEase extends EasingFunction implements IEasingFunction {
  72156. /** @hidden */
  72157. easeInCore(gradient: number): number;
  72158. }
  72159. /**
  72160. * Easing function with a bezier shape (see link below).
  72161. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72163. */
  72164. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72165. /** Defines the x component of the start tangent in the bezier curve */
  72166. x1: number;
  72167. /** Defines the y component of the start tangent in the bezier curve */
  72168. y1: number;
  72169. /** Defines the x component of the end tangent in the bezier curve */
  72170. x2: number;
  72171. /** Defines the y component of the end tangent in the bezier curve */
  72172. y2: number;
  72173. /**
  72174. * Instantiates a bezier function
  72175. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72176. * @param x1 Defines the x component of the start tangent in the bezier curve
  72177. * @param y1 Defines the y component of the start tangent in the bezier curve
  72178. * @param x2 Defines the x component of the end tangent in the bezier curve
  72179. * @param y2 Defines the y component of the end tangent in the bezier curve
  72180. */
  72181. constructor(
  72182. /** Defines the x component of the start tangent in the bezier curve */
  72183. x1?: number,
  72184. /** Defines the y component of the start tangent in the bezier curve */
  72185. y1?: number,
  72186. /** Defines the x component of the end tangent in the bezier curve */
  72187. x2?: number,
  72188. /** Defines the y component of the end tangent in the bezier curve */
  72189. y2?: number);
  72190. /** @hidden */
  72191. easeInCore(gradient: number): number;
  72192. }
  72193. }
  72194. declare module BABYLON {
  72195. /**
  72196. * Defines an interface which represents an animation key frame
  72197. */
  72198. export interface IAnimationKey {
  72199. /**
  72200. * Frame of the key frame
  72201. */
  72202. frame: number;
  72203. /**
  72204. * Value at the specifies key frame
  72205. */
  72206. value: any;
  72207. /**
  72208. * The input tangent for the cubic hermite spline
  72209. */
  72210. inTangent?: any;
  72211. /**
  72212. * The output tangent for the cubic hermite spline
  72213. */
  72214. outTangent?: any;
  72215. /**
  72216. * The animation interpolation type
  72217. */
  72218. interpolation?: AnimationKeyInterpolation;
  72219. }
  72220. /**
  72221. * Enum for the animation key frame interpolation type
  72222. */
  72223. export enum AnimationKeyInterpolation {
  72224. /**
  72225. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72226. */
  72227. STEP = 1
  72228. }
  72229. }
  72230. declare module BABYLON {
  72231. /**
  72232. * Represents the range of an animation
  72233. */
  72234. export class AnimationRange {
  72235. /**The name of the animation range**/
  72236. name: string;
  72237. /**The starting frame of the animation */
  72238. from: number;
  72239. /**The ending frame of the animation*/
  72240. to: number;
  72241. /**
  72242. * Initializes the range of an animation
  72243. * @param name The name of the animation range
  72244. * @param from The starting frame of the animation
  72245. * @param to The ending frame of the animation
  72246. */
  72247. constructor(
  72248. /**The name of the animation range**/
  72249. name: string,
  72250. /**The starting frame of the animation */
  72251. from: number,
  72252. /**The ending frame of the animation*/
  72253. to: number);
  72254. /**
  72255. * Makes a copy of the animation range
  72256. * @returns A copy of the animation range
  72257. */
  72258. clone(): AnimationRange;
  72259. }
  72260. }
  72261. declare module BABYLON {
  72262. /**
  72263. * Composed of a frame, and an action function
  72264. */
  72265. export class AnimationEvent {
  72266. /** The frame for which the event is triggered **/
  72267. frame: number;
  72268. /** The event to perform when triggered **/
  72269. action: (currentFrame: number) => void;
  72270. /** Specifies if the event should be triggered only once**/
  72271. onlyOnce?: boolean | undefined;
  72272. /**
  72273. * Specifies if the animation event is done
  72274. */
  72275. isDone: boolean;
  72276. /**
  72277. * Initializes the animation event
  72278. * @param frame The frame for which the event is triggered
  72279. * @param action The event to perform when triggered
  72280. * @param onlyOnce Specifies if the event should be triggered only once
  72281. */
  72282. constructor(
  72283. /** The frame for which the event is triggered **/
  72284. frame: number,
  72285. /** The event to perform when triggered **/
  72286. action: (currentFrame: number) => void,
  72287. /** Specifies if the event should be triggered only once**/
  72288. onlyOnce?: boolean | undefined);
  72289. /** @hidden */
  72290. _clone(): AnimationEvent;
  72291. }
  72292. }
  72293. declare module BABYLON {
  72294. /**
  72295. * Interface used to define a behavior
  72296. */
  72297. export interface Behavior<T> {
  72298. /** gets or sets behavior's name */
  72299. name: string;
  72300. /**
  72301. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72302. */
  72303. init(): void;
  72304. /**
  72305. * Called when the behavior is attached to a target
  72306. * @param target defines the target where the behavior is attached to
  72307. */
  72308. attach(target: T): void;
  72309. /**
  72310. * Called when the behavior is detached from its target
  72311. */
  72312. detach(): void;
  72313. }
  72314. /**
  72315. * Interface implemented by classes supporting behaviors
  72316. */
  72317. export interface IBehaviorAware<T> {
  72318. /**
  72319. * Attach a behavior
  72320. * @param behavior defines the behavior to attach
  72321. * @returns the current host
  72322. */
  72323. addBehavior(behavior: Behavior<T>): T;
  72324. /**
  72325. * Remove a behavior from the current object
  72326. * @param behavior defines the behavior to detach
  72327. * @returns the current host
  72328. */
  72329. removeBehavior(behavior: Behavior<T>): T;
  72330. /**
  72331. * Gets a behavior using its name to search
  72332. * @param name defines the name to search
  72333. * @returns the behavior or null if not found
  72334. */
  72335. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72336. }
  72337. }
  72338. declare module BABYLON {
  72339. /**
  72340. * Defines an array and its length.
  72341. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72342. */
  72343. export interface ISmartArrayLike<T> {
  72344. /**
  72345. * The data of the array.
  72346. */
  72347. data: Array<T>;
  72348. /**
  72349. * The active length of the array.
  72350. */
  72351. length: number;
  72352. }
  72353. /**
  72354. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72355. */
  72356. export class SmartArray<T> implements ISmartArrayLike<T> {
  72357. /**
  72358. * The full set of data from the array.
  72359. */
  72360. data: Array<T>;
  72361. /**
  72362. * The active length of the array.
  72363. */
  72364. length: number;
  72365. protected _id: number;
  72366. /**
  72367. * Instantiates a Smart Array.
  72368. * @param capacity defines the default capacity of the array.
  72369. */
  72370. constructor(capacity: number);
  72371. /**
  72372. * Pushes a value at the end of the active data.
  72373. * @param value defines the object to push in the array.
  72374. */
  72375. push(value: T): void;
  72376. /**
  72377. * Iterates over the active data and apply the lambda to them.
  72378. * @param func defines the action to apply on each value.
  72379. */
  72380. forEach(func: (content: T) => void): void;
  72381. /**
  72382. * Sorts the full sets of data.
  72383. * @param compareFn defines the comparison function to apply.
  72384. */
  72385. sort(compareFn: (a: T, b: T) => number): void;
  72386. /**
  72387. * Resets the active data to an empty array.
  72388. */
  72389. reset(): void;
  72390. /**
  72391. * Releases all the data from the array as well as the array.
  72392. */
  72393. dispose(): void;
  72394. /**
  72395. * Concats the active data with a given array.
  72396. * @param array defines the data to concatenate with.
  72397. */
  72398. concat(array: any): void;
  72399. /**
  72400. * Returns the position of a value in the active data.
  72401. * @param value defines the value to find the index for
  72402. * @returns the index if found in the active data otherwise -1
  72403. */
  72404. indexOf(value: T): number;
  72405. /**
  72406. * Returns whether an element is part of the active data.
  72407. * @param value defines the value to look for
  72408. * @returns true if found in the active data otherwise false
  72409. */
  72410. contains(value: T): boolean;
  72411. private static _GlobalId;
  72412. }
  72413. /**
  72414. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72415. * The data in this array can only be present once
  72416. */
  72417. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72418. private _duplicateId;
  72419. /**
  72420. * Pushes a value at the end of the active data.
  72421. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72422. * @param value defines the object to push in the array.
  72423. */
  72424. push(value: T): void;
  72425. /**
  72426. * Pushes a value at the end of the active data.
  72427. * If the data is already present, it won t be added again
  72428. * @param value defines the object to push in the array.
  72429. * @returns true if added false if it was already present
  72430. */
  72431. pushNoDuplicate(value: T): boolean;
  72432. /**
  72433. * Resets the active data to an empty array.
  72434. */
  72435. reset(): void;
  72436. /**
  72437. * Concats the active data with a given array.
  72438. * This ensures no dupplicate will be present in the result.
  72439. * @param array defines the data to concatenate with.
  72440. */
  72441. concatWithNoDuplicate(array: any): void;
  72442. }
  72443. }
  72444. declare module BABYLON {
  72445. /**
  72446. * @ignore
  72447. * This is a list of all the different input types that are available in the application.
  72448. * Fo instance: ArcRotateCameraGamepadInput...
  72449. */
  72450. export var CameraInputTypes: {};
  72451. /**
  72452. * This is the contract to implement in order to create a new input class.
  72453. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72454. */
  72455. export interface ICameraInput<TCamera extends Camera> {
  72456. /**
  72457. * Defines the camera the input is attached to.
  72458. */
  72459. camera: Nullable<TCamera>;
  72460. /**
  72461. * Gets the class name of the current intput.
  72462. * @returns the class name
  72463. */
  72464. getClassName(): string;
  72465. /**
  72466. * Get the friendly name associated with the input class.
  72467. * @returns the input friendly name
  72468. */
  72469. getSimpleName(): string;
  72470. /**
  72471. * Attach the input controls to a specific dom element to get the input from.
  72472. * @param element Defines the element the controls should be listened from
  72473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72474. */
  72475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72476. /**
  72477. * Detach the current controls from the specified dom element.
  72478. * @param element Defines the element to stop listening the inputs from
  72479. */
  72480. detachControl(element: Nullable<HTMLElement>): void;
  72481. /**
  72482. * Update the current camera state depending on the inputs that have been used this frame.
  72483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72484. */
  72485. checkInputs?: () => void;
  72486. }
  72487. /**
  72488. * Represents a map of input types to input instance or input index to input instance.
  72489. */
  72490. export interface CameraInputsMap<TCamera extends Camera> {
  72491. /**
  72492. * Accessor to the input by input type.
  72493. */
  72494. [name: string]: ICameraInput<TCamera>;
  72495. /**
  72496. * Accessor to the input by input index.
  72497. */
  72498. [idx: number]: ICameraInput<TCamera>;
  72499. }
  72500. /**
  72501. * This represents the input manager used within a camera.
  72502. * It helps dealing with all the different kind of input attached to a camera.
  72503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72504. */
  72505. export class CameraInputsManager<TCamera extends Camera> {
  72506. /**
  72507. * Defines the list of inputs attahed to the camera.
  72508. */
  72509. attached: CameraInputsMap<TCamera>;
  72510. /**
  72511. * Defines the dom element the camera is collecting inputs from.
  72512. * This is null if the controls have not been attached.
  72513. */
  72514. attachedElement: Nullable<HTMLElement>;
  72515. /**
  72516. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72517. */
  72518. noPreventDefault: boolean;
  72519. /**
  72520. * Defined the camera the input manager belongs to.
  72521. */
  72522. camera: TCamera;
  72523. /**
  72524. * Update the current camera state depending on the inputs that have been used this frame.
  72525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72526. */
  72527. checkInputs: () => void;
  72528. /**
  72529. * Instantiate a new Camera Input Manager.
  72530. * @param camera Defines the camera the input manager blongs to
  72531. */
  72532. constructor(camera: TCamera);
  72533. /**
  72534. * Add an input method to a camera
  72535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72536. * @param input camera input method
  72537. */
  72538. add(input: ICameraInput<TCamera>): void;
  72539. /**
  72540. * Remove a specific input method from a camera
  72541. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72542. * @param inputToRemove camera input method
  72543. */
  72544. remove(inputToRemove: ICameraInput<TCamera>): void;
  72545. /**
  72546. * Remove a specific input type from a camera
  72547. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72548. * @param inputType the type of the input to remove
  72549. */
  72550. removeByType(inputType: string): void;
  72551. private _addCheckInputs;
  72552. /**
  72553. * Attach the input controls to the currently attached dom element to listen the events from.
  72554. * @param input Defines the input to attach
  72555. */
  72556. attachInput(input: ICameraInput<TCamera>): void;
  72557. /**
  72558. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72559. * @param element Defines the dom element to collect the events from
  72560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72561. */
  72562. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72563. /**
  72564. * Detach the current manager inputs controls from a specific dom element.
  72565. * @param element Defines the dom element to collect the events from
  72566. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72567. */
  72568. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72569. /**
  72570. * Rebuild the dynamic inputCheck function from the current list of
  72571. * defined inputs in the manager.
  72572. */
  72573. rebuildInputCheck(): void;
  72574. /**
  72575. * Remove all attached input methods from a camera
  72576. */
  72577. clear(): void;
  72578. /**
  72579. * Serialize the current input manager attached to a camera.
  72580. * This ensures than once parsed,
  72581. * the input associated to the camera will be identical to the current ones
  72582. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72583. */
  72584. serialize(serializedCamera: any): void;
  72585. /**
  72586. * Parses an input manager serialized JSON to restore the previous list of inputs
  72587. * and states associated to a camera.
  72588. * @param parsedCamera Defines the JSON to parse
  72589. */
  72590. parse(parsedCamera: any): void;
  72591. }
  72592. }
  72593. declare module BABYLON {
  72594. /**
  72595. * Class used to store data that will be store in GPU memory
  72596. */
  72597. export class Buffer {
  72598. private _engine;
  72599. private _buffer;
  72600. /** @hidden */
  72601. _data: Nullable<DataArray>;
  72602. private _updatable;
  72603. private _instanced;
  72604. /**
  72605. * Gets the byte stride.
  72606. */
  72607. readonly byteStride: number;
  72608. /**
  72609. * Constructor
  72610. * @param engine the engine
  72611. * @param data the data to use for this buffer
  72612. * @param updatable whether the data is updatable
  72613. * @param stride the stride (optional)
  72614. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72615. * @param instanced whether the buffer is instanced (optional)
  72616. * @param useBytes set to true if the stride in in bytes (optional)
  72617. */
  72618. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72619. /**
  72620. * Create a new VertexBuffer based on the current buffer
  72621. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72622. * @param offset defines offset in the buffer (0 by default)
  72623. * @param size defines the size in floats of attributes (position is 3 for instance)
  72624. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72625. * @param instanced defines if the vertex buffer contains indexed data
  72626. * @param useBytes defines if the offset and stride are in bytes
  72627. * @returns the new vertex buffer
  72628. */
  72629. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72630. /**
  72631. * Gets a boolean indicating if the Buffer is updatable?
  72632. * @returns true if the buffer is updatable
  72633. */
  72634. isUpdatable(): boolean;
  72635. /**
  72636. * Gets current buffer's data
  72637. * @returns a DataArray or null
  72638. */
  72639. getData(): Nullable<DataArray>;
  72640. /**
  72641. * Gets underlying native buffer
  72642. * @returns underlying native buffer
  72643. */
  72644. getBuffer(): Nullable<DataBuffer>;
  72645. /**
  72646. * Gets the stride in float32 units (i.e. byte stride / 4).
  72647. * May not be an integer if the byte stride is not divisible by 4.
  72648. * DEPRECATED. Use byteStride instead.
  72649. * @returns the stride in float32 units
  72650. */
  72651. getStrideSize(): number;
  72652. /**
  72653. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72654. * @param data defines the data to store
  72655. */
  72656. create(data?: Nullable<DataArray>): void;
  72657. /** @hidden */
  72658. _rebuild(): void;
  72659. /**
  72660. * Update current buffer data
  72661. * @param data defines the data to store
  72662. */
  72663. update(data: DataArray): void;
  72664. /**
  72665. * Updates the data directly.
  72666. * @param data the new data
  72667. * @param offset the new offset
  72668. * @param vertexCount the vertex count (optional)
  72669. * @param useBytes set to true if the offset is in bytes
  72670. */
  72671. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72672. /**
  72673. * Release all resources
  72674. */
  72675. dispose(): void;
  72676. }
  72677. /**
  72678. * Specialized buffer used to store vertex data
  72679. */
  72680. export class VertexBuffer {
  72681. /** @hidden */
  72682. _buffer: Buffer;
  72683. private _kind;
  72684. private _size;
  72685. private _ownsBuffer;
  72686. private _instanced;
  72687. private _instanceDivisor;
  72688. /**
  72689. * The byte type.
  72690. */
  72691. static readonly BYTE: number;
  72692. /**
  72693. * The unsigned byte type.
  72694. */
  72695. static readonly UNSIGNED_BYTE: number;
  72696. /**
  72697. * The short type.
  72698. */
  72699. static readonly SHORT: number;
  72700. /**
  72701. * The unsigned short type.
  72702. */
  72703. static readonly UNSIGNED_SHORT: number;
  72704. /**
  72705. * The integer type.
  72706. */
  72707. static readonly INT: number;
  72708. /**
  72709. * The unsigned integer type.
  72710. */
  72711. static readonly UNSIGNED_INT: number;
  72712. /**
  72713. * The float type.
  72714. */
  72715. static readonly FLOAT: number;
  72716. /**
  72717. * Gets or sets the instance divisor when in instanced mode
  72718. */
  72719. instanceDivisor: number;
  72720. /**
  72721. * Gets the byte stride.
  72722. */
  72723. readonly byteStride: number;
  72724. /**
  72725. * Gets the byte offset.
  72726. */
  72727. readonly byteOffset: number;
  72728. /**
  72729. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  72730. */
  72731. readonly normalized: boolean;
  72732. /**
  72733. * Gets the data type of each component in the array.
  72734. */
  72735. readonly type: number;
  72736. /**
  72737. * Constructor
  72738. * @param engine the engine
  72739. * @param data the data to use for this vertex buffer
  72740. * @param kind the vertex buffer kind
  72741. * @param updatable whether the data is updatable
  72742. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72743. * @param stride the stride (optional)
  72744. * @param instanced whether the buffer is instanced (optional)
  72745. * @param offset the offset of the data (optional)
  72746. * @param size the number of components (optional)
  72747. * @param type the type of the component (optional)
  72748. * @param normalized whether the data contains normalized data (optional)
  72749. * @param useBytes set to true if stride and offset are in bytes (optional)
  72750. */
  72751. 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);
  72752. /** @hidden */
  72753. _rebuild(): void;
  72754. /**
  72755. * Returns the kind of the VertexBuffer (string)
  72756. * @returns a string
  72757. */
  72758. getKind(): string;
  72759. /**
  72760. * Gets a boolean indicating if the VertexBuffer is updatable?
  72761. * @returns true if the buffer is updatable
  72762. */
  72763. isUpdatable(): boolean;
  72764. /**
  72765. * Gets current buffer's data
  72766. * @returns a DataArray or null
  72767. */
  72768. getData(): Nullable<DataArray>;
  72769. /**
  72770. * Gets underlying native buffer
  72771. * @returns underlying native buffer
  72772. */
  72773. getBuffer(): Nullable<DataBuffer>;
  72774. /**
  72775. * Gets the stride in float32 units (i.e. byte stride / 4).
  72776. * May not be an integer if the byte stride is not divisible by 4.
  72777. * DEPRECATED. Use byteStride instead.
  72778. * @returns the stride in float32 units
  72779. */
  72780. getStrideSize(): number;
  72781. /**
  72782. * Returns the offset as a multiple of the type byte length.
  72783. * DEPRECATED. Use byteOffset instead.
  72784. * @returns the offset in bytes
  72785. */
  72786. getOffset(): number;
  72787. /**
  72788. * Returns the number of components per vertex attribute (integer)
  72789. * @returns the size in float
  72790. */
  72791. getSize(): number;
  72792. /**
  72793. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  72794. * @returns true if this buffer is instanced
  72795. */
  72796. getIsInstanced(): boolean;
  72797. /**
  72798. * Returns the instancing divisor, zero for non-instanced (integer).
  72799. * @returns a number
  72800. */
  72801. getInstanceDivisor(): number;
  72802. /**
  72803. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72804. * @param data defines the data to store
  72805. */
  72806. create(data?: DataArray): void;
  72807. /**
  72808. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  72809. * This function will create a new buffer if the current one is not updatable
  72810. * @param data defines the data to store
  72811. */
  72812. update(data: DataArray): void;
  72813. /**
  72814. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  72815. * Returns the directly updated WebGLBuffer.
  72816. * @param data the new data
  72817. * @param offset the new offset
  72818. * @param useBytes set to true if the offset is in bytes
  72819. */
  72820. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  72821. /**
  72822. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  72823. */
  72824. dispose(): void;
  72825. /**
  72826. * Enumerates each value of this vertex buffer as numbers.
  72827. * @param count the number of values to enumerate
  72828. * @param callback the callback function called for each value
  72829. */
  72830. forEach(count: number, callback: (value: number, index: number) => void): void;
  72831. /**
  72832. * Positions
  72833. */
  72834. static readonly PositionKind: string;
  72835. /**
  72836. * Normals
  72837. */
  72838. static readonly NormalKind: string;
  72839. /**
  72840. * Tangents
  72841. */
  72842. static readonly TangentKind: string;
  72843. /**
  72844. * Texture coordinates
  72845. */
  72846. static readonly UVKind: string;
  72847. /**
  72848. * Texture coordinates 2
  72849. */
  72850. static readonly UV2Kind: string;
  72851. /**
  72852. * Texture coordinates 3
  72853. */
  72854. static readonly UV3Kind: string;
  72855. /**
  72856. * Texture coordinates 4
  72857. */
  72858. static readonly UV4Kind: string;
  72859. /**
  72860. * Texture coordinates 5
  72861. */
  72862. static readonly UV5Kind: string;
  72863. /**
  72864. * Texture coordinates 6
  72865. */
  72866. static readonly UV6Kind: string;
  72867. /**
  72868. * Colors
  72869. */
  72870. static readonly ColorKind: string;
  72871. /**
  72872. * Matrix indices (for bones)
  72873. */
  72874. static readonly MatricesIndicesKind: string;
  72875. /**
  72876. * Matrix weights (for bones)
  72877. */
  72878. static readonly MatricesWeightsKind: string;
  72879. /**
  72880. * Additional matrix indices (for bones)
  72881. */
  72882. static readonly MatricesIndicesExtraKind: string;
  72883. /**
  72884. * Additional matrix weights (for bones)
  72885. */
  72886. static readonly MatricesWeightsExtraKind: string;
  72887. /**
  72888. * Deduces the stride given a kind.
  72889. * @param kind The kind string to deduce
  72890. * @returns The deduced stride
  72891. */
  72892. static DeduceStride(kind: string): number;
  72893. /**
  72894. * Gets the byte length of the given type.
  72895. * @param type the type
  72896. * @returns the number of bytes
  72897. */
  72898. static GetTypeByteLength(type: number): number;
  72899. /**
  72900. * Enumerates each value of the given parameters as numbers.
  72901. * @param data the data to enumerate
  72902. * @param byteOffset the byte offset of the data
  72903. * @param byteStride the byte stride of the data
  72904. * @param componentCount the number of components per element
  72905. * @param componentType the type of the component
  72906. * @param count the number of values to enumerate
  72907. * @param normalized whether the data is normalized
  72908. * @param callback the callback function called for each value
  72909. */
  72910. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  72911. private static _GetFloatValue;
  72912. }
  72913. }
  72914. declare module BABYLON {
  72915. /**
  72916. * @hidden
  72917. */
  72918. export class IntersectionInfo {
  72919. bu: Nullable<number>;
  72920. bv: Nullable<number>;
  72921. distance: number;
  72922. faceId: number;
  72923. subMeshId: number;
  72924. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72925. }
  72926. }
  72927. declare module BABYLON {
  72928. /**
  72929. * Represens a plane by the equation ax + by + cz + d = 0
  72930. */
  72931. export class Plane {
  72932. private static _TmpMatrix;
  72933. /**
  72934. * Normal of the plane (a,b,c)
  72935. */
  72936. normal: Vector3;
  72937. /**
  72938. * d component of the plane
  72939. */
  72940. d: number;
  72941. /**
  72942. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72943. * @param a a component of the plane
  72944. * @param b b component of the plane
  72945. * @param c c component of the plane
  72946. * @param d d component of the plane
  72947. */
  72948. constructor(a: number, b: number, c: number, d: number);
  72949. /**
  72950. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72951. */
  72952. asArray(): number[];
  72953. /**
  72954. * @returns a new plane copied from the current Plane.
  72955. */
  72956. clone(): Plane;
  72957. /**
  72958. * @returns the string "Plane".
  72959. */
  72960. getClassName(): string;
  72961. /**
  72962. * @returns the Plane hash code.
  72963. */
  72964. getHashCode(): number;
  72965. /**
  72966. * Normalize the current Plane in place.
  72967. * @returns the updated Plane.
  72968. */
  72969. normalize(): Plane;
  72970. /**
  72971. * Applies a transformation the plane and returns the result
  72972. * @param transformation the transformation matrix to be applied to the plane
  72973. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72974. */
  72975. transform(transformation: DeepImmutable<Matrix>): Plane;
  72976. /**
  72977. * Calcualtte the dot product between the point and the plane normal
  72978. * @param point point to calculate the dot product with
  72979. * @returns the dot product (float) of the point coordinates and the plane normal.
  72980. */
  72981. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72982. /**
  72983. * Updates the current Plane from the plane defined by the three given points.
  72984. * @param point1 one of the points used to contruct the plane
  72985. * @param point2 one of the points used to contruct the plane
  72986. * @param point3 one of the points used to contruct the plane
  72987. * @returns the updated Plane.
  72988. */
  72989. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72990. /**
  72991. * Checks if the plane is facing a given direction
  72992. * @param direction the direction to check if the plane is facing
  72993. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72994. * @returns True is the vector "direction" is the same side than the plane normal.
  72995. */
  72996. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72997. /**
  72998. * Calculates the distance to a point
  72999. * @param point point to calculate distance to
  73000. * @returns the signed distance (float) from the given point to the Plane.
  73001. */
  73002. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73003. /**
  73004. * Creates a plane from an array
  73005. * @param array the array to create a plane from
  73006. * @returns a new Plane from the given array.
  73007. */
  73008. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73009. /**
  73010. * Creates a plane from three points
  73011. * @param point1 point used to create the plane
  73012. * @param point2 point used to create the plane
  73013. * @param point3 point used to create the plane
  73014. * @returns a new Plane defined by the three given points.
  73015. */
  73016. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73017. /**
  73018. * Creates a plane from an origin point and a normal
  73019. * @param origin origin of the plane to be constructed
  73020. * @param normal normal of the plane to be constructed
  73021. * @returns a new Plane the normal vector to this plane at the given origin point.
  73022. * Note : the vector "normal" is updated because normalized.
  73023. */
  73024. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73025. /**
  73026. * Calculates the distance from a plane and a point
  73027. * @param origin origin of the plane to be constructed
  73028. * @param normal normal of the plane to be constructed
  73029. * @param point point to calculate distance to
  73030. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73031. */
  73032. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73033. }
  73034. }
  73035. declare module BABYLON {
  73036. /**
  73037. * Class used to store bounding sphere information
  73038. */
  73039. export class BoundingSphere {
  73040. /**
  73041. * Gets the center of the bounding sphere in local space
  73042. */
  73043. readonly center: Vector3;
  73044. /**
  73045. * Radius of the bounding sphere in local space
  73046. */
  73047. radius: number;
  73048. /**
  73049. * Gets the center of the bounding sphere in world space
  73050. */
  73051. readonly centerWorld: Vector3;
  73052. /**
  73053. * Radius of the bounding sphere in world space
  73054. */
  73055. radiusWorld: number;
  73056. /**
  73057. * Gets the minimum vector in local space
  73058. */
  73059. readonly minimum: Vector3;
  73060. /**
  73061. * Gets the maximum vector in local space
  73062. */
  73063. readonly maximum: Vector3;
  73064. private _worldMatrix;
  73065. private static readonly TmpVector3;
  73066. /**
  73067. * Creates a new bounding sphere
  73068. * @param min defines the minimum vector (in local space)
  73069. * @param max defines the maximum vector (in local space)
  73070. * @param worldMatrix defines the new world matrix
  73071. */
  73072. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73073. /**
  73074. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73075. * @param min defines the new minimum vector (in local space)
  73076. * @param max defines the new maximum vector (in local space)
  73077. * @param worldMatrix defines the new world matrix
  73078. */
  73079. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73080. /**
  73081. * Scale the current bounding sphere by applying a scale factor
  73082. * @param factor defines the scale factor to apply
  73083. * @returns the current bounding box
  73084. */
  73085. scale(factor: number): BoundingSphere;
  73086. /**
  73087. * Gets the world matrix of the bounding box
  73088. * @returns a matrix
  73089. */
  73090. getWorldMatrix(): DeepImmutable<Matrix>;
  73091. /** @hidden */
  73092. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73093. /**
  73094. * Tests if the bounding sphere is intersecting the frustum planes
  73095. * @param frustumPlanes defines the frustum planes to test
  73096. * @returns true if there is an intersection
  73097. */
  73098. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73099. /**
  73100. * Tests if the bounding sphere center is in between the frustum planes.
  73101. * Used for optimistic fast inclusion.
  73102. * @param frustumPlanes defines the frustum planes to test
  73103. * @returns true if the sphere center is in between the frustum planes
  73104. */
  73105. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73106. /**
  73107. * Tests if a point is inside the bounding sphere
  73108. * @param point defines the point to test
  73109. * @returns true if the point is inside the bounding sphere
  73110. */
  73111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73112. /**
  73113. * Checks if two sphere intersct
  73114. * @param sphere0 sphere 0
  73115. * @param sphere1 sphere 1
  73116. * @returns true if the speres intersect
  73117. */
  73118. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73119. }
  73120. }
  73121. declare module BABYLON {
  73122. /**
  73123. * Class used to store bounding box information
  73124. */
  73125. export class BoundingBox implements ICullable {
  73126. /**
  73127. * Gets the 8 vectors representing the bounding box in local space
  73128. */
  73129. readonly vectors: Vector3[];
  73130. /**
  73131. * Gets the center of the bounding box in local space
  73132. */
  73133. readonly center: Vector3;
  73134. /**
  73135. * Gets the center of the bounding box in world space
  73136. */
  73137. readonly centerWorld: Vector3;
  73138. /**
  73139. * Gets the extend size in local space
  73140. */
  73141. readonly extendSize: Vector3;
  73142. /**
  73143. * Gets the extend size in world space
  73144. */
  73145. readonly extendSizeWorld: Vector3;
  73146. /**
  73147. * Gets the OBB (object bounding box) directions
  73148. */
  73149. readonly directions: Vector3[];
  73150. /**
  73151. * Gets the 8 vectors representing the bounding box in world space
  73152. */
  73153. readonly vectorsWorld: Vector3[];
  73154. /**
  73155. * Gets the minimum vector in world space
  73156. */
  73157. readonly minimumWorld: Vector3;
  73158. /**
  73159. * Gets the maximum vector in world space
  73160. */
  73161. readonly maximumWorld: Vector3;
  73162. /**
  73163. * Gets the minimum vector in local space
  73164. */
  73165. readonly minimum: Vector3;
  73166. /**
  73167. * Gets the maximum vector in local space
  73168. */
  73169. readonly maximum: Vector3;
  73170. private _worldMatrix;
  73171. private static readonly TmpVector3;
  73172. /**
  73173. * @hidden
  73174. */
  73175. _tag: number;
  73176. /**
  73177. * Creates a new bounding box
  73178. * @param min defines the minimum vector (in local space)
  73179. * @param max defines the maximum vector (in local space)
  73180. * @param worldMatrix defines the new world matrix
  73181. */
  73182. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73183. /**
  73184. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73185. * @param min defines the new minimum vector (in local space)
  73186. * @param max defines the new maximum vector (in local space)
  73187. * @param worldMatrix defines the new world matrix
  73188. */
  73189. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73190. /**
  73191. * Scale the current bounding box by applying a scale factor
  73192. * @param factor defines the scale factor to apply
  73193. * @returns the current bounding box
  73194. */
  73195. scale(factor: number): BoundingBox;
  73196. /**
  73197. * Gets the world matrix of the bounding box
  73198. * @returns a matrix
  73199. */
  73200. getWorldMatrix(): DeepImmutable<Matrix>;
  73201. /** @hidden */
  73202. _update(world: DeepImmutable<Matrix>): void;
  73203. /**
  73204. * Tests if the bounding box is intersecting the frustum planes
  73205. * @param frustumPlanes defines the frustum planes to test
  73206. * @returns true if there is an intersection
  73207. */
  73208. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73209. /**
  73210. * Tests if the bounding box is entirely inside the frustum planes
  73211. * @param frustumPlanes defines the frustum planes to test
  73212. * @returns true if there is an inclusion
  73213. */
  73214. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73215. /**
  73216. * Tests if a point is inside the bounding box
  73217. * @param point defines the point to test
  73218. * @returns true if the point is inside the bounding box
  73219. */
  73220. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73221. /**
  73222. * Tests if the bounding box intersects with a bounding sphere
  73223. * @param sphere defines the sphere to test
  73224. * @returns true if there is an intersection
  73225. */
  73226. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73227. /**
  73228. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73229. * @param min defines the min vector to use
  73230. * @param max defines the max vector to use
  73231. * @returns true if there is an intersection
  73232. */
  73233. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73234. /**
  73235. * Tests if two bounding boxes are intersections
  73236. * @param box0 defines the first box to test
  73237. * @param box1 defines the second box to test
  73238. * @returns true if there is an intersection
  73239. */
  73240. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73241. /**
  73242. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73243. * @param minPoint defines the minimum vector of the bounding box
  73244. * @param maxPoint defines the maximum vector of the bounding box
  73245. * @param sphereCenter defines the sphere center
  73246. * @param sphereRadius defines the sphere radius
  73247. * @returns true if there is an intersection
  73248. */
  73249. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73250. /**
  73251. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73252. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73253. * @param frustumPlanes defines the frustum planes to test
  73254. * @return true if there is an inclusion
  73255. */
  73256. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73257. /**
  73258. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73259. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73260. * @param frustumPlanes defines the frustum planes to test
  73261. * @return true if there is an intersection
  73262. */
  73263. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73264. }
  73265. }
  73266. declare module BABYLON {
  73267. /** @hidden */
  73268. export class Collider {
  73269. /** Define if a collision was found */
  73270. collisionFound: boolean;
  73271. /**
  73272. * Define last intersection point in local space
  73273. */
  73274. intersectionPoint: Vector3;
  73275. /**
  73276. * Define last collided mesh
  73277. */
  73278. collidedMesh: Nullable<AbstractMesh>;
  73279. private _collisionPoint;
  73280. private _planeIntersectionPoint;
  73281. private _tempVector;
  73282. private _tempVector2;
  73283. private _tempVector3;
  73284. private _tempVector4;
  73285. private _edge;
  73286. private _baseToVertex;
  73287. private _destinationPoint;
  73288. private _slidePlaneNormal;
  73289. private _displacementVector;
  73290. /** @hidden */
  73291. _radius: Vector3;
  73292. /** @hidden */
  73293. _retry: number;
  73294. private _velocity;
  73295. private _basePoint;
  73296. private _epsilon;
  73297. /** @hidden */
  73298. _velocityWorldLength: number;
  73299. /** @hidden */
  73300. _basePointWorld: Vector3;
  73301. private _velocityWorld;
  73302. private _normalizedVelocity;
  73303. /** @hidden */
  73304. _initialVelocity: Vector3;
  73305. /** @hidden */
  73306. _initialPosition: Vector3;
  73307. private _nearestDistance;
  73308. private _collisionMask;
  73309. collisionMask: number;
  73310. /**
  73311. * Gets the plane normal used to compute the sliding response (in local space)
  73312. */
  73313. readonly slidePlaneNormal: Vector3;
  73314. /** @hidden */
  73315. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73316. /** @hidden */
  73317. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73318. /** @hidden */
  73319. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73320. /** @hidden */
  73321. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73322. /** @hidden */
  73323. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73324. /** @hidden */
  73325. _getResponse(pos: Vector3, vel: Vector3): void;
  73326. }
  73327. }
  73328. declare module BABYLON {
  73329. /**
  73330. * Interface for cullable objects
  73331. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73332. */
  73333. export interface ICullable {
  73334. /**
  73335. * Checks if the object or part of the object is in the frustum
  73336. * @param frustumPlanes Camera near/planes
  73337. * @returns true if the object is in frustum otherwise false
  73338. */
  73339. isInFrustum(frustumPlanes: Plane[]): boolean;
  73340. /**
  73341. * Checks if a cullable object (mesh...) is in the camera frustum
  73342. * Unlike isInFrustum this cheks the full bounding box
  73343. * @param frustumPlanes Camera near/planes
  73344. * @returns true if the object is in frustum otherwise false
  73345. */
  73346. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73347. }
  73348. /**
  73349. * Info for a bounding data of a mesh
  73350. */
  73351. export class BoundingInfo implements ICullable {
  73352. /**
  73353. * Bounding box for the mesh
  73354. */
  73355. readonly boundingBox: BoundingBox;
  73356. /**
  73357. * Bounding sphere for the mesh
  73358. */
  73359. readonly boundingSphere: BoundingSphere;
  73360. private _isLocked;
  73361. private static readonly TmpVector3;
  73362. /**
  73363. * Constructs bounding info
  73364. * @param minimum min vector of the bounding box/sphere
  73365. * @param maximum max vector of the bounding box/sphere
  73366. * @param worldMatrix defines the new world matrix
  73367. */
  73368. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73369. /**
  73370. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73371. * @param min defines the new minimum vector (in local space)
  73372. * @param max defines the new maximum vector (in local space)
  73373. * @param worldMatrix defines the new world matrix
  73374. */
  73375. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73376. /**
  73377. * min vector of the bounding box/sphere
  73378. */
  73379. readonly minimum: Vector3;
  73380. /**
  73381. * max vector of the bounding box/sphere
  73382. */
  73383. readonly maximum: Vector3;
  73384. /**
  73385. * If the info is locked and won't be updated to avoid perf overhead
  73386. */
  73387. isLocked: boolean;
  73388. /**
  73389. * Updates the bounding sphere and box
  73390. * @param world world matrix to be used to update
  73391. */
  73392. update(world: DeepImmutable<Matrix>): void;
  73393. /**
  73394. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73395. * @param center New center of the bounding info
  73396. * @param extend New extend of the bounding info
  73397. * @returns the current bounding info
  73398. */
  73399. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73400. /**
  73401. * Scale the current bounding info by applying a scale factor
  73402. * @param factor defines the scale factor to apply
  73403. * @returns the current bounding info
  73404. */
  73405. scale(factor: number): BoundingInfo;
  73406. /**
  73407. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73408. * @param frustumPlanes defines the frustum to test
  73409. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73410. * @returns true if the bounding info is in the frustum planes
  73411. */
  73412. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73413. /**
  73414. * Gets the world distance between the min and max points of the bounding box
  73415. */
  73416. readonly diagonalLength: number;
  73417. /**
  73418. * Checks if a cullable object (mesh...) is in the camera frustum
  73419. * Unlike isInFrustum this cheks the full bounding box
  73420. * @param frustumPlanes Camera near/planes
  73421. * @returns true if the object is in frustum otherwise false
  73422. */
  73423. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73424. /** @hidden */
  73425. _checkCollision(collider: Collider): boolean;
  73426. /**
  73427. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73428. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73429. * @param point the point to check intersection with
  73430. * @returns if the point intersects
  73431. */
  73432. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73433. /**
  73434. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73435. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73436. * @param boundingInfo the bounding info to check intersection with
  73437. * @param precise if the intersection should be done using OBB
  73438. * @returns if the bounding info intersects
  73439. */
  73440. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73441. }
  73442. }
  73443. declare module BABYLON {
  73444. /**
  73445. * Extracts minimum and maximum values from a list of indexed positions
  73446. * @param positions defines the positions to use
  73447. * @param indices defines the indices to the positions
  73448. * @param indexStart defines the start index
  73449. * @param indexCount defines the end index
  73450. * @param bias defines bias value to add to the result
  73451. * @return minimum and maximum values
  73452. */
  73453. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73454. minimum: Vector3;
  73455. maximum: Vector3;
  73456. };
  73457. /**
  73458. * Extracts minimum and maximum values from a list of positions
  73459. * @param positions defines the positions to use
  73460. * @param start defines the start index in the positions array
  73461. * @param count defines the number of positions to handle
  73462. * @param bias defines bias value to add to the result
  73463. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73464. * @return minimum and maximum values
  73465. */
  73466. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73467. minimum: Vector3;
  73468. maximum: Vector3;
  73469. };
  73470. }
  73471. declare module BABYLON {
  73472. /** @hidden */
  73473. export class WebGLDataBuffer extends DataBuffer {
  73474. private _buffer;
  73475. constructor(resource: WebGLBuffer);
  73476. readonly underlyingResource: any;
  73477. }
  73478. }
  73479. declare module BABYLON {
  73480. /** @hidden */
  73481. export class WebGLPipelineContext implements IPipelineContext {
  73482. engine: ThinEngine;
  73483. program: Nullable<WebGLProgram>;
  73484. context?: WebGLRenderingContext;
  73485. vertexShader?: WebGLShader;
  73486. fragmentShader?: WebGLShader;
  73487. isParallelCompiled: boolean;
  73488. onCompiled?: () => void;
  73489. transformFeedback?: WebGLTransformFeedback | null;
  73490. readonly isAsync: boolean;
  73491. readonly isReady: boolean;
  73492. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73493. }
  73494. }
  73495. declare module BABYLON {
  73496. interface ThinEngine {
  73497. /**
  73498. * Create an uniform buffer
  73499. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73500. * @param elements defines the content of the uniform buffer
  73501. * @returns the webGL uniform buffer
  73502. */
  73503. createUniformBuffer(elements: FloatArray): DataBuffer;
  73504. /**
  73505. * Create a dynamic uniform buffer
  73506. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73507. * @param elements defines the content of the uniform buffer
  73508. * @returns the webGL uniform buffer
  73509. */
  73510. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73511. /**
  73512. * Update an existing uniform buffer
  73513. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73514. * @param uniformBuffer defines the target uniform buffer
  73515. * @param elements defines the content to update
  73516. * @param offset defines the offset in the uniform buffer where update should start
  73517. * @param count defines the size of the data to update
  73518. */
  73519. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73520. /**
  73521. * Bind an uniform buffer to the current webGL context
  73522. * @param buffer defines the buffer to bind
  73523. */
  73524. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73525. /**
  73526. * Bind a buffer to the current webGL context at a given location
  73527. * @param buffer defines the buffer to bind
  73528. * @param location defines the index where to bind the buffer
  73529. */
  73530. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73531. /**
  73532. * Bind a specific block at a given index in a specific shader program
  73533. * @param pipelineContext defines the pipeline context to use
  73534. * @param blockName defines the block name
  73535. * @param index defines the index where to bind the block
  73536. */
  73537. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73538. }
  73539. }
  73540. declare module BABYLON {
  73541. /**
  73542. * Uniform buffer objects.
  73543. *
  73544. * Handles blocks of uniform on the GPU.
  73545. *
  73546. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73547. *
  73548. * For more information, please refer to :
  73549. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73550. */
  73551. export class UniformBuffer {
  73552. private _engine;
  73553. private _buffer;
  73554. private _data;
  73555. private _bufferData;
  73556. private _dynamic?;
  73557. private _uniformLocations;
  73558. private _uniformSizes;
  73559. private _uniformLocationPointer;
  73560. private _needSync;
  73561. private _noUBO;
  73562. private _currentEffect;
  73563. private static _MAX_UNIFORM_SIZE;
  73564. private static _tempBuffer;
  73565. /**
  73566. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73567. * This is dynamic to allow compat with webgl 1 and 2.
  73568. * You will need to pass the name of the uniform as well as the value.
  73569. */
  73570. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73571. /**
  73572. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73573. * This is dynamic to allow compat with webgl 1 and 2.
  73574. * You will need to pass the name of the uniform as well as the value.
  73575. */
  73576. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73577. /**
  73578. * Lambda to Update a single float in a uniform buffer.
  73579. * This is dynamic to allow compat with webgl 1 and 2.
  73580. * You will need to pass the name of the uniform as well as the value.
  73581. */
  73582. updateFloat: (name: string, x: number) => void;
  73583. /**
  73584. * Lambda to Update a vec2 of float in a uniform buffer.
  73585. * This is dynamic to allow compat with webgl 1 and 2.
  73586. * You will need to pass the name of the uniform as well as the value.
  73587. */
  73588. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73589. /**
  73590. * Lambda to Update a vec3 of float in a uniform buffer.
  73591. * This is dynamic to allow compat with webgl 1 and 2.
  73592. * You will need to pass the name of the uniform as well as the value.
  73593. */
  73594. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73595. /**
  73596. * Lambda to Update a vec4 of float in a uniform buffer.
  73597. * This is dynamic to allow compat with webgl 1 and 2.
  73598. * You will need to pass the name of the uniform as well as the value.
  73599. */
  73600. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73601. /**
  73602. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73603. * This is dynamic to allow compat with webgl 1 and 2.
  73604. * You will need to pass the name of the uniform as well as the value.
  73605. */
  73606. updateMatrix: (name: string, mat: Matrix) => void;
  73607. /**
  73608. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73609. * This is dynamic to allow compat with webgl 1 and 2.
  73610. * You will need to pass the name of the uniform as well as the value.
  73611. */
  73612. updateVector3: (name: string, vector: Vector3) => void;
  73613. /**
  73614. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73615. * This is dynamic to allow compat with webgl 1 and 2.
  73616. * You will need to pass the name of the uniform as well as the value.
  73617. */
  73618. updateVector4: (name: string, vector: Vector4) => void;
  73619. /**
  73620. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73621. * This is dynamic to allow compat with webgl 1 and 2.
  73622. * You will need to pass the name of the uniform as well as the value.
  73623. */
  73624. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73625. /**
  73626. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73627. * This is dynamic to allow compat with webgl 1 and 2.
  73628. * You will need to pass the name of the uniform as well as the value.
  73629. */
  73630. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73631. /**
  73632. * Instantiates a new Uniform buffer objects.
  73633. *
  73634. * Handles blocks of uniform on the GPU.
  73635. *
  73636. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73637. *
  73638. * For more information, please refer to :
  73639. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73640. * @param engine Define the engine the buffer is associated with
  73641. * @param data Define the data contained in the buffer
  73642. * @param dynamic Define if the buffer is updatable
  73643. */
  73644. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73645. /**
  73646. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73647. * or just falling back on setUniformXXX calls.
  73648. */
  73649. readonly useUbo: boolean;
  73650. /**
  73651. * Indicates if the WebGL underlying uniform buffer is in sync
  73652. * with the javascript cache data.
  73653. */
  73654. readonly isSync: boolean;
  73655. /**
  73656. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73657. * Also, a dynamic UniformBuffer will disable cache verification and always
  73658. * update the underlying WebGL uniform buffer to the GPU.
  73659. * @returns if Dynamic, otherwise false
  73660. */
  73661. isDynamic(): boolean;
  73662. /**
  73663. * The data cache on JS side.
  73664. * @returns the underlying data as a float array
  73665. */
  73666. getData(): Float32Array;
  73667. /**
  73668. * The underlying WebGL Uniform buffer.
  73669. * @returns the webgl buffer
  73670. */
  73671. getBuffer(): Nullable<DataBuffer>;
  73672. /**
  73673. * std140 layout specifies how to align data within an UBO structure.
  73674. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73675. * for specs.
  73676. */
  73677. private _fillAlignment;
  73678. /**
  73679. * Adds an uniform in the buffer.
  73680. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73681. * for the layout to be correct !
  73682. * @param name Name of the uniform, as used in the uniform block in the shader.
  73683. * @param size Data size, or data directly.
  73684. */
  73685. addUniform(name: string, size: number | number[]): void;
  73686. /**
  73687. * Adds a Matrix 4x4 to the uniform buffer.
  73688. * @param name Name of the uniform, as used in the uniform block in the shader.
  73689. * @param mat A 4x4 matrix.
  73690. */
  73691. addMatrix(name: string, mat: Matrix): void;
  73692. /**
  73693. * Adds a vec2 to the uniform buffer.
  73694. * @param name Name of the uniform, as used in the uniform block in the shader.
  73695. * @param x Define the x component value of the vec2
  73696. * @param y Define the y component value of the vec2
  73697. */
  73698. addFloat2(name: string, x: number, y: number): void;
  73699. /**
  73700. * Adds a vec3 to the uniform buffer.
  73701. * @param name Name of the uniform, as used in the uniform block in the shader.
  73702. * @param x Define the x component value of the vec3
  73703. * @param y Define the y component value of the vec3
  73704. * @param z Define the z component value of the vec3
  73705. */
  73706. addFloat3(name: string, x: number, y: number, z: number): void;
  73707. /**
  73708. * Adds a vec3 to the uniform buffer.
  73709. * @param name Name of the uniform, as used in the uniform block in the shader.
  73710. * @param color Define the vec3 from a Color
  73711. */
  73712. addColor3(name: string, color: Color3): void;
  73713. /**
  73714. * Adds a vec4 to the uniform buffer.
  73715. * @param name Name of the uniform, as used in the uniform block in the shader.
  73716. * @param color Define the rgb components from a Color
  73717. * @param alpha Define the a component of the vec4
  73718. */
  73719. addColor4(name: string, color: Color3, alpha: number): void;
  73720. /**
  73721. * Adds a vec3 to the uniform buffer.
  73722. * @param name Name of the uniform, as used in the uniform block in the shader.
  73723. * @param vector Define the vec3 components from a Vector
  73724. */
  73725. addVector3(name: string, vector: Vector3): void;
  73726. /**
  73727. * Adds a Matrix 3x3 to the uniform buffer.
  73728. * @param name Name of the uniform, as used in the uniform block in the shader.
  73729. */
  73730. addMatrix3x3(name: string): void;
  73731. /**
  73732. * Adds a Matrix 2x2 to the uniform buffer.
  73733. * @param name Name of the uniform, as used in the uniform block in the shader.
  73734. */
  73735. addMatrix2x2(name: string): void;
  73736. /**
  73737. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  73738. */
  73739. create(): void;
  73740. /** @hidden */
  73741. _rebuild(): void;
  73742. /**
  73743. * Updates the WebGL Uniform Buffer on the GPU.
  73744. * If the `dynamic` flag is set to true, no cache comparison is done.
  73745. * Otherwise, the buffer will be updated only if the cache differs.
  73746. */
  73747. update(): void;
  73748. /**
  73749. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  73750. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  73751. * @param data Define the flattened data
  73752. * @param size Define the size of the data.
  73753. */
  73754. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  73755. private _valueCache;
  73756. private _cacheMatrix;
  73757. private _updateMatrix3x3ForUniform;
  73758. private _updateMatrix3x3ForEffect;
  73759. private _updateMatrix2x2ForEffect;
  73760. private _updateMatrix2x2ForUniform;
  73761. private _updateFloatForEffect;
  73762. private _updateFloatForUniform;
  73763. private _updateFloat2ForEffect;
  73764. private _updateFloat2ForUniform;
  73765. private _updateFloat3ForEffect;
  73766. private _updateFloat3ForUniform;
  73767. private _updateFloat4ForEffect;
  73768. private _updateFloat4ForUniform;
  73769. private _updateMatrixForEffect;
  73770. private _updateMatrixForUniform;
  73771. private _updateVector3ForEffect;
  73772. private _updateVector3ForUniform;
  73773. private _updateVector4ForEffect;
  73774. private _updateVector4ForUniform;
  73775. private _updateColor3ForEffect;
  73776. private _updateColor3ForUniform;
  73777. private _updateColor4ForEffect;
  73778. private _updateColor4ForUniform;
  73779. /**
  73780. * Sets a sampler uniform on the effect.
  73781. * @param name Define the name of the sampler.
  73782. * @param texture Define the texture to set in the sampler
  73783. */
  73784. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  73785. /**
  73786. * Directly updates the value of the uniform in the cache AND on the GPU.
  73787. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  73788. * @param data Define the flattened data
  73789. */
  73790. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  73791. /**
  73792. * Binds this uniform buffer to an effect.
  73793. * @param effect Define the effect to bind the buffer to
  73794. * @param name Name of the uniform block in the shader.
  73795. */
  73796. bindToEffect(effect: Effect, name: string): void;
  73797. /**
  73798. * Disposes the uniform buffer.
  73799. */
  73800. dispose(): void;
  73801. }
  73802. }
  73803. declare module BABYLON {
  73804. /**
  73805. * Enum that determines the text-wrapping mode to use.
  73806. */
  73807. export enum InspectableType {
  73808. /**
  73809. * Checkbox for booleans
  73810. */
  73811. Checkbox = 0,
  73812. /**
  73813. * Sliders for numbers
  73814. */
  73815. Slider = 1,
  73816. /**
  73817. * Vector3
  73818. */
  73819. Vector3 = 2,
  73820. /**
  73821. * Quaternions
  73822. */
  73823. Quaternion = 3,
  73824. /**
  73825. * Color3
  73826. */
  73827. Color3 = 4,
  73828. /**
  73829. * String
  73830. */
  73831. String = 5
  73832. }
  73833. /**
  73834. * Interface used to define custom inspectable properties.
  73835. * This interface is used by the inspector to display custom property grids
  73836. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73837. */
  73838. export interface IInspectable {
  73839. /**
  73840. * Gets the label to display
  73841. */
  73842. label: string;
  73843. /**
  73844. * Gets the name of the property to edit
  73845. */
  73846. propertyName: string;
  73847. /**
  73848. * Gets the type of the editor to use
  73849. */
  73850. type: InspectableType;
  73851. /**
  73852. * Gets the minimum value of the property when using in "slider" mode
  73853. */
  73854. min?: number;
  73855. /**
  73856. * Gets the maximum value of the property when using in "slider" mode
  73857. */
  73858. max?: number;
  73859. /**
  73860. * Gets the setp to use when using in "slider" mode
  73861. */
  73862. step?: number;
  73863. }
  73864. }
  73865. declare module BABYLON {
  73866. /**
  73867. * Class used to provide helper for timing
  73868. */
  73869. export class TimingTools {
  73870. /**
  73871. * Polyfill for setImmediate
  73872. * @param action defines the action to execute after the current execution block
  73873. */
  73874. static SetImmediate(action: () => void): void;
  73875. }
  73876. }
  73877. declare module BABYLON {
  73878. /**
  73879. * Class used to enable instatition of objects by class name
  73880. */
  73881. export class InstantiationTools {
  73882. /**
  73883. * Use this object to register external classes like custom textures or material
  73884. * to allow the laoders to instantiate them
  73885. */
  73886. static RegisteredExternalClasses: {
  73887. [key: string]: Object;
  73888. };
  73889. /**
  73890. * Tries to instantiate a new object from a given class name
  73891. * @param className defines the class name to instantiate
  73892. * @returns the new object or null if the system was not able to do the instantiation
  73893. */
  73894. static Instantiate(className: string): any;
  73895. }
  73896. }
  73897. declare module BABYLON {
  73898. /**
  73899. * Define options used to create a depth texture
  73900. */
  73901. export class DepthTextureCreationOptions {
  73902. /** Specifies whether or not a stencil should be allocated in the texture */
  73903. generateStencil?: boolean;
  73904. /** Specifies whether or not bilinear filtering is enable on the texture */
  73905. bilinearFiltering?: boolean;
  73906. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  73907. comparisonFunction?: number;
  73908. /** Specifies if the created texture is a cube texture */
  73909. isCube?: boolean;
  73910. }
  73911. }
  73912. declare module BABYLON {
  73913. interface ThinEngine {
  73914. /**
  73915. * Creates a depth stencil cube texture.
  73916. * This is only available in WebGL 2.
  73917. * @param size The size of face edge in the cube texture.
  73918. * @param options The options defining the cube texture.
  73919. * @returns The cube texture
  73920. */
  73921. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73922. /**
  73923. * Creates a cube texture
  73924. * @param rootUrl defines the url where the files to load is located
  73925. * @param scene defines the current scene
  73926. * @param files defines the list of files to load (1 per face)
  73927. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73928. * @param onLoad defines an optional callback raised when the texture is loaded
  73929. * @param onError defines an optional callback raised if there is an issue to load the texture
  73930. * @param format defines the format of the data
  73931. * @param forcedExtension defines the extension to use to pick the right loader
  73932. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73933. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73934. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73935. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73936. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73937. * @returns the cube texture as an InternalTexture
  73938. */
  73939. 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;
  73940. /**
  73941. * Creates a cube texture
  73942. * @param rootUrl defines the url where the files to load is located
  73943. * @param scene defines the current scene
  73944. * @param files defines the list of files to load (1 per face)
  73945. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73946. * @param onLoad defines an optional callback raised when the texture is loaded
  73947. * @param onError defines an optional callback raised if there is an issue to load the texture
  73948. * @param format defines the format of the data
  73949. * @param forcedExtension defines the extension to use to pick the right loader
  73950. * @returns the cube texture as an InternalTexture
  73951. */
  73952. 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;
  73953. /**
  73954. * Creates a cube texture
  73955. * @param rootUrl defines the url where the files to load is located
  73956. * @param scene defines the current scene
  73957. * @param files defines the list of files to load (1 per face)
  73958. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73959. * @param onLoad defines an optional callback raised when the texture is loaded
  73960. * @param onError defines an optional callback raised if there is an issue to load the texture
  73961. * @param format defines the format of the data
  73962. * @param forcedExtension defines the extension to use to pick the right loader
  73963. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73964. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73965. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73966. * @returns the cube texture as an InternalTexture
  73967. */
  73968. 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;
  73969. /** @hidden */
  73970. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73971. /** @hidden */
  73972. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73973. /** @hidden */
  73974. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73975. /** @hidden */
  73976. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73977. }
  73978. }
  73979. declare module BABYLON {
  73980. /**
  73981. * Class for creating a cube texture
  73982. */
  73983. export class CubeTexture extends BaseTexture {
  73984. private _delayedOnLoad;
  73985. /**
  73986. * The url of the texture
  73987. */
  73988. url: string;
  73989. /**
  73990. * Gets or sets the center of the bounding box associated with the cube texture.
  73991. * It must define where the camera used to render the texture was set
  73992. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73993. */
  73994. boundingBoxPosition: Vector3;
  73995. private _boundingBoxSize;
  73996. /**
  73997. * Gets or sets the size of the bounding box associated with the cube texture
  73998. * When defined, the cubemap will switch to local mode
  73999. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74000. * @example https://www.babylonjs-playground.com/#RNASML
  74001. */
  74002. /**
  74003. * Returns the bounding box size
  74004. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74005. */
  74006. boundingBoxSize: Vector3;
  74007. protected _rotationY: number;
  74008. /**
  74009. * Sets texture matrix rotation angle around Y axis in radians.
  74010. */
  74011. /**
  74012. * Gets texture matrix rotation angle around Y axis radians.
  74013. */
  74014. rotationY: number;
  74015. /**
  74016. * Are mip maps generated for this texture or not.
  74017. */
  74018. readonly noMipmap: boolean;
  74019. private _noMipmap;
  74020. private _files;
  74021. private _extensions;
  74022. private _textureMatrix;
  74023. private _format;
  74024. private _createPolynomials;
  74025. /** @hidden */
  74026. _prefiltered: boolean;
  74027. /**
  74028. * Creates a cube texture from an array of image urls
  74029. * @param files defines an array of image urls
  74030. * @param scene defines the hosting scene
  74031. * @param noMipmap specifies if mip maps are not used
  74032. * @returns a cube texture
  74033. */
  74034. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74035. /**
  74036. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74037. * @param url defines the url of the prefiltered texture
  74038. * @param scene defines the scene the texture is attached to
  74039. * @param forcedExtension defines the extension of the file if different from the url
  74040. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74041. * @return the prefiltered texture
  74042. */
  74043. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74044. /**
  74045. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74046. * as prefiltered data.
  74047. * @param rootUrl defines the url of the texture or the root name of the six images
  74048. * @param scene defines the scene the texture is attached to
  74049. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74050. * @param noMipmap defines if mipmaps should be created or not
  74051. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74052. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74053. * @param onError defines a callback triggered in case of error during load
  74054. * @param format defines the internal format to use for the texture once loaded
  74055. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74056. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74057. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74058. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74059. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74060. * @return the cube texture
  74061. */
  74062. 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);
  74063. /**
  74064. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74065. */
  74066. readonly isPrefiltered: boolean;
  74067. /**
  74068. * Get the current class name of the texture useful for serialization or dynamic coding.
  74069. * @returns "CubeTexture"
  74070. */
  74071. getClassName(): string;
  74072. /**
  74073. * Update the url (and optional buffer) of this texture if url was null during construction.
  74074. * @param url the url of the texture
  74075. * @param forcedExtension defines the extension to use
  74076. * @param onLoad callback called when the texture is loaded (defaults to null)
  74077. */
  74078. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74079. /**
  74080. * Delays loading of the cube texture
  74081. * @param forcedExtension defines the extension to use
  74082. */
  74083. delayLoad(forcedExtension?: string): void;
  74084. /**
  74085. * Returns the reflection texture matrix
  74086. * @returns the reflection texture matrix
  74087. */
  74088. getReflectionTextureMatrix(): Matrix;
  74089. /**
  74090. * Sets the reflection texture matrix
  74091. * @param value Reflection texture matrix
  74092. */
  74093. setReflectionTextureMatrix(value: Matrix): void;
  74094. /**
  74095. * Parses text to create a cube texture
  74096. * @param parsedTexture define the serialized text to read from
  74097. * @param scene defines the hosting scene
  74098. * @param rootUrl defines the root url of the cube texture
  74099. * @returns a cube texture
  74100. */
  74101. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74102. /**
  74103. * Makes a clone, or deep copy, of the cube texture
  74104. * @returns a new cube texture
  74105. */
  74106. clone(): CubeTexture;
  74107. }
  74108. }
  74109. declare module BABYLON {
  74110. /**
  74111. * Manages the defines for the Material
  74112. */
  74113. export class MaterialDefines {
  74114. /** @hidden */
  74115. protected _keys: string[];
  74116. private _isDirty;
  74117. /** @hidden */
  74118. _renderId: number;
  74119. /** @hidden */
  74120. _areLightsDirty: boolean;
  74121. /** @hidden */
  74122. _areLightsDisposed: boolean;
  74123. /** @hidden */
  74124. _areAttributesDirty: boolean;
  74125. /** @hidden */
  74126. _areTexturesDirty: boolean;
  74127. /** @hidden */
  74128. _areFresnelDirty: boolean;
  74129. /** @hidden */
  74130. _areMiscDirty: boolean;
  74131. /** @hidden */
  74132. _areImageProcessingDirty: boolean;
  74133. /** @hidden */
  74134. _normals: boolean;
  74135. /** @hidden */
  74136. _uvs: boolean;
  74137. /** @hidden */
  74138. _needNormals: boolean;
  74139. /** @hidden */
  74140. _needUVs: boolean;
  74141. [id: string]: any;
  74142. /**
  74143. * Specifies if the material needs to be re-calculated
  74144. */
  74145. readonly isDirty: boolean;
  74146. /**
  74147. * Marks the material to indicate that it has been re-calculated
  74148. */
  74149. markAsProcessed(): void;
  74150. /**
  74151. * Marks the material to indicate that it needs to be re-calculated
  74152. */
  74153. markAsUnprocessed(): void;
  74154. /**
  74155. * Marks the material to indicate all of its defines need to be re-calculated
  74156. */
  74157. markAllAsDirty(): void;
  74158. /**
  74159. * Marks the material to indicate that image processing needs to be re-calculated
  74160. */
  74161. markAsImageProcessingDirty(): void;
  74162. /**
  74163. * Marks the material to indicate the lights need to be re-calculated
  74164. * @param disposed Defines whether the light is dirty due to dispose or not
  74165. */
  74166. markAsLightDirty(disposed?: boolean): void;
  74167. /**
  74168. * Marks the attribute state as changed
  74169. */
  74170. markAsAttributesDirty(): void;
  74171. /**
  74172. * Marks the texture state as changed
  74173. */
  74174. markAsTexturesDirty(): void;
  74175. /**
  74176. * Marks the fresnel state as changed
  74177. */
  74178. markAsFresnelDirty(): void;
  74179. /**
  74180. * Marks the misc state as changed
  74181. */
  74182. markAsMiscDirty(): void;
  74183. /**
  74184. * Rebuilds the material defines
  74185. */
  74186. rebuild(): void;
  74187. /**
  74188. * Specifies if two material defines are equal
  74189. * @param other - A material define instance to compare to
  74190. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74191. */
  74192. isEqual(other: MaterialDefines): boolean;
  74193. /**
  74194. * Clones this instance's defines to another instance
  74195. * @param other - material defines to clone values to
  74196. */
  74197. cloneTo(other: MaterialDefines): void;
  74198. /**
  74199. * Resets the material define values
  74200. */
  74201. reset(): void;
  74202. /**
  74203. * Converts the material define values to a string
  74204. * @returns - String of material define information
  74205. */
  74206. toString(): string;
  74207. }
  74208. }
  74209. declare module BABYLON {
  74210. /**
  74211. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74212. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74213. * 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;
  74214. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74215. */
  74216. export class ColorCurves {
  74217. private _dirty;
  74218. private _tempColor;
  74219. private _globalCurve;
  74220. private _highlightsCurve;
  74221. private _midtonesCurve;
  74222. private _shadowsCurve;
  74223. private _positiveCurve;
  74224. private _negativeCurve;
  74225. private _globalHue;
  74226. private _globalDensity;
  74227. private _globalSaturation;
  74228. private _globalExposure;
  74229. /**
  74230. * Gets the global Hue value.
  74231. * 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).
  74232. */
  74233. /**
  74234. * Sets the global Hue value.
  74235. * 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).
  74236. */
  74237. globalHue: number;
  74238. /**
  74239. * Gets the global Density value.
  74240. * 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.
  74241. * Values less than zero provide a filter of opposite hue.
  74242. */
  74243. /**
  74244. * Sets the global Density value.
  74245. * 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.
  74246. * Values less than zero provide a filter of opposite hue.
  74247. */
  74248. globalDensity: number;
  74249. /**
  74250. * Gets the global Saturation value.
  74251. * 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.
  74252. */
  74253. /**
  74254. * Sets the global Saturation value.
  74255. * 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.
  74256. */
  74257. globalSaturation: number;
  74258. /**
  74259. * Gets the global Exposure value.
  74260. * 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.
  74261. */
  74262. /**
  74263. * Sets the global Exposure value.
  74264. * 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.
  74265. */
  74266. globalExposure: number;
  74267. private _highlightsHue;
  74268. private _highlightsDensity;
  74269. private _highlightsSaturation;
  74270. private _highlightsExposure;
  74271. /**
  74272. * Gets the highlights Hue value.
  74273. * 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).
  74274. */
  74275. /**
  74276. * Sets the highlights Hue value.
  74277. * 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).
  74278. */
  74279. highlightsHue: number;
  74280. /**
  74281. * Gets the highlights Density value.
  74282. * 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.
  74283. * Values less than zero provide a filter of opposite hue.
  74284. */
  74285. /**
  74286. * Sets the highlights Density value.
  74287. * 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.
  74288. * Values less than zero provide a filter of opposite hue.
  74289. */
  74290. highlightsDensity: number;
  74291. /**
  74292. * Gets the highlights Saturation value.
  74293. * 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.
  74294. */
  74295. /**
  74296. * Sets the highlights Saturation value.
  74297. * 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.
  74298. */
  74299. highlightsSaturation: number;
  74300. /**
  74301. * Gets the highlights Exposure value.
  74302. * 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.
  74303. */
  74304. /**
  74305. * Sets the highlights Exposure value.
  74306. * 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.
  74307. */
  74308. highlightsExposure: number;
  74309. private _midtonesHue;
  74310. private _midtonesDensity;
  74311. private _midtonesSaturation;
  74312. private _midtonesExposure;
  74313. /**
  74314. * Gets the midtones Hue value.
  74315. * 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).
  74316. */
  74317. /**
  74318. * Sets the midtones Hue value.
  74319. * 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).
  74320. */
  74321. midtonesHue: number;
  74322. /**
  74323. * Gets the midtones Density value.
  74324. * 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.
  74325. * Values less than zero provide a filter of opposite hue.
  74326. */
  74327. /**
  74328. * Sets the midtones Density value.
  74329. * 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.
  74330. * Values less than zero provide a filter of opposite hue.
  74331. */
  74332. midtonesDensity: number;
  74333. /**
  74334. * Gets the midtones Saturation value.
  74335. * 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.
  74336. */
  74337. /**
  74338. * Sets the midtones Saturation value.
  74339. * 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.
  74340. */
  74341. midtonesSaturation: number;
  74342. /**
  74343. * Gets the midtones Exposure value.
  74344. * 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.
  74345. */
  74346. /**
  74347. * Sets the midtones Exposure value.
  74348. * 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.
  74349. */
  74350. midtonesExposure: number;
  74351. private _shadowsHue;
  74352. private _shadowsDensity;
  74353. private _shadowsSaturation;
  74354. private _shadowsExposure;
  74355. /**
  74356. * Gets the shadows Hue value.
  74357. * 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).
  74358. */
  74359. /**
  74360. * Sets the shadows Hue value.
  74361. * 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).
  74362. */
  74363. shadowsHue: number;
  74364. /**
  74365. * Gets the shadows Density value.
  74366. * 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.
  74367. * Values less than zero provide a filter of opposite hue.
  74368. */
  74369. /**
  74370. * Sets the shadows Density value.
  74371. * 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.
  74372. * Values less than zero provide a filter of opposite hue.
  74373. */
  74374. shadowsDensity: number;
  74375. /**
  74376. * Gets the shadows Saturation value.
  74377. * 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.
  74378. */
  74379. /**
  74380. * Sets the shadows Saturation value.
  74381. * 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.
  74382. */
  74383. shadowsSaturation: number;
  74384. /**
  74385. * Gets the shadows Exposure value.
  74386. * 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.
  74387. */
  74388. /**
  74389. * Sets the shadows Exposure value.
  74390. * 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.
  74391. */
  74392. shadowsExposure: number;
  74393. /**
  74394. * Returns the class name
  74395. * @returns The class name
  74396. */
  74397. getClassName(): string;
  74398. /**
  74399. * Binds the color curves to the shader.
  74400. * @param colorCurves The color curve to bind
  74401. * @param effect The effect to bind to
  74402. * @param positiveUniform The positive uniform shader parameter
  74403. * @param neutralUniform The neutral uniform shader parameter
  74404. * @param negativeUniform The negative uniform shader parameter
  74405. */
  74406. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74407. /**
  74408. * Prepare the list of uniforms associated with the ColorCurves effects.
  74409. * @param uniformsList The list of uniforms used in the effect
  74410. */
  74411. static PrepareUniforms(uniformsList: string[]): void;
  74412. /**
  74413. * Returns color grading data based on a hue, density, saturation and exposure value.
  74414. * @param filterHue The hue of the color filter.
  74415. * @param filterDensity The density of the color filter.
  74416. * @param saturation The saturation.
  74417. * @param exposure The exposure.
  74418. * @param result The result data container.
  74419. */
  74420. private getColorGradingDataToRef;
  74421. /**
  74422. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74423. * @param value The input slider value in range [-100,100].
  74424. * @returns Adjusted value.
  74425. */
  74426. private static applyColorGradingSliderNonlinear;
  74427. /**
  74428. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74429. * @param hue The hue (H) input.
  74430. * @param saturation The saturation (S) input.
  74431. * @param brightness The brightness (B) input.
  74432. * @result An RGBA color represented as Vector4.
  74433. */
  74434. private static fromHSBToRef;
  74435. /**
  74436. * Returns a value clamped between min and max
  74437. * @param value The value to clamp
  74438. * @param min The minimum of value
  74439. * @param max The maximum of value
  74440. * @returns The clamped value.
  74441. */
  74442. private static clamp;
  74443. /**
  74444. * Clones the current color curve instance.
  74445. * @return The cloned curves
  74446. */
  74447. clone(): ColorCurves;
  74448. /**
  74449. * Serializes the current color curve instance to a json representation.
  74450. * @return a JSON representation
  74451. */
  74452. serialize(): any;
  74453. /**
  74454. * Parses the color curve from a json representation.
  74455. * @param source the JSON source to parse
  74456. * @return The parsed curves
  74457. */
  74458. static Parse(source: any): ColorCurves;
  74459. }
  74460. }
  74461. declare module BABYLON {
  74462. /**
  74463. * Interface to follow in your material defines to integrate easily the
  74464. * Image proccessing functions.
  74465. * @hidden
  74466. */
  74467. export interface IImageProcessingConfigurationDefines {
  74468. IMAGEPROCESSING: boolean;
  74469. VIGNETTE: boolean;
  74470. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74471. VIGNETTEBLENDMODEOPAQUE: boolean;
  74472. TONEMAPPING: boolean;
  74473. TONEMAPPING_ACES: boolean;
  74474. CONTRAST: boolean;
  74475. EXPOSURE: boolean;
  74476. COLORCURVES: boolean;
  74477. COLORGRADING: boolean;
  74478. COLORGRADING3D: boolean;
  74479. SAMPLER3DGREENDEPTH: boolean;
  74480. SAMPLER3DBGRMAP: boolean;
  74481. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74482. }
  74483. /**
  74484. * @hidden
  74485. */
  74486. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74487. IMAGEPROCESSING: boolean;
  74488. VIGNETTE: boolean;
  74489. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74490. VIGNETTEBLENDMODEOPAQUE: boolean;
  74491. TONEMAPPING: boolean;
  74492. TONEMAPPING_ACES: boolean;
  74493. CONTRAST: boolean;
  74494. COLORCURVES: boolean;
  74495. COLORGRADING: boolean;
  74496. COLORGRADING3D: boolean;
  74497. SAMPLER3DGREENDEPTH: boolean;
  74498. SAMPLER3DBGRMAP: boolean;
  74499. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74500. EXPOSURE: boolean;
  74501. constructor();
  74502. }
  74503. /**
  74504. * This groups together the common properties used for image processing either in direct forward pass
  74505. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74506. * or not.
  74507. */
  74508. export class ImageProcessingConfiguration {
  74509. /**
  74510. * Default tone mapping applied in BabylonJS.
  74511. */
  74512. static readonly TONEMAPPING_STANDARD: number;
  74513. /**
  74514. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74515. * to other engines rendering to increase portability.
  74516. */
  74517. static readonly TONEMAPPING_ACES: number;
  74518. /**
  74519. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74520. */
  74521. colorCurves: Nullable<ColorCurves>;
  74522. private _colorCurvesEnabled;
  74523. /**
  74524. * Gets wether the color curves effect is enabled.
  74525. */
  74526. /**
  74527. * Sets wether the color curves effect is enabled.
  74528. */
  74529. colorCurvesEnabled: boolean;
  74530. private _colorGradingTexture;
  74531. /**
  74532. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74533. */
  74534. /**
  74535. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74536. */
  74537. colorGradingTexture: Nullable<BaseTexture>;
  74538. private _colorGradingEnabled;
  74539. /**
  74540. * Gets wether the color grading effect is enabled.
  74541. */
  74542. /**
  74543. * Sets wether the color grading effect is enabled.
  74544. */
  74545. colorGradingEnabled: boolean;
  74546. private _colorGradingWithGreenDepth;
  74547. /**
  74548. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74549. */
  74550. /**
  74551. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74552. */
  74553. colorGradingWithGreenDepth: boolean;
  74554. private _colorGradingBGR;
  74555. /**
  74556. * Gets wether the color grading texture contains BGR values.
  74557. */
  74558. /**
  74559. * Sets wether the color grading texture contains BGR values.
  74560. */
  74561. colorGradingBGR: boolean;
  74562. /** @hidden */
  74563. _exposure: number;
  74564. /**
  74565. * Gets the Exposure used in the effect.
  74566. */
  74567. /**
  74568. * Sets the Exposure used in the effect.
  74569. */
  74570. exposure: number;
  74571. private _toneMappingEnabled;
  74572. /**
  74573. * Gets wether the tone mapping effect is enabled.
  74574. */
  74575. /**
  74576. * Sets wether the tone mapping effect is enabled.
  74577. */
  74578. toneMappingEnabled: boolean;
  74579. private _toneMappingType;
  74580. /**
  74581. * Gets the type of tone mapping effect.
  74582. */
  74583. /**
  74584. * Sets the type of tone mapping effect used in BabylonJS.
  74585. */
  74586. toneMappingType: number;
  74587. protected _contrast: number;
  74588. /**
  74589. * Gets the contrast used in the effect.
  74590. */
  74591. /**
  74592. * Sets the contrast used in the effect.
  74593. */
  74594. contrast: number;
  74595. /**
  74596. * Vignette stretch size.
  74597. */
  74598. vignetteStretch: number;
  74599. /**
  74600. * Vignette centre X Offset.
  74601. */
  74602. vignetteCentreX: number;
  74603. /**
  74604. * Vignette centre Y Offset.
  74605. */
  74606. vignetteCentreY: number;
  74607. /**
  74608. * Vignette weight or intensity of the vignette effect.
  74609. */
  74610. vignetteWeight: number;
  74611. /**
  74612. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74613. * if vignetteEnabled is set to true.
  74614. */
  74615. vignetteColor: Color4;
  74616. /**
  74617. * Camera field of view used by the Vignette effect.
  74618. */
  74619. vignetteCameraFov: number;
  74620. private _vignetteBlendMode;
  74621. /**
  74622. * Gets the vignette blend mode allowing different kind of effect.
  74623. */
  74624. /**
  74625. * Sets the vignette blend mode allowing different kind of effect.
  74626. */
  74627. vignetteBlendMode: number;
  74628. private _vignetteEnabled;
  74629. /**
  74630. * Gets wether the vignette effect is enabled.
  74631. */
  74632. /**
  74633. * Sets wether the vignette effect is enabled.
  74634. */
  74635. vignetteEnabled: boolean;
  74636. private _applyByPostProcess;
  74637. /**
  74638. * Gets wether the image processing is applied through a post process or not.
  74639. */
  74640. /**
  74641. * Sets wether the image processing is applied through a post process or not.
  74642. */
  74643. applyByPostProcess: boolean;
  74644. private _isEnabled;
  74645. /**
  74646. * Gets wether the image processing is enabled or not.
  74647. */
  74648. /**
  74649. * Sets wether the image processing is enabled or not.
  74650. */
  74651. isEnabled: boolean;
  74652. /**
  74653. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74654. */
  74655. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74656. /**
  74657. * Method called each time the image processing information changes requires to recompile the effect.
  74658. */
  74659. protected _updateParameters(): void;
  74660. /**
  74661. * Gets the current class name.
  74662. * @return "ImageProcessingConfiguration"
  74663. */
  74664. getClassName(): string;
  74665. /**
  74666. * Prepare the list of uniforms associated with the Image Processing effects.
  74667. * @param uniforms The list of uniforms used in the effect
  74668. * @param defines the list of defines currently in use
  74669. */
  74670. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74671. /**
  74672. * Prepare the list of samplers associated with the Image Processing effects.
  74673. * @param samplersList The list of uniforms used in the effect
  74674. * @param defines the list of defines currently in use
  74675. */
  74676. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74677. /**
  74678. * Prepare the list of defines associated to the shader.
  74679. * @param defines the list of defines to complete
  74680. * @param forPostProcess Define if we are currently in post process mode or not
  74681. */
  74682. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74683. /**
  74684. * Returns true if all the image processing information are ready.
  74685. * @returns True if ready, otherwise, false
  74686. */
  74687. isReady(): boolean;
  74688. /**
  74689. * Binds the image processing to the shader.
  74690. * @param effect The effect to bind to
  74691. * @param aspectRatio Define the current aspect ratio of the effect
  74692. */
  74693. bind(effect: Effect, aspectRatio?: number): void;
  74694. /**
  74695. * Clones the current image processing instance.
  74696. * @return The cloned image processing
  74697. */
  74698. clone(): ImageProcessingConfiguration;
  74699. /**
  74700. * Serializes the current image processing instance to a json representation.
  74701. * @return a JSON representation
  74702. */
  74703. serialize(): any;
  74704. /**
  74705. * Parses the image processing from a json representation.
  74706. * @param source the JSON source to parse
  74707. * @return The parsed image processing
  74708. */
  74709. static Parse(source: any): ImageProcessingConfiguration;
  74710. private static _VIGNETTEMODE_MULTIPLY;
  74711. private static _VIGNETTEMODE_OPAQUE;
  74712. /**
  74713. * Used to apply the vignette as a mix with the pixel color.
  74714. */
  74715. static readonly VIGNETTEMODE_MULTIPLY: number;
  74716. /**
  74717. * Used to apply the vignette as a replacement of the pixel color.
  74718. */
  74719. static readonly VIGNETTEMODE_OPAQUE: number;
  74720. }
  74721. }
  74722. declare module BABYLON {
  74723. /** @hidden */
  74724. export var postprocessVertexShader: {
  74725. name: string;
  74726. shader: string;
  74727. };
  74728. }
  74729. declare module BABYLON {
  74730. /** Defines supported spaces */
  74731. export enum Space {
  74732. /** Local (object) space */
  74733. LOCAL = 0,
  74734. /** World space */
  74735. WORLD = 1,
  74736. /** Bone space */
  74737. BONE = 2
  74738. }
  74739. /** Defines the 3 main axes */
  74740. export class Axis {
  74741. /** X axis */
  74742. static X: Vector3;
  74743. /** Y axis */
  74744. static Y: Vector3;
  74745. /** Z axis */
  74746. static Z: Vector3;
  74747. }
  74748. }
  74749. declare module BABYLON {
  74750. /**
  74751. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74752. * This is the base of the follow, arc rotate cameras and Free camera
  74753. * @see http://doc.babylonjs.com/features/cameras
  74754. */
  74755. export class TargetCamera extends Camera {
  74756. private static _RigCamTransformMatrix;
  74757. private static _TargetTransformMatrix;
  74758. private static _TargetFocalPoint;
  74759. /**
  74760. * Define the current direction the camera is moving to
  74761. */
  74762. cameraDirection: Vector3;
  74763. /**
  74764. * Define the current rotation the camera is rotating to
  74765. */
  74766. cameraRotation: Vector2;
  74767. /**
  74768. * When set, the up vector of the camera will be updated by the rotation of the camera
  74769. */
  74770. updateUpVectorFromRotation: boolean;
  74771. private _tmpQuaternion;
  74772. /**
  74773. * Define the current rotation of the camera
  74774. */
  74775. rotation: Vector3;
  74776. /**
  74777. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74778. */
  74779. rotationQuaternion: Quaternion;
  74780. /**
  74781. * Define the current speed of the camera
  74782. */
  74783. speed: number;
  74784. /**
  74785. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74786. * around all axis.
  74787. */
  74788. noRotationConstraint: boolean;
  74789. /**
  74790. * Define the current target of the camera as an object or a position.
  74791. */
  74792. lockedTarget: any;
  74793. /** @hidden */
  74794. _currentTarget: Vector3;
  74795. /** @hidden */
  74796. _initialFocalDistance: number;
  74797. /** @hidden */
  74798. _viewMatrix: Matrix;
  74799. /** @hidden */
  74800. _camMatrix: Matrix;
  74801. /** @hidden */
  74802. _cameraTransformMatrix: Matrix;
  74803. /** @hidden */
  74804. _cameraRotationMatrix: Matrix;
  74805. /** @hidden */
  74806. _referencePoint: Vector3;
  74807. /** @hidden */
  74808. _transformedReferencePoint: Vector3;
  74809. protected _globalCurrentTarget: Vector3;
  74810. protected _globalCurrentUpVector: Vector3;
  74811. /** @hidden */
  74812. _reset: () => void;
  74813. private _defaultUp;
  74814. /**
  74815. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74816. * This is the base of the follow, arc rotate cameras and Free camera
  74817. * @see http://doc.babylonjs.com/features/cameras
  74818. * @param name Defines the name of the camera in the scene
  74819. * @param position Defines the start position of the camera in the scene
  74820. * @param scene Defines the scene the camera belongs to
  74821. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74822. */
  74823. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74824. /**
  74825. * Gets the position in front of the camera at a given distance.
  74826. * @param distance The distance from the camera we want the position to be
  74827. * @returns the position
  74828. */
  74829. getFrontPosition(distance: number): Vector3;
  74830. /** @hidden */
  74831. _getLockedTargetPosition(): Nullable<Vector3>;
  74832. private _storedPosition;
  74833. private _storedRotation;
  74834. private _storedRotationQuaternion;
  74835. /**
  74836. * Store current camera state of the camera (fov, position, rotation, etc..)
  74837. * @returns the camera
  74838. */
  74839. storeState(): Camera;
  74840. /**
  74841. * Restored camera state. You must call storeState() first
  74842. * @returns whether it was successful or not
  74843. * @hidden
  74844. */
  74845. _restoreStateValues(): boolean;
  74846. /** @hidden */
  74847. _initCache(): void;
  74848. /** @hidden */
  74849. _updateCache(ignoreParentClass?: boolean): void;
  74850. /** @hidden */
  74851. _isSynchronizedViewMatrix(): boolean;
  74852. /** @hidden */
  74853. _computeLocalCameraSpeed(): number;
  74854. /**
  74855. * Defines the target the camera should look at.
  74856. * @param target Defines the new target as a Vector or a mesh
  74857. */
  74858. setTarget(target: Vector3): void;
  74859. /**
  74860. * Return the current target position of the camera. This value is expressed in local space.
  74861. * @returns the target position
  74862. */
  74863. getTarget(): Vector3;
  74864. /** @hidden */
  74865. _decideIfNeedsToMove(): boolean;
  74866. /** @hidden */
  74867. _updatePosition(): void;
  74868. /** @hidden */
  74869. _checkInputs(): void;
  74870. protected _updateCameraRotationMatrix(): void;
  74871. /**
  74872. * 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)
  74873. * @returns the current camera
  74874. */
  74875. private _rotateUpVectorWithCameraRotationMatrix;
  74876. private _cachedRotationZ;
  74877. private _cachedQuaternionRotationZ;
  74878. /** @hidden */
  74879. _getViewMatrix(): Matrix;
  74880. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74881. /**
  74882. * @hidden
  74883. */
  74884. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74885. /**
  74886. * @hidden
  74887. */
  74888. _updateRigCameras(): void;
  74889. private _getRigCamPositionAndTarget;
  74890. /**
  74891. * Gets the current object class name.
  74892. * @return the class name
  74893. */
  74894. getClassName(): string;
  74895. }
  74896. }
  74897. declare module BABYLON {
  74898. /**
  74899. * Gather the list of keyboard event types as constants.
  74900. */
  74901. export class KeyboardEventTypes {
  74902. /**
  74903. * The keydown event is fired when a key becomes active (pressed).
  74904. */
  74905. static readonly KEYDOWN: number;
  74906. /**
  74907. * The keyup event is fired when a key has been released.
  74908. */
  74909. static readonly KEYUP: number;
  74910. }
  74911. /**
  74912. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74913. */
  74914. export class KeyboardInfo {
  74915. /**
  74916. * Defines the type of event (KeyboardEventTypes)
  74917. */
  74918. type: number;
  74919. /**
  74920. * Defines the related dom event
  74921. */
  74922. event: KeyboardEvent;
  74923. /**
  74924. * Instantiates a new keyboard info.
  74925. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74926. * @param type Defines the type of event (KeyboardEventTypes)
  74927. * @param event Defines the related dom event
  74928. */
  74929. constructor(
  74930. /**
  74931. * Defines the type of event (KeyboardEventTypes)
  74932. */
  74933. type: number,
  74934. /**
  74935. * Defines the related dom event
  74936. */
  74937. event: KeyboardEvent);
  74938. }
  74939. /**
  74940. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74941. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74942. */
  74943. export class KeyboardInfoPre extends KeyboardInfo {
  74944. /**
  74945. * Defines the type of event (KeyboardEventTypes)
  74946. */
  74947. type: number;
  74948. /**
  74949. * Defines the related dom event
  74950. */
  74951. event: KeyboardEvent;
  74952. /**
  74953. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74954. */
  74955. skipOnPointerObservable: boolean;
  74956. /**
  74957. * Instantiates a new keyboard pre info.
  74958. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74959. * @param type Defines the type of event (KeyboardEventTypes)
  74960. * @param event Defines the related dom event
  74961. */
  74962. constructor(
  74963. /**
  74964. * Defines the type of event (KeyboardEventTypes)
  74965. */
  74966. type: number,
  74967. /**
  74968. * Defines the related dom event
  74969. */
  74970. event: KeyboardEvent);
  74971. }
  74972. }
  74973. declare module BABYLON {
  74974. /**
  74975. * Manage the keyboard inputs to control the movement of a free camera.
  74976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74977. */
  74978. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74979. /**
  74980. * Defines the camera the input is attached to.
  74981. */
  74982. camera: FreeCamera;
  74983. /**
  74984. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74985. */
  74986. keysUp: number[];
  74987. /**
  74988. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74989. */
  74990. keysDown: number[];
  74991. /**
  74992. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74993. */
  74994. keysLeft: number[];
  74995. /**
  74996. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74997. */
  74998. keysRight: number[];
  74999. private _keys;
  75000. private _onCanvasBlurObserver;
  75001. private _onKeyboardObserver;
  75002. private _engine;
  75003. private _scene;
  75004. /**
  75005. * Attach the input controls to a specific dom element to get the input from.
  75006. * @param element Defines the element the controls should be listened from
  75007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75008. */
  75009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75010. /**
  75011. * Detach the current controls from the specified dom element.
  75012. * @param element Defines the element to stop listening the inputs from
  75013. */
  75014. detachControl(element: Nullable<HTMLElement>): void;
  75015. /**
  75016. * Update the current camera state depending on the inputs that have been used this frame.
  75017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75018. */
  75019. checkInputs(): void;
  75020. /**
  75021. * Gets the class name of the current intput.
  75022. * @returns the class name
  75023. */
  75024. getClassName(): string;
  75025. /** @hidden */
  75026. _onLostFocus(): void;
  75027. /**
  75028. * Get the friendly name associated with the input class.
  75029. * @returns the input friendly name
  75030. */
  75031. getSimpleName(): string;
  75032. }
  75033. }
  75034. declare module BABYLON {
  75035. /**
  75036. * Interface describing all the common properties and methods a shadow light needs to implement.
  75037. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75038. * as well as binding the different shadow properties to the effects.
  75039. */
  75040. export interface IShadowLight extends Light {
  75041. /**
  75042. * The light id in the scene (used in scene.findLighById for instance)
  75043. */
  75044. id: string;
  75045. /**
  75046. * The position the shdow will be casted from.
  75047. */
  75048. position: Vector3;
  75049. /**
  75050. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75051. */
  75052. direction: Vector3;
  75053. /**
  75054. * The transformed position. Position of the light in world space taking parenting in account.
  75055. */
  75056. transformedPosition: Vector3;
  75057. /**
  75058. * The transformed direction. Direction of the light in world space taking parenting in account.
  75059. */
  75060. transformedDirection: Vector3;
  75061. /**
  75062. * The friendly name of the light in the scene.
  75063. */
  75064. name: string;
  75065. /**
  75066. * Defines the shadow projection clipping minimum z value.
  75067. */
  75068. shadowMinZ: number;
  75069. /**
  75070. * Defines the shadow projection clipping maximum z value.
  75071. */
  75072. shadowMaxZ: number;
  75073. /**
  75074. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75075. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75076. */
  75077. computeTransformedInformation(): boolean;
  75078. /**
  75079. * Gets the scene the light belongs to.
  75080. * @returns The scene
  75081. */
  75082. getScene(): Scene;
  75083. /**
  75084. * Callback defining a custom Projection Matrix Builder.
  75085. * This can be used to override the default projection matrix computation.
  75086. */
  75087. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75088. /**
  75089. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75090. * @param matrix The materix to updated with the projection information
  75091. * @param viewMatrix The transform matrix of the light
  75092. * @param renderList The list of mesh to render in the map
  75093. * @returns The current light
  75094. */
  75095. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75096. /**
  75097. * Gets the current depth scale used in ESM.
  75098. * @returns The scale
  75099. */
  75100. getDepthScale(): number;
  75101. /**
  75102. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75103. * @returns true if a cube texture needs to be use
  75104. */
  75105. needCube(): boolean;
  75106. /**
  75107. * Detects if the projection matrix requires to be recomputed this frame.
  75108. * @returns true if it requires to be recomputed otherwise, false.
  75109. */
  75110. needProjectionMatrixCompute(): boolean;
  75111. /**
  75112. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75113. */
  75114. forceProjectionMatrixCompute(): void;
  75115. /**
  75116. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75117. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75118. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75119. */
  75120. getShadowDirection(faceIndex?: number): Vector3;
  75121. /**
  75122. * Gets the minZ used for shadow according to both the scene and the light.
  75123. * @param activeCamera The camera we are returning the min for
  75124. * @returns the depth min z
  75125. */
  75126. getDepthMinZ(activeCamera: Camera): number;
  75127. /**
  75128. * Gets the maxZ used for shadow according to both the scene and the light.
  75129. * @param activeCamera The camera we are returning the max for
  75130. * @returns the depth max z
  75131. */
  75132. getDepthMaxZ(activeCamera: Camera): number;
  75133. }
  75134. /**
  75135. * Base implementation IShadowLight
  75136. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75137. */
  75138. export abstract class ShadowLight extends Light implements IShadowLight {
  75139. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75140. protected _position: Vector3;
  75141. protected _setPosition(value: Vector3): void;
  75142. /**
  75143. * Sets the position the shadow will be casted from. Also use as the light position for both
  75144. * point and spot lights.
  75145. */
  75146. /**
  75147. * Sets the position the shadow will be casted from. Also use as the light position for both
  75148. * point and spot lights.
  75149. */
  75150. position: Vector3;
  75151. protected _direction: Vector3;
  75152. protected _setDirection(value: Vector3): void;
  75153. /**
  75154. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75155. * Also use as the light direction on spot and directional lights.
  75156. */
  75157. /**
  75158. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75159. * Also use as the light direction on spot and directional lights.
  75160. */
  75161. direction: Vector3;
  75162. private _shadowMinZ;
  75163. /**
  75164. * Gets the shadow projection clipping minimum z value.
  75165. */
  75166. /**
  75167. * Sets the shadow projection clipping minimum z value.
  75168. */
  75169. shadowMinZ: number;
  75170. private _shadowMaxZ;
  75171. /**
  75172. * Sets the shadow projection clipping maximum z value.
  75173. */
  75174. /**
  75175. * Gets the shadow projection clipping maximum z value.
  75176. */
  75177. shadowMaxZ: number;
  75178. /**
  75179. * Callback defining a custom Projection Matrix Builder.
  75180. * This can be used to override the default projection matrix computation.
  75181. */
  75182. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75183. /**
  75184. * The transformed position. Position of the light in world space taking parenting in account.
  75185. */
  75186. transformedPosition: Vector3;
  75187. /**
  75188. * The transformed direction. Direction of the light in world space taking parenting in account.
  75189. */
  75190. transformedDirection: Vector3;
  75191. private _needProjectionMatrixCompute;
  75192. /**
  75193. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75194. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75195. */
  75196. computeTransformedInformation(): boolean;
  75197. /**
  75198. * Return the depth scale used for the shadow map.
  75199. * @returns the depth scale.
  75200. */
  75201. getDepthScale(): number;
  75202. /**
  75203. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75204. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75205. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75206. */
  75207. getShadowDirection(faceIndex?: number): Vector3;
  75208. /**
  75209. * Returns the ShadowLight absolute position in the World.
  75210. * @returns the position vector in world space
  75211. */
  75212. getAbsolutePosition(): Vector3;
  75213. /**
  75214. * Sets the ShadowLight direction toward the passed target.
  75215. * @param target The point to target in local space
  75216. * @returns the updated ShadowLight direction
  75217. */
  75218. setDirectionToTarget(target: Vector3): Vector3;
  75219. /**
  75220. * Returns the light rotation in euler definition.
  75221. * @returns the x y z rotation in local space.
  75222. */
  75223. getRotation(): Vector3;
  75224. /**
  75225. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75226. * @returns true if a cube texture needs to be use
  75227. */
  75228. needCube(): boolean;
  75229. /**
  75230. * Detects if the projection matrix requires to be recomputed this frame.
  75231. * @returns true if it requires to be recomputed otherwise, false.
  75232. */
  75233. needProjectionMatrixCompute(): boolean;
  75234. /**
  75235. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75236. */
  75237. forceProjectionMatrixCompute(): void;
  75238. /** @hidden */
  75239. _initCache(): void;
  75240. /** @hidden */
  75241. _isSynchronized(): boolean;
  75242. /**
  75243. * Computes the world matrix of the node
  75244. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75245. * @returns the world matrix
  75246. */
  75247. computeWorldMatrix(force?: boolean): Matrix;
  75248. /**
  75249. * Gets the minZ used for shadow according to both the scene and the light.
  75250. * @param activeCamera The camera we are returning the min for
  75251. * @returns the depth min z
  75252. */
  75253. getDepthMinZ(activeCamera: Camera): number;
  75254. /**
  75255. * Gets the maxZ used for shadow according to both the scene and the light.
  75256. * @param activeCamera The camera we are returning the max for
  75257. * @returns the depth max z
  75258. */
  75259. getDepthMaxZ(activeCamera: Camera): number;
  75260. /**
  75261. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75262. * @param matrix The materix to updated with the projection information
  75263. * @param viewMatrix The transform matrix of the light
  75264. * @param renderList The list of mesh to render in the map
  75265. * @returns The current light
  75266. */
  75267. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75268. }
  75269. }
  75270. declare module BABYLON {
  75271. /**
  75272. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75273. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75274. */
  75275. export class EffectFallbacks implements IEffectFallbacks {
  75276. private _defines;
  75277. private _currentRank;
  75278. private _maxRank;
  75279. private _mesh;
  75280. /**
  75281. * Removes the fallback from the bound mesh.
  75282. */
  75283. unBindMesh(): void;
  75284. /**
  75285. * Adds a fallback on the specified property.
  75286. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75287. * @param define The name of the define in the shader
  75288. */
  75289. addFallback(rank: number, define: string): void;
  75290. /**
  75291. * Sets the mesh to use CPU skinning when needing to fallback.
  75292. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75293. * @param mesh The mesh to use the fallbacks.
  75294. */
  75295. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75296. /**
  75297. * Checks to see if more fallbacks are still availible.
  75298. */
  75299. readonly hasMoreFallbacks: boolean;
  75300. /**
  75301. * Removes the defines that should be removed when falling back.
  75302. * @param currentDefines defines the current define statements for the shader.
  75303. * @param effect defines the current effect we try to compile
  75304. * @returns The resulting defines with defines of the current rank removed.
  75305. */
  75306. reduce(currentDefines: string, effect: Effect): string;
  75307. }
  75308. }
  75309. declare module BABYLON {
  75310. /**
  75311. * "Static Class" containing the most commonly used helper while dealing with material for
  75312. * rendering purpose.
  75313. *
  75314. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75315. *
  75316. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75317. */
  75318. export class MaterialHelper {
  75319. /**
  75320. * Bind the current view position to an effect.
  75321. * @param effect The effect to be bound
  75322. * @param scene The scene the eyes position is used from
  75323. */
  75324. static BindEyePosition(effect: Effect, scene: Scene): void;
  75325. /**
  75326. * Helps preparing the defines values about the UVs in used in the effect.
  75327. * UVs are shared as much as we can accross channels in the shaders.
  75328. * @param texture The texture we are preparing the UVs for
  75329. * @param defines The defines to update
  75330. * @param key The channel key "diffuse", "specular"... used in the shader
  75331. */
  75332. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75333. /**
  75334. * Binds a texture matrix value to its corrsponding uniform
  75335. * @param texture The texture to bind the matrix for
  75336. * @param uniformBuffer The uniform buffer receivin the data
  75337. * @param key The channel key "diffuse", "specular"... used in the shader
  75338. */
  75339. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75340. /**
  75341. * Gets the current status of the fog (should it be enabled?)
  75342. * @param mesh defines the mesh to evaluate for fog support
  75343. * @param scene defines the hosting scene
  75344. * @returns true if fog must be enabled
  75345. */
  75346. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75347. /**
  75348. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75349. * @param mesh defines the current mesh
  75350. * @param scene defines the current scene
  75351. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75352. * @param pointsCloud defines if point cloud rendering has to be turned on
  75353. * @param fogEnabled defines if fog has to be turned on
  75354. * @param alphaTest defines if alpha testing has to be turned on
  75355. * @param defines defines the current list of defines
  75356. */
  75357. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75358. /**
  75359. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75360. * @param scene defines the current scene
  75361. * @param engine defines the current engine
  75362. * @param defines specifies the list of active defines
  75363. * @param useInstances defines if instances have to be turned on
  75364. * @param useClipPlane defines if clip plane have to be turned on
  75365. */
  75366. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75367. /**
  75368. * Prepares the defines for bones
  75369. * @param mesh The mesh containing the geometry data we will draw
  75370. * @param defines The defines to update
  75371. */
  75372. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75373. /**
  75374. * Prepares the defines for morph targets
  75375. * @param mesh The mesh containing the geometry data we will draw
  75376. * @param defines The defines to update
  75377. */
  75378. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75379. /**
  75380. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75381. * @param mesh The mesh containing the geometry data we will draw
  75382. * @param defines The defines to update
  75383. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75384. * @param useBones Precise whether bones should be used or not (override mesh info)
  75385. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75386. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75387. * @returns false if defines are considered not dirty and have not been checked
  75388. */
  75389. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75390. /**
  75391. * Prepares the defines related to multiview
  75392. * @param scene The scene we are intending to draw
  75393. * @param defines The defines to update
  75394. */
  75395. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75396. /**
  75397. * Prepares the defines related to the light information passed in parameter
  75398. * @param scene The scene we are intending to draw
  75399. * @param mesh The mesh the effect is compiling for
  75400. * @param light The light the effect is compiling for
  75401. * @param lightIndex The index of the light
  75402. * @param defines The defines to update
  75403. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75404. * @param state Defines the current state regarding what is needed (normals, etc...)
  75405. */
  75406. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75407. needNormals: boolean;
  75408. needRebuild: boolean;
  75409. shadowEnabled: boolean;
  75410. specularEnabled: boolean;
  75411. lightmapMode: boolean;
  75412. }): void;
  75413. /**
  75414. * Prepares the defines related to the light information passed in parameter
  75415. * @param scene The scene we are intending to draw
  75416. * @param mesh The mesh the effect is compiling for
  75417. * @param defines The defines to update
  75418. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75419. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75420. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75421. * @returns true if normals will be required for the rest of the effect
  75422. */
  75423. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75424. /**
  75425. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75426. * @param lightIndex defines the light index
  75427. * @param uniformsList The uniform list
  75428. * @param samplersList The sampler list
  75429. * @param projectedLightTexture defines if projected texture must be used
  75430. * @param uniformBuffersList defines an optional list of uniform buffers
  75431. */
  75432. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75433. /**
  75434. * Prepares the uniforms and samplers list to be used in the effect
  75435. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75436. * @param samplersList The sampler list
  75437. * @param defines The defines helping in the list generation
  75438. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75439. */
  75440. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75441. /**
  75442. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75443. * @param defines The defines to update while falling back
  75444. * @param fallbacks The authorized effect fallbacks
  75445. * @param maxSimultaneousLights The maximum number of lights allowed
  75446. * @param rank the current rank of the Effect
  75447. * @returns The newly affected rank
  75448. */
  75449. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75450. private static _TmpMorphInfluencers;
  75451. /**
  75452. * Prepares the list of attributes required for morph targets according to the effect defines.
  75453. * @param attribs The current list of supported attribs
  75454. * @param mesh The mesh to prepare the morph targets attributes for
  75455. * @param influencers The number of influencers
  75456. */
  75457. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75458. /**
  75459. * Prepares the list of attributes required for morph targets according to the effect defines.
  75460. * @param attribs The current list of supported attribs
  75461. * @param mesh The mesh to prepare the morph targets attributes for
  75462. * @param defines The current Defines of the effect
  75463. */
  75464. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75465. /**
  75466. * Prepares the list of attributes required for bones according to the effect defines.
  75467. * @param attribs The current list of supported attribs
  75468. * @param mesh The mesh to prepare the bones attributes for
  75469. * @param defines The current Defines of the effect
  75470. * @param fallbacks The current efffect fallback strategy
  75471. */
  75472. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75473. /**
  75474. * Check and prepare the list of attributes required for instances according to the effect defines.
  75475. * @param attribs The current list of supported attribs
  75476. * @param defines The current MaterialDefines of the effect
  75477. */
  75478. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75479. /**
  75480. * Add the list of attributes required for instances to the attribs array.
  75481. * @param attribs The current list of supported attribs
  75482. */
  75483. static PushAttributesForInstances(attribs: string[]): void;
  75484. /**
  75485. * Binds the light shadow information to the effect for the given mesh.
  75486. * @param light The light containing the generator
  75487. * @param scene The scene the lights belongs to
  75488. * @param mesh The mesh we are binding the information to render
  75489. * @param lightIndex The light index in the effect used to render the mesh
  75490. * @param effect The effect we are binding the data to
  75491. */
  75492. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75493. /**
  75494. * Binds the light information to the effect.
  75495. * @param light The light containing the generator
  75496. * @param effect The effect we are binding the data to
  75497. * @param lightIndex The light index in the effect used to render
  75498. */
  75499. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75500. /**
  75501. * Binds the lights information from the scene to the effect for the given mesh.
  75502. * @param light Light to bind
  75503. * @param lightIndex Light index
  75504. * @param scene The scene where the light belongs to
  75505. * @param mesh The mesh we are binding the information to render
  75506. * @param effect The effect we are binding the data to
  75507. * @param useSpecular Defines if specular is supported
  75508. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75509. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75510. */
  75511. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75512. /**
  75513. * Binds the lights information from the scene to the effect for the given mesh.
  75514. * @param scene The scene the lights belongs to
  75515. * @param mesh The mesh we are binding the information to render
  75516. * @param effect The effect we are binding the data to
  75517. * @param defines The generated defines for the effect
  75518. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75519. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75520. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75521. */
  75522. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75523. private static _tempFogColor;
  75524. /**
  75525. * Binds the fog information from the scene to the effect for the given mesh.
  75526. * @param scene The scene the lights belongs to
  75527. * @param mesh The mesh we are binding the information to render
  75528. * @param effect The effect we are binding the data to
  75529. * @param linearSpace Defines if the fog effect is applied in linear space
  75530. */
  75531. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75532. /**
  75533. * Binds the bones information from the mesh to the effect.
  75534. * @param mesh The mesh we are binding the information to render
  75535. * @param effect The effect we are binding the data to
  75536. */
  75537. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75538. /**
  75539. * Binds the morph targets information from the mesh to the effect.
  75540. * @param abstractMesh The mesh we are binding the information to render
  75541. * @param effect The effect we are binding the data to
  75542. */
  75543. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75544. /**
  75545. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75546. * @param defines The generated defines used in the effect
  75547. * @param effect The effect we are binding the data to
  75548. * @param scene The scene we are willing to render with logarithmic scale for
  75549. */
  75550. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75551. /**
  75552. * Binds the clip plane information from the scene to the effect.
  75553. * @param scene The scene the clip plane information are extracted from
  75554. * @param effect The effect we are binding the data to
  75555. */
  75556. static BindClipPlane(effect: Effect, scene: Scene): void;
  75557. }
  75558. }
  75559. declare module BABYLON {
  75560. /** @hidden */
  75561. export var packingFunctions: {
  75562. name: string;
  75563. shader: string;
  75564. };
  75565. }
  75566. declare module BABYLON {
  75567. /** @hidden */
  75568. export var shadowMapPixelShader: {
  75569. name: string;
  75570. shader: string;
  75571. };
  75572. }
  75573. declare module BABYLON {
  75574. /** @hidden */
  75575. export var bonesDeclaration: {
  75576. name: string;
  75577. shader: string;
  75578. };
  75579. }
  75580. declare module BABYLON {
  75581. /** @hidden */
  75582. export var morphTargetsVertexGlobalDeclaration: {
  75583. name: string;
  75584. shader: string;
  75585. };
  75586. }
  75587. declare module BABYLON {
  75588. /** @hidden */
  75589. export var morphTargetsVertexDeclaration: {
  75590. name: string;
  75591. shader: string;
  75592. };
  75593. }
  75594. declare module BABYLON {
  75595. /** @hidden */
  75596. export var instancesDeclaration: {
  75597. name: string;
  75598. shader: string;
  75599. };
  75600. }
  75601. declare module BABYLON {
  75602. /** @hidden */
  75603. export var helperFunctions: {
  75604. name: string;
  75605. shader: string;
  75606. };
  75607. }
  75608. declare module BABYLON {
  75609. /** @hidden */
  75610. export var morphTargetsVertex: {
  75611. name: string;
  75612. shader: string;
  75613. };
  75614. }
  75615. declare module BABYLON {
  75616. /** @hidden */
  75617. export var instancesVertex: {
  75618. name: string;
  75619. shader: string;
  75620. };
  75621. }
  75622. declare module BABYLON {
  75623. /** @hidden */
  75624. export var bonesVertex: {
  75625. name: string;
  75626. shader: string;
  75627. };
  75628. }
  75629. declare module BABYLON {
  75630. /** @hidden */
  75631. export var shadowMapVertexShader: {
  75632. name: string;
  75633. shader: string;
  75634. };
  75635. }
  75636. declare module BABYLON {
  75637. /** @hidden */
  75638. export var depthBoxBlurPixelShader: {
  75639. name: string;
  75640. shader: string;
  75641. };
  75642. }
  75643. declare module BABYLON {
  75644. /**
  75645. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75646. */
  75647. export interface ICustomShaderOptions {
  75648. /**
  75649. * Gets or sets the custom shader name to use
  75650. */
  75651. shaderName: string;
  75652. /**
  75653. * The list of attribute names used in the shader
  75654. */
  75655. attributes?: string[];
  75656. /**
  75657. * The list of unifrom names used in the shader
  75658. */
  75659. uniforms?: string[];
  75660. /**
  75661. * The list of sampler names used in the shader
  75662. */
  75663. samplers?: string[];
  75664. /**
  75665. * The list of defines used in the shader
  75666. */
  75667. defines?: string[];
  75668. }
  75669. /**
  75670. * Interface to implement to create a shadow generator compatible with BJS.
  75671. */
  75672. export interface IShadowGenerator {
  75673. /**
  75674. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75675. * @returns The render target texture if present otherwise, null
  75676. */
  75677. getShadowMap(): Nullable<RenderTargetTexture>;
  75678. /**
  75679. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75680. * @returns The render target texture if the shadow map is present otherwise, null
  75681. */
  75682. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75683. /**
  75684. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75685. * @param subMesh The submesh we want to render in the shadow map
  75686. * @param useInstances Defines wether will draw in the map using instances
  75687. * @returns true if ready otherwise, false
  75688. */
  75689. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75690. /**
  75691. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75692. * @param defines Defines of the material we want to update
  75693. * @param lightIndex Index of the light in the enabled light list of the material
  75694. */
  75695. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75696. /**
  75697. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75698. * defined in the generator but impacting the effect).
  75699. * It implies the unifroms available on the materials are the standard BJS ones.
  75700. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75701. * @param effect The effect we are binfing the information for
  75702. */
  75703. bindShadowLight(lightIndex: string, effect: Effect): void;
  75704. /**
  75705. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75706. * (eq to shadow prjection matrix * light transform matrix)
  75707. * @returns The transform matrix used to create the shadow map
  75708. */
  75709. getTransformMatrix(): Matrix;
  75710. /**
  75711. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75712. * Cube and 2D textures for instance.
  75713. */
  75714. recreateShadowMap(): void;
  75715. /**
  75716. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75717. * @param onCompiled Callback triggered at the and of the effects compilation
  75718. * @param options Sets of optional options forcing the compilation with different modes
  75719. */
  75720. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75721. useInstances: boolean;
  75722. }>): void;
  75723. /**
  75724. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75725. * @param options Sets of optional options forcing the compilation with different modes
  75726. * @returns A promise that resolves when the compilation completes
  75727. */
  75728. forceCompilationAsync(options?: Partial<{
  75729. useInstances: boolean;
  75730. }>): Promise<void>;
  75731. /**
  75732. * Serializes the shadow generator setup to a json object.
  75733. * @returns The serialized JSON object
  75734. */
  75735. serialize(): any;
  75736. /**
  75737. * Disposes the Shadow map and related Textures and effects.
  75738. */
  75739. dispose(): void;
  75740. }
  75741. /**
  75742. * Default implementation IShadowGenerator.
  75743. * This is the main object responsible of generating shadows in the framework.
  75744. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75745. */
  75746. export class ShadowGenerator implements IShadowGenerator {
  75747. /**
  75748. * Shadow generator mode None: no filtering applied.
  75749. */
  75750. static readonly FILTER_NONE: number;
  75751. /**
  75752. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75753. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75754. */
  75755. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75756. /**
  75757. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75758. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75759. */
  75760. static readonly FILTER_POISSONSAMPLING: number;
  75761. /**
  75762. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75763. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75764. */
  75765. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75766. /**
  75767. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75768. * edge artifacts on steep falloff.
  75769. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75770. */
  75771. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75772. /**
  75773. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75774. * edge artifacts on steep falloff.
  75775. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75776. */
  75777. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75778. /**
  75779. * Shadow generator mode PCF: Percentage Closer Filtering
  75780. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75781. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75782. */
  75783. static readonly FILTER_PCF: number;
  75784. /**
  75785. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75786. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75787. * Contact Hardening
  75788. */
  75789. static readonly FILTER_PCSS: number;
  75790. /**
  75791. * Reserved for PCF and PCSS
  75792. * Highest Quality.
  75793. *
  75794. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75795. *
  75796. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75797. */
  75798. static readonly QUALITY_HIGH: number;
  75799. /**
  75800. * Reserved for PCF and PCSS
  75801. * Good tradeoff for quality/perf cross devices
  75802. *
  75803. * Execute PCF on a 3*3 kernel.
  75804. *
  75805. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75806. */
  75807. static readonly QUALITY_MEDIUM: number;
  75808. /**
  75809. * Reserved for PCF and PCSS
  75810. * The lowest quality but the fastest.
  75811. *
  75812. * Execute PCF on a 1*1 kernel.
  75813. *
  75814. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75815. */
  75816. static readonly QUALITY_LOW: number;
  75817. /** Gets or sets the custom shader name to use */
  75818. customShaderOptions: ICustomShaderOptions;
  75819. /**
  75820. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75821. */
  75822. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75823. /**
  75824. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75825. */
  75826. onAfterShadowMapRenderObservable: Observable<Effect>;
  75827. /**
  75828. * Observable triggered before a mesh is rendered in the shadow map.
  75829. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75830. */
  75831. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75832. /**
  75833. * Observable triggered after a mesh is rendered in the shadow map.
  75834. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75835. */
  75836. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75837. private _bias;
  75838. /**
  75839. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75840. */
  75841. /**
  75842. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75843. */
  75844. bias: number;
  75845. private _normalBias;
  75846. /**
  75847. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75848. */
  75849. /**
  75850. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75851. */
  75852. normalBias: number;
  75853. private _blurBoxOffset;
  75854. /**
  75855. * Gets the blur box offset: offset applied during the blur pass.
  75856. * Only useful if useKernelBlur = false
  75857. */
  75858. /**
  75859. * Sets the blur box offset: offset applied during the blur pass.
  75860. * Only useful if useKernelBlur = false
  75861. */
  75862. blurBoxOffset: number;
  75863. private _blurScale;
  75864. /**
  75865. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75866. * 2 means half of the size.
  75867. */
  75868. /**
  75869. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75870. * 2 means half of the size.
  75871. */
  75872. blurScale: number;
  75873. private _blurKernel;
  75874. /**
  75875. * Gets the blur kernel: kernel size of the blur pass.
  75876. * Only useful if useKernelBlur = true
  75877. */
  75878. /**
  75879. * Sets the blur kernel: kernel size of the blur pass.
  75880. * Only useful if useKernelBlur = true
  75881. */
  75882. blurKernel: number;
  75883. private _useKernelBlur;
  75884. /**
  75885. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75886. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75887. */
  75888. /**
  75889. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75890. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75891. */
  75892. useKernelBlur: boolean;
  75893. private _depthScale;
  75894. /**
  75895. * Gets the depth scale used in ESM mode.
  75896. */
  75897. /**
  75898. * Sets the depth scale used in ESM mode.
  75899. * This can override the scale stored on the light.
  75900. */
  75901. depthScale: number;
  75902. private _filter;
  75903. /**
  75904. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75905. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75906. */
  75907. /**
  75908. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75909. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75910. */
  75911. filter: number;
  75912. /**
  75913. * Gets if the current filter is set to Poisson Sampling.
  75914. */
  75915. /**
  75916. * Sets the current filter to Poisson Sampling.
  75917. */
  75918. usePoissonSampling: boolean;
  75919. /**
  75920. * Gets if the current filter is set to ESM.
  75921. */
  75922. /**
  75923. * Sets the current filter is to ESM.
  75924. */
  75925. useExponentialShadowMap: boolean;
  75926. /**
  75927. * Gets if the current filter is set to filtered ESM.
  75928. */
  75929. /**
  75930. * Gets if the current filter is set to filtered ESM.
  75931. */
  75932. useBlurExponentialShadowMap: boolean;
  75933. /**
  75934. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75935. * exponential to prevent steep falloff artifacts).
  75936. */
  75937. /**
  75938. * Sets the current filter to "close ESM" (using the inverse of the
  75939. * exponential to prevent steep falloff artifacts).
  75940. */
  75941. useCloseExponentialShadowMap: boolean;
  75942. /**
  75943. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75944. * exponential to prevent steep falloff artifacts).
  75945. */
  75946. /**
  75947. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75948. * exponential to prevent steep falloff artifacts).
  75949. */
  75950. useBlurCloseExponentialShadowMap: boolean;
  75951. /**
  75952. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75953. */
  75954. /**
  75955. * Sets the current filter to "PCF" (percentage closer filtering).
  75956. */
  75957. usePercentageCloserFiltering: boolean;
  75958. private _filteringQuality;
  75959. /**
  75960. * Gets the PCF or PCSS Quality.
  75961. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75962. */
  75963. /**
  75964. * Sets the PCF or PCSS Quality.
  75965. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75966. */
  75967. filteringQuality: number;
  75968. /**
  75969. * Gets if the current filter is set to "PCSS" (contact hardening).
  75970. */
  75971. /**
  75972. * Sets the current filter to "PCSS" (contact hardening).
  75973. */
  75974. useContactHardeningShadow: boolean;
  75975. private _contactHardeningLightSizeUVRatio;
  75976. /**
  75977. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75978. * Using a ratio helps keeping shape stability independently of the map size.
  75979. *
  75980. * It does not account for the light projection as it was having too much
  75981. * instability during the light setup or during light position changes.
  75982. *
  75983. * Only valid if useContactHardeningShadow is true.
  75984. */
  75985. /**
  75986. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75987. * Using a ratio helps keeping shape stability independently of the map size.
  75988. *
  75989. * It does not account for the light projection as it was having too much
  75990. * instability during the light setup or during light position changes.
  75991. *
  75992. * Only valid if useContactHardeningShadow is true.
  75993. */
  75994. contactHardeningLightSizeUVRatio: number;
  75995. private _darkness;
  75996. /** Gets or sets the actual darkness of a shadow */
  75997. darkness: number;
  75998. /**
  75999. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76000. * 0 means strongest and 1 would means no shadow.
  76001. * @returns the darkness.
  76002. */
  76003. getDarkness(): number;
  76004. /**
  76005. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76006. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76007. * @returns the shadow generator allowing fluent coding.
  76008. */
  76009. setDarkness(darkness: number): ShadowGenerator;
  76010. private _transparencyShadow;
  76011. /** Gets or sets the ability to have transparent shadow */
  76012. transparencyShadow: boolean;
  76013. /**
  76014. * Sets the ability to have transparent shadow (boolean).
  76015. * @param transparent True if transparent else False
  76016. * @returns the shadow generator allowing fluent coding
  76017. */
  76018. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76019. private _shadowMap;
  76020. private _shadowMap2;
  76021. /**
  76022. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76023. * @returns The render target texture if present otherwise, null
  76024. */
  76025. getShadowMap(): Nullable<RenderTargetTexture>;
  76026. /**
  76027. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76028. * @returns The render target texture if the shadow map is present otherwise, null
  76029. */
  76030. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76031. /**
  76032. * Gets the class name of that object
  76033. * @returns "ShadowGenerator"
  76034. */
  76035. getClassName(): string;
  76036. /**
  76037. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76038. * @param mesh Mesh to add
  76039. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76040. * @returns the Shadow Generator itself
  76041. */
  76042. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76043. /**
  76044. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76045. * @param mesh Mesh to remove
  76046. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76047. * @returns the Shadow Generator itself
  76048. */
  76049. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76050. /**
  76051. * Controls the extent to which the shadows fade out at the edge of the frustum
  76052. * Used only by directionals and spots
  76053. */
  76054. frustumEdgeFalloff: number;
  76055. private _light;
  76056. /**
  76057. * Returns the associated light object.
  76058. * @returns the light generating the shadow
  76059. */
  76060. getLight(): IShadowLight;
  76061. /**
  76062. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76063. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76064. * It might on the other hand introduce peter panning.
  76065. */
  76066. forceBackFacesOnly: boolean;
  76067. private _scene;
  76068. private _lightDirection;
  76069. private _effect;
  76070. private _viewMatrix;
  76071. private _projectionMatrix;
  76072. private _transformMatrix;
  76073. private _cachedPosition;
  76074. private _cachedDirection;
  76075. private _cachedDefines;
  76076. private _currentRenderID;
  76077. private _boxBlurPostprocess;
  76078. private _kernelBlurXPostprocess;
  76079. private _kernelBlurYPostprocess;
  76080. private _blurPostProcesses;
  76081. private _mapSize;
  76082. private _currentFaceIndex;
  76083. private _currentFaceIndexCache;
  76084. private _textureType;
  76085. private _defaultTextureMatrix;
  76086. /** @hidden */
  76087. static _SceneComponentInitialization: (scene: Scene) => void;
  76088. /**
  76089. * Creates a ShadowGenerator object.
  76090. * A ShadowGenerator is the required tool to use the shadows.
  76091. * Each light casting shadows needs to use its own ShadowGenerator.
  76092. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76093. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76094. * @param light The light object generating the shadows.
  76095. * @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.
  76096. */
  76097. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76098. private _initializeGenerator;
  76099. private _initializeShadowMap;
  76100. private _initializeBlurRTTAndPostProcesses;
  76101. private _renderForShadowMap;
  76102. private _renderSubMeshForShadowMap;
  76103. private _applyFilterValues;
  76104. /**
  76105. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76106. * @param onCompiled Callback triggered at the and of the effects compilation
  76107. * @param options Sets of optional options forcing the compilation with different modes
  76108. */
  76109. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76110. useInstances: boolean;
  76111. }>): void;
  76112. /**
  76113. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76114. * @param options Sets of optional options forcing the compilation with different modes
  76115. * @returns A promise that resolves when the compilation completes
  76116. */
  76117. forceCompilationAsync(options?: Partial<{
  76118. useInstances: boolean;
  76119. }>): Promise<void>;
  76120. /**
  76121. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76122. * @param subMesh The submesh we want to render in the shadow map
  76123. * @param useInstances Defines wether will draw in the map using instances
  76124. * @returns true if ready otherwise, false
  76125. */
  76126. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76127. /**
  76128. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76129. * @param defines Defines of the material we want to update
  76130. * @param lightIndex Index of the light in the enabled light list of the material
  76131. */
  76132. prepareDefines(defines: any, lightIndex: number): void;
  76133. /**
  76134. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76135. * defined in the generator but impacting the effect).
  76136. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76137. * @param effect The effect we are binfing the information for
  76138. */
  76139. bindShadowLight(lightIndex: string, effect: Effect): void;
  76140. /**
  76141. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76142. * (eq to shadow prjection matrix * light transform matrix)
  76143. * @returns The transform matrix used to create the shadow map
  76144. */
  76145. getTransformMatrix(): Matrix;
  76146. /**
  76147. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76148. * Cube and 2D textures for instance.
  76149. */
  76150. recreateShadowMap(): void;
  76151. private _disposeBlurPostProcesses;
  76152. private _disposeRTTandPostProcesses;
  76153. /**
  76154. * Disposes the ShadowGenerator.
  76155. * Returns nothing.
  76156. */
  76157. dispose(): void;
  76158. /**
  76159. * Serializes the shadow generator setup to a json object.
  76160. * @returns The serialized JSON object
  76161. */
  76162. serialize(): any;
  76163. /**
  76164. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76165. * @param parsedShadowGenerator The JSON object to parse
  76166. * @param scene The scene to create the shadow map for
  76167. * @returns The parsed shadow generator
  76168. */
  76169. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76170. }
  76171. }
  76172. declare module BABYLON {
  76173. /**
  76174. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76175. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76176. * 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.
  76177. */
  76178. export abstract class Light extends Node {
  76179. /**
  76180. * Falloff Default: light is falling off following the material specification:
  76181. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76182. */
  76183. static readonly FALLOFF_DEFAULT: number;
  76184. /**
  76185. * Falloff Physical: light is falling off following the inverse squared distance law.
  76186. */
  76187. static readonly FALLOFF_PHYSICAL: number;
  76188. /**
  76189. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76190. * to enhance interoperability with other engines.
  76191. */
  76192. static readonly FALLOFF_GLTF: number;
  76193. /**
  76194. * Falloff Standard: light is falling off like in the standard material
  76195. * to enhance interoperability with other materials.
  76196. */
  76197. static readonly FALLOFF_STANDARD: number;
  76198. /**
  76199. * If every light affecting the material is in this lightmapMode,
  76200. * material.lightmapTexture adds or multiplies
  76201. * (depends on material.useLightmapAsShadowmap)
  76202. * after every other light calculations.
  76203. */
  76204. static readonly LIGHTMAP_DEFAULT: number;
  76205. /**
  76206. * material.lightmapTexture as only diffuse lighting from this light
  76207. * adds only specular lighting from this light
  76208. * adds dynamic shadows
  76209. */
  76210. static readonly LIGHTMAP_SPECULAR: number;
  76211. /**
  76212. * material.lightmapTexture as only lighting
  76213. * no light calculation from this light
  76214. * only adds dynamic shadows from this light
  76215. */
  76216. static readonly LIGHTMAP_SHADOWSONLY: number;
  76217. /**
  76218. * Each light type uses the default quantity according to its type:
  76219. * point/spot lights use luminous intensity
  76220. * directional lights use illuminance
  76221. */
  76222. static readonly INTENSITYMODE_AUTOMATIC: number;
  76223. /**
  76224. * lumen (lm)
  76225. */
  76226. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76227. /**
  76228. * candela (lm/sr)
  76229. */
  76230. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76231. /**
  76232. * lux (lm/m^2)
  76233. */
  76234. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76235. /**
  76236. * nit (cd/m^2)
  76237. */
  76238. static readonly INTENSITYMODE_LUMINANCE: number;
  76239. /**
  76240. * Light type const id of the point light.
  76241. */
  76242. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76243. /**
  76244. * Light type const id of the directional light.
  76245. */
  76246. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76247. /**
  76248. * Light type const id of the spot light.
  76249. */
  76250. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76251. /**
  76252. * Light type const id of the hemispheric light.
  76253. */
  76254. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76255. /**
  76256. * Diffuse gives the basic color to an object.
  76257. */
  76258. diffuse: Color3;
  76259. /**
  76260. * Specular produces a highlight color on an object.
  76261. * Note: This is note affecting PBR materials.
  76262. */
  76263. specular: Color3;
  76264. /**
  76265. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76266. * falling off base on range or angle.
  76267. * This can be set to any values in Light.FALLOFF_x.
  76268. *
  76269. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76270. * other types of materials.
  76271. */
  76272. falloffType: number;
  76273. /**
  76274. * Strength of the light.
  76275. * Note: By default it is define in the framework own unit.
  76276. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76277. */
  76278. intensity: number;
  76279. private _range;
  76280. protected _inverseSquaredRange: number;
  76281. /**
  76282. * Defines how far from the source the light is impacting in scene units.
  76283. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76284. */
  76285. /**
  76286. * Defines how far from the source the light is impacting in scene units.
  76287. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76288. */
  76289. range: number;
  76290. /**
  76291. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76292. * of light.
  76293. */
  76294. private _photometricScale;
  76295. private _intensityMode;
  76296. /**
  76297. * Gets the photometric scale used to interpret the intensity.
  76298. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76299. */
  76300. /**
  76301. * Sets the photometric scale used to interpret the intensity.
  76302. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76303. */
  76304. intensityMode: number;
  76305. private _radius;
  76306. /**
  76307. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76308. */
  76309. /**
  76310. * sets the light radius used by PBR Materials to simulate soft area lights.
  76311. */
  76312. radius: number;
  76313. private _renderPriority;
  76314. /**
  76315. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76316. * exceeding the number allowed of the materials.
  76317. */
  76318. renderPriority: number;
  76319. private _shadowEnabled;
  76320. /**
  76321. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76322. * the current shadow generator.
  76323. */
  76324. /**
  76325. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76326. * the current shadow generator.
  76327. */
  76328. shadowEnabled: boolean;
  76329. private _includedOnlyMeshes;
  76330. /**
  76331. * Gets the only meshes impacted by this light.
  76332. */
  76333. /**
  76334. * Sets the only meshes impacted by this light.
  76335. */
  76336. includedOnlyMeshes: AbstractMesh[];
  76337. private _excludedMeshes;
  76338. /**
  76339. * Gets the meshes not impacted by this light.
  76340. */
  76341. /**
  76342. * Sets the meshes not impacted by this light.
  76343. */
  76344. excludedMeshes: AbstractMesh[];
  76345. private _excludeWithLayerMask;
  76346. /**
  76347. * Gets the layer id use to find what meshes are not impacted by the light.
  76348. * Inactive if 0
  76349. */
  76350. /**
  76351. * Sets the layer id use to find what meshes are not impacted by the light.
  76352. * Inactive if 0
  76353. */
  76354. excludeWithLayerMask: number;
  76355. private _includeOnlyWithLayerMask;
  76356. /**
  76357. * Gets the layer id use to find what meshes are impacted by the light.
  76358. * Inactive if 0
  76359. */
  76360. /**
  76361. * Sets the layer id use to find what meshes are impacted by the light.
  76362. * Inactive if 0
  76363. */
  76364. includeOnlyWithLayerMask: number;
  76365. private _lightmapMode;
  76366. /**
  76367. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76368. */
  76369. /**
  76370. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76371. */
  76372. lightmapMode: number;
  76373. /**
  76374. * Shadow generator associted to the light.
  76375. * @hidden Internal use only.
  76376. */
  76377. _shadowGenerator: Nullable<IShadowGenerator>;
  76378. /**
  76379. * @hidden Internal use only.
  76380. */
  76381. _excludedMeshesIds: string[];
  76382. /**
  76383. * @hidden Internal use only.
  76384. */
  76385. _includedOnlyMeshesIds: string[];
  76386. /**
  76387. * The current light unifom buffer.
  76388. * @hidden Internal use only.
  76389. */
  76390. _uniformBuffer: UniformBuffer;
  76391. /**
  76392. * Creates a Light object in the scene.
  76393. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76394. * @param name The firendly name of the light
  76395. * @param scene The scene the light belongs too
  76396. */
  76397. constructor(name: string, scene: Scene);
  76398. protected abstract _buildUniformLayout(): void;
  76399. /**
  76400. * Sets the passed Effect "effect" with the Light information.
  76401. * @param effect The effect to update
  76402. * @param lightIndex The index of the light in the effect to update
  76403. * @returns The light
  76404. */
  76405. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76406. /**
  76407. * Sets the passed Effect "effect" with the Light information.
  76408. * @param effect The effect to update
  76409. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76410. * @returns The light
  76411. */
  76412. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76413. /**
  76414. * Returns the string "Light".
  76415. * @returns the class name
  76416. */
  76417. getClassName(): string;
  76418. /** @hidden */
  76419. readonly _isLight: boolean;
  76420. /**
  76421. * Converts the light information to a readable string for debug purpose.
  76422. * @param fullDetails Supports for multiple levels of logging within scene loading
  76423. * @returns the human readable light info
  76424. */
  76425. toString(fullDetails?: boolean): string;
  76426. /** @hidden */
  76427. protected _syncParentEnabledState(): void;
  76428. /**
  76429. * Set the enabled state of this node.
  76430. * @param value - the new enabled state
  76431. */
  76432. setEnabled(value: boolean): void;
  76433. /**
  76434. * Returns the Light associated shadow generator if any.
  76435. * @return the associated shadow generator.
  76436. */
  76437. getShadowGenerator(): Nullable<IShadowGenerator>;
  76438. /**
  76439. * Returns a Vector3, the absolute light position in the World.
  76440. * @returns the world space position of the light
  76441. */
  76442. getAbsolutePosition(): Vector3;
  76443. /**
  76444. * Specifies if the light will affect the passed mesh.
  76445. * @param mesh The mesh to test against the light
  76446. * @return true the mesh is affected otherwise, false.
  76447. */
  76448. canAffectMesh(mesh: AbstractMesh): boolean;
  76449. /**
  76450. * Sort function to order lights for rendering.
  76451. * @param a First Light object to compare to second.
  76452. * @param b Second Light object to compare first.
  76453. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76454. */
  76455. static CompareLightsPriority(a: Light, b: Light): number;
  76456. /**
  76457. * Releases resources associated with this node.
  76458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76460. */
  76461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76462. /**
  76463. * Returns the light type ID (integer).
  76464. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76465. */
  76466. getTypeID(): number;
  76467. /**
  76468. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76469. * @returns the scaled intensity in intensity mode unit
  76470. */
  76471. getScaledIntensity(): number;
  76472. /**
  76473. * Returns a new Light object, named "name", from the current one.
  76474. * @param name The name of the cloned light
  76475. * @returns the new created light
  76476. */
  76477. clone(name: string): Nullable<Light>;
  76478. /**
  76479. * Serializes the current light into a Serialization object.
  76480. * @returns the serialized object.
  76481. */
  76482. serialize(): any;
  76483. /**
  76484. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76485. * This new light is named "name" and added to the passed scene.
  76486. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76487. * @param name The friendly name of the light
  76488. * @param scene The scene the new light will belong to
  76489. * @returns the constructor function
  76490. */
  76491. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76492. /**
  76493. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76494. * @param parsedLight The JSON representation of the light
  76495. * @param scene The scene to create the parsed light in
  76496. * @returns the created light after parsing
  76497. */
  76498. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76499. private _hookArrayForExcluded;
  76500. private _hookArrayForIncludedOnly;
  76501. private _resyncMeshes;
  76502. /**
  76503. * Forces the meshes to update their light related information in their rendering used effects
  76504. * @hidden Internal Use Only
  76505. */
  76506. _markMeshesAsLightDirty(): void;
  76507. /**
  76508. * Recomputes the cached photometric scale if needed.
  76509. */
  76510. private _computePhotometricScale;
  76511. /**
  76512. * Returns the Photometric Scale according to the light type and intensity mode.
  76513. */
  76514. private _getPhotometricScale;
  76515. /**
  76516. * Reorder the light in the scene according to their defined priority.
  76517. * @hidden Internal Use Only
  76518. */
  76519. _reorderLightsInScene(): void;
  76520. /**
  76521. * Prepares the list of defines specific to the light type.
  76522. * @param defines the list of defines
  76523. * @param lightIndex defines the index of the light for the effect
  76524. */
  76525. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76526. }
  76527. }
  76528. declare module BABYLON {
  76529. /**
  76530. * Interface used to define Action
  76531. */
  76532. export interface IAction {
  76533. /**
  76534. * Trigger for the action
  76535. */
  76536. trigger: number;
  76537. /** Options of the trigger */
  76538. triggerOptions: any;
  76539. /**
  76540. * Gets the trigger parameters
  76541. * @returns the trigger parameters
  76542. */
  76543. getTriggerParameter(): any;
  76544. /**
  76545. * Internal only - executes current action event
  76546. * @hidden
  76547. */
  76548. _executeCurrent(evt?: ActionEvent): void;
  76549. /**
  76550. * Serialize placeholder for child classes
  76551. * @param parent of child
  76552. * @returns the serialized object
  76553. */
  76554. serialize(parent: any): any;
  76555. /**
  76556. * Internal only
  76557. * @hidden
  76558. */
  76559. _prepare(): void;
  76560. /**
  76561. * Internal only - manager for action
  76562. * @hidden
  76563. */
  76564. _actionManager: AbstractActionManager;
  76565. /**
  76566. * Adds action to chain of actions, may be a DoNothingAction
  76567. * @param action defines the next action to execute
  76568. * @returns The action passed in
  76569. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76570. */
  76571. then(action: IAction): IAction;
  76572. }
  76573. /**
  76574. * The action to be carried out following a trigger
  76575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76576. */
  76577. export class Action implements IAction {
  76578. /** the trigger, with or without parameters, for the action */
  76579. triggerOptions: any;
  76580. /**
  76581. * Trigger for the action
  76582. */
  76583. trigger: number;
  76584. /**
  76585. * Internal only - manager for action
  76586. * @hidden
  76587. */
  76588. _actionManager: ActionManager;
  76589. private _nextActiveAction;
  76590. private _child;
  76591. private _condition?;
  76592. private _triggerParameter;
  76593. /**
  76594. * An event triggered prior to action being executed.
  76595. */
  76596. onBeforeExecuteObservable: Observable<Action>;
  76597. /**
  76598. * Creates a new Action
  76599. * @param triggerOptions the trigger, with or without parameters, for the action
  76600. * @param condition an optional determinant of action
  76601. */
  76602. constructor(
  76603. /** the trigger, with or without parameters, for the action */
  76604. triggerOptions: any, condition?: Condition);
  76605. /**
  76606. * Internal only
  76607. * @hidden
  76608. */
  76609. _prepare(): void;
  76610. /**
  76611. * Gets the trigger parameters
  76612. * @returns the trigger parameters
  76613. */
  76614. getTriggerParameter(): any;
  76615. /**
  76616. * Internal only - executes current action event
  76617. * @hidden
  76618. */
  76619. _executeCurrent(evt?: ActionEvent): void;
  76620. /**
  76621. * Execute placeholder for child classes
  76622. * @param evt optional action event
  76623. */
  76624. execute(evt?: ActionEvent): void;
  76625. /**
  76626. * Skips to next active action
  76627. */
  76628. skipToNextActiveAction(): void;
  76629. /**
  76630. * Adds action to chain of actions, may be a DoNothingAction
  76631. * @param action defines the next action to execute
  76632. * @returns The action passed in
  76633. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76634. */
  76635. then(action: Action): Action;
  76636. /**
  76637. * Internal only
  76638. * @hidden
  76639. */
  76640. _getProperty(propertyPath: string): string;
  76641. /**
  76642. * Internal only
  76643. * @hidden
  76644. */
  76645. _getEffectiveTarget(target: any, propertyPath: string): any;
  76646. /**
  76647. * Serialize placeholder for child classes
  76648. * @param parent of child
  76649. * @returns the serialized object
  76650. */
  76651. serialize(parent: any): any;
  76652. /**
  76653. * Internal only called by serialize
  76654. * @hidden
  76655. */
  76656. protected _serialize(serializedAction: any, parent?: any): any;
  76657. /**
  76658. * Internal only
  76659. * @hidden
  76660. */
  76661. static _SerializeValueAsString: (value: any) => string;
  76662. /**
  76663. * Internal only
  76664. * @hidden
  76665. */
  76666. static _GetTargetProperty: (target: Node | Scene) => {
  76667. name: string;
  76668. targetType: string;
  76669. value: string;
  76670. };
  76671. }
  76672. }
  76673. declare module BABYLON {
  76674. /**
  76675. * A Condition applied to an Action
  76676. */
  76677. export class Condition {
  76678. /**
  76679. * Internal only - manager for action
  76680. * @hidden
  76681. */
  76682. _actionManager: ActionManager;
  76683. /**
  76684. * Internal only
  76685. * @hidden
  76686. */
  76687. _evaluationId: number;
  76688. /**
  76689. * Internal only
  76690. * @hidden
  76691. */
  76692. _currentResult: boolean;
  76693. /**
  76694. * Creates a new Condition
  76695. * @param actionManager the manager of the action the condition is applied to
  76696. */
  76697. constructor(actionManager: ActionManager);
  76698. /**
  76699. * Check if the current condition is valid
  76700. * @returns a boolean
  76701. */
  76702. isValid(): boolean;
  76703. /**
  76704. * Internal only
  76705. * @hidden
  76706. */
  76707. _getProperty(propertyPath: string): string;
  76708. /**
  76709. * Internal only
  76710. * @hidden
  76711. */
  76712. _getEffectiveTarget(target: any, propertyPath: string): any;
  76713. /**
  76714. * Serialize placeholder for child classes
  76715. * @returns the serialized object
  76716. */
  76717. serialize(): any;
  76718. /**
  76719. * Internal only
  76720. * @hidden
  76721. */
  76722. protected _serialize(serializedCondition: any): any;
  76723. }
  76724. /**
  76725. * Defines specific conditional operators as extensions of Condition
  76726. */
  76727. export class ValueCondition extends Condition {
  76728. /** path to specify the property of the target the conditional operator uses */
  76729. propertyPath: string;
  76730. /** the value compared by the conditional operator against the current value of the property */
  76731. value: any;
  76732. /** the conditional operator, default ValueCondition.IsEqual */
  76733. operator: number;
  76734. /**
  76735. * Internal only
  76736. * @hidden
  76737. */
  76738. private static _IsEqual;
  76739. /**
  76740. * Internal only
  76741. * @hidden
  76742. */
  76743. private static _IsDifferent;
  76744. /**
  76745. * Internal only
  76746. * @hidden
  76747. */
  76748. private static _IsGreater;
  76749. /**
  76750. * Internal only
  76751. * @hidden
  76752. */
  76753. private static _IsLesser;
  76754. /**
  76755. * returns the number for IsEqual
  76756. */
  76757. static readonly IsEqual: number;
  76758. /**
  76759. * Returns the number for IsDifferent
  76760. */
  76761. static readonly IsDifferent: number;
  76762. /**
  76763. * Returns the number for IsGreater
  76764. */
  76765. static readonly IsGreater: number;
  76766. /**
  76767. * Returns the number for IsLesser
  76768. */
  76769. static readonly IsLesser: number;
  76770. /**
  76771. * Internal only The action manager for the condition
  76772. * @hidden
  76773. */
  76774. _actionManager: ActionManager;
  76775. /**
  76776. * Internal only
  76777. * @hidden
  76778. */
  76779. private _target;
  76780. /**
  76781. * Internal only
  76782. * @hidden
  76783. */
  76784. private _effectiveTarget;
  76785. /**
  76786. * Internal only
  76787. * @hidden
  76788. */
  76789. private _property;
  76790. /**
  76791. * Creates a new ValueCondition
  76792. * @param actionManager manager for the action the condition applies to
  76793. * @param target for the action
  76794. * @param propertyPath path to specify the property of the target the conditional operator uses
  76795. * @param value the value compared by the conditional operator against the current value of the property
  76796. * @param operator the conditional operator, default ValueCondition.IsEqual
  76797. */
  76798. constructor(actionManager: ActionManager, target: any,
  76799. /** path to specify the property of the target the conditional operator uses */
  76800. propertyPath: string,
  76801. /** the value compared by the conditional operator against the current value of the property */
  76802. value: any,
  76803. /** the conditional operator, default ValueCondition.IsEqual */
  76804. operator?: number);
  76805. /**
  76806. * Compares the given value with the property value for the specified conditional operator
  76807. * @returns the result of the comparison
  76808. */
  76809. isValid(): boolean;
  76810. /**
  76811. * Serialize the ValueCondition into a JSON compatible object
  76812. * @returns serialization object
  76813. */
  76814. serialize(): any;
  76815. /**
  76816. * Gets the name of the conditional operator for the ValueCondition
  76817. * @param operator the conditional operator
  76818. * @returns the name
  76819. */
  76820. static GetOperatorName(operator: number): string;
  76821. }
  76822. /**
  76823. * Defines a predicate condition as an extension of Condition
  76824. */
  76825. export class PredicateCondition extends Condition {
  76826. /** defines the predicate function used to validate the condition */
  76827. predicate: () => boolean;
  76828. /**
  76829. * Internal only - manager for action
  76830. * @hidden
  76831. */
  76832. _actionManager: ActionManager;
  76833. /**
  76834. * Creates a new PredicateCondition
  76835. * @param actionManager manager for the action the condition applies to
  76836. * @param predicate defines the predicate function used to validate the condition
  76837. */
  76838. constructor(actionManager: ActionManager,
  76839. /** defines the predicate function used to validate the condition */
  76840. predicate: () => boolean);
  76841. /**
  76842. * @returns the validity of the predicate condition
  76843. */
  76844. isValid(): boolean;
  76845. }
  76846. /**
  76847. * Defines a state condition as an extension of Condition
  76848. */
  76849. export class StateCondition extends Condition {
  76850. /** Value to compare with target state */
  76851. value: string;
  76852. /**
  76853. * Internal only - manager for action
  76854. * @hidden
  76855. */
  76856. _actionManager: ActionManager;
  76857. /**
  76858. * Internal only
  76859. * @hidden
  76860. */
  76861. private _target;
  76862. /**
  76863. * Creates a new StateCondition
  76864. * @param actionManager manager for the action the condition applies to
  76865. * @param target of the condition
  76866. * @param value to compare with target state
  76867. */
  76868. constructor(actionManager: ActionManager, target: any,
  76869. /** Value to compare with target state */
  76870. value: string);
  76871. /**
  76872. * Gets a boolean indicating if the current condition is met
  76873. * @returns the validity of the state
  76874. */
  76875. isValid(): boolean;
  76876. /**
  76877. * Serialize the StateCondition into a JSON compatible object
  76878. * @returns serialization object
  76879. */
  76880. serialize(): any;
  76881. }
  76882. }
  76883. declare module BABYLON {
  76884. /**
  76885. * This defines an action responsible to toggle a boolean once triggered.
  76886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76887. */
  76888. export class SwitchBooleanAction extends Action {
  76889. /**
  76890. * The path to the boolean property in the target object
  76891. */
  76892. propertyPath: string;
  76893. private _target;
  76894. private _effectiveTarget;
  76895. private _property;
  76896. /**
  76897. * Instantiate the action
  76898. * @param triggerOptions defines the trigger options
  76899. * @param target defines the object containing the boolean
  76900. * @param propertyPath defines the path to the boolean property in the target object
  76901. * @param condition defines the trigger related conditions
  76902. */
  76903. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76904. /** @hidden */
  76905. _prepare(): void;
  76906. /**
  76907. * Execute the action toggle the boolean value.
  76908. */
  76909. execute(): void;
  76910. /**
  76911. * Serializes the actions and its related information.
  76912. * @param parent defines the object to serialize in
  76913. * @returns the serialized object
  76914. */
  76915. serialize(parent: any): any;
  76916. }
  76917. /**
  76918. * This defines an action responsible to set a the state field of the target
  76919. * to a desired value once triggered.
  76920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76921. */
  76922. export class SetStateAction extends Action {
  76923. /**
  76924. * The value to store in the state field.
  76925. */
  76926. value: string;
  76927. private _target;
  76928. /**
  76929. * Instantiate the action
  76930. * @param triggerOptions defines the trigger options
  76931. * @param target defines the object containing the state property
  76932. * @param value defines the value to store in the state field
  76933. * @param condition defines the trigger related conditions
  76934. */
  76935. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76936. /**
  76937. * Execute the action and store the value on the target state property.
  76938. */
  76939. execute(): void;
  76940. /**
  76941. * Serializes the actions and its related information.
  76942. * @param parent defines the object to serialize in
  76943. * @returns the serialized object
  76944. */
  76945. serialize(parent: any): any;
  76946. }
  76947. /**
  76948. * This defines an action responsible to set a property of the target
  76949. * to a desired value once triggered.
  76950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76951. */
  76952. export class SetValueAction extends Action {
  76953. /**
  76954. * The path of the property to set in the target.
  76955. */
  76956. propertyPath: string;
  76957. /**
  76958. * The value to set in the property
  76959. */
  76960. value: any;
  76961. private _target;
  76962. private _effectiveTarget;
  76963. private _property;
  76964. /**
  76965. * Instantiate the action
  76966. * @param triggerOptions defines the trigger options
  76967. * @param target defines the object containing the property
  76968. * @param propertyPath defines the path of the property to set in the target
  76969. * @param value defines the value to set in the property
  76970. * @param condition defines the trigger related conditions
  76971. */
  76972. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76973. /** @hidden */
  76974. _prepare(): void;
  76975. /**
  76976. * Execute the action and set the targetted property to the desired value.
  76977. */
  76978. execute(): void;
  76979. /**
  76980. * Serializes the actions and its related information.
  76981. * @param parent defines the object to serialize in
  76982. * @returns the serialized object
  76983. */
  76984. serialize(parent: any): any;
  76985. }
  76986. /**
  76987. * This defines an action responsible to increment the target value
  76988. * to a desired value once triggered.
  76989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76990. */
  76991. export class IncrementValueAction extends Action {
  76992. /**
  76993. * The path of the property to increment in the target.
  76994. */
  76995. propertyPath: string;
  76996. /**
  76997. * The value we should increment the property by.
  76998. */
  76999. value: any;
  77000. private _target;
  77001. private _effectiveTarget;
  77002. private _property;
  77003. /**
  77004. * Instantiate the action
  77005. * @param triggerOptions defines the trigger options
  77006. * @param target defines the object containing the property
  77007. * @param propertyPath defines the path of the property to increment in the target
  77008. * @param value defines the value value we should increment the property by
  77009. * @param condition defines the trigger related conditions
  77010. */
  77011. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77012. /** @hidden */
  77013. _prepare(): void;
  77014. /**
  77015. * Execute the action and increment the target of the value amount.
  77016. */
  77017. execute(): void;
  77018. /**
  77019. * Serializes the actions and its related information.
  77020. * @param parent defines the object to serialize in
  77021. * @returns the serialized object
  77022. */
  77023. serialize(parent: any): any;
  77024. }
  77025. /**
  77026. * This defines an action responsible to start an animation once triggered.
  77027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77028. */
  77029. export class PlayAnimationAction extends Action {
  77030. /**
  77031. * Where the animation should start (animation frame)
  77032. */
  77033. from: number;
  77034. /**
  77035. * Where the animation should stop (animation frame)
  77036. */
  77037. to: number;
  77038. /**
  77039. * Define if the animation should loop or stop after the first play.
  77040. */
  77041. loop?: boolean;
  77042. private _target;
  77043. /**
  77044. * Instantiate the action
  77045. * @param triggerOptions defines the trigger options
  77046. * @param target defines the target animation or animation name
  77047. * @param from defines from where the animation should start (animation frame)
  77048. * @param end defines where the animation should stop (animation frame)
  77049. * @param loop defines if the animation should loop or stop after the first play
  77050. * @param condition defines the trigger related conditions
  77051. */
  77052. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77053. /** @hidden */
  77054. _prepare(): void;
  77055. /**
  77056. * Execute the action and play the animation.
  77057. */
  77058. execute(): void;
  77059. /**
  77060. * Serializes the actions and its related information.
  77061. * @param parent defines the object to serialize in
  77062. * @returns the serialized object
  77063. */
  77064. serialize(parent: any): any;
  77065. }
  77066. /**
  77067. * This defines an action responsible to stop an animation once triggered.
  77068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77069. */
  77070. export class StopAnimationAction extends Action {
  77071. private _target;
  77072. /**
  77073. * Instantiate the action
  77074. * @param triggerOptions defines the trigger options
  77075. * @param target defines the target animation or animation name
  77076. * @param condition defines the trigger related conditions
  77077. */
  77078. constructor(triggerOptions: any, target: any, condition?: Condition);
  77079. /** @hidden */
  77080. _prepare(): void;
  77081. /**
  77082. * Execute the action and stop the animation.
  77083. */
  77084. execute(): void;
  77085. /**
  77086. * Serializes the actions and its related information.
  77087. * @param parent defines the object to serialize in
  77088. * @returns the serialized object
  77089. */
  77090. serialize(parent: any): any;
  77091. }
  77092. /**
  77093. * This defines an action responsible that does nothing once triggered.
  77094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77095. */
  77096. export class DoNothingAction extends Action {
  77097. /**
  77098. * Instantiate the action
  77099. * @param triggerOptions defines the trigger options
  77100. * @param condition defines the trigger related conditions
  77101. */
  77102. constructor(triggerOptions?: any, condition?: Condition);
  77103. /**
  77104. * Execute the action and do nothing.
  77105. */
  77106. execute(): void;
  77107. /**
  77108. * Serializes the actions and its related information.
  77109. * @param parent defines the object to serialize in
  77110. * @returns the serialized object
  77111. */
  77112. serialize(parent: any): any;
  77113. }
  77114. /**
  77115. * This defines an action responsible to trigger several actions once triggered.
  77116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77117. */
  77118. export class CombineAction extends Action {
  77119. /**
  77120. * The list of aggregated animations to run.
  77121. */
  77122. children: Action[];
  77123. /**
  77124. * Instantiate the action
  77125. * @param triggerOptions defines the trigger options
  77126. * @param children defines the list of aggregated animations to run
  77127. * @param condition defines the trigger related conditions
  77128. */
  77129. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77130. /** @hidden */
  77131. _prepare(): void;
  77132. /**
  77133. * Execute the action and executes all the aggregated actions.
  77134. */
  77135. execute(evt: ActionEvent): void;
  77136. /**
  77137. * Serializes the actions and its related information.
  77138. * @param parent defines the object to serialize in
  77139. * @returns the serialized object
  77140. */
  77141. serialize(parent: any): any;
  77142. }
  77143. /**
  77144. * This defines an action responsible to run code (external event) once triggered.
  77145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77146. */
  77147. export class ExecuteCodeAction extends Action {
  77148. /**
  77149. * The callback function to run.
  77150. */
  77151. func: (evt: ActionEvent) => void;
  77152. /**
  77153. * Instantiate the action
  77154. * @param triggerOptions defines the trigger options
  77155. * @param func defines the callback function to run
  77156. * @param condition defines the trigger related conditions
  77157. */
  77158. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77159. /**
  77160. * Execute the action and run the attached code.
  77161. */
  77162. execute(evt: ActionEvent): void;
  77163. }
  77164. /**
  77165. * This defines an action responsible to set the parent property of the target once triggered.
  77166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77167. */
  77168. export class SetParentAction extends Action {
  77169. private _parent;
  77170. private _target;
  77171. /**
  77172. * Instantiate the action
  77173. * @param triggerOptions defines the trigger options
  77174. * @param target defines the target containing the parent property
  77175. * @param parent defines from where the animation should start (animation frame)
  77176. * @param condition defines the trigger related conditions
  77177. */
  77178. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77179. /** @hidden */
  77180. _prepare(): void;
  77181. /**
  77182. * Execute the action and set the parent property.
  77183. */
  77184. execute(): void;
  77185. /**
  77186. * Serializes the actions and its related information.
  77187. * @param parent defines the object to serialize in
  77188. * @returns the serialized object
  77189. */
  77190. serialize(parent: any): any;
  77191. }
  77192. }
  77193. declare module BABYLON {
  77194. /**
  77195. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77196. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77198. */
  77199. export class ActionManager extends AbstractActionManager {
  77200. /**
  77201. * Nothing
  77202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77203. */
  77204. static readonly NothingTrigger: number;
  77205. /**
  77206. * On pick
  77207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77208. */
  77209. static readonly OnPickTrigger: number;
  77210. /**
  77211. * On left pick
  77212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77213. */
  77214. static readonly OnLeftPickTrigger: number;
  77215. /**
  77216. * On right pick
  77217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77218. */
  77219. static readonly OnRightPickTrigger: number;
  77220. /**
  77221. * On center pick
  77222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77223. */
  77224. static readonly OnCenterPickTrigger: number;
  77225. /**
  77226. * On pick down
  77227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77228. */
  77229. static readonly OnPickDownTrigger: number;
  77230. /**
  77231. * On double pick
  77232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77233. */
  77234. static readonly OnDoublePickTrigger: number;
  77235. /**
  77236. * On pick up
  77237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77238. */
  77239. static readonly OnPickUpTrigger: number;
  77240. /**
  77241. * On pick out.
  77242. * This trigger will only be raised if you also declared a OnPickDown
  77243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77244. */
  77245. static readonly OnPickOutTrigger: number;
  77246. /**
  77247. * On long press
  77248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77249. */
  77250. static readonly OnLongPressTrigger: number;
  77251. /**
  77252. * On pointer over
  77253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77254. */
  77255. static readonly OnPointerOverTrigger: number;
  77256. /**
  77257. * On pointer out
  77258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77259. */
  77260. static readonly OnPointerOutTrigger: number;
  77261. /**
  77262. * On every frame
  77263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77264. */
  77265. static readonly OnEveryFrameTrigger: number;
  77266. /**
  77267. * On intersection enter
  77268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77269. */
  77270. static readonly OnIntersectionEnterTrigger: number;
  77271. /**
  77272. * On intersection exit
  77273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77274. */
  77275. static readonly OnIntersectionExitTrigger: number;
  77276. /**
  77277. * On key down
  77278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77279. */
  77280. static readonly OnKeyDownTrigger: number;
  77281. /**
  77282. * On key up
  77283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77284. */
  77285. static readonly OnKeyUpTrigger: number;
  77286. private _scene;
  77287. /**
  77288. * Creates a new action manager
  77289. * @param scene defines the hosting scene
  77290. */
  77291. constructor(scene: Scene);
  77292. /**
  77293. * Releases all associated resources
  77294. */
  77295. dispose(): void;
  77296. /**
  77297. * Gets hosting scene
  77298. * @returns the hosting scene
  77299. */
  77300. getScene(): Scene;
  77301. /**
  77302. * Does this action manager handles actions of any of the given triggers
  77303. * @param triggers defines the triggers to be tested
  77304. * @return a boolean indicating whether one (or more) of the triggers is handled
  77305. */
  77306. hasSpecificTriggers(triggers: number[]): boolean;
  77307. /**
  77308. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77309. * speed.
  77310. * @param triggerA defines the trigger to be tested
  77311. * @param triggerB defines the trigger to be tested
  77312. * @return a boolean indicating whether one (or more) of the triggers is handled
  77313. */
  77314. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77315. /**
  77316. * Does this action manager handles actions of a given trigger
  77317. * @param trigger defines the trigger to be tested
  77318. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77319. * @return whether the trigger is handled
  77320. */
  77321. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77322. /**
  77323. * Does this action manager has pointer triggers
  77324. */
  77325. readonly hasPointerTriggers: boolean;
  77326. /**
  77327. * Does this action manager has pick triggers
  77328. */
  77329. readonly hasPickTriggers: boolean;
  77330. /**
  77331. * Registers an action to this action manager
  77332. * @param action defines the action to be registered
  77333. * @return the action amended (prepared) after registration
  77334. */
  77335. registerAction(action: IAction): Nullable<IAction>;
  77336. /**
  77337. * Unregisters an action to this action manager
  77338. * @param action defines the action to be unregistered
  77339. * @return a boolean indicating whether the action has been unregistered
  77340. */
  77341. unregisterAction(action: IAction): Boolean;
  77342. /**
  77343. * Process a specific trigger
  77344. * @param trigger defines the trigger to process
  77345. * @param evt defines the event details to be processed
  77346. */
  77347. processTrigger(trigger: number, evt?: IActionEvent): void;
  77348. /** @hidden */
  77349. _getEffectiveTarget(target: any, propertyPath: string): any;
  77350. /** @hidden */
  77351. _getProperty(propertyPath: string): string;
  77352. /**
  77353. * Serialize this manager to a JSON object
  77354. * @param name defines the property name to store this manager
  77355. * @returns a JSON representation of this manager
  77356. */
  77357. serialize(name: string): any;
  77358. /**
  77359. * Creates a new ActionManager from a JSON data
  77360. * @param parsedActions defines the JSON data to read from
  77361. * @param object defines the hosting mesh
  77362. * @param scene defines the hosting scene
  77363. */
  77364. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77365. /**
  77366. * Get a trigger name by index
  77367. * @param trigger defines the trigger index
  77368. * @returns a trigger name
  77369. */
  77370. static GetTriggerName(trigger: number): string;
  77371. }
  77372. }
  77373. declare module BABYLON {
  77374. /**
  77375. * Class representing a ray with position and direction
  77376. */
  77377. export class Ray {
  77378. /** origin point */
  77379. origin: Vector3;
  77380. /** direction */
  77381. direction: Vector3;
  77382. /** length of the ray */
  77383. length: number;
  77384. private static readonly TmpVector3;
  77385. private _tmpRay;
  77386. /**
  77387. * Creates a new ray
  77388. * @param origin origin point
  77389. * @param direction direction
  77390. * @param length length of the ray
  77391. */
  77392. constructor(
  77393. /** origin point */
  77394. origin: Vector3,
  77395. /** direction */
  77396. direction: Vector3,
  77397. /** length of the ray */
  77398. length?: number);
  77399. /**
  77400. * Checks if the ray intersects a box
  77401. * @param minimum bound of the box
  77402. * @param maximum bound of the box
  77403. * @param intersectionTreshold extra extend to be added to the box in all direction
  77404. * @returns if the box was hit
  77405. */
  77406. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77407. /**
  77408. * Checks if the ray intersects a box
  77409. * @param box the bounding box to check
  77410. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77411. * @returns if the box was hit
  77412. */
  77413. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77414. /**
  77415. * If the ray hits a sphere
  77416. * @param sphere the bounding sphere to check
  77417. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77418. * @returns true if it hits the sphere
  77419. */
  77420. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77421. /**
  77422. * If the ray hits a triange
  77423. * @param vertex0 triangle vertex
  77424. * @param vertex1 triangle vertex
  77425. * @param vertex2 triangle vertex
  77426. * @returns intersection information if hit
  77427. */
  77428. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77429. /**
  77430. * Checks if ray intersects a plane
  77431. * @param plane the plane to check
  77432. * @returns the distance away it was hit
  77433. */
  77434. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77435. /**
  77436. * Calculate the intercept of a ray on a given axis
  77437. * @param axis to check 'x' | 'y' | 'z'
  77438. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77439. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77440. */
  77441. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77442. /**
  77443. * Checks if ray intersects a mesh
  77444. * @param mesh the mesh to check
  77445. * @param fastCheck if only the bounding box should checked
  77446. * @returns picking info of the intersecton
  77447. */
  77448. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77449. /**
  77450. * Checks if ray intersects a mesh
  77451. * @param meshes the meshes to check
  77452. * @param fastCheck if only the bounding box should checked
  77453. * @param results array to store result in
  77454. * @returns Array of picking infos
  77455. */
  77456. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77457. private _comparePickingInfo;
  77458. private static smallnum;
  77459. private static rayl;
  77460. /**
  77461. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77462. * @param sega the first point of the segment to test the intersection against
  77463. * @param segb the second point of the segment to test the intersection against
  77464. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77465. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77466. */
  77467. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77468. /**
  77469. * Update the ray from viewport position
  77470. * @param x position
  77471. * @param y y position
  77472. * @param viewportWidth viewport width
  77473. * @param viewportHeight viewport height
  77474. * @param world world matrix
  77475. * @param view view matrix
  77476. * @param projection projection matrix
  77477. * @returns this ray updated
  77478. */
  77479. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77480. /**
  77481. * Creates a ray with origin and direction of 0,0,0
  77482. * @returns the new ray
  77483. */
  77484. static Zero(): Ray;
  77485. /**
  77486. * Creates a new ray from screen space and viewport
  77487. * @param x position
  77488. * @param y y position
  77489. * @param viewportWidth viewport width
  77490. * @param viewportHeight viewport height
  77491. * @param world world matrix
  77492. * @param view view matrix
  77493. * @param projection projection matrix
  77494. * @returns new ray
  77495. */
  77496. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77497. /**
  77498. * 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
  77499. * transformed to the given world matrix.
  77500. * @param origin The origin point
  77501. * @param end The end point
  77502. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77503. * @returns the new ray
  77504. */
  77505. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77506. /**
  77507. * Transforms a ray by a matrix
  77508. * @param ray ray to transform
  77509. * @param matrix matrix to apply
  77510. * @returns the resulting new ray
  77511. */
  77512. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77513. /**
  77514. * Transforms a ray by a matrix
  77515. * @param ray ray to transform
  77516. * @param matrix matrix to apply
  77517. * @param result ray to store result in
  77518. */
  77519. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77520. /**
  77521. * Unproject a ray from screen space to object space
  77522. * @param sourceX defines the screen space x coordinate to use
  77523. * @param sourceY defines the screen space y coordinate to use
  77524. * @param viewportWidth defines the current width of the viewport
  77525. * @param viewportHeight defines the current height of the viewport
  77526. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77527. * @param view defines the view matrix to use
  77528. * @param projection defines the projection matrix to use
  77529. */
  77530. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77531. }
  77532. /**
  77533. * Type used to define predicate used to select faces when a mesh intersection is detected
  77534. */
  77535. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77536. interface Scene {
  77537. /** @hidden */
  77538. _tempPickingRay: Nullable<Ray>;
  77539. /** @hidden */
  77540. _cachedRayForTransform: Ray;
  77541. /** @hidden */
  77542. _pickWithRayInverseMatrix: Matrix;
  77543. /** @hidden */
  77544. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77545. /** @hidden */
  77546. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77547. }
  77548. }
  77549. declare module BABYLON {
  77550. /**
  77551. * Groups all the scene component constants in one place to ease maintenance.
  77552. * @hidden
  77553. */
  77554. export class SceneComponentConstants {
  77555. static readonly NAME_EFFECTLAYER: string;
  77556. static readonly NAME_LAYER: string;
  77557. static readonly NAME_LENSFLARESYSTEM: string;
  77558. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77559. static readonly NAME_PARTICLESYSTEM: string;
  77560. static readonly NAME_GAMEPAD: string;
  77561. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77562. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77563. static readonly NAME_DEPTHRENDERER: string;
  77564. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77565. static readonly NAME_SPRITE: string;
  77566. static readonly NAME_OUTLINERENDERER: string;
  77567. static readonly NAME_PROCEDURALTEXTURE: string;
  77568. static readonly NAME_SHADOWGENERATOR: string;
  77569. static readonly NAME_OCTREE: string;
  77570. static readonly NAME_PHYSICSENGINE: string;
  77571. static readonly NAME_AUDIO: string;
  77572. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77573. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77574. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77575. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77576. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77577. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77578. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77579. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77580. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77581. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77582. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77583. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77584. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77585. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77586. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77587. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77588. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77589. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77590. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77591. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77592. static readonly STEP_AFTERRENDER_AUDIO: number;
  77593. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77594. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77595. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77596. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77597. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77598. static readonly STEP_POINTERMOVE_SPRITE: number;
  77599. static readonly STEP_POINTERDOWN_SPRITE: number;
  77600. static readonly STEP_POINTERUP_SPRITE: number;
  77601. }
  77602. /**
  77603. * This represents a scene component.
  77604. *
  77605. * This is used to decouple the dependency the scene is having on the different workloads like
  77606. * layers, post processes...
  77607. */
  77608. export interface ISceneComponent {
  77609. /**
  77610. * The name of the component. Each component must have a unique name.
  77611. */
  77612. name: string;
  77613. /**
  77614. * The scene the component belongs to.
  77615. */
  77616. scene: Scene;
  77617. /**
  77618. * Register the component to one instance of a scene.
  77619. */
  77620. register(): void;
  77621. /**
  77622. * Rebuilds the elements related to this component in case of
  77623. * context lost for instance.
  77624. */
  77625. rebuild(): void;
  77626. /**
  77627. * Disposes the component and the associated ressources.
  77628. */
  77629. dispose(): void;
  77630. }
  77631. /**
  77632. * This represents a SERIALIZABLE scene component.
  77633. *
  77634. * This extends Scene Component to add Serialization methods on top.
  77635. */
  77636. export interface ISceneSerializableComponent extends ISceneComponent {
  77637. /**
  77638. * Adds all the elements from the container to the scene
  77639. * @param container the container holding the elements
  77640. */
  77641. addFromContainer(container: AbstractScene): void;
  77642. /**
  77643. * Removes all the elements in the container from the scene
  77644. * @param container contains the elements to remove
  77645. * @param dispose if the removed element should be disposed (default: false)
  77646. */
  77647. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77648. /**
  77649. * Serializes the component data to the specified json object
  77650. * @param serializationObject The object to serialize to
  77651. */
  77652. serialize(serializationObject: any): void;
  77653. }
  77654. /**
  77655. * Strong typing of a Mesh related stage step action
  77656. */
  77657. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77658. /**
  77659. * Strong typing of a Evaluate Sub Mesh related stage step action
  77660. */
  77661. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77662. /**
  77663. * Strong typing of a Active Mesh related stage step action
  77664. */
  77665. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77666. /**
  77667. * Strong typing of a Camera related stage step action
  77668. */
  77669. export type CameraStageAction = (camera: Camera) => void;
  77670. /**
  77671. * Strong typing of a Camera Frame buffer related stage step action
  77672. */
  77673. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77674. /**
  77675. * Strong typing of a Render Target related stage step action
  77676. */
  77677. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77678. /**
  77679. * Strong typing of a RenderingGroup related stage step action
  77680. */
  77681. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77682. /**
  77683. * Strong typing of a Mesh Render related stage step action
  77684. */
  77685. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77686. /**
  77687. * Strong typing of a simple stage step action
  77688. */
  77689. export type SimpleStageAction = () => void;
  77690. /**
  77691. * Strong typing of a render target action.
  77692. */
  77693. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77694. /**
  77695. * Strong typing of a pointer move action.
  77696. */
  77697. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77698. /**
  77699. * Strong typing of a pointer up/down action.
  77700. */
  77701. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77702. /**
  77703. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  77704. * @hidden
  77705. */
  77706. export class Stage<T extends Function> extends Array<{
  77707. index: number;
  77708. component: ISceneComponent;
  77709. action: T;
  77710. }> {
  77711. /**
  77712. * Hide ctor from the rest of the world.
  77713. * @param items The items to add.
  77714. */
  77715. private constructor();
  77716. /**
  77717. * Creates a new Stage.
  77718. * @returns A new instance of a Stage
  77719. */
  77720. static Create<T extends Function>(): Stage<T>;
  77721. /**
  77722. * Registers a step in an ordered way in the targeted stage.
  77723. * @param index Defines the position to register the step in
  77724. * @param component Defines the component attached to the step
  77725. * @param action Defines the action to launch during the step
  77726. */
  77727. registerStep(index: number, component: ISceneComponent, action: T): void;
  77728. /**
  77729. * Clears all the steps from the stage.
  77730. */
  77731. clear(): void;
  77732. }
  77733. }
  77734. declare module BABYLON {
  77735. interface Scene {
  77736. /** @hidden */
  77737. _pointerOverSprite: Nullable<Sprite>;
  77738. /** @hidden */
  77739. _pickedDownSprite: Nullable<Sprite>;
  77740. /** @hidden */
  77741. _tempSpritePickingRay: Nullable<Ray>;
  77742. /**
  77743. * All of the sprite managers added to this scene
  77744. * @see http://doc.babylonjs.com/babylon101/sprites
  77745. */
  77746. spriteManagers: Array<ISpriteManager>;
  77747. /**
  77748. * An event triggered when sprites rendering is about to start
  77749. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77750. */
  77751. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77752. /**
  77753. * An event triggered when sprites rendering is done
  77754. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77755. */
  77756. onAfterSpritesRenderingObservable: Observable<Scene>;
  77757. /** @hidden */
  77758. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77759. /** Launch a ray to try to pick a sprite in the scene
  77760. * @param x position on screen
  77761. * @param y position on screen
  77762. * @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
  77763. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77764. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77765. * @returns a PickingInfo
  77766. */
  77767. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77768. /** Use the given ray to pick a sprite in the scene
  77769. * @param ray The ray (in world space) to use to pick meshes
  77770. * @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
  77771. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77772. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77773. * @returns a PickingInfo
  77774. */
  77775. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77776. /** @hidden */
  77777. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77778. /** Launch a ray to try to pick sprites in the scene
  77779. * @param x position on screen
  77780. * @param y position on screen
  77781. * @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
  77782. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77783. * @returns a PickingInfo array
  77784. */
  77785. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77786. /** Use the given ray to pick sprites in the scene
  77787. * @param ray The ray (in world space) to use to pick meshes
  77788. * @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
  77789. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77790. * @returns a PickingInfo array
  77791. */
  77792. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77793. /**
  77794. * Force the sprite under the pointer
  77795. * @param sprite defines the sprite to use
  77796. */
  77797. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77798. /**
  77799. * Gets the sprite under the pointer
  77800. * @returns a Sprite or null if no sprite is under the pointer
  77801. */
  77802. getPointerOverSprite(): Nullable<Sprite>;
  77803. }
  77804. /**
  77805. * Defines the sprite scene component responsible to manage sprites
  77806. * in a given scene.
  77807. */
  77808. export class SpriteSceneComponent implements ISceneComponent {
  77809. /**
  77810. * The component name helpfull to identify the component in the list of scene components.
  77811. */
  77812. readonly name: string;
  77813. /**
  77814. * The scene the component belongs to.
  77815. */
  77816. scene: Scene;
  77817. /** @hidden */
  77818. private _spritePredicate;
  77819. /**
  77820. * Creates a new instance of the component for the given scene
  77821. * @param scene Defines the scene to register the component in
  77822. */
  77823. constructor(scene: Scene);
  77824. /**
  77825. * Registers the component in a given scene
  77826. */
  77827. register(): void;
  77828. /**
  77829. * Rebuilds the elements related to this component in case of
  77830. * context lost for instance.
  77831. */
  77832. rebuild(): void;
  77833. /**
  77834. * Disposes the component and the associated ressources.
  77835. */
  77836. dispose(): void;
  77837. private _pickSpriteButKeepRay;
  77838. private _pointerMove;
  77839. private _pointerDown;
  77840. private _pointerUp;
  77841. }
  77842. }
  77843. declare module BABYLON {
  77844. /** @hidden */
  77845. export var fogFragmentDeclaration: {
  77846. name: string;
  77847. shader: string;
  77848. };
  77849. }
  77850. declare module BABYLON {
  77851. /** @hidden */
  77852. export var fogFragment: {
  77853. name: string;
  77854. shader: string;
  77855. };
  77856. }
  77857. declare module BABYLON {
  77858. /** @hidden */
  77859. export var spritesPixelShader: {
  77860. name: string;
  77861. shader: string;
  77862. };
  77863. }
  77864. declare module BABYLON {
  77865. /** @hidden */
  77866. export var fogVertexDeclaration: {
  77867. name: string;
  77868. shader: string;
  77869. };
  77870. }
  77871. declare module BABYLON {
  77872. /** @hidden */
  77873. export var spritesVertexShader: {
  77874. name: string;
  77875. shader: string;
  77876. };
  77877. }
  77878. declare module BABYLON {
  77879. /**
  77880. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77881. */
  77882. export interface ISpriteManager extends IDisposable {
  77883. /**
  77884. * Restricts the camera to viewing objects with the same layerMask.
  77885. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77886. */
  77887. layerMask: number;
  77888. /**
  77889. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77890. */
  77891. isPickable: boolean;
  77892. /**
  77893. * Specifies the rendering group id for this mesh (0 by default)
  77894. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77895. */
  77896. renderingGroupId: number;
  77897. /**
  77898. * Defines the list of sprites managed by the manager.
  77899. */
  77900. sprites: Array<Sprite>;
  77901. /**
  77902. * Tests the intersection of a sprite with a specific ray.
  77903. * @param ray The ray we are sending to test the collision
  77904. * @param camera The camera space we are sending rays in
  77905. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77906. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77907. * @returns picking info or null.
  77908. */
  77909. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77910. /**
  77911. * Intersects the sprites with a ray
  77912. * @param ray defines the ray to intersect with
  77913. * @param camera defines the current active camera
  77914. * @param predicate defines a predicate used to select candidate sprites
  77915. * @returns null if no hit or a PickingInfo array
  77916. */
  77917. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77918. /**
  77919. * Renders the list of sprites on screen.
  77920. */
  77921. render(): void;
  77922. }
  77923. /**
  77924. * Class used to manage multiple sprites on the same spritesheet
  77925. * @see http://doc.babylonjs.com/babylon101/sprites
  77926. */
  77927. export class SpriteManager implements ISpriteManager {
  77928. /** defines the manager's name */
  77929. name: string;
  77930. /** Gets the list of sprites */
  77931. sprites: Sprite[];
  77932. /** Gets or sets the rendering group id (0 by default) */
  77933. renderingGroupId: number;
  77934. /** Gets or sets camera layer mask */
  77935. layerMask: number;
  77936. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77937. fogEnabled: boolean;
  77938. /** Gets or sets a boolean indicating if the sprites are pickable */
  77939. isPickable: boolean;
  77940. /** Defines the default width of a cell in the spritesheet */
  77941. cellWidth: number;
  77942. /** Defines the default height of a cell in the spritesheet */
  77943. cellHeight: number;
  77944. /** Associative array from JSON sprite data file */
  77945. private _cellData;
  77946. /** Array of sprite names from JSON sprite data file */
  77947. private _spriteMap;
  77948. /** True when packed cell data from JSON file is ready*/
  77949. private _packedAndReady;
  77950. /**
  77951. * An event triggered when the manager is disposed.
  77952. */
  77953. onDisposeObservable: Observable<SpriteManager>;
  77954. private _onDisposeObserver;
  77955. /**
  77956. * Callback called when the manager is disposed
  77957. */
  77958. onDispose: () => void;
  77959. private _capacity;
  77960. private _fromPacked;
  77961. private _spriteTexture;
  77962. private _epsilon;
  77963. private _scene;
  77964. private _vertexData;
  77965. private _buffer;
  77966. private _vertexBuffers;
  77967. private _indexBuffer;
  77968. private _effectBase;
  77969. private _effectFog;
  77970. /**
  77971. * Gets or sets the spritesheet texture
  77972. */
  77973. texture: Texture;
  77974. /**
  77975. * Creates a new sprite manager
  77976. * @param name defines the manager's name
  77977. * @param imgUrl defines the sprite sheet url
  77978. * @param capacity defines the maximum allowed number of sprites
  77979. * @param cellSize defines the size of a sprite cell
  77980. * @param scene defines the hosting scene
  77981. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77982. * @param samplingMode defines the smapling mode to use with spritesheet
  77983. * @param fromPacked set to false; do not alter
  77984. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77985. */
  77986. constructor(
  77987. /** defines the manager's name */
  77988. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77989. private _makePacked;
  77990. private _appendSpriteVertex;
  77991. /**
  77992. * Intersects the sprites with a ray
  77993. * @param ray defines the ray to intersect with
  77994. * @param camera defines the current active camera
  77995. * @param predicate defines a predicate used to select candidate sprites
  77996. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77997. * @returns null if no hit or a PickingInfo
  77998. */
  77999. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78000. /**
  78001. * Intersects the sprites with a ray
  78002. * @param ray defines the ray to intersect with
  78003. * @param camera defines the current active camera
  78004. * @param predicate defines a predicate used to select candidate sprites
  78005. * @returns null if no hit or a PickingInfo array
  78006. */
  78007. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78008. /**
  78009. * Render all child sprites
  78010. */
  78011. render(): void;
  78012. /**
  78013. * Release associated resources
  78014. */
  78015. dispose(): void;
  78016. }
  78017. }
  78018. declare module BABYLON {
  78019. /**
  78020. * Class used to represent a sprite
  78021. * @see http://doc.babylonjs.com/babylon101/sprites
  78022. */
  78023. export class Sprite {
  78024. /** defines the name */
  78025. name: string;
  78026. /** Gets or sets the current world position */
  78027. position: Vector3;
  78028. /** Gets or sets the main color */
  78029. color: Color4;
  78030. /** Gets or sets the width */
  78031. width: number;
  78032. /** Gets or sets the height */
  78033. height: number;
  78034. /** Gets or sets rotation angle */
  78035. angle: number;
  78036. /** Gets or sets the cell index in the sprite sheet */
  78037. cellIndex: number;
  78038. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78039. cellRef: string;
  78040. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78041. invertU: number;
  78042. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78043. invertV: number;
  78044. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78045. disposeWhenFinishedAnimating: boolean;
  78046. /** Gets the list of attached animations */
  78047. animations: Animation[];
  78048. /** Gets or sets a boolean indicating if the sprite can be picked */
  78049. isPickable: boolean;
  78050. /**
  78051. * Gets or sets the associated action manager
  78052. */
  78053. actionManager: Nullable<ActionManager>;
  78054. private _animationStarted;
  78055. private _loopAnimation;
  78056. private _fromIndex;
  78057. private _toIndex;
  78058. private _delay;
  78059. private _direction;
  78060. private _manager;
  78061. private _time;
  78062. private _onAnimationEnd;
  78063. /**
  78064. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78065. */
  78066. isVisible: boolean;
  78067. /**
  78068. * Gets or sets the sprite size
  78069. */
  78070. size: number;
  78071. /**
  78072. * Creates a new Sprite
  78073. * @param name defines the name
  78074. * @param manager defines the manager
  78075. */
  78076. constructor(
  78077. /** defines the name */
  78078. name: string, manager: ISpriteManager);
  78079. /**
  78080. * Starts an animation
  78081. * @param from defines the initial key
  78082. * @param to defines the end key
  78083. * @param loop defines if the animation must loop
  78084. * @param delay defines the start delay (in ms)
  78085. * @param onAnimationEnd defines a callback to call when animation ends
  78086. */
  78087. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78088. /** Stops current animation (if any) */
  78089. stopAnimation(): void;
  78090. /** @hidden */
  78091. _animate(deltaTime: number): void;
  78092. /** Release associated resources */
  78093. dispose(): void;
  78094. }
  78095. }
  78096. declare module BABYLON {
  78097. /**
  78098. * Information about the result of picking within a scene
  78099. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78100. */
  78101. export class PickingInfo {
  78102. /** @hidden */
  78103. _pickingUnavailable: boolean;
  78104. /**
  78105. * If the pick collided with an object
  78106. */
  78107. hit: boolean;
  78108. /**
  78109. * Distance away where the pick collided
  78110. */
  78111. distance: number;
  78112. /**
  78113. * The location of pick collision
  78114. */
  78115. pickedPoint: Nullable<Vector3>;
  78116. /**
  78117. * The mesh corresponding the the pick collision
  78118. */
  78119. pickedMesh: Nullable<AbstractMesh>;
  78120. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78121. bu: number;
  78122. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78123. bv: number;
  78124. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78125. faceId: number;
  78126. /** Id of the the submesh that was picked */
  78127. subMeshId: number;
  78128. /** If a sprite was picked, this will be the sprite the pick collided with */
  78129. pickedSprite: Nullable<Sprite>;
  78130. /**
  78131. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78132. */
  78133. originMesh: Nullable<AbstractMesh>;
  78134. /**
  78135. * The ray that was used to perform the picking.
  78136. */
  78137. ray: Nullable<Ray>;
  78138. /**
  78139. * Gets the normal correspodning to the face the pick collided with
  78140. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78141. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78142. * @returns The normal correspodning to the face the pick collided with
  78143. */
  78144. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78145. /**
  78146. * Gets the texture coordinates of where the pick occured
  78147. * @returns the vector containing the coordnates of the texture
  78148. */
  78149. getTextureCoordinates(): Nullable<Vector2>;
  78150. }
  78151. }
  78152. declare module BABYLON {
  78153. /**
  78154. * Gather the list of pointer event types as constants.
  78155. */
  78156. export class PointerEventTypes {
  78157. /**
  78158. * 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.
  78159. */
  78160. static readonly POINTERDOWN: number;
  78161. /**
  78162. * The pointerup event is fired when a pointer is no longer active.
  78163. */
  78164. static readonly POINTERUP: number;
  78165. /**
  78166. * The pointermove event is fired when a pointer changes coordinates.
  78167. */
  78168. static readonly POINTERMOVE: number;
  78169. /**
  78170. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78171. */
  78172. static readonly POINTERWHEEL: number;
  78173. /**
  78174. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78175. */
  78176. static readonly POINTERPICK: number;
  78177. /**
  78178. * The pointertap event is fired when a the object has been touched and released without drag.
  78179. */
  78180. static readonly POINTERTAP: number;
  78181. /**
  78182. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78183. */
  78184. static readonly POINTERDOUBLETAP: number;
  78185. }
  78186. /**
  78187. * Base class of pointer info types.
  78188. */
  78189. export class PointerInfoBase {
  78190. /**
  78191. * Defines the type of event (PointerEventTypes)
  78192. */
  78193. type: number;
  78194. /**
  78195. * Defines the related dom event
  78196. */
  78197. event: PointerEvent | MouseWheelEvent;
  78198. /**
  78199. * Instantiates the base class of pointers info.
  78200. * @param type Defines the type of event (PointerEventTypes)
  78201. * @param event Defines the related dom event
  78202. */
  78203. constructor(
  78204. /**
  78205. * Defines the type of event (PointerEventTypes)
  78206. */
  78207. type: number,
  78208. /**
  78209. * Defines the related dom event
  78210. */
  78211. event: PointerEvent | MouseWheelEvent);
  78212. }
  78213. /**
  78214. * This class is used to store pointer related info for the onPrePointerObservable event.
  78215. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78216. */
  78217. export class PointerInfoPre extends PointerInfoBase {
  78218. /**
  78219. * Ray from a pointer if availible (eg. 6dof controller)
  78220. */
  78221. ray: Nullable<Ray>;
  78222. /**
  78223. * Defines the local position of the pointer on the canvas.
  78224. */
  78225. localPosition: Vector2;
  78226. /**
  78227. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78228. */
  78229. skipOnPointerObservable: boolean;
  78230. /**
  78231. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78232. * @param type Defines the type of event (PointerEventTypes)
  78233. * @param event Defines the related dom event
  78234. * @param localX Defines the local x coordinates of the pointer when the event occured
  78235. * @param localY Defines the local y coordinates of the pointer when the event occured
  78236. */
  78237. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78238. }
  78239. /**
  78240. * This type contains all the data related to a pointer event in Babylon.js.
  78241. * 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.
  78242. */
  78243. export class PointerInfo extends PointerInfoBase {
  78244. /**
  78245. * Defines the picking info associated to the info (if any)\
  78246. */
  78247. pickInfo: Nullable<PickingInfo>;
  78248. /**
  78249. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78250. * @param type Defines the type of event (PointerEventTypes)
  78251. * @param event Defines the related dom event
  78252. * @param pickInfo Defines the picking info associated to the info (if any)\
  78253. */
  78254. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78255. /**
  78256. * Defines the picking info associated to the info (if any)\
  78257. */
  78258. pickInfo: Nullable<PickingInfo>);
  78259. }
  78260. /**
  78261. * Data relating to a touch event on the screen.
  78262. */
  78263. export interface PointerTouch {
  78264. /**
  78265. * X coordinate of touch.
  78266. */
  78267. x: number;
  78268. /**
  78269. * Y coordinate of touch.
  78270. */
  78271. y: number;
  78272. /**
  78273. * Id of touch. Unique for each finger.
  78274. */
  78275. pointerId: number;
  78276. /**
  78277. * Event type passed from DOM.
  78278. */
  78279. type: any;
  78280. }
  78281. }
  78282. declare module BABYLON {
  78283. /**
  78284. * Manage the mouse inputs to control the movement of a free camera.
  78285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78286. */
  78287. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78288. /**
  78289. * Define if touch is enabled in the mouse input
  78290. */
  78291. touchEnabled: boolean;
  78292. /**
  78293. * Defines the camera the input is attached to.
  78294. */
  78295. camera: FreeCamera;
  78296. /**
  78297. * Defines the buttons associated with the input to handle camera move.
  78298. */
  78299. buttons: number[];
  78300. /**
  78301. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78302. */
  78303. angularSensibility: number;
  78304. private _pointerInput;
  78305. private _onMouseMove;
  78306. private _observer;
  78307. private previousPosition;
  78308. /**
  78309. * Observable for when a pointer move event occurs containing the move offset
  78310. */
  78311. onPointerMovedObservable: Observable<{
  78312. offsetX: number;
  78313. offsetY: number;
  78314. }>;
  78315. /**
  78316. * @hidden
  78317. * If the camera should be rotated automatically based on pointer movement
  78318. */
  78319. _allowCameraRotation: boolean;
  78320. /**
  78321. * Manage the mouse inputs to control the movement of a free camera.
  78322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78323. * @param touchEnabled Defines if touch is enabled or not
  78324. */
  78325. constructor(
  78326. /**
  78327. * Define if touch is enabled in the mouse input
  78328. */
  78329. touchEnabled?: boolean);
  78330. /**
  78331. * Attach the input controls to a specific dom element to get the input from.
  78332. * @param element Defines the element the controls should be listened from
  78333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78334. */
  78335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78336. /**
  78337. * Called on JS contextmenu event.
  78338. * Override this method to provide functionality.
  78339. */
  78340. protected onContextMenu(evt: PointerEvent): void;
  78341. /**
  78342. * Detach the current controls from the specified dom element.
  78343. * @param element Defines the element to stop listening the inputs from
  78344. */
  78345. detachControl(element: Nullable<HTMLElement>): void;
  78346. /**
  78347. * Gets the class name of the current intput.
  78348. * @returns the class name
  78349. */
  78350. getClassName(): string;
  78351. /**
  78352. * Get the friendly name associated with the input class.
  78353. * @returns the input friendly name
  78354. */
  78355. getSimpleName(): string;
  78356. }
  78357. }
  78358. declare module BABYLON {
  78359. /**
  78360. * Manage the touch inputs to control the movement of a free camera.
  78361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78362. */
  78363. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78364. /**
  78365. * Defines the camera the input is attached to.
  78366. */
  78367. camera: FreeCamera;
  78368. /**
  78369. * Defines the touch sensibility for rotation.
  78370. * The higher the faster.
  78371. */
  78372. touchAngularSensibility: number;
  78373. /**
  78374. * Defines the touch sensibility for move.
  78375. * The higher the faster.
  78376. */
  78377. touchMoveSensibility: number;
  78378. private _offsetX;
  78379. private _offsetY;
  78380. private _pointerPressed;
  78381. private _pointerInput;
  78382. private _observer;
  78383. private _onLostFocus;
  78384. /**
  78385. * Attach the input controls to a specific dom element to get the input from.
  78386. * @param element Defines the element the controls should be listened from
  78387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78388. */
  78389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78390. /**
  78391. * Detach the current controls from the specified dom element.
  78392. * @param element Defines the element to stop listening the inputs from
  78393. */
  78394. detachControl(element: Nullable<HTMLElement>): void;
  78395. /**
  78396. * Update the current camera state depending on the inputs that have been used this frame.
  78397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78398. */
  78399. checkInputs(): void;
  78400. /**
  78401. * Gets the class name of the current intput.
  78402. * @returns the class name
  78403. */
  78404. getClassName(): string;
  78405. /**
  78406. * Get the friendly name associated with the input class.
  78407. * @returns the input friendly name
  78408. */
  78409. getSimpleName(): string;
  78410. }
  78411. }
  78412. declare module BABYLON {
  78413. /**
  78414. * Default Inputs manager for the FreeCamera.
  78415. * It groups all the default supported inputs for ease of use.
  78416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78417. */
  78418. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78419. /**
  78420. * @hidden
  78421. */
  78422. _mouseInput: Nullable<FreeCameraMouseInput>;
  78423. /**
  78424. * Instantiates a new FreeCameraInputsManager.
  78425. * @param camera Defines the camera the inputs belong to
  78426. */
  78427. constructor(camera: FreeCamera);
  78428. /**
  78429. * Add keyboard input support to the input manager.
  78430. * @returns the current input manager
  78431. */
  78432. addKeyboard(): FreeCameraInputsManager;
  78433. /**
  78434. * Add mouse input support to the input manager.
  78435. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78436. * @returns the current input manager
  78437. */
  78438. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78439. /**
  78440. * Removes the mouse input support from the manager
  78441. * @returns the current input manager
  78442. */
  78443. removeMouse(): FreeCameraInputsManager;
  78444. /**
  78445. * Add touch input support to the input manager.
  78446. * @returns the current input manager
  78447. */
  78448. addTouch(): FreeCameraInputsManager;
  78449. /**
  78450. * Remove all attached input methods from a camera
  78451. */
  78452. clear(): void;
  78453. }
  78454. }
  78455. declare module BABYLON {
  78456. /**
  78457. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78458. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78460. */
  78461. export class FreeCamera extends TargetCamera {
  78462. /**
  78463. * Define the collision ellipsoid of the camera.
  78464. * This is helpful to simulate a camera body like the player body around the camera
  78465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78466. */
  78467. ellipsoid: Vector3;
  78468. /**
  78469. * Define an offset for the position of the ellipsoid around the camera.
  78470. * This can be helpful to determine the center of the body near the gravity center of the body
  78471. * instead of its head.
  78472. */
  78473. ellipsoidOffset: Vector3;
  78474. /**
  78475. * Enable or disable collisions of the camera with the rest of the scene objects.
  78476. */
  78477. checkCollisions: boolean;
  78478. /**
  78479. * Enable or disable gravity on the camera.
  78480. */
  78481. applyGravity: boolean;
  78482. /**
  78483. * Define the input manager associated to the camera.
  78484. */
  78485. inputs: FreeCameraInputsManager;
  78486. /**
  78487. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78488. * Higher values reduce sensitivity.
  78489. */
  78490. /**
  78491. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78492. * Higher values reduce sensitivity.
  78493. */
  78494. angularSensibility: number;
  78495. /**
  78496. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78497. */
  78498. keysUp: number[];
  78499. /**
  78500. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78501. */
  78502. keysDown: number[];
  78503. /**
  78504. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78505. */
  78506. keysLeft: number[];
  78507. /**
  78508. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78509. */
  78510. keysRight: number[];
  78511. /**
  78512. * Event raised when the camera collide with a mesh in the scene.
  78513. */
  78514. onCollide: (collidedMesh: AbstractMesh) => void;
  78515. private _collider;
  78516. private _needMoveForGravity;
  78517. private _oldPosition;
  78518. private _diffPosition;
  78519. private _newPosition;
  78520. /** @hidden */
  78521. _localDirection: Vector3;
  78522. /** @hidden */
  78523. _transformedDirection: Vector3;
  78524. /**
  78525. * Instantiates a Free Camera.
  78526. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78527. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78528. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78529. * @param name Define the name of the camera in the scene
  78530. * @param position Define the start position of the camera in the scene
  78531. * @param scene Define the scene the camera belongs to
  78532. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78533. */
  78534. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78535. /**
  78536. * Attached controls to the current camera.
  78537. * @param element Defines the element the controls should be listened from
  78538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78539. */
  78540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78541. /**
  78542. * Detach the current controls from the camera.
  78543. * The camera will stop reacting to inputs.
  78544. * @param element Defines the element to stop listening the inputs from
  78545. */
  78546. detachControl(element: HTMLElement): void;
  78547. private _collisionMask;
  78548. /**
  78549. * Define a collision mask to limit the list of object the camera can collide with
  78550. */
  78551. collisionMask: number;
  78552. /** @hidden */
  78553. _collideWithWorld(displacement: Vector3): void;
  78554. private _onCollisionPositionChange;
  78555. /** @hidden */
  78556. _checkInputs(): void;
  78557. /** @hidden */
  78558. _decideIfNeedsToMove(): boolean;
  78559. /** @hidden */
  78560. _updatePosition(): void;
  78561. /**
  78562. * Destroy the camera and release the current resources hold by it.
  78563. */
  78564. dispose(): void;
  78565. /**
  78566. * Gets the current object class name.
  78567. * @return the class name
  78568. */
  78569. getClassName(): string;
  78570. }
  78571. }
  78572. declare module BABYLON {
  78573. /**
  78574. * Represents a gamepad control stick position
  78575. */
  78576. export class StickValues {
  78577. /**
  78578. * The x component of the control stick
  78579. */
  78580. x: number;
  78581. /**
  78582. * The y component of the control stick
  78583. */
  78584. y: number;
  78585. /**
  78586. * Initializes the gamepad x and y control stick values
  78587. * @param x The x component of the gamepad control stick value
  78588. * @param y The y component of the gamepad control stick value
  78589. */
  78590. constructor(
  78591. /**
  78592. * The x component of the control stick
  78593. */
  78594. x: number,
  78595. /**
  78596. * The y component of the control stick
  78597. */
  78598. y: number);
  78599. }
  78600. /**
  78601. * An interface which manages callbacks for gamepad button changes
  78602. */
  78603. export interface GamepadButtonChanges {
  78604. /**
  78605. * Called when a gamepad has been changed
  78606. */
  78607. changed: boolean;
  78608. /**
  78609. * Called when a gamepad press event has been triggered
  78610. */
  78611. pressChanged: boolean;
  78612. /**
  78613. * Called when a touch event has been triggered
  78614. */
  78615. touchChanged: boolean;
  78616. /**
  78617. * Called when a value has changed
  78618. */
  78619. valueChanged: boolean;
  78620. }
  78621. /**
  78622. * Represents a gamepad
  78623. */
  78624. export class Gamepad {
  78625. /**
  78626. * The id of the gamepad
  78627. */
  78628. id: string;
  78629. /**
  78630. * The index of the gamepad
  78631. */
  78632. index: number;
  78633. /**
  78634. * The browser gamepad
  78635. */
  78636. browserGamepad: any;
  78637. /**
  78638. * Specifies what type of gamepad this represents
  78639. */
  78640. type: number;
  78641. private _leftStick;
  78642. private _rightStick;
  78643. /** @hidden */
  78644. _isConnected: boolean;
  78645. private _leftStickAxisX;
  78646. private _leftStickAxisY;
  78647. private _rightStickAxisX;
  78648. private _rightStickAxisY;
  78649. /**
  78650. * Triggered when the left control stick has been changed
  78651. */
  78652. private _onleftstickchanged;
  78653. /**
  78654. * Triggered when the right control stick has been changed
  78655. */
  78656. private _onrightstickchanged;
  78657. /**
  78658. * Represents a gamepad controller
  78659. */
  78660. static GAMEPAD: number;
  78661. /**
  78662. * Represents a generic controller
  78663. */
  78664. static GENERIC: number;
  78665. /**
  78666. * Represents an XBox controller
  78667. */
  78668. static XBOX: number;
  78669. /**
  78670. * Represents a pose-enabled controller
  78671. */
  78672. static POSE_ENABLED: number;
  78673. /**
  78674. * Represents an Dual Shock controller
  78675. */
  78676. static DUALSHOCK: number;
  78677. /**
  78678. * Specifies whether the left control stick should be Y-inverted
  78679. */
  78680. protected _invertLeftStickY: boolean;
  78681. /**
  78682. * Specifies if the gamepad has been connected
  78683. */
  78684. readonly isConnected: boolean;
  78685. /**
  78686. * Initializes the gamepad
  78687. * @param id The id of the gamepad
  78688. * @param index The index of the gamepad
  78689. * @param browserGamepad The browser gamepad
  78690. * @param leftStickX The x component of the left joystick
  78691. * @param leftStickY The y component of the left joystick
  78692. * @param rightStickX The x component of the right joystick
  78693. * @param rightStickY The y component of the right joystick
  78694. */
  78695. constructor(
  78696. /**
  78697. * The id of the gamepad
  78698. */
  78699. id: string,
  78700. /**
  78701. * The index of the gamepad
  78702. */
  78703. index: number,
  78704. /**
  78705. * The browser gamepad
  78706. */
  78707. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  78708. /**
  78709. * Callback triggered when the left joystick has changed
  78710. * @param callback
  78711. */
  78712. onleftstickchanged(callback: (values: StickValues) => void): void;
  78713. /**
  78714. * Callback triggered when the right joystick has changed
  78715. * @param callback
  78716. */
  78717. onrightstickchanged(callback: (values: StickValues) => void): void;
  78718. /**
  78719. * Gets the left joystick
  78720. */
  78721. /**
  78722. * Sets the left joystick values
  78723. */
  78724. leftStick: StickValues;
  78725. /**
  78726. * Gets the right joystick
  78727. */
  78728. /**
  78729. * Sets the right joystick value
  78730. */
  78731. rightStick: StickValues;
  78732. /**
  78733. * Updates the gamepad joystick positions
  78734. */
  78735. update(): void;
  78736. /**
  78737. * Disposes the gamepad
  78738. */
  78739. dispose(): void;
  78740. }
  78741. /**
  78742. * Represents a generic gamepad
  78743. */
  78744. export class GenericPad extends Gamepad {
  78745. private _buttons;
  78746. private _onbuttondown;
  78747. private _onbuttonup;
  78748. /**
  78749. * Observable triggered when a button has been pressed
  78750. */
  78751. onButtonDownObservable: Observable<number>;
  78752. /**
  78753. * Observable triggered when a button has been released
  78754. */
  78755. onButtonUpObservable: Observable<number>;
  78756. /**
  78757. * Callback triggered when a button has been pressed
  78758. * @param callback Called when a button has been pressed
  78759. */
  78760. onbuttondown(callback: (buttonPressed: number) => void): void;
  78761. /**
  78762. * Callback triggered when a button has been released
  78763. * @param callback Called when a button has been released
  78764. */
  78765. onbuttonup(callback: (buttonReleased: number) => void): void;
  78766. /**
  78767. * Initializes the generic gamepad
  78768. * @param id The id of the generic gamepad
  78769. * @param index The index of the generic gamepad
  78770. * @param browserGamepad The browser gamepad
  78771. */
  78772. constructor(id: string, index: number, browserGamepad: any);
  78773. private _setButtonValue;
  78774. /**
  78775. * Updates the generic gamepad
  78776. */
  78777. update(): void;
  78778. /**
  78779. * Disposes the generic gamepad
  78780. */
  78781. dispose(): void;
  78782. }
  78783. }
  78784. declare module BABYLON {
  78785. interface Engine {
  78786. /**
  78787. * Creates a raw texture
  78788. * @param data defines the data to store in the texture
  78789. * @param width defines the width of the texture
  78790. * @param height defines the height of the texture
  78791. * @param format defines the format of the data
  78792. * @param generateMipMaps defines if the engine should generate the mip levels
  78793. * @param invertY defines if data must be stored with Y axis inverted
  78794. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78795. * @param compression defines the compression used (null by default)
  78796. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78797. * @returns the raw texture inside an InternalTexture
  78798. */
  78799. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78800. /**
  78801. * Update a raw texture
  78802. * @param texture defines the texture to update
  78803. * @param data defines the data to store in the texture
  78804. * @param format defines the format of the data
  78805. * @param invertY defines if data must be stored with Y axis inverted
  78806. */
  78807. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78808. /**
  78809. * Update a raw texture
  78810. * @param texture defines the texture to update
  78811. * @param data defines the data to store in the texture
  78812. * @param format defines the format of the data
  78813. * @param invertY defines if data must be stored with Y axis inverted
  78814. * @param compression defines the compression used (null by default)
  78815. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78816. */
  78817. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78818. /**
  78819. * Creates a new raw cube texture
  78820. * @param data defines the array of data to use to create each face
  78821. * @param size defines the size of the textures
  78822. * @param format defines the format of the data
  78823. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78824. * @param generateMipMaps defines if the engine should generate the mip levels
  78825. * @param invertY defines if data must be stored with Y axis inverted
  78826. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78827. * @param compression defines the compression used (null by default)
  78828. * @returns the cube texture as an InternalTexture
  78829. */
  78830. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78831. /**
  78832. * Update a raw cube texture
  78833. * @param texture defines the texture to udpdate
  78834. * @param data defines the data to store
  78835. * @param format defines the data format
  78836. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78837. * @param invertY defines if data must be stored with Y axis inverted
  78838. */
  78839. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78840. /**
  78841. * Update a raw cube texture
  78842. * @param texture defines the texture to udpdate
  78843. * @param data defines the data to store
  78844. * @param format defines the data format
  78845. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78846. * @param invertY defines if data must be stored with Y axis inverted
  78847. * @param compression defines the compression used (null by default)
  78848. */
  78849. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78850. /**
  78851. * Update a raw cube texture
  78852. * @param texture defines the texture to udpdate
  78853. * @param data defines the data to store
  78854. * @param format defines the data format
  78855. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78856. * @param invertY defines if data must be stored with Y axis inverted
  78857. * @param compression defines the compression used (null by default)
  78858. * @param level defines which level of the texture to update
  78859. */
  78860. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78861. /**
  78862. * Creates a new raw cube texture from a specified url
  78863. * @param url defines the url where the data is located
  78864. * @param scene defines the current scene
  78865. * @param size defines the size of the textures
  78866. * @param format defines the format of the data
  78867. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78868. * @param noMipmap defines if the engine should avoid generating the mip levels
  78869. * @param callback defines a callback used to extract texture data from loaded data
  78870. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78871. * @param onLoad defines a callback called when texture is loaded
  78872. * @param onError defines a callback called if there is an error
  78873. * @returns the cube texture as an InternalTexture
  78874. */
  78875. 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;
  78876. /**
  78877. * Creates a new raw cube texture from a specified url
  78878. * @param url defines the url where the data is located
  78879. * @param scene defines the current scene
  78880. * @param size defines the size of the textures
  78881. * @param format defines the format of the data
  78882. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78883. * @param noMipmap defines if the engine should avoid generating the mip levels
  78884. * @param callback defines a callback used to extract texture data from loaded data
  78885. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78886. * @param onLoad defines a callback called when texture is loaded
  78887. * @param onError defines a callback called if there is an error
  78888. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78889. * @param invertY defines if data must be stored with Y axis inverted
  78890. * @returns the cube texture as an InternalTexture
  78891. */
  78892. 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;
  78893. /**
  78894. * Creates a new raw 3D texture
  78895. * @param data defines the data used to create the texture
  78896. * @param width defines the width of the texture
  78897. * @param height defines the height of the texture
  78898. * @param depth defines the depth of the texture
  78899. * @param format defines the format of the texture
  78900. * @param generateMipMaps defines if the engine must generate mip levels
  78901. * @param invertY defines if data must be stored with Y axis inverted
  78902. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78903. * @param compression defines the compressed used (can be null)
  78904. * @param textureType defines the compressed used (can be null)
  78905. * @returns a new raw 3D texture (stored in an InternalTexture)
  78906. */
  78907. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78908. /**
  78909. * Update a raw 3D texture
  78910. * @param texture defines the texture to update
  78911. * @param data defines the data to store
  78912. * @param format defines the data format
  78913. * @param invertY defines if data must be stored with Y axis inverted
  78914. */
  78915. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78916. /**
  78917. * Update a raw 3D texture
  78918. * @param texture defines the texture to update
  78919. * @param data defines the data to store
  78920. * @param format defines the data format
  78921. * @param invertY defines if data must be stored with Y axis inverted
  78922. * @param compression defines the used compression (can be null)
  78923. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78924. */
  78925. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78926. }
  78927. }
  78928. declare module BABYLON {
  78929. /**
  78930. * Raw texture can help creating a texture directly from an array of data.
  78931. * This can be super useful if you either get the data from an uncompressed source or
  78932. * if you wish to create your texture pixel by pixel.
  78933. */
  78934. export class RawTexture extends Texture {
  78935. /**
  78936. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78937. */
  78938. format: number;
  78939. private _engine;
  78940. /**
  78941. * Instantiates a new RawTexture.
  78942. * Raw texture can help creating a texture directly from an array of data.
  78943. * This can be super useful if you either get the data from an uncompressed source or
  78944. * if you wish to create your texture pixel by pixel.
  78945. * @param data define the array of data to use to create the texture
  78946. * @param width define the width of the texture
  78947. * @param height define the height of the texture
  78948. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78949. * @param scene define the scene the texture belongs to
  78950. * @param generateMipMaps define whether mip maps should be generated or not
  78951. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78952. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78953. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78954. */
  78955. constructor(data: ArrayBufferView, width: number, height: number,
  78956. /**
  78957. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78958. */
  78959. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78960. /**
  78961. * Updates the texture underlying data.
  78962. * @param data Define the new data of the texture
  78963. */
  78964. update(data: ArrayBufferView): void;
  78965. /**
  78966. * Creates a luminance texture from some data.
  78967. * @param data Define the texture data
  78968. * @param width Define the width of the texture
  78969. * @param height Define the height of the texture
  78970. * @param scene Define the scene the texture belongs to
  78971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78974. * @returns the luminance texture
  78975. */
  78976. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78977. /**
  78978. * Creates a luminance alpha texture from some data.
  78979. * @param data Define the texture data
  78980. * @param width Define the width of the texture
  78981. * @param height Define the height of the texture
  78982. * @param scene Define the scene the texture belongs to
  78983. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78984. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78985. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78986. * @returns the luminance alpha texture
  78987. */
  78988. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78989. /**
  78990. * Creates an alpha texture from some data.
  78991. * @param data Define the texture data
  78992. * @param width Define the width of the texture
  78993. * @param height Define the height of the texture
  78994. * @param scene Define the scene the texture belongs to
  78995. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78996. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78997. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78998. * @returns the alpha texture
  78999. */
  79000. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79001. /**
  79002. * Creates a RGB texture from some data.
  79003. * @param data Define the texture data
  79004. * @param width Define the width of the texture
  79005. * @param height Define the height of the texture
  79006. * @param scene Define the scene the texture belongs to
  79007. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79008. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79009. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79010. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79011. * @returns the RGB alpha texture
  79012. */
  79013. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79014. /**
  79015. * Creates a RGBA texture from some data.
  79016. * @param data Define the texture data
  79017. * @param width Define the width of the texture
  79018. * @param height Define the height of the texture
  79019. * @param scene Define the scene the texture belongs to
  79020. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79021. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79022. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79023. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79024. * @returns the RGBA texture
  79025. */
  79026. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79027. /**
  79028. * Creates a R texture from some data.
  79029. * @param data Define the texture data
  79030. * @param width Define the width of the texture
  79031. * @param height Define the height of the texture
  79032. * @param scene Define the scene the texture belongs to
  79033. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79034. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79035. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79036. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79037. * @returns the R texture
  79038. */
  79039. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79040. }
  79041. }
  79042. declare module BABYLON {
  79043. /**
  79044. * Interface for the size containing width and height
  79045. */
  79046. export interface ISize {
  79047. /**
  79048. * Width
  79049. */
  79050. width: number;
  79051. /**
  79052. * Heighht
  79053. */
  79054. height: number;
  79055. }
  79056. /**
  79057. * Size containing widht and height
  79058. */
  79059. export class Size implements ISize {
  79060. /**
  79061. * Width
  79062. */
  79063. width: number;
  79064. /**
  79065. * Height
  79066. */
  79067. height: number;
  79068. /**
  79069. * Creates a Size object from the given width and height (floats).
  79070. * @param width width of the new size
  79071. * @param height height of the new size
  79072. */
  79073. constructor(width: number, height: number);
  79074. /**
  79075. * Returns a string with the Size width and height
  79076. * @returns a string with the Size width and height
  79077. */
  79078. toString(): string;
  79079. /**
  79080. * "Size"
  79081. * @returns the string "Size"
  79082. */
  79083. getClassName(): string;
  79084. /**
  79085. * Returns the Size hash code.
  79086. * @returns a hash code for a unique width and height
  79087. */
  79088. getHashCode(): number;
  79089. /**
  79090. * Updates the current size from the given one.
  79091. * @param src the given size
  79092. */
  79093. copyFrom(src: Size): void;
  79094. /**
  79095. * Updates in place the current Size from the given floats.
  79096. * @param width width of the new size
  79097. * @param height height of the new size
  79098. * @returns the updated Size.
  79099. */
  79100. copyFromFloats(width: number, height: number): Size;
  79101. /**
  79102. * Updates in place the current Size from the given floats.
  79103. * @param width width to set
  79104. * @param height height to set
  79105. * @returns the updated Size.
  79106. */
  79107. set(width: number, height: number): Size;
  79108. /**
  79109. * Multiplies the width and height by numbers
  79110. * @param w factor to multiple the width by
  79111. * @param h factor to multiple the height by
  79112. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79113. */
  79114. multiplyByFloats(w: number, h: number): Size;
  79115. /**
  79116. * Clones the size
  79117. * @returns a new Size copied from the given one.
  79118. */
  79119. clone(): Size;
  79120. /**
  79121. * True if the current Size and the given one width and height are strictly equal.
  79122. * @param other the other size to compare against
  79123. * @returns True if the current Size and the given one width and height are strictly equal.
  79124. */
  79125. equals(other: Size): boolean;
  79126. /**
  79127. * The surface of the Size : width * height (float).
  79128. */
  79129. readonly surface: number;
  79130. /**
  79131. * Create a new size of zero
  79132. * @returns a new Size set to (0.0, 0.0)
  79133. */
  79134. static Zero(): Size;
  79135. /**
  79136. * Sums the width and height of two sizes
  79137. * @param otherSize size to add to this size
  79138. * @returns a new Size set as the addition result of the current Size and the given one.
  79139. */
  79140. add(otherSize: Size): Size;
  79141. /**
  79142. * Subtracts the width and height of two
  79143. * @param otherSize size to subtract to this size
  79144. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79145. */
  79146. subtract(otherSize: Size): Size;
  79147. /**
  79148. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79149. * @param start starting size to lerp between
  79150. * @param end end size to lerp between
  79151. * @param amount amount to lerp between the start and end values
  79152. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79153. */
  79154. static Lerp(start: Size, end: Size, amount: number): Size;
  79155. }
  79156. }
  79157. declare module BABYLON {
  79158. /**
  79159. * Defines a runtime animation
  79160. */
  79161. export class RuntimeAnimation {
  79162. private _events;
  79163. /**
  79164. * The current frame of the runtime animation
  79165. */
  79166. private _currentFrame;
  79167. /**
  79168. * The animation used by the runtime animation
  79169. */
  79170. private _animation;
  79171. /**
  79172. * The target of the runtime animation
  79173. */
  79174. private _target;
  79175. /**
  79176. * The initiating animatable
  79177. */
  79178. private _host;
  79179. /**
  79180. * The original value of the runtime animation
  79181. */
  79182. private _originalValue;
  79183. /**
  79184. * The original blend value of the runtime animation
  79185. */
  79186. private _originalBlendValue;
  79187. /**
  79188. * The offsets cache of the runtime animation
  79189. */
  79190. private _offsetsCache;
  79191. /**
  79192. * The high limits cache of the runtime animation
  79193. */
  79194. private _highLimitsCache;
  79195. /**
  79196. * Specifies if the runtime animation has been stopped
  79197. */
  79198. private _stopped;
  79199. /**
  79200. * The blending factor of the runtime animation
  79201. */
  79202. private _blendingFactor;
  79203. /**
  79204. * The BabylonJS scene
  79205. */
  79206. private _scene;
  79207. /**
  79208. * The current value of the runtime animation
  79209. */
  79210. private _currentValue;
  79211. /** @hidden */
  79212. _animationState: _IAnimationState;
  79213. /**
  79214. * The active target of the runtime animation
  79215. */
  79216. private _activeTargets;
  79217. private _currentActiveTarget;
  79218. private _directTarget;
  79219. /**
  79220. * The target path of the runtime animation
  79221. */
  79222. private _targetPath;
  79223. /**
  79224. * The weight of the runtime animation
  79225. */
  79226. private _weight;
  79227. /**
  79228. * The ratio offset of the runtime animation
  79229. */
  79230. private _ratioOffset;
  79231. /**
  79232. * The previous delay of the runtime animation
  79233. */
  79234. private _previousDelay;
  79235. /**
  79236. * The previous ratio of the runtime animation
  79237. */
  79238. private _previousRatio;
  79239. private _enableBlending;
  79240. private _keys;
  79241. private _minFrame;
  79242. private _maxFrame;
  79243. private _minValue;
  79244. private _maxValue;
  79245. private _targetIsArray;
  79246. /**
  79247. * Gets the current frame of the runtime animation
  79248. */
  79249. readonly currentFrame: number;
  79250. /**
  79251. * Gets the weight of the runtime animation
  79252. */
  79253. readonly weight: number;
  79254. /**
  79255. * Gets the current value of the runtime animation
  79256. */
  79257. readonly currentValue: any;
  79258. /**
  79259. * Gets the target path of the runtime animation
  79260. */
  79261. readonly targetPath: string;
  79262. /**
  79263. * Gets the actual target of the runtime animation
  79264. */
  79265. readonly target: any;
  79266. /** @hidden */
  79267. _onLoop: () => void;
  79268. /**
  79269. * Create a new RuntimeAnimation object
  79270. * @param target defines the target of the animation
  79271. * @param animation defines the source animation object
  79272. * @param scene defines the hosting scene
  79273. * @param host defines the initiating Animatable
  79274. */
  79275. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79276. private _preparePath;
  79277. /**
  79278. * Gets the animation from the runtime animation
  79279. */
  79280. readonly animation: Animation;
  79281. /**
  79282. * Resets the runtime animation to the beginning
  79283. * @param restoreOriginal defines whether to restore the target property to the original value
  79284. */
  79285. reset(restoreOriginal?: boolean): void;
  79286. /**
  79287. * Specifies if the runtime animation is stopped
  79288. * @returns Boolean specifying if the runtime animation is stopped
  79289. */
  79290. isStopped(): boolean;
  79291. /**
  79292. * Disposes of the runtime animation
  79293. */
  79294. dispose(): void;
  79295. /**
  79296. * Apply the interpolated value to the target
  79297. * @param currentValue defines the value computed by the animation
  79298. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79299. */
  79300. setValue(currentValue: any, weight: number): void;
  79301. private _getOriginalValues;
  79302. private _setValue;
  79303. /**
  79304. * Gets the loop pmode of the runtime animation
  79305. * @returns Loop Mode
  79306. */
  79307. private _getCorrectLoopMode;
  79308. /**
  79309. * Move the current animation to a given frame
  79310. * @param frame defines the frame to move to
  79311. */
  79312. goToFrame(frame: number): void;
  79313. /**
  79314. * @hidden Internal use only
  79315. */
  79316. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79317. /**
  79318. * Execute the current animation
  79319. * @param delay defines the delay to add to the current frame
  79320. * @param from defines the lower bound of the animation range
  79321. * @param to defines the upper bound of the animation range
  79322. * @param loop defines if the current animation must loop
  79323. * @param speedRatio defines the current speed ratio
  79324. * @param weight defines the weight of the animation (default is -1 so no weight)
  79325. * @param onLoop optional callback called when animation loops
  79326. * @returns a boolean indicating if the animation is running
  79327. */
  79328. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79329. }
  79330. }
  79331. declare module BABYLON {
  79332. /**
  79333. * Class used to store an actual running animation
  79334. */
  79335. export class Animatable {
  79336. /** defines the target object */
  79337. target: any;
  79338. /** defines the starting frame number (default is 0) */
  79339. fromFrame: number;
  79340. /** defines the ending frame number (default is 100) */
  79341. toFrame: number;
  79342. /** defines if the animation must loop (default is false) */
  79343. loopAnimation: boolean;
  79344. /** defines a callback to call when animation ends if it is not looping */
  79345. onAnimationEnd?: (() => void) | null | undefined;
  79346. /** defines a callback to call when animation loops */
  79347. onAnimationLoop?: (() => void) | null | undefined;
  79348. private _localDelayOffset;
  79349. private _pausedDelay;
  79350. private _runtimeAnimations;
  79351. private _paused;
  79352. private _scene;
  79353. private _speedRatio;
  79354. private _weight;
  79355. private _syncRoot;
  79356. /**
  79357. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79358. * This will only apply for non looping animation (default is true)
  79359. */
  79360. disposeOnEnd: boolean;
  79361. /**
  79362. * Gets a boolean indicating if the animation has started
  79363. */
  79364. animationStarted: boolean;
  79365. /**
  79366. * Observer raised when the animation ends
  79367. */
  79368. onAnimationEndObservable: Observable<Animatable>;
  79369. /**
  79370. * Observer raised when the animation loops
  79371. */
  79372. onAnimationLoopObservable: Observable<Animatable>;
  79373. /**
  79374. * Gets the root Animatable used to synchronize and normalize animations
  79375. */
  79376. readonly syncRoot: Nullable<Animatable>;
  79377. /**
  79378. * Gets the current frame of the first RuntimeAnimation
  79379. * Used to synchronize Animatables
  79380. */
  79381. readonly masterFrame: number;
  79382. /**
  79383. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79384. */
  79385. weight: number;
  79386. /**
  79387. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79388. */
  79389. speedRatio: number;
  79390. /**
  79391. * Creates a new Animatable
  79392. * @param scene defines the hosting scene
  79393. * @param target defines the target object
  79394. * @param fromFrame defines the starting frame number (default is 0)
  79395. * @param toFrame defines the ending frame number (default is 100)
  79396. * @param loopAnimation defines if the animation must loop (default is false)
  79397. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79398. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79399. * @param animations defines a group of animation to add to the new Animatable
  79400. * @param onAnimationLoop defines a callback to call when animation loops
  79401. */
  79402. constructor(scene: Scene,
  79403. /** defines the target object */
  79404. target: any,
  79405. /** defines the starting frame number (default is 0) */
  79406. fromFrame?: number,
  79407. /** defines the ending frame number (default is 100) */
  79408. toFrame?: number,
  79409. /** defines if the animation must loop (default is false) */
  79410. loopAnimation?: boolean, speedRatio?: number,
  79411. /** defines a callback to call when animation ends if it is not looping */
  79412. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79413. /** defines a callback to call when animation loops */
  79414. onAnimationLoop?: (() => void) | null | undefined);
  79415. /**
  79416. * Synchronize and normalize current Animatable with a source Animatable
  79417. * This is useful when using animation weights and when animations are not of the same length
  79418. * @param root defines the root Animatable to synchronize with
  79419. * @returns the current Animatable
  79420. */
  79421. syncWith(root: Animatable): Animatable;
  79422. /**
  79423. * Gets the list of runtime animations
  79424. * @returns an array of RuntimeAnimation
  79425. */
  79426. getAnimations(): RuntimeAnimation[];
  79427. /**
  79428. * Adds more animations to the current animatable
  79429. * @param target defines the target of the animations
  79430. * @param animations defines the new animations to add
  79431. */
  79432. appendAnimations(target: any, animations: Animation[]): void;
  79433. /**
  79434. * Gets the source animation for a specific property
  79435. * @param property defines the propertyu to look for
  79436. * @returns null or the source animation for the given property
  79437. */
  79438. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79439. /**
  79440. * Gets the runtime animation for a specific property
  79441. * @param property defines the propertyu to look for
  79442. * @returns null or the runtime animation for the given property
  79443. */
  79444. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79445. /**
  79446. * Resets the animatable to its original state
  79447. */
  79448. reset(): void;
  79449. /**
  79450. * Allows the animatable to blend with current running animations
  79451. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79452. * @param blendingSpeed defines the blending speed to use
  79453. */
  79454. enableBlending(blendingSpeed: number): void;
  79455. /**
  79456. * Disable animation blending
  79457. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79458. */
  79459. disableBlending(): void;
  79460. /**
  79461. * Jump directly to a given frame
  79462. * @param frame defines the frame to jump to
  79463. */
  79464. goToFrame(frame: number): void;
  79465. /**
  79466. * Pause the animation
  79467. */
  79468. pause(): void;
  79469. /**
  79470. * Restart the animation
  79471. */
  79472. restart(): void;
  79473. private _raiseOnAnimationEnd;
  79474. /**
  79475. * Stop and delete the current animation
  79476. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79477. * @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)
  79478. */
  79479. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79480. /**
  79481. * Wait asynchronously for the animation to end
  79482. * @returns a promise which will be fullfilled when the animation ends
  79483. */
  79484. waitAsync(): Promise<Animatable>;
  79485. /** @hidden */
  79486. _animate(delay: number): boolean;
  79487. }
  79488. interface Scene {
  79489. /** @hidden */
  79490. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79491. /** @hidden */
  79492. _processLateAnimationBindingsForMatrices(holder: {
  79493. totalWeight: number;
  79494. animations: RuntimeAnimation[];
  79495. originalValue: Matrix;
  79496. }): any;
  79497. /** @hidden */
  79498. _processLateAnimationBindingsForQuaternions(holder: {
  79499. totalWeight: number;
  79500. animations: RuntimeAnimation[];
  79501. originalValue: Quaternion;
  79502. }, refQuaternion: Quaternion): Quaternion;
  79503. /** @hidden */
  79504. _processLateAnimationBindings(): void;
  79505. /**
  79506. * Will start the animation sequence of a given target
  79507. * @param target defines the target
  79508. * @param from defines from which frame should animation start
  79509. * @param to defines until which frame should animation run.
  79510. * @param weight defines the weight to apply to the animation (1.0 by default)
  79511. * @param loop defines if the animation loops
  79512. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79513. * @param onAnimationEnd defines the function to be executed when the animation ends
  79514. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79515. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79516. * @param onAnimationLoop defines the callback to call when an animation loops
  79517. * @returns the animatable object created for this animation
  79518. */
  79519. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79520. /**
  79521. * Will start the animation sequence of a given target
  79522. * @param target defines the target
  79523. * @param from defines from which frame should animation start
  79524. * @param to defines until which frame should animation run.
  79525. * @param loop defines if the animation loops
  79526. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79527. * @param onAnimationEnd defines the function to be executed when the animation ends
  79528. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79529. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79530. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79531. * @param onAnimationLoop defines the callback to call when an animation loops
  79532. * @returns the animatable object created for this animation
  79533. */
  79534. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79535. /**
  79536. * Will start the animation sequence of a given target and its hierarchy
  79537. * @param target defines the target
  79538. * @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.
  79539. * @param from defines from which frame should animation start
  79540. * @param to defines until which frame should animation run.
  79541. * @param loop defines if the animation loops
  79542. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79543. * @param onAnimationEnd defines the function to be executed when the animation ends
  79544. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79545. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79546. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79547. * @param onAnimationLoop defines the callback to call when an animation loops
  79548. * @returns the list of created animatables
  79549. */
  79550. 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[];
  79551. /**
  79552. * Begin a new animation on a given node
  79553. * @param target defines the target where the animation will take place
  79554. * @param animations defines the list of animations to start
  79555. * @param from defines the initial value
  79556. * @param to defines the final value
  79557. * @param loop defines if you want animation to loop (off by default)
  79558. * @param speedRatio defines the speed ratio to apply to all animations
  79559. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79560. * @param onAnimationLoop defines the callback to call when an animation loops
  79561. * @returns the list of created animatables
  79562. */
  79563. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79564. /**
  79565. * Begin a new animation on a given node and its hierarchy
  79566. * @param target defines the root node where the animation will take place
  79567. * @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.
  79568. * @param animations defines the list of animations to start
  79569. * @param from defines the initial value
  79570. * @param to defines the final value
  79571. * @param loop defines if you want animation to loop (off by default)
  79572. * @param speedRatio defines the speed ratio to apply to all animations
  79573. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79574. * @param onAnimationLoop defines the callback to call when an animation loops
  79575. * @returns the list of animatables created for all nodes
  79576. */
  79577. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79578. /**
  79579. * Gets the animatable associated with a specific target
  79580. * @param target defines the target of the animatable
  79581. * @returns the required animatable if found
  79582. */
  79583. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79584. /**
  79585. * Gets all animatables associated with a given target
  79586. * @param target defines the target to look animatables for
  79587. * @returns an array of Animatables
  79588. */
  79589. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79590. /**
  79591. * Stops and removes all animations that have been applied to the scene
  79592. */
  79593. stopAllAnimations(): void;
  79594. }
  79595. interface Bone {
  79596. /**
  79597. * Copy an animation range from another bone
  79598. * @param source defines the source bone
  79599. * @param rangeName defines the range name to copy
  79600. * @param frameOffset defines the frame offset
  79601. * @param rescaleAsRequired defines if rescaling must be applied if required
  79602. * @param skelDimensionsRatio defines the scaling ratio
  79603. * @returns true if operation was successful
  79604. */
  79605. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79606. }
  79607. }
  79608. declare module BABYLON {
  79609. /**
  79610. * Class used to override all child animations of a given target
  79611. */
  79612. export class AnimationPropertiesOverride {
  79613. /**
  79614. * Gets or sets a value indicating if animation blending must be used
  79615. */
  79616. enableBlending: boolean;
  79617. /**
  79618. * Gets or sets the blending speed to use when enableBlending is true
  79619. */
  79620. blendingSpeed: number;
  79621. /**
  79622. * Gets or sets the default loop mode to use
  79623. */
  79624. loopMode: number;
  79625. }
  79626. }
  79627. declare module BABYLON {
  79628. /**
  79629. * Class used to handle skinning animations
  79630. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79631. */
  79632. export class Skeleton implements IAnimatable {
  79633. /** defines the skeleton name */
  79634. name: string;
  79635. /** defines the skeleton Id */
  79636. id: string;
  79637. /**
  79638. * Defines the list of child bones
  79639. */
  79640. bones: Bone[];
  79641. /**
  79642. * Defines an estimate of the dimension of the skeleton at rest
  79643. */
  79644. dimensionsAtRest: Vector3;
  79645. /**
  79646. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79647. */
  79648. needInitialSkinMatrix: boolean;
  79649. /**
  79650. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79651. */
  79652. overrideMesh: Nullable<AbstractMesh>;
  79653. /**
  79654. * Gets the list of animations attached to this skeleton
  79655. */
  79656. animations: Array<Animation>;
  79657. private _scene;
  79658. private _isDirty;
  79659. private _transformMatrices;
  79660. private _transformMatrixTexture;
  79661. private _meshesWithPoseMatrix;
  79662. private _animatables;
  79663. private _identity;
  79664. private _synchronizedWithMesh;
  79665. private _ranges;
  79666. private _lastAbsoluteTransformsUpdateId;
  79667. private _canUseTextureForBones;
  79668. private _uniqueId;
  79669. /** @hidden */
  79670. _numBonesWithLinkedTransformNode: number;
  79671. /** @hidden */
  79672. _hasWaitingData: Nullable<boolean>;
  79673. /**
  79674. * Specifies if the skeleton should be serialized
  79675. */
  79676. doNotSerialize: boolean;
  79677. private _useTextureToStoreBoneMatrices;
  79678. /**
  79679. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79680. * Please note that this option is not available if the hardware does not support it
  79681. */
  79682. useTextureToStoreBoneMatrices: boolean;
  79683. private _animationPropertiesOverride;
  79684. /**
  79685. * Gets or sets the animation properties override
  79686. */
  79687. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79688. /**
  79689. * List of inspectable custom properties (used by the Inspector)
  79690. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79691. */
  79692. inspectableCustomProperties: IInspectable[];
  79693. /**
  79694. * An observable triggered before computing the skeleton's matrices
  79695. */
  79696. onBeforeComputeObservable: Observable<Skeleton>;
  79697. /**
  79698. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79699. */
  79700. readonly isUsingTextureForMatrices: boolean;
  79701. /**
  79702. * Gets the unique ID of this skeleton
  79703. */
  79704. readonly uniqueId: number;
  79705. /**
  79706. * Creates a new skeleton
  79707. * @param name defines the skeleton name
  79708. * @param id defines the skeleton Id
  79709. * @param scene defines the hosting scene
  79710. */
  79711. constructor(
  79712. /** defines the skeleton name */
  79713. name: string,
  79714. /** defines the skeleton Id */
  79715. id: string, scene: Scene);
  79716. /**
  79717. * Gets the current object class name.
  79718. * @return the class name
  79719. */
  79720. getClassName(): string;
  79721. /**
  79722. * Returns an array containing the root bones
  79723. * @returns an array containing the root bones
  79724. */
  79725. getChildren(): Array<Bone>;
  79726. /**
  79727. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79728. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79729. * @returns a Float32Array containing matrices data
  79730. */
  79731. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79732. /**
  79733. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79734. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79735. * @returns a raw texture containing the data
  79736. */
  79737. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79738. /**
  79739. * Gets the current hosting scene
  79740. * @returns a scene object
  79741. */
  79742. getScene(): Scene;
  79743. /**
  79744. * Gets a string representing the current skeleton data
  79745. * @param fullDetails defines a boolean indicating if we want a verbose version
  79746. * @returns a string representing the current skeleton data
  79747. */
  79748. toString(fullDetails?: boolean): string;
  79749. /**
  79750. * Get bone's index searching by name
  79751. * @param name defines bone's name to search for
  79752. * @return the indice of the bone. Returns -1 if not found
  79753. */
  79754. getBoneIndexByName(name: string): number;
  79755. /**
  79756. * Creater a new animation range
  79757. * @param name defines the name of the range
  79758. * @param from defines the start key
  79759. * @param to defines the end key
  79760. */
  79761. createAnimationRange(name: string, from: number, to: number): void;
  79762. /**
  79763. * Delete a specific animation range
  79764. * @param name defines the name of the range
  79765. * @param deleteFrames defines if frames must be removed as well
  79766. */
  79767. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79768. /**
  79769. * Gets a specific animation range
  79770. * @param name defines the name of the range to look for
  79771. * @returns the requested animation range or null if not found
  79772. */
  79773. getAnimationRange(name: string): Nullable<AnimationRange>;
  79774. /**
  79775. * Gets the list of all animation ranges defined on this skeleton
  79776. * @returns an array
  79777. */
  79778. getAnimationRanges(): Nullable<AnimationRange>[];
  79779. /**
  79780. * Copy animation range from a source skeleton.
  79781. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79782. * @param source defines the source skeleton
  79783. * @param name defines the name of the range to copy
  79784. * @param rescaleAsRequired defines if rescaling must be applied if required
  79785. * @returns true if operation was successful
  79786. */
  79787. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79788. /**
  79789. * Forces the skeleton to go to rest pose
  79790. */
  79791. returnToRest(): void;
  79792. private _getHighestAnimationFrame;
  79793. /**
  79794. * Begin a specific animation range
  79795. * @param name defines the name of the range to start
  79796. * @param loop defines if looping must be turned on (false by default)
  79797. * @param speedRatio defines the speed ratio to apply (1 by default)
  79798. * @param onAnimationEnd defines a callback which will be called when animation will end
  79799. * @returns a new animatable
  79800. */
  79801. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79802. /** @hidden */
  79803. _markAsDirty(): void;
  79804. /** @hidden */
  79805. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79806. /** @hidden */
  79807. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79808. private _computeTransformMatrices;
  79809. /**
  79810. * Build all resources required to render a skeleton
  79811. */
  79812. prepare(): void;
  79813. /**
  79814. * Gets the list of animatables currently running for this skeleton
  79815. * @returns an array of animatables
  79816. */
  79817. getAnimatables(): IAnimatable[];
  79818. /**
  79819. * Clone the current skeleton
  79820. * @param name defines the name of the new skeleton
  79821. * @param id defines the id of the new skeleton
  79822. * @returns the new skeleton
  79823. */
  79824. clone(name: string, id: string): Skeleton;
  79825. /**
  79826. * Enable animation blending for this skeleton
  79827. * @param blendingSpeed defines the blending speed to apply
  79828. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79829. */
  79830. enableBlending(blendingSpeed?: number): void;
  79831. /**
  79832. * Releases all resources associated with the current skeleton
  79833. */
  79834. dispose(): void;
  79835. /**
  79836. * Serialize the skeleton in a JSON object
  79837. * @returns a JSON object
  79838. */
  79839. serialize(): any;
  79840. /**
  79841. * Creates a new skeleton from serialized data
  79842. * @param parsedSkeleton defines the serialized data
  79843. * @param scene defines the hosting scene
  79844. * @returns a new skeleton
  79845. */
  79846. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79847. /**
  79848. * Compute all node absolute transforms
  79849. * @param forceUpdate defines if computation must be done even if cache is up to date
  79850. */
  79851. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79852. /**
  79853. * Gets the root pose matrix
  79854. * @returns a matrix
  79855. */
  79856. getPoseMatrix(): Nullable<Matrix>;
  79857. /**
  79858. * Sorts bones per internal index
  79859. */
  79860. sortBones(): void;
  79861. private _sortBones;
  79862. }
  79863. }
  79864. declare module BABYLON {
  79865. /**
  79866. * Class used to store bone information
  79867. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79868. */
  79869. export class Bone extends Node {
  79870. /**
  79871. * defines the bone name
  79872. */
  79873. name: string;
  79874. private static _tmpVecs;
  79875. private static _tmpQuat;
  79876. private static _tmpMats;
  79877. /**
  79878. * Gets the list of child bones
  79879. */
  79880. children: Bone[];
  79881. /** Gets the animations associated with this bone */
  79882. animations: Animation[];
  79883. /**
  79884. * Gets or sets bone length
  79885. */
  79886. length: number;
  79887. /**
  79888. * @hidden Internal only
  79889. * Set this value to map this bone to a different index in the transform matrices
  79890. * Set this value to -1 to exclude the bone from the transform matrices
  79891. */
  79892. _index: Nullable<number>;
  79893. private _skeleton;
  79894. private _localMatrix;
  79895. private _restPose;
  79896. private _baseMatrix;
  79897. private _absoluteTransform;
  79898. private _invertedAbsoluteTransform;
  79899. private _parent;
  79900. private _scalingDeterminant;
  79901. private _worldTransform;
  79902. private _localScaling;
  79903. private _localRotation;
  79904. private _localPosition;
  79905. private _needToDecompose;
  79906. private _needToCompose;
  79907. /** @hidden */
  79908. _linkedTransformNode: Nullable<TransformNode>;
  79909. /** @hidden */
  79910. _waitingTransformNodeId: Nullable<string>;
  79911. /** @hidden */
  79912. /** @hidden */
  79913. _matrix: Matrix;
  79914. /**
  79915. * Create a new bone
  79916. * @param name defines the bone name
  79917. * @param skeleton defines the parent skeleton
  79918. * @param parentBone defines the parent (can be null if the bone is the root)
  79919. * @param localMatrix defines the local matrix
  79920. * @param restPose defines the rest pose matrix
  79921. * @param baseMatrix defines the base matrix
  79922. * @param index defines index of the bone in the hiearchy
  79923. */
  79924. constructor(
  79925. /**
  79926. * defines the bone name
  79927. */
  79928. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79929. /**
  79930. * Gets the current object class name.
  79931. * @return the class name
  79932. */
  79933. getClassName(): string;
  79934. /**
  79935. * Gets the parent skeleton
  79936. * @returns a skeleton
  79937. */
  79938. getSkeleton(): Skeleton;
  79939. /**
  79940. * Gets parent bone
  79941. * @returns a bone or null if the bone is the root of the bone hierarchy
  79942. */
  79943. getParent(): Nullable<Bone>;
  79944. /**
  79945. * Returns an array containing the root bones
  79946. * @returns an array containing the root bones
  79947. */
  79948. getChildren(): Array<Bone>;
  79949. /**
  79950. * Sets the parent bone
  79951. * @param parent defines the parent (can be null if the bone is the root)
  79952. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79953. */
  79954. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79955. /**
  79956. * Gets the local matrix
  79957. * @returns a matrix
  79958. */
  79959. getLocalMatrix(): Matrix;
  79960. /**
  79961. * Gets the base matrix (initial matrix which remains unchanged)
  79962. * @returns a matrix
  79963. */
  79964. getBaseMatrix(): Matrix;
  79965. /**
  79966. * Gets the rest pose matrix
  79967. * @returns a matrix
  79968. */
  79969. getRestPose(): Matrix;
  79970. /**
  79971. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79972. */
  79973. getWorldMatrix(): Matrix;
  79974. /**
  79975. * Sets the local matrix to rest pose matrix
  79976. */
  79977. returnToRest(): void;
  79978. /**
  79979. * Gets the inverse of the absolute transform matrix.
  79980. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79981. * @returns a matrix
  79982. */
  79983. getInvertedAbsoluteTransform(): Matrix;
  79984. /**
  79985. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79986. * @returns a matrix
  79987. */
  79988. getAbsoluteTransform(): Matrix;
  79989. /**
  79990. * Links with the given transform node.
  79991. * The local matrix of this bone is copied from the transform node every frame.
  79992. * @param transformNode defines the transform node to link to
  79993. */
  79994. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79995. /**
  79996. * Gets the node used to drive the bone's transformation
  79997. * @returns a transform node or null
  79998. */
  79999. getTransformNode(): Nullable<TransformNode>;
  80000. /** Gets or sets current position (in local space) */
  80001. position: Vector3;
  80002. /** Gets or sets current rotation (in local space) */
  80003. rotation: Vector3;
  80004. /** Gets or sets current rotation quaternion (in local space) */
  80005. rotationQuaternion: Quaternion;
  80006. /** Gets or sets current scaling (in local space) */
  80007. scaling: Vector3;
  80008. /**
  80009. * Gets the animation properties override
  80010. */
  80011. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80012. private _decompose;
  80013. private _compose;
  80014. /**
  80015. * Update the base and local matrices
  80016. * @param matrix defines the new base or local matrix
  80017. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80018. * @param updateLocalMatrix defines if the local matrix should be updated
  80019. */
  80020. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80021. /** @hidden */
  80022. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80023. /**
  80024. * Flag the bone as dirty (Forcing it to update everything)
  80025. */
  80026. markAsDirty(): void;
  80027. /** @hidden */
  80028. _markAsDirtyAndCompose(): void;
  80029. private _markAsDirtyAndDecompose;
  80030. /**
  80031. * Translate the bone in local or world space
  80032. * @param vec The amount to translate the bone
  80033. * @param space The space that the translation is in
  80034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80035. */
  80036. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80037. /**
  80038. * Set the postion of the bone in local or world space
  80039. * @param position The position to set the bone
  80040. * @param space The space that the position is in
  80041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80042. */
  80043. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80044. /**
  80045. * Set the absolute position of the bone (world space)
  80046. * @param position The position to set the bone
  80047. * @param mesh The mesh that this bone is attached to
  80048. */
  80049. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80050. /**
  80051. * Scale the bone on the x, y and z axes (in local space)
  80052. * @param x The amount to scale the bone on the x axis
  80053. * @param y The amount to scale the bone on the y axis
  80054. * @param z The amount to scale the bone on the z axis
  80055. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80056. */
  80057. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80058. /**
  80059. * Set the bone scaling in local space
  80060. * @param scale defines the scaling vector
  80061. */
  80062. setScale(scale: Vector3): void;
  80063. /**
  80064. * Gets the current scaling in local space
  80065. * @returns the current scaling vector
  80066. */
  80067. getScale(): Vector3;
  80068. /**
  80069. * Gets the current scaling in local space and stores it in a target vector
  80070. * @param result defines the target vector
  80071. */
  80072. getScaleToRef(result: Vector3): void;
  80073. /**
  80074. * Set the yaw, pitch, and roll of the bone in local or world space
  80075. * @param yaw The rotation of the bone on the y axis
  80076. * @param pitch The rotation of the bone on the x axis
  80077. * @param roll The rotation of the bone on the z axis
  80078. * @param space The space that the axes of rotation are in
  80079. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80080. */
  80081. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80082. /**
  80083. * Add a rotation to the bone on an axis in local or world space
  80084. * @param axis The axis to rotate the bone on
  80085. * @param amount The amount to rotate the bone
  80086. * @param space The space that the axis is in
  80087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80088. */
  80089. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80090. /**
  80091. * Set the rotation of the bone to a particular axis angle in local or world space
  80092. * @param axis The axis to rotate the bone on
  80093. * @param angle The angle that the bone should be rotated to
  80094. * @param space The space that the axis is in
  80095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80096. */
  80097. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80098. /**
  80099. * Set the euler rotation of the bone in local of world space
  80100. * @param rotation The euler rotation that the bone should be set to
  80101. * @param space The space that the rotation is in
  80102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80103. */
  80104. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80105. /**
  80106. * Set the quaternion rotation of the bone in local of world space
  80107. * @param quat The quaternion rotation that the bone should be set to
  80108. * @param space The space that the rotation is in
  80109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80110. */
  80111. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80112. /**
  80113. * Set the rotation matrix of the bone in local of world space
  80114. * @param rotMat The rotation matrix that the bone should be set to
  80115. * @param space The space that the rotation is in
  80116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80117. */
  80118. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80119. private _rotateWithMatrix;
  80120. private _getNegativeRotationToRef;
  80121. /**
  80122. * Get the position of the bone in local or world space
  80123. * @param space The space that the returned position is in
  80124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80125. * @returns The position of the bone
  80126. */
  80127. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80128. /**
  80129. * Copy the position of the bone to a vector3 in local or world space
  80130. * @param space The space that the returned position is in
  80131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80132. * @param result The vector3 to copy the position to
  80133. */
  80134. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80135. /**
  80136. * Get the absolute position of the bone (world space)
  80137. * @param mesh The mesh that this bone is attached to
  80138. * @returns The absolute position of the bone
  80139. */
  80140. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80141. /**
  80142. * Copy the absolute position of the bone (world space) to the result param
  80143. * @param mesh The mesh that this bone is attached to
  80144. * @param result The vector3 to copy the absolute position to
  80145. */
  80146. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80147. /**
  80148. * Compute the absolute transforms of this bone and its children
  80149. */
  80150. computeAbsoluteTransforms(): void;
  80151. /**
  80152. * Get the world direction from an axis that is in the local space of the bone
  80153. * @param localAxis The local direction that is used to compute the world direction
  80154. * @param mesh The mesh that this bone is attached to
  80155. * @returns The world direction
  80156. */
  80157. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80158. /**
  80159. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80160. * @param localAxis The local direction that is used to compute the world direction
  80161. * @param mesh The mesh that this bone is attached to
  80162. * @param result The vector3 that the world direction will be copied to
  80163. */
  80164. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80165. /**
  80166. * Get the euler rotation of the bone in local or world space
  80167. * @param space The space that the rotation should be in
  80168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80169. * @returns The euler rotation
  80170. */
  80171. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80172. /**
  80173. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80174. * @param space The space that the rotation should be in
  80175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80176. * @param result The vector3 that the rotation should be copied to
  80177. */
  80178. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80179. /**
  80180. * Get the quaternion rotation of the bone in either local or world space
  80181. * @param space The space that the rotation should be in
  80182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80183. * @returns The quaternion rotation
  80184. */
  80185. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80186. /**
  80187. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80188. * @param space The space that the rotation should be in
  80189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80190. * @param result The quaternion that the rotation should be copied to
  80191. */
  80192. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80193. /**
  80194. * Get the rotation matrix of the bone in local or world space
  80195. * @param space The space that the rotation should be in
  80196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80197. * @returns The rotation matrix
  80198. */
  80199. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80200. /**
  80201. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80202. * @param space The space that the rotation should be in
  80203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80204. * @param result The quaternion that the rotation should be copied to
  80205. */
  80206. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80207. /**
  80208. * Get the world position of a point that is in the local space of the bone
  80209. * @param position The local position
  80210. * @param mesh The mesh that this bone is attached to
  80211. * @returns The world position
  80212. */
  80213. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80214. /**
  80215. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80216. * @param position The local position
  80217. * @param mesh The mesh that this bone is attached to
  80218. * @param result The vector3 that the world position should be copied to
  80219. */
  80220. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80221. /**
  80222. * Get the local position of a point that is in world space
  80223. * @param position The world position
  80224. * @param mesh The mesh that this bone is attached to
  80225. * @returns The local position
  80226. */
  80227. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80228. /**
  80229. * Get the local position of a point that is in world space and copy it to the result param
  80230. * @param position The world position
  80231. * @param mesh The mesh that this bone is attached to
  80232. * @param result The vector3 that the local position should be copied to
  80233. */
  80234. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80235. }
  80236. }
  80237. declare module BABYLON {
  80238. /**
  80239. * 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.
  80240. * @see https://doc.babylonjs.com/how_to/transformnode
  80241. */
  80242. export class TransformNode extends Node {
  80243. /**
  80244. * Object will not rotate to face the camera
  80245. */
  80246. static BILLBOARDMODE_NONE: number;
  80247. /**
  80248. * Object will rotate to face the camera but only on the x axis
  80249. */
  80250. static BILLBOARDMODE_X: number;
  80251. /**
  80252. * Object will rotate to face the camera but only on the y axis
  80253. */
  80254. static BILLBOARDMODE_Y: number;
  80255. /**
  80256. * Object will rotate to face the camera but only on the z axis
  80257. */
  80258. static BILLBOARDMODE_Z: number;
  80259. /**
  80260. * Object will rotate to face the camera
  80261. */
  80262. static BILLBOARDMODE_ALL: number;
  80263. /**
  80264. * Object will rotate to face the camera's position instead of orientation
  80265. */
  80266. static BILLBOARDMODE_USE_POSITION: number;
  80267. private _forward;
  80268. private _forwardInverted;
  80269. private _up;
  80270. private _right;
  80271. private _rightInverted;
  80272. private _position;
  80273. private _rotation;
  80274. private _rotationQuaternion;
  80275. protected _scaling: Vector3;
  80276. protected _isDirty: boolean;
  80277. private _transformToBoneReferal;
  80278. private _isAbsoluteSynced;
  80279. private _billboardMode;
  80280. /**
  80281. * Gets or sets the billboard mode. Default is 0.
  80282. *
  80283. * | Value | Type | Description |
  80284. * | --- | --- | --- |
  80285. * | 0 | BILLBOARDMODE_NONE | |
  80286. * | 1 | BILLBOARDMODE_X | |
  80287. * | 2 | BILLBOARDMODE_Y | |
  80288. * | 4 | BILLBOARDMODE_Z | |
  80289. * | 7 | BILLBOARDMODE_ALL | |
  80290. *
  80291. */
  80292. billboardMode: number;
  80293. private _preserveParentRotationForBillboard;
  80294. /**
  80295. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80296. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80297. */
  80298. preserveParentRotationForBillboard: boolean;
  80299. /**
  80300. * 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
  80301. */
  80302. scalingDeterminant: number;
  80303. private _infiniteDistance;
  80304. /**
  80305. * Gets or sets the distance of the object to max, often used by skybox
  80306. */
  80307. infiniteDistance: boolean;
  80308. /**
  80309. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80310. * By default the system will update normals to compensate
  80311. */
  80312. ignoreNonUniformScaling: boolean;
  80313. /**
  80314. * 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
  80315. */
  80316. reIntegrateRotationIntoRotationQuaternion: boolean;
  80317. /** @hidden */
  80318. _poseMatrix: Nullable<Matrix>;
  80319. /** @hidden */
  80320. _localMatrix: Matrix;
  80321. private _usePivotMatrix;
  80322. private _absolutePosition;
  80323. private _absoluteScaling;
  80324. private _absoluteRotationQuaternion;
  80325. private _pivotMatrix;
  80326. private _pivotMatrixInverse;
  80327. protected _postMultiplyPivotMatrix: boolean;
  80328. protected _isWorldMatrixFrozen: boolean;
  80329. /** @hidden */
  80330. _indexInSceneTransformNodesArray: number;
  80331. /**
  80332. * An event triggered after the world matrix is updated
  80333. */
  80334. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80335. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80336. /**
  80337. * Gets a string identifying the name of the class
  80338. * @returns "TransformNode" string
  80339. */
  80340. getClassName(): string;
  80341. /**
  80342. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80343. */
  80344. position: Vector3;
  80345. /**
  80346. * 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)).
  80347. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80348. */
  80349. rotation: Vector3;
  80350. /**
  80351. * 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)).
  80352. */
  80353. scaling: Vector3;
  80354. /**
  80355. * 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).
  80356. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80357. */
  80358. rotationQuaternion: Nullable<Quaternion>;
  80359. /**
  80360. * The forward direction of that transform in world space.
  80361. */
  80362. readonly forward: Vector3;
  80363. /**
  80364. * The up direction of that transform in world space.
  80365. */
  80366. readonly up: Vector3;
  80367. /**
  80368. * The right direction of that transform in world space.
  80369. */
  80370. readonly right: Vector3;
  80371. /**
  80372. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80373. * @param matrix the matrix to copy the pose from
  80374. * @returns this TransformNode.
  80375. */
  80376. updatePoseMatrix(matrix: Matrix): TransformNode;
  80377. /**
  80378. * Returns the mesh Pose matrix.
  80379. * @returns the pose matrix
  80380. */
  80381. getPoseMatrix(): Matrix;
  80382. /** @hidden */
  80383. _isSynchronized(): boolean;
  80384. /** @hidden */
  80385. _initCache(): void;
  80386. /**
  80387. * Flag the transform node as dirty (Forcing it to update everything)
  80388. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80389. * @returns this transform node
  80390. */
  80391. markAsDirty(property: string): TransformNode;
  80392. /**
  80393. * Returns the current mesh absolute position.
  80394. * Returns a Vector3.
  80395. */
  80396. readonly absolutePosition: Vector3;
  80397. /**
  80398. * Returns the current mesh absolute scaling.
  80399. * Returns a Vector3.
  80400. */
  80401. readonly absoluteScaling: Vector3;
  80402. /**
  80403. * Returns the current mesh absolute rotation.
  80404. * Returns a Quaternion.
  80405. */
  80406. readonly absoluteRotationQuaternion: Quaternion;
  80407. /**
  80408. * Sets a new matrix to apply before all other transformation
  80409. * @param matrix defines the transform matrix
  80410. * @returns the current TransformNode
  80411. */
  80412. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80413. /**
  80414. * Sets a new pivot matrix to the current node
  80415. * @param matrix defines the new pivot matrix to use
  80416. * @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
  80417. * @returns the current TransformNode
  80418. */
  80419. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80420. /**
  80421. * Returns the mesh pivot matrix.
  80422. * Default : Identity.
  80423. * @returns the matrix
  80424. */
  80425. getPivotMatrix(): Matrix;
  80426. /**
  80427. * Instantiate (when possible) or clone that node with its hierarchy
  80428. * @param newParent defines the new parent to use for the instance (or clone)
  80429. * @returns an instance (or a clone) of the current node with its hiearchy
  80430. */
  80431. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80432. /**
  80433. * Prevents the World matrix to be computed any longer
  80434. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80435. * @returns the TransformNode.
  80436. */
  80437. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80438. /**
  80439. * Allows back the World matrix computation.
  80440. * @returns the TransformNode.
  80441. */
  80442. unfreezeWorldMatrix(): this;
  80443. /**
  80444. * True if the World matrix has been frozen.
  80445. */
  80446. readonly isWorldMatrixFrozen: boolean;
  80447. /**
  80448. * Retuns the mesh absolute position in the World.
  80449. * @returns a Vector3.
  80450. */
  80451. getAbsolutePosition(): Vector3;
  80452. /**
  80453. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80454. * @param absolutePosition the absolute position to set
  80455. * @returns the TransformNode.
  80456. */
  80457. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80458. /**
  80459. * Sets the mesh position in its local space.
  80460. * @param vector3 the position to set in localspace
  80461. * @returns the TransformNode.
  80462. */
  80463. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80464. /**
  80465. * Returns the mesh position in the local space from the current World matrix values.
  80466. * @returns a new Vector3.
  80467. */
  80468. getPositionExpressedInLocalSpace(): Vector3;
  80469. /**
  80470. * Translates the mesh along the passed Vector3 in its local space.
  80471. * @param vector3 the distance to translate in localspace
  80472. * @returns the TransformNode.
  80473. */
  80474. locallyTranslate(vector3: Vector3): TransformNode;
  80475. private static _lookAtVectorCache;
  80476. /**
  80477. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80478. * @param targetPoint the position (must be in same space as current mesh) to look at
  80479. * @param yawCor optional yaw (y-axis) correction in radians
  80480. * @param pitchCor optional pitch (x-axis) correction in radians
  80481. * @param rollCor optional roll (z-axis) correction in radians
  80482. * @param space the choosen space of the target
  80483. * @returns the TransformNode.
  80484. */
  80485. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80486. /**
  80487. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80488. * This Vector3 is expressed in the World space.
  80489. * @param localAxis axis to rotate
  80490. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80491. */
  80492. getDirection(localAxis: Vector3): Vector3;
  80493. /**
  80494. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80495. * localAxis is expressed in the mesh local space.
  80496. * result is computed in the Wordl space from the mesh World matrix.
  80497. * @param localAxis axis to rotate
  80498. * @param result the resulting transformnode
  80499. * @returns this TransformNode.
  80500. */
  80501. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80502. /**
  80503. * Sets this transform node rotation to the given local axis.
  80504. * @param localAxis the axis in local space
  80505. * @param yawCor optional yaw (y-axis) correction in radians
  80506. * @param pitchCor optional pitch (x-axis) correction in radians
  80507. * @param rollCor optional roll (z-axis) correction in radians
  80508. * @returns this TransformNode
  80509. */
  80510. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80511. /**
  80512. * Sets a new pivot point to the current node
  80513. * @param point defines the new pivot point to use
  80514. * @param space defines if the point is in world or local space (local by default)
  80515. * @returns the current TransformNode
  80516. */
  80517. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80518. /**
  80519. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80520. * @returns the pivot point
  80521. */
  80522. getPivotPoint(): Vector3;
  80523. /**
  80524. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80525. * @param result the vector3 to store the result
  80526. * @returns this TransformNode.
  80527. */
  80528. getPivotPointToRef(result: Vector3): TransformNode;
  80529. /**
  80530. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80531. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80532. */
  80533. getAbsolutePivotPoint(): Vector3;
  80534. /**
  80535. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80536. * @param result vector3 to store the result
  80537. * @returns this TransformNode.
  80538. */
  80539. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80540. /**
  80541. * Defines the passed node as the parent of the current node.
  80542. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80543. * @see https://doc.babylonjs.com/how_to/parenting
  80544. * @param node the node ot set as the parent
  80545. * @returns this TransformNode.
  80546. */
  80547. setParent(node: Nullable<Node>): TransformNode;
  80548. private _nonUniformScaling;
  80549. /**
  80550. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80551. */
  80552. readonly nonUniformScaling: boolean;
  80553. /** @hidden */
  80554. _updateNonUniformScalingState(value: boolean): boolean;
  80555. /**
  80556. * Attach the current TransformNode to another TransformNode associated with a bone
  80557. * @param bone Bone affecting the TransformNode
  80558. * @param affectedTransformNode TransformNode associated with the bone
  80559. * @returns this object
  80560. */
  80561. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80562. /**
  80563. * Detach the transform node if its associated with a bone
  80564. * @returns this object
  80565. */
  80566. detachFromBone(): TransformNode;
  80567. private static _rotationAxisCache;
  80568. /**
  80569. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80570. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80571. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80572. * The passed axis is also normalized.
  80573. * @param axis the axis to rotate around
  80574. * @param amount the amount to rotate in radians
  80575. * @param space Space to rotate in (Default: local)
  80576. * @returns the TransformNode.
  80577. */
  80578. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80579. /**
  80580. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80581. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80582. * The passed axis is also normalized. .
  80583. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80584. * @param point the point to rotate around
  80585. * @param axis the axis to rotate around
  80586. * @param amount the amount to rotate in radians
  80587. * @returns the TransformNode
  80588. */
  80589. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80590. /**
  80591. * Translates the mesh along the axis vector for the passed distance in the given space.
  80592. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80593. * @param axis the axis to translate in
  80594. * @param distance the distance to translate
  80595. * @param space Space to rotate in (Default: local)
  80596. * @returns the TransformNode.
  80597. */
  80598. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80599. /**
  80600. * Adds a rotation step to the mesh current rotation.
  80601. * x, y, z are Euler angles expressed in radians.
  80602. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80603. * This means this rotation is made in the mesh local space only.
  80604. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80605. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80606. * ```javascript
  80607. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80608. * ```
  80609. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80610. * 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.
  80611. * @param x Rotation to add
  80612. * @param y Rotation to add
  80613. * @param z Rotation to add
  80614. * @returns the TransformNode.
  80615. */
  80616. addRotation(x: number, y: number, z: number): TransformNode;
  80617. /**
  80618. * @hidden
  80619. */
  80620. protected _getEffectiveParent(): Nullable<Node>;
  80621. /**
  80622. * Computes the world matrix of the node
  80623. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80624. * @returns the world matrix
  80625. */
  80626. computeWorldMatrix(force?: boolean): Matrix;
  80627. protected _afterComputeWorldMatrix(): void;
  80628. /**
  80629. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80630. * @param func callback function to add
  80631. *
  80632. * @returns the TransformNode.
  80633. */
  80634. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80635. /**
  80636. * Removes a registered callback function.
  80637. * @param func callback function to remove
  80638. * @returns the TransformNode.
  80639. */
  80640. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80641. /**
  80642. * Gets the position of the current mesh in camera space
  80643. * @param camera defines the camera to use
  80644. * @returns a position
  80645. */
  80646. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80647. /**
  80648. * Returns the distance from the mesh to the active camera
  80649. * @param camera defines the camera to use
  80650. * @returns the distance
  80651. */
  80652. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80653. /**
  80654. * Clone the current transform node
  80655. * @param name Name of the new clone
  80656. * @param newParent New parent for the clone
  80657. * @param doNotCloneChildren Do not clone children hierarchy
  80658. * @returns the new transform node
  80659. */
  80660. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80661. /**
  80662. * Serializes the objects information.
  80663. * @param currentSerializationObject defines the object to serialize in
  80664. * @returns the serialized object
  80665. */
  80666. serialize(currentSerializationObject?: any): any;
  80667. /**
  80668. * Returns a new TransformNode object parsed from the source provided.
  80669. * @param parsedTransformNode is the source.
  80670. * @param scene the scne the object belongs to
  80671. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80672. * @returns a new TransformNode object parsed from the source provided.
  80673. */
  80674. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80675. /**
  80676. * Get all child-transformNodes of this node
  80677. * @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
  80678. * @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
  80679. * @returns an array of TransformNode
  80680. */
  80681. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80682. /**
  80683. * Releases resources associated with this transform node.
  80684. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80685. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80686. */
  80687. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80688. /**
  80689. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80690. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80691. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80692. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80693. * @returns the current mesh
  80694. */
  80695. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80696. private _syncAbsoluteScalingAndRotation;
  80697. }
  80698. }
  80699. declare module BABYLON {
  80700. /**
  80701. * Defines the types of pose enabled controllers that are supported
  80702. */
  80703. export enum PoseEnabledControllerType {
  80704. /**
  80705. * HTC Vive
  80706. */
  80707. VIVE = 0,
  80708. /**
  80709. * Oculus Rift
  80710. */
  80711. OCULUS = 1,
  80712. /**
  80713. * Windows mixed reality
  80714. */
  80715. WINDOWS = 2,
  80716. /**
  80717. * Samsung gear VR
  80718. */
  80719. GEAR_VR = 3,
  80720. /**
  80721. * Google Daydream
  80722. */
  80723. DAYDREAM = 4,
  80724. /**
  80725. * Generic
  80726. */
  80727. GENERIC = 5
  80728. }
  80729. /**
  80730. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80731. */
  80732. export interface MutableGamepadButton {
  80733. /**
  80734. * Value of the button/trigger
  80735. */
  80736. value: number;
  80737. /**
  80738. * If the button/trigger is currently touched
  80739. */
  80740. touched: boolean;
  80741. /**
  80742. * If the button/trigger is currently pressed
  80743. */
  80744. pressed: boolean;
  80745. }
  80746. /**
  80747. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80748. * @hidden
  80749. */
  80750. export interface ExtendedGamepadButton extends GamepadButton {
  80751. /**
  80752. * If the button/trigger is currently pressed
  80753. */
  80754. readonly pressed: boolean;
  80755. /**
  80756. * If the button/trigger is currently touched
  80757. */
  80758. readonly touched: boolean;
  80759. /**
  80760. * Value of the button/trigger
  80761. */
  80762. readonly value: number;
  80763. }
  80764. /** @hidden */
  80765. export interface _GamePadFactory {
  80766. /**
  80767. * Returns wether or not the current gamepad can be created for this type of controller.
  80768. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80769. * @returns true if it can be created, otherwise false
  80770. */
  80771. canCreate(gamepadInfo: any): boolean;
  80772. /**
  80773. * Creates a new instance of the Gamepad.
  80774. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80775. * @returns the new gamepad instance
  80776. */
  80777. create(gamepadInfo: any): Gamepad;
  80778. }
  80779. /**
  80780. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80781. */
  80782. export class PoseEnabledControllerHelper {
  80783. /** @hidden */
  80784. static _ControllerFactories: _GamePadFactory[];
  80785. /** @hidden */
  80786. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80787. /**
  80788. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80789. * @param vrGamepad the gamepad to initialized
  80790. * @returns a vr controller of the type the gamepad identified as
  80791. */
  80792. static InitiateController(vrGamepad: any): Gamepad;
  80793. }
  80794. /**
  80795. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80796. */
  80797. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80798. /**
  80799. * If the controller is used in a webXR session
  80800. */
  80801. isXR: boolean;
  80802. private _deviceRoomPosition;
  80803. private _deviceRoomRotationQuaternion;
  80804. /**
  80805. * The device position in babylon space
  80806. */
  80807. devicePosition: Vector3;
  80808. /**
  80809. * The device rotation in babylon space
  80810. */
  80811. deviceRotationQuaternion: Quaternion;
  80812. /**
  80813. * The scale factor of the device in babylon space
  80814. */
  80815. deviceScaleFactor: number;
  80816. /**
  80817. * (Likely devicePosition should be used instead) The device position in its room space
  80818. */
  80819. position: Vector3;
  80820. /**
  80821. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80822. */
  80823. rotationQuaternion: Quaternion;
  80824. /**
  80825. * The type of controller (Eg. Windows mixed reality)
  80826. */
  80827. controllerType: PoseEnabledControllerType;
  80828. protected _calculatedPosition: Vector3;
  80829. private _calculatedRotation;
  80830. /**
  80831. * The raw pose from the device
  80832. */
  80833. rawPose: DevicePose;
  80834. private _trackPosition;
  80835. private _maxRotationDistFromHeadset;
  80836. private _draggedRoomRotation;
  80837. /**
  80838. * @hidden
  80839. */
  80840. _disableTrackPosition(fixedPosition: Vector3): void;
  80841. /**
  80842. * Internal, the mesh attached to the controller
  80843. * @hidden
  80844. */
  80845. _mesh: Nullable<AbstractMesh>;
  80846. private _poseControlledCamera;
  80847. private _leftHandSystemQuaternion;
  80848. /**
  80849. * Internal, matrix used to convert room space to babylon space
  80850. * @hidden
  80851. */
  80852. _deviceToWorld: Matrix;
  80853. /**
  80854. * Node to be used when casting a ray from the controller
  80855. * @hidden
  80856. */
  80857. _pointingPoseNode: Nullable<TransformNode>;
  80858. /**
  80859. * Name of the child mesh that can be used to cast a ray from the controller
  80860. */
  80861. static readonly POINTING_POSE: string;
  80862. /**
  80863. * Creates a new PoseEnabledController from a gamepad
  80864. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80865. */
  80866. constructor(browserGamepad: any);
  80867. private _workingMatrix;
  80868. /**
  80869. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80870. */
  80871. update(): void;
  80872. /**
  80873. * Updates only the pose device and mesh without doing any button event checking
  80874. */
  80875. protected _updatePoseAndMesh(): void;
  80876. /**
  80877. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80878. * @param poseData raw pose fromthe device
  80879. */
  80880. updateFromDevice(poseData: DevicePose): void;
  80881. /**
  80882. * @hidden
  80883. */
  80884. _meshAttachedObservable: Observable<AbstractMesh>;
  80885. /**
  80886. * Attaches a mesh to the controller
  80887. * @param mesh the mesh to be attached
  80888. */
  80889. attachToMesh(mesh: AbstractMesh): void;
  80890. /**
  80891. * Attaches the controllers mesh to a camera
  80892. * @param camera the camera the mesh should be attached to
  80893. */
  80894. attachToPoseControlledCamera(camera: TargetCamera): void;
  80895. /**
  80896. * Disposes of the controller
  80897. */
  80898. dispose(): void;
  80899. /**
  80900. * The mesh that is attached to the controller
  80901. */
  80902. readonly mesh: Nullable<AbstractMesh>;
  80903. /**
  80904. * Gets the ray of the controller in the direction the controller is pointing
  80905. * @param length the length the resulting ray should be
  80906. * @returns a ray in the direction the controller is pointing
  80907. */
  80908. getForwardRay(length?: number): Ray;
  80909. }
  80910. }
  80911. declare module BABYLON {
  80912. /**
  80913. * Defines the WebVRController object that represents controllers tracked in 3D space
  80914. */
  80915. export abstract class WebVRController extends PoseEnabledController {
  80916. /**
  80917. * Internal, the default controller model for the controller
  80918. */
  80919. protected _defaultModel: Nullable<AbstractMesh>;
  80920. /**
  80921. * Fired when the trigger state has changed
  80922. */
  80923. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80924. /**
  80925. * Fired when the main button state has changed
  80926. */
  80927. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80928. /**
  80929. * Fired when the secondary button state has changed
  80930. */
  80931. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80932. /**
  80933. * Fired when the pad state has changed
  80934. */
  80935. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80936. /**
  80937. * Fired when controllers stick values have changed
  80938. */
  80939. onPadValuesChangedObservable: Observable<StickValues>;
  80940. /**
  80941. * Array of button availible on the controller
  80942. */
  80943. protected _buttons: Array<MutableGamepadButton>;
  80944. private _onButtonStateChange;
  80945. /**
  80946. * Fired when a controller button's state has changed
  80947. * @param callback the callback containing the button that was modified
  80948. */
  80949. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80950. /**
  80951. * X and Y axis corresponding to the controllers joystick
  80952. */
  80953. pad: StickValues;
  80954. /**
  80955. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80956. */
  80957. hand: string;
  80958. /**
  80959. * The default controller model for the controller
  80960. */
  80961. readonly defaultModel: Nullable<AbstractMesh>;
  80962. /**
  80963. * Creates a new WebVRController from a gamepad
  80964. * @param vrGamepad the gamepad that the WebVRController should be created from
  80965. */
  80966. constructor(vrGamepad: any);
  80967. /**
  80968. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80969. */
  80970. update(): void;
  80971. /**
  80972. * Function to be called when a button is modified
  80973. */
  80974. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80975. /**
  80976. * Loads a mesh and attaches it to the controller
  80977. * @param scene the scene the mesh should be added to
  80978. * @param meshLoaded callback for when the mesh has been loaded
  80979. */
  80980. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80981. private _setButtonValue;
  80982. private _changes;
  80983. private _checkChanges;
  80984. /**
  80985. * Disposes of th webVRCOntroller
  80986. */
  80987. dispose(): void;
  80988. }
  80989. }
  80990. declare module BABYLON {
  80991. /**
  80992. * The HemisphericLight simulates the ambient environment light,
  80993. * so the passed direction is the light reflection direction, not the incoming direction.
  80994. */
  80995. export class HemisphericLight extends Light {
  80996. /**
  80997. * The groundColor is the light in the opposite direction to the one specified during creation.
  80998. * 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.
  80999. */
  81000. groundColor: Color3;
  81001. /**
  81002. * The light reflection direction, not the incoming direction.
  81003. */
  81004. direction: Vector3;
  81005. /**
  81006. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81007. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81008. * The HemisphericLight can't cast shadows.
  81009. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81010. * @param name The friendly name of the light
  81011. * @param direction The direction of the light reflection
  81012. * @param scene The scene the light belongs to
  81013. */
  81014. constructor(name: string, direction: Vector3, scene: Scene);
  81015. protected _buildUniformLayout(): void;
  81016. /**
  81017. * Returns the string "HemisphericLight".
  81018. * @return The class name
  81019. */
  81020. getClassName(): string;
  81021. /**
  81022. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81023. * Returns the updated direction.
  81024. * @param target The target the direction should point to
  81025. * @return The computed direction
  81026. */
  81027. setDirectionToTarget(target: Vector3): Vector3;
  81028. /**
  81029. * Returns the shadow generator associated to the light.
  81030. * @returns Always null for hemispheric lights because it does not support shadows.
  81031. */
  81032. getShadowGenerator(): Nullable<IShadowGenerator>;
  81033. /**
  81034. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81035. * @param effect The effect to update
  81036. * @param lightIndex The index of the light in the effect to update
  81037. * @returns The hemispheric light
  81038. */
  81039. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81040. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81041. /**
  81042. * Computes the world matrix of the node
  81043. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81044. * @param useWasUpdatedFlag defines a reserved property
  81045. * @returns the world matrix
  81046. */
  81047. computeWorldMatrix(): Matrix;
  81048. /**
  81049. * Returns the integer 3.
  81050. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81051. */
  81052. getTypeID(): number;
  81053. /**
  81054. * Prepares the list of defines specific to the light type.
  81055. * @param defines the list of defines
  81056. * @param lightIndex defines the index of the light for the effect
  81057. */
  81058. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81059. }
  81060. }
  81061. declare module BABYLON {
  81062. /** @hidden */
  81063. export var vrMultiviewToSingleviewPixelShader: {
  81064. name: string;
  81065. shader: string;
  81066. };
  81067. }
  81068. declare module BABYLON {
  81069. /**
  81070. * Renders to multiple views with a single draw call
  81071. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81072. */
  81073. export class MultiviewRenderTarget extends RenderTargetTexture {
  81074. /**
  81075. * Creates a multiview render target
  81076. * @param scene scene used with the render target
  81077. * @param size the size of the render target (used for each view)
  81078. */
  81079. constructor(scene: Scene, size?: number | {
  81080. width: number;
  81081. height: number;
  81082. } | {
  81083. ratio: number;
  81084. });
  81085. /**
  81086. * @hidden
  81087. * @param faceIndex the face index, if its a cube texture
  81088. */
  81089. _bindFrameBuffer(faceIndex?: number): void;
  81090. /**
  81091. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81092. * @returns the view count
  81093. */
  81094. getViewCount(): number;
  81095. }
  81096. }
  81097. declare module BABYLON {
  81098. /**
  81099. * Represents a camera frustum
  81100. */
  81101. export class Frustum {
  81102. /**
  81103. * Gets the planes representing the frustum
  81104. * @param transform matrix to be applied to the returned planes
  81105. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81106. */
  81107. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81108. /**
  81109. * Gets the near frustum plane transformed by the transform matrix
  81110. * @param transform transformation matrix to be applied to the resulting frustum plane
  81111. * @param frustumPlane the resuling frustum plane
  81112. */
  81113. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81114. /**
  81115. * Gets the far frustum plane transformed by the transform matrix
  81116. * @param transform transformation matrix to be applied to the resulting frustum plane
  81117. * @param frustumPlane the resuling frustum plane
  81118. */
  81119. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81120. /**
  81121. * Gets the left frustum plane transformed by the transform matrix
  81122. * @param transform transformation matrix to be applied to the resulting frustum plane
  81123. * @param frustumPlane the resuling frustum plane
  81124. */
  81125. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81126. /**
  81127. * Gets the right frustum plane transformed by the transform matrix
  81128. * @param transform transformation matrix to be applied to the resulting frustum plane
  81129. * @param frustumPlane the resuling frustum plane
  81130. */
  81131. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81132. /**
  81133. * Gets the top frustum plane transformed by the transform matrix
  81134. * @param transform transformation matrix to be applied to the resulting frustum plane
  81135. * @param frustumPlane the resuling frustum plane
  81136. */
  81137. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81138. /**
  81139. * Gets the bottom frustum plane transformed by the transform matrix
  81140. * @param transform transformation matrix to be applied to the resulting frustum plane
  81141. * @param frustumPlane the resuling frustum plane
  81142. */
  81143. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81144. /**
  81145. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81146. * @param transform transformation matrix to be applied to the resulting frustum planes
  81147. * @param frustumPlanes the resuling frustum planes
  81148. */
  81149. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81150. }
  81151. }
  81152. declare module BABYLON {
  81153. interface Engine {
  81154. /**
  81155. * Creates a new multiview render target
  81156. * @param width defines the width of the texture
  81157. * @param height defines the height of the texture
  81158. * @returns the created multiview texture
  81159. */
  81160. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81161. /**
  81162. * Binds a multiview framebuffer to be drawn to
  81163. * @param multiviewTexture texture to bind
  81164. */
  81165. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81166. }
  81167. interface Camera {
  81168. /**
  81169. * @hidden
  81170. * 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)
  81171. */
  81172. _useMultiviewToSingleView: boolean;
  81173. /**
  81174. * @hidden
  81175. * 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)
  81176. */
  81177. _multiviewTexture: Nullable<RenderTargetTexture>;
  81178. /**
  81179. * @hidden
  81180. * ensures the multiview texture of the camera exists and has the specified width/height
  81181. * @param width height to set on the multiview texture
  81182. * @param height width to set on the multiview texture
  81183. */
  81184. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81185. }
  81186. interface Scene {
  81187. /** @hidden */
  81188. _transformMatrixR: Matrix;
  81189. /** @hidden */
  81190. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81191. /** @hidden */
  81192. _createMultiviewUbo(): void;
  81193. /** @hidden */
  81194. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81195. /** @hidden */
  81196. _renderMultiviewToSingleView(camera: Camera): void;
  81197. }
  81198. }
  81199. declare module BABYLON {
  81200. /**
  81201. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81202. * This will not be used for webXR as it supports displaying texture arrays directly
  81203. */
  81204. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81205. /**
  81206. * Initializes a VRMultiviewToSingleview
  81207. * @param name name of the post process
  81208. * @param camera camera to be applied to
  81209. * @param scaleFactor scaling factor to the size of the output texture
  81210. */
  81211. constructor(name: string, camera: Camera, scaleFactor: number);
  81212. }
  81213. }
  81214. declare module BABYLON {
  81215. interface Engine {
  81216. /** @hidden */
  81217. _vrDisplay: any;
  81218. /** @hidden */
  81219. _vrSupported: boolean;
  81220. /** @hidden */
  81221. _oldSize: Size;
  81222. /** @hidden */
  81223. _oldHardwareScaleFactor: number;
  81224. /** @hidden */
  81225. _vrExclusivePointerMode: boolean;
  81226. /** @hidden */
  81227. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81228. /** @hidden */
  81229. _onVRDisplayPointerRestricted: () => void;
  81230. /** @hidden */
  81231. _onVRDisplayPointerUnrestricted: () => void;
  81232. /** @hidden */
  81233. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81234. /** @hidden */
  81235. _onVrDisplayDisconnect: Nullable<() => void>;
  81236. /** @hidden */
  81237. _onVrDisplayPresentChange: Nullable<() => void>;
  81238. /**
  81239. * Observable signaled when VR display mode changes
  81240. */
  81241. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81242. /**
  81243. * Observable signaled when VR request present is complete
  81244. */
  81245. onVRRequestPresentComplete: Observable<boolean>;
  81246. /**
  81247. * Observable signaled when VR request present starts
  81248. */
  81249. onVRRequestPresentStart: Observable<Engine>;
  81250. /**
  81251. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81252. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81253. */
  81254. isInVRExclusivePointerMode: boolean;
  81255. /**
  81256. * Gets a boolean indicating if a webVR device was detected
  81257. * @returns true if a webVR device was detected
  81258. */
  81259. isVRDevicePresent(): boolean;
  81260. /**
  81261. * Gets the current webVR device
  81262. * @returns the current webVR device (or null)
  81263. */
  81264. getVRDevice(): any;
  81265. /**
  81266. * Initializes a webVR display and starts listening to display change events
  81267. * The onVRDisplayChangedObservable will be notified upon these changes
  81268. * @returns A promise containing a VRDisplay and if vr is supported
  81269. */
  81270. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81271. /** @hidden */
  81272. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81273. /**
  81274. * Call this function to switch to webVR mode
  81275. * Will do nothing if webVR is not supported or if there is no webVR device
  81276. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81277. */
  81278. enableVR(): void;
  81279. /** @hidden */
  81280. _onVRFullScreenTriggered(): void;
  81281. }
  81282. }
  81283. declare module BABYLON {
  81284. /**
  81285. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81286. * IMPORTANT!! The data is right-hand data.
  81287. * @export
  81288. * @interface DevicePose
  81289. */
  81290. export interface DevicePose {
  81291. /**
  81292. * The position of the device, values in array are [x,y,z].
  81293. */
  81294. readonly position: Nullable<Float32Array>;
  81295. /**
  81296. * The linearVelocity of the device, values in array are [x,y,z].
  81297. */
  81298. readonly linearVelocity: Nullable<Float32Array>;
  81299. /**
  81300. * The linearAcceleration of the device, values in array are [x,y,z].
  81301. */
  81302. readonly linearAcceleration: Nullable<Float32Array>;
  81303. /**
  81304. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81305. */
  81306. readonly orientation: Nullable<Float32Array>;
  81307. /**
  81308. * The angularVelocity of the device, values in array are [x,y,z].
  81309. */
  81310. readonly angularVelocity: Nullable<Float32Array>;
  81311. /**
  81312. * The angularAcceleration of the device, values in array are [x,y,z].
  81313. */
  81314. readonly angularAcceleration: Nullable<Float32Array>;
  81315. }
  81316. /**
  81317. * Interface representing a pose controlled object in Babylon.
  81318. * A pose controlled object has both regular pose values as well as pose values
  81319. * from an external device such as a VR head mounted display
  81320. */
  81321. export interface PoseControlled {
  81322. /**
  81323. * The position of the object in babylon space.
  81324. */
  81325. position: Vector3;
  81326. /**
  81327. * The rotation quaternion of the object in babylon space.
  81328. */
  81329. rotationQuaternion: Quaternion;
  81330. /**
  81331. * The position of the device in babylon space.
  81332. */
  81333. devicePosition?: Vector3;
  81334. /**
  81335. * The rotation quaternion of the device in babylon space.
  81336. */
  81337. deviceRotationQuaternion: Quaternion;
  81338. /**
  81339. * The raw pose coming from the device.
  81340. */
  81341. rawPose: Nullable<DevicePose>;
  81342. /**
  81343. * The scale of the device to be used when translating from device space to babylon space.
  81344. */
  81345. deviceScaleFactor: number;
  81346. /**
  81347. * Updates the poseControlled values based on the input device pose.
  81348. * @param poseData the pose data to update the object with
  81349. */
  81350. updateFromDevice(poseData: DevicePose): void;
  81351. }
  81352. /**
  81353. * Set of options to customize the webVRCamera
  81354. */
  81355. export interface WebVROptions {
  81356. /**
  81357. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81358. */
  81359. trackPosition?: boolean;
  81360. /**
  81361. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81362. */
  81363. positionScale?: number;
  81364. /**
  81365. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81366. */
  81367. displayName?: string;
  81368. /**
  81369. * Should the native controller meshes be initialized. (default: true)
  81370. */
  81371. controllerMeshes?: boolean;
  81372. /**
  81373. * Creating a default HemiLight only on controllers. (default: true)
  81374. */
  81375. defaultLightingOnControllers?: boolean;
  81376. /**
  81377. * If you don't want to use the default VR button of the helper. (default: false)
  81378. */
  81379. useCustomVRButton?: boolean;
  81380. /**
  81381. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81382. */
  81383. customVRButton?: HTMLButtonElement;
  81384. /**
  81385. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81386. */
  81387. rayLength?: number;
  81388. /**
  81389. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81390. */
  81391. defaultHeight?: number;
  81392. /**
  81393. * If multiview should be used if availible (default: false)
  81394. */
  81395. useMultiview?: boolean;
  81396. }
  81397. /**
  81398. * This represents a WebVR camera.
  81399. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81400. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81401. */
  81402. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81403. private webVROptions;
  81404. /**
  81405. * @hidden
  81406. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81407. */
  81408. _vrDevice: any;
  81409. /**
  81410. * The rawPose of the vrDevice.
  81411. */
  81412. rawPose: Nullable<DevicePose>;
  81413. private _onVREnabled;
  81414. private _specsVersion;
  81415. private _attached;
  81416. private _frameData;
  81417. protected _descendants: Array<Node>;
  81418. private _deviceRoomPosition;
  81419. /** @hidden */
  81420. _deviceRoomRotationQuaternion: Quaternion;
  81421. private _standingMatrix;
  81422. /**
  81423. * Represents device position in babylon space.
  81424. */
  81425. devicePosition: Vector3;
  81426. /**
  81427. * Represents device rotation in babylon space.
  81428. */
  81429. deviceRotationQuaternion: Quaternion;
  81430. /**
  81431. * The scale of the device to be used when translating from device space to babylon space.
  81432. */
  81433. deviceScaleFactor: number;
  81434. private _deviceToWorld;
  81435. private _worldToDevice;
  81436. /**
  81437. * References to the webVR controllers for the vrDevice.
  81438. */
  81439. controllers: Array<WebVRController>;
  81440. /**
  81441. * Emits an event when a controller is attached.
  81442. */
  81443. onControllersAttachedObservable: Observable<WebVRController[]>;
  81444. /**
  81445. * Emits an event when a controller's mesh has been loaded;
  81446. */
  81447. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81448. /**
  81449. * Emits an event when the HMD's pose has been updated.
  81450. */
  81451. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81452. private _poseSet;
  81453. /**
  81454. * If the rig cameras be used as parent instead of this camera.
  81455. */
  81456. rigParenting: boolean;
  81457. private _lightOnControllers;
  81458. private _defaultHeight?;
  81459. /**
  81460. * Instantiates a WebVRFreeCamera.
  81461. * @param name The name of the WebVRFreeCamera
  81462. * @param position The starting anchor position for the camera
  81463. * @param scene The scene the camera belongs to
  81464. * @param webVROptions a set of customizable options for the webVRCamera
  81465. */
  81466. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81467. /**
  81468. * Gets the device distance from the ground in meters.
  81469. * @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.
  81470. */
  81471. deviceDistanceToRoomGround(): number;
  81472. /**
  81473. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81474. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81475. */
  81476. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81477. /**
  81478. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81479. * @returns A promise with a boolean set to if the standing matrix is supported.
  81480. */
  81481. useStandingMatrixAsync(): Promise<boolean>;
  81482. /**
  81483. * Disposes the camera
  81484. */
  81485. dispose(): void;
  81486. /**
  81487. * Gets a vrController by name.
  81488. * @param name The name of the controller to retreive
  81489. * @returns the controller matching the name specified or null if not found
  81490. */
  81491. getControllerByName(name: string): Nullable<WebVRController>;
  81492. private _leftController;
  81493. /**
  81494. * The controller corresponding to the users left hand.
  81495. */
  81496. readonly leftController: Nullable<WebVRController>;
  81497. private _rightController;
  81498. /**
  81499. * The controller corresponding to the users right hand.
  81500. */
  81501. readonly rightController: Nullable<WebVRController>;
  81502. /**
  81503. * Casts a ray forward from the vrCamera's gaze.
  81504. * @param length Length of the ray (default: 100)
  81505. * @returns the ray corresponding to the gaze
  81506. */
  81507. getForwardRay(length?: number): Ray;
  81508. /**
  81509. * @hidden
  81510. * Updates the camera based on device's frame data
  81511. */
  81512. _checkInputs(): void;
  81513. /**
  81514. * Updates the poseControlled values based on the input device pose.
  81515. * @param poseData Pose coming from the device
  81516. */
  81517. updateFromDevice(poseData: DevicePose): void;
  81518. private _htmlElementAttached;
  81519. private _detachIfAttached;
  81520. /**
  81521. * WebVR's attach control will start broadcasting frames to the device.
  81522. * Note that in certain browsers (chrome for example) this function must be called
  81523. * within a user-interaction callback. Example:
  81524. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81525. *
  81526. * @param element html element to attach the vrDevice to
  81527. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81528. */
  81529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81530. /**
  81531. * Detaches the camera from the html element and disables VR
  81532. *
  81533. * @param element html element to detach from
  81534. */
  81535. detachControl(element: HTMLElement): void;
  81536. /**
  81537. * @returns the name of this class
  81538. */
  81539. getClassName(): string;
  81540. /**
  81541. * Calls resetPose on the vrDisplay
  81542. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81543. */
  81544. resetToCurrentRotation(): void;
  81545. /**
  81546. * @hidden
  81547. * Updates the rig cameras (left and right eye)
  81548. */
  81549. _updateRigCameras(): void;
  81550. private _workingVector;
  81551. private _oneVector;
  81552. private _workingMatrix;
  81553. private updateCacheCalled;
  81554. private _correctPositionIfNotTrackPosition;
  81555. /**
  81556. * @hidden
  81557. * Updates the cached values of the camera
  81558. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81559. */
  81560. _updateCache(ignoreParentClass?: boolean): void;
  81561. /**
  81562. * @hidden
  81563. * Get current device position in babylon world
  81564. */
  81565. _computeDevicePosition(): void;
  81566. /**
  81567. * Updates the current device position and rotation in the babylon world
  81568. */
  81569. update(): void;
  81570. /**
  81571. * @hidden
  81572. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81573. * @returns an identity matrix
  81574. */
  81575. _getViewMatrix(): Matrix;
  81576. private _tmpMatrix;
  81577. /**
  81578. * This function is called by the two RIG cameras.
  81579. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81580. * @hidden
  81581. */
  81582. _getWebVRViewMatrix(): Matrix;
  81583. /** @hidden */
  81584. _getWebVRProjectionMatrix(): Matrix;
  81585. private _onGamepadConnectedObserver;
  81586. private _onGamepadDisconnectedObserver;
  81587. private _updateCacheWhenTrackingDisabledObserver;
  81588. /**
  81589. * Initializes the controllers and their meshes
  81590. */
  81591. initControllers(): void;
  81592. }
  81593. }
  81594. declare module BABYLON {
  81595. /**
  81596. * Size options for a post process
  81597. */
  81598. export type PostProcessOptions = {
  81599. width: number;
  81600. height: number;
  81601. };
  81602. /**
  81603. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81604. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81605. */
  81606. export class PostProcess {
  81607. /** Name of the PostProcess. */
  81608. name: string;
  81609. /**
  81610. * Gets or sets the unique id of the post process
  81611. */
  81612. uniqueId: number;
  81613. /**
  81614. * Width of the texture to apply the post process on
  81615. */
  81616. width: number;
  81617. /**
  81618. * Height of the texture to apply the post process on
  81619. */
  81620. height: number;
  81621. /**
  81622. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81623. * @hidden
  81624. */
  81625. _outputTexture: Nullable<InternalTexture>;
  81626. /**
  81627. * Sampling mode used by the shader
  81628. * See https://doc.babylonjs.com/classes/3.1/texture
  81629. */
  81630. renderTargetSamplingMode: number;
  81631. /**
  81632. * Clear color to use when screen clearing
  81633. */
  81634. clearColor: Color4;
  81635. /**
  81636. * If the buffer needs to be cleared before applying the post process. (default: true)
  81637. * Should be set to false if shader will overwrite all previous pixels.
  81638. */
  81639. autoClear: boolean;
  81640. /**
  81641. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81642. */
  81643. alphaMode: number;
  81644. /**
  81645. * Sets the setAlphaBlendConstants of the babylon engine
  81646. */
  81647. alphaConstants: Color4;
  81648. /**
  81649. * Animations to be used for the post processing
  81650. */
  81651. animations: Animation[];
  81652. /**
  81653. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81654. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81655. */
  81656. enablePixelPerfectMode: boolean;
  81657. /**
  81658. * Force the postprocess to be applied without taking in account viewport
  81659. */
  81660. forceFullscreenViewport: boolean;
  81661. /**
  81662. * List of inspectable custom properties (used by the Inspector)
  81663. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81664. */
  81665. inspectableCustomProperties: IInspectable[];
  81666. /**
  81667. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81668. *
  81669. * | Value | Type | Description |
  81670. * | ----- | ----------------------------------- | ----------- |
  81671. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81672. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81673. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81674. *
  81675. */
  81676. scaleMode: number;
  81677. /**
  81678. * Force textures to be a power of two (default: false)
  81679. */
  81680. alwaysForcePOT: boolean;
  81681. private _samples;
  81682. /**
  81683. * Number of sample textures (default: 1)
  81684. */
  81685. samples: number;
  81686. /**
  81687. * Modify the scale of the post process to be the same as the viewport (default: false)
  81688. */
  81689. adaptScaleToCurrentViewport: boolean;
  81690. private _camera;
  81691. private _scene;
  81692. private _engine;
  81693. private _options;
  81694. private _reusable;
  81695. private _textureType;
  81696. /**
  81697. * Smart array of input and output textures for the post process.
  81698. * @hidden
  81699. */
  81700. _textures: SmartArray<InternalTexture>;
  81701. /**
  81702. * The index in _textures that corresponds to the output texture.
  81703. * @hidden
  81704. */
  81705. _currentRenderTextureInd: number;
  81706. private _effect;
  81707. private _samplers;
  81708. private _fragmentUrl;
  81709. private _vertexUrl;
  81710. private _parameters;
  81711. private _scaleRatio;
  81712. protected _indexParameters: any;
  81713. private _shareOutputWithPostProcess;
  81714. private _texelSize;
  81715. private _forcedOutputTexture;
  81716. /**
  81717. * Returns the fragment url or shader name used in the post process.
  81718. * @returns the fragment url or name in the shader store.
  81719. */
  81720. getEffectName(): string;
  81721. /**
  81722. * An event triggered when the postprocess is activated.
  81723. */
  81724. onActivateObservable: Observable<Camera>;
  81725. private _onActivateObserver;
  81726. /**
  81727. * A function that is added to the onActivateObservable
  81728. */
  81729. onActivate: Nullable<(camera: Camera) => void>;
  81730. /**
  81731. * An event triggered when the postprocess changes its size.
  81732. */
  81733. onSizeChangedObservable: Observable<PostProcess>;
  81734. private _onSizeChangedObserver;
  81735. /**
  81736. * A function that is added to the onSizeChangedObservable
  81737. */
  81738. onSizeChanged: (postProcess: PostProcess) => void;
  81739. /**
  81740. * An event triggered when the postprocess applies its effect.
  81741. */
  81742. onApplyObservable: Observable<Effect>;
  81743. private _onApplyObserver;
  81744. /**
  81745. * A function that is added to the onApplyObservable
  81746. */
  81747. onApply: (effect: Effect) => void;
  81748. /**
  81749. * An event triggered before rendering the postprocess
  81750. */
  81751. onBeforeRenderObservable: Observable<Effect>;
  81752. private _onBeforeRenderObserver;
  81753. /**
  81754. * A function that is added to the onBeforeRenderObservable
  81755. */
  81756. onBeforeRender: (effect: Effect) => void;
  81757. /**
  81758. * An event triggered after rendering the postprocess
  81759. */
  81760. onAfterRenderObservable: Observable<Effect>;
  81761. private _onAfterRenderObserver;
  81762. /**
  81763. * A function that is added to the onAfterRenderObservable
  81764. */
  81765. onAfterRender: (efect: Effect) => void;
  81766. /**
  81767. * 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
  81768. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81769. */
  81770. inputTexture: InternalTexture;
  81771. /**
  81772. * Gets the camera which post process is applied to.
  81773. * @returns The camera the post process is applied to.
  81774. */
  81775. getCamera(): Camera;
  81776. /**
  81777. * Gets the texel size of the postprocess.
  81778. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81779. */
  81780. readonly texelSize: Vector2;
  81781. /**
  81782. * Creates a new instance PostProcess
  81783. * @param name The name of the PostProcess.
  81784. * @param fragmentUrl The url of the fragment shader to be used.
  81785. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81786. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81787. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81788. * @param camera The camera to apply the render pass to.
  81789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81790. * @param engine The engine which the post process will be applied. (default: current engine)
  81791. * @param reusable If the post process can be reused on the same frame. (default: false)
  81792. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81793. * @param textureType Type of textures used when performing the post process. (default: 0)
  81794. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81795. * @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
  81796. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81797. */
  81798. constructor(
  81799. /** Name of the PostProcess. */
  81800. 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);
  81801. /**
  81802. * Gets a string idenfifying the name of the class
  81803. * @returns "PostProcess" string
  81804. */
  81805. getClassName(): string;
  81806. /**
  81807. * Gets the engine which this post process belongs to.
  81808. * @returns The engine the post process was enabled with.
  81809. */
  81810. getEngine(): Engine;
  81811. /**
  81812. * The effect that is created when initializing the post process.
  81813. * @returns The created effect corresponding the the postprocess.
  81814. */
  81815. getEffect(): Effect;
  81816. /**
  81817. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81818. * @param postProcess The post process to share the output with.
  81819. * @returns This post process.
  81820. */
  81821. shareOutputWith(postProcess: PostProcess): PostProcess;
  81822. /**
  81823. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81824. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81825. */
  81826. useOwnOutput(): void;
  81827. /**
  81828. * Updates the effect with the current post process compile time values and recompiles the shader.
  81829. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81830. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81831. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81832. * @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
  81833. * @param onCompiled Called when the shader has been compiled.
  81834. * @param onError Called if there is an error when compiling a shader.
  81835. */
  81836. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81837. /**
  81838. * The post process is reusable if it can be used multiple times within one frame.
  81839. * @returns If the post process is reusable
  81840. */
  81841. isReusable(): boolean;
  81842. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81843. markTextureDirty(): void;
  81844. /**
  81845. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81846. * 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.
  81847. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81848. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81849. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81850. * @returns The target texture that was bound to be written to.
  81851. */
  81852. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81853. /**
  81854. * If the post process is supported.
  81855. */
  81856. readonly isSupported: boolean;
  81857. /**
  81858. * The aspect ratio of the output texture.
  81859. */
  81860. readonly aspectRatio: number;
  81861. /**
  81862. * Get a value indicating if the post-process is ready to be used
  81863. * @returns true if the post-process is ready (shader is compiled)
  81864. */
  81865. isReady(): boolean;
  81866. /**
  81867. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81868. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81869. */
  81870. apply(): Nullable<Effect>;
  81871. private _disposeTextures;
  81872. /**
  81873. * Disposes the post process.
  81874. * @param camera The camera to dispose the post process on.
  81875. */
  81876. dispose(camera?: Camera): void;
  81877. }
  81878. }
  81879. declare module BABYLON {
  81880. /** @hidden */
  81881. export var kernelBlurVaryingDeclaration: {
  81882. name: string;
  81883. shader: string;
  81884. };
  81885. }
  81886. declare module BABYLON {
  81887. /** @hidden */
  81888. export var kernelBlurFragment: {
  81889. name: string;
  81890. shader: string;
  81891. };
  81892. }
  81893. declare module BABYLON {
  81894. /** @hidden */
  81895. export var kernelBlurFragment2: {
  81896. name: string;
  81897. shader: string;
  81898. };
  81899. }
  81900. declare module BABYLON {
  81901. /** @hidden */
  81902. export var kernelBlurPixelShader: {
  81903. name: string;
  81904. shader: string;
  81905. };
  81906. }
  81907. declare module BABYLON {
  81908. /** @hidden */
  81909. export var kernelBlurVertex: {
  81910. name: string;
  81911. shader: string;
  81912. };
  81913. }
  81914. declare module BABYLON {
  81915. /** @hidden */
  81916. export var kernelBlurVertexShader: {
  81917. name: string;
  81918. shader: string;
  81919. };
  81920. }
  81921. declare module BABYLON {
  81922. /**
  81923. * The Blur Post Process which blurs an image based on a kernel and direction.
  81924. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81925. */
  81926. export class BlurPostProcess extends PostProcess {
  81927. /** The direction in which to blur the image. */
  81928. direction: Vector2;
  81929. private blockCompilation;
  81930. protected _kernel: number;
  81931. protected _idealKernel: number;
  81932. protected _packedFloat: boolean;
  81933. private _staticDefines;
  81934. /**
  81935. * Sets the length in pixels of the blur sample region
  81936. */
  81937. /**
  81938. * Gets the length in pixels of the blur sample region
  81939. */
  81940. kernel: number;
  81941. /**
  81942. * Sets wether or not the blur needs to unpack/repack floats
  81943. */
  81944. /**
  81945. * Gets wether or not the blur is unpacking/repacking floats
  81946. */
  81947. packedFloat: boolean;
  81948. /**
  81949. * Creates a new instance BlurPostProcess
  81950. * @param name The name of the effect.
  81951. * @param direction The direction in which to blur the image.
  81952. * @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.
  81953. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81954. * @param camera The camera to apply the render pass to.
  81955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81956. * @param engine The engine which the post process will be applied. (default: current engine)
  81957. * @param reusable If the post process can be reused on the same frame. (default: false)
  81958. * @param textureType Type of textures used when performing the post process. (default: 0)
  81959. * @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)
  81960. */
  81961. constructor(name: string,
  81962. /** The direction in which to blur the image. */
  81963. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81964. /**
  81965. * Updates the effect with the current post process compile time values and recompiles the shader.
  81966. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81967. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81968. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81969. * @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
  81970. * @param onCompiled Called when the shader has been compiled.
  81971. * @param onError Called if there is an error when compiling a shader.
  81972. */
  81973. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81974. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81975. /**
  81976. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81977. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81978. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81979. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81980. * The gaps between physical kernels are compensated for in the weighting of the samples
  81981. * @param idealKernel Ideal blur kernel.
  81982. * @return Nearest best kernel.
  81983. */
  81984. protected _nearestBestKernel(idealKernel: number): number;
  81985. /**
  81986. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81987. * @param x The point on the Gaussian distribution to sample.
  81988. * @return the value of the Gaussian function at x.
  81989. */
  81990. protected _gaussianWeight(x: number): number;
  81991. /**
  81992. * Generates a string that can be used as a floating point number in GLSL.
  81993. * @param x Value to print.
  81994. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81995. * @return GLSL float string.
  81996. */
  81997. protected _glslFloat(x: number, decimalFigures?: number): string;
  81998. }
  81999. }
  82000. declare module BABYLON {
  82001. /**
  82002. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82003. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82004. * You can then easily use it as a reflectionTexture on a flat surface.
  82005. * In case the surface is not a plane, please consider relying on reflection probes.
  82006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82007. */
  82008. export class MirrorTexture extends RenderTargetTexture {
  82009. private scene;
  82010. /**
  82011. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82012. * 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.
  82013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82014. */
  82015. mirrorPlane: Plane;
  82016. /**
  82017. * Define the blur ratio used to blur the reflection if needed.
  82018. */
  82019. blurRatio: number;
  82020. /**
  82021. * Define the adaptive blur kernel used to blur the reflection if needed.
  82022. * This will autocompute the closest best match for the `blurKernel`
  82023. */
  82024. adaptiveBlurKernel: number;
  82025. /**
  82026. * Define the blur kernel used to blur the reflection if needed.
  82027. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82028. */
  82029. blurKernel: number;
  82030. /**
  82031. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82032. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82033. */
  82034. blurKernelX: number;
  82035. /**
  82036. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82037. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82038. */
  82039. blurKernelY: number;
  82040. private _autoComputeBlurKernel;
  82041. protected _onRatioRescale(): void;
  82042. private _updateGammaSpace;
  82043. private _imageProcessingConfigChangeObserver;
  82044. private _transformMatrix;
  82045. private _mirrorMatrix;
  82046. private _savedViewMatrix;
  82047. private _blurX;
  82048. private _blurY;
  82049. private _adaptiveBlurKernel;
  82050. private _blurKernelX;
  82051. private _blurKernelY;
  82052. private _blurRatio;
  82053. /**
  82054. * Instantiates a Mirror Texture.
  82055. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82056. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82057. * You can then easily use it as a reflectionTexture on a flat surface.
  82058. * In case the surface is not a plane, please consider relying on reflection probes.
  82059. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82060. * @param name
  82061. * @param size
  82062. * @param scene
  82063. * @param generateMipMaps
  82064. * @param type
  82065. * @param samplingMode
  82066. * @param generateDepthBuffer
  82067. */
  82068. constructor(name: string, size: number | {
  82069. width: number;
  82070. height: number;
  82071. } | {
  82072. ratio: number;
  82073. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82074. private _preparePostProcesses;
  82075. /**
  82076. * Clone the mirror texture.
  82077. * @returns the cloned texture
  82078. */
  82079. clone(): MirrorTexture;
  82080. /**
  82081. * Serialize the texture to a JSON representation you could use in Parse later on
  82082. * @returns the serialized JSON representation
  82083. */
  82084. serialize(): any;
  82085. /**
  82086. * Dispose the texture and release its associated resources.
  82087. */
  82088. dispose(): void;
  82089. }
  82090. }
  82091. declare module BABYLON {
  82092. /**
  82093. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82094. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82095. */
  82096. export class Texture extends BaseTexture {
  82097. /**
  82098. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82099. */
  82100. static SerializeBuffers: boolean;
  82101. /** @hidden */
  82102. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82103. /** @hidden */
  82104. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82105. /** @hidden */
  82106. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82107. /** nearest is mag = nearest and min = nearest and mip = linear */
  82108. static readonly NEAREST_SAMPLINGMODE: number;
  82109. /** nearest is mag = nearest and min = nearest and mip = linear */
  82110. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82111. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82112. static readonly BILINEAR_SAMPLINGMODE: number;
  82113. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82114. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82115. /** Trilinear is mag = linear and min = linear and mip = linear */
  82116. static readonly TRILINEAR_SAMPLINGMODE: number;
  82117. /** Trilinear is mag = linear and min = linear and mip = linear */
  82118. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82119. /** mag = nearest and min = nearest and mip = nearest */
  82120. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82121. /** mag = nearest and min = linear and mip = nearest */
  82122. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82123. /** mag = nearest and min = linear and mip = linear */
  82124. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82125. /** mag = nearest and min = linear and mip = none */
  82126. static readonly NEAREST_LINEAR: number;
  82127. /** mag = nearest and min = nearest and mip = none */
  82128. static readonly NEAREST_NEAREST: number;
  82129. /** mag = linear and min = nearest and mip = nearest */
  82130. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82131. /** mag = linear and min = nearest and mip = linear */
  82132. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82133. /** mag = linear and min = linear and mip = none */
  82134. static readonly LINEAR_LINEAR: number;
  82135. /** mag = linear and min = nearest and mip = none */
  82136. static readonly LINEAR_NEAREST: number;
  82137. /** Explicit coordinates mode */
  82138. static readonly EXPLICIT_MODE: number;
  82139. /** Spherical coordinates mode */
  82140. static readonly SPHERICAL_MODE: number;
  82141. /** Planar coordinates mode */
  82142. static readonly PLANAR_MODE: number;
  82143. /** Cubic coordinates mode */
  82144. static readonly CUBIC_MODE: number;
  82145. /** Projection coordinates mode */
  82146. static readonly PROJECTION_MODE: number;
  82147. /** Inverse Cubic coordinates mode */
  82148. static readonly SKYBOX_MODE: number;
  82149. /** Inverse Cubic coordinates mode */
  82150. static readonly INVCUBIC_MODE: number;
  82151. /** Equirectangular coordinates mode */
  82152. static readonly EQUIRECTANGULAR_MODE: number;
  82153. /** Equirectangular Fixed coordinates mode */
  82154. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82155. /** Equirectangular Fixed Mirrored coordinates mode */
  82156. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82157. /** Texture is not repeating outside of 0..1 UVs */
  82158. static readonly CLAMP_ADDRESSMODE: number;
  82159. /** Texture is repeating outside of 0..1 UVs */
  82160. static readonly WRAP_ADDRESSMODE: number;
  82161. /** Texture is repeating and mirrored */
  82162. static readonly MIRROR_ADDRESSMODE: number;
  82163. /**
  82164. * 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
  82165. */
  82166. static UseSerializedUrlIfAny: boolean;
  82167. /**
  82168. * Define the url of the texture.
  82169. */
  82170. url: Nullable<string>;
  82171. /**
  82172. * Define an offset on the texture to offset the u coordinates of the UVs
  82173. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82174. */
  82175. uOffset: number;
  82176. /**
  82177. * Define an offset on the texture to offset the v coordinates of the UVs
  82178. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82179. */
  82180. vOffset: number;
  82181. /**
  82182. * Define an offset on the texture to scale the u coordinates of the UVs
  82183. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82184. */
  82185. uScale: number;
  82186. /**
  82187. * Define an offset on the texture to scale the v coordinates of the UVs
  82188. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82189. */
  82190. vScale: number;
  82191. /**
  82192. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82193. * @see http://doc.babylonjs.com/how_to/more_materials
  82194. */
  82195. uAng: number;
  82196. /**
  82197. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82198. * @see http://doc.babylonjs.com/how_to/more_materials
  82199. */
  82200. vAng: number;
  82201. /**
  82202. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82203. * @see http://doc.babylonjs.com/how_to/more_materials
  82204. */
  82205. wAng: number;
  82206. /**
  82207. * Defines the center of rotation (U)
  82208. */
  82209. uRotationCenter: number;
  82210. /**
  82211. * Defines the center of rotation (V)
  82212. */
  82213. vRotationCenter: number;
  82214. /**
  82215. * Defines the center of rotation (W)
  82216. */
  82217. wRotationCenter: number;
  82218. /**
  82219. * Are mip maps generated for this texture or not.
  82220. */
  82221. readonly noMipmap: boolean;
  82222. /**
  82223. * List of inspectable custom properties (used by the Inspector)
  82224. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82225. */
  82226. inspectableCustomProperties: Nullable<IInspectable[]>;
  82227. private _noMipmap;
  82228. /** @hidden */
  82229. _invertY: boolean;
  82230. private _rowGenerationMatrix;
  82231. private _cachedTextureMatrix;
  82232. private _projectionModeMatrix;
  82233. private _t0;
  82234. private _t1;
  82235. private _t2;
  82236. private _cachedUOffset;
  82237. private _cachedVOffset;
  82238. private _cachedUScale;
  82239. private _cachedVScale;
  82240. private _cachedUAng;
  82241. private _cachedVAng;
  82242. private _cachedWAng;
  82243. private _cachedProjectionMatrixId;
  82244. private _cachedCoordinatesMode;
  82245. /** @hidden */
  82246. protected _initialSamplingMode: number;
  82247. /** @hidden */
  82248. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82249. private _deleteBuffer;
  82250. protected _format: Nullable<number>;
  82251. private _delayedOnLoad;
  82252. private _delayedOnError;
  82253. /**
  82254. * Observable triggered once the texture has been loaded.
  82255. */
  82256. onLoadObservable: Observable<Texture>;
  82257. protected _isBlocking: boolean;
  82258. /**
  82259. * Is the texture preventing material to render while loading.
  82260. * If false, a default texture will be used instead of the loading one during the preparation step.
  82261. */
  82262. isBlocking: boolean;
  82263. /**
  82264. * Get the current sampling mode associated with the texture.
  82265. */
  82266. readonly samplingMode: number;
  82267. /**
  82268. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82269. */
  82270. readonly invertY: boolean;
  82271. /**
  82272. * Instantiates a new texture.
  82273. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82274. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82275. * @param url define the url of the picture to load as a texture
  82276. * @param scene define the scene or engine the texture will belong to
  82277. * @param noMipmap define if the texture will require mip maps or not
  82278. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82279. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82280. * @param onLoad define a callback triggered when the texture has been loaded
  82281. * @param onError define a callback triggered when an error occurred during the loading session
  82282. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82283. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82284. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82285. */
  82286. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  82287. /**
  82288. * Update the url (and optional buffer) of this texture if url was null during construction.
  82289. * @param url the url of the texture
  82290. * @param buffer the buffer of the texture (defaults to null)
  82291. * @param onLoad callback called when the texture is loaded (defaults to null)
  82292. */
  82293. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82294. /**
  82295. * Finish the loading sequence of a texture flagged as delayed load.
  82296. * @hidden
  82297. */
  82298. delayLoad(): void;
  82299. private _prepareRowForTextureGeneration;
  82300. /**
  82301. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82302. * @returns the transform matrix of the texture.
  82303. */
  82304. getTextureMatrix(): Matrix;
  82305. /**
  82306. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82307. * @returns The reflection texture transform
  82308. */
  82309. getReflectionTextureMatrix(): Matrix;
  82310. /**
  82311. * Clones the texture.
  82312. * @returns the cloned texture
  82313. */
  82314. clone(): Texture;
  82315. /**
  82316. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82317. * @returns The JSON representation of the texture
  82318. */
  82319. serialize(): any;
  82320. /**
  82321. * Get the current class name of the texture useful for serialization or dynamic coding.
  82322. * @returns "Texture"
  82323. */
  82324. getClassName(): string;
  82325. /**
  82326. * Dispose the texture and release its associated resources.
  82327. */
  82328. dispose(): void;
  82329. /**
  82330. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82331. * @param parsedTexture Define the JSON representation of the texture
  82332. * @param scene Define the scene the parsed texture should be instantiated in
  82333. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82334. * @returns The parsed texture if successful
  82335. */
  82336. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82337. /**
  82338. * Creates a texture from its base 64 representation.
  82339. * @param data Define the base64 payload without the data: prefix
  82340. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82341. * @param scene Define the scene the texture should belong to
  82342. * @param noMipmap Forces the texture to not create mip map information if true
  82343. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82344. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82345. * @param onLoad define a callback triggered when the texture has been loaded
  82346. * @param onError define a callback triggered when an error occurred during the loading session
  82347. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82348. * @returns the created texture
  82349. */
  82350. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82351. /**
  82352. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82353. * @param data Define the base64 payload without the data: prefix
  82354. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82355. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82356. * @param scene Define the scene the texture should belong to
  82357. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82358. * @param noMipmap Forces the texture to not create mip map information if true
  82359. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82360. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82361. * @param onLoad define a callback triggered when the texture has been loaded
  82362. * @param onError define a callback triggered when an error occurred during the loading session
  82363. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82364. * @returns the created texture
  82365. */
  82366. 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;
  82367. }
  82368. }
  82369. declare module BABYLON {
  82370. /**
  82371. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82372. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82373. */
  82374. export class PostProcessManager {
  82375. private _scene;
  82376. private _indexBuffer;
  82377. private _vertexBuffers;
  82378. /**
  82379. * Creates a new instance PostProcess
  82380. * @param scene The scene that the post process is associated with.
  82381. */
  82382. constructor(scene: Scene);
  82383. private _prepareBuffers;
  82384. private _buildIndexBuffer;
  82385. /**
  82386. * Rebuilds the vertex buffers of the manager.
  82387. * @hidden
  82388. */
  82389. _rebuild(): void;
  82390. /**
  82391. * Prepares a frame to be run through a post process.
  82392. * @param sourceTexture The input texture to the post procesess. (default: null)
  82393. * @param postProcesses An array of post processes to be run. (default: null)
  82394. * @returns True if the post processes were able to be run.
  82395. * @hidden
  82396. */
  82397. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82398. /**
  82399. * Manually render a set of post processes to a texture.
  82400. * @param postProcesses An array of post processes to be run.
  82401. * @param targetTexture The target texture to render to.
  82402. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82403. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82404. * @param lodLevel defines which lod of the texture to render to
  82405. */
  82406. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82407. /**
  82408. * Finalize the result of the output of the postprocesses.
  82409. * @param doNotPresent If true the result will not be displayed to the screen.
  82410. * @param targetTexture The target texture to render to.
  82411. * @param faceIndex The index of the face to bind the target texture to.
  82412. * @param postProcesses The array of post processes to render.
  82413. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82414. * @hidden
  82415. */
  82416. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82417. /**
  82418. * Disposes of the post process manager.
  82419. */
  82420. dispose(): void;
  82421. }
  82422. }
  82423. declare module BABYLON {
  82424. /** Interface used by value gradients (color, factor, ...) */
  82425. export interface IValueGradient {
  82426. /**
  82427. * Gets or sets the gradient value (between 0 and 1)
  82428. */
  82429. gradient: number;
  82430. }
  82431. /** Class used to store color4 gradient */
  82432. export class ColorGradient implements IValueGradient {
  82433. /**
  82434. * Gets or sets the gradient value (between 0 and 1)
  82435. */
  82436. gradient: number;
  82437. /**
  82438. * Gets or sets first associated color
  82439. */
  82440. color1: Color4;
  82441. /**
  82442. * Gets or sets second associated color
  82443. */
  82444. color2?: Color4;
  82445. /**
  82446. * Will get a color picked randomly between color1 and color2.
  82447. * If color2 is undefined then color1 will be used
  82448. * @param result defines the target Color4 to store the result in
  82449. */
  82450. getColorToRef(result: Color4): void;
  82451. }
  82452. /** Class used to store color 3 gradient */
  82453. export class Color3Gradient implements IValueGradient {
  82454. /**
  82455. * Gets or sets the gradient value (between 0 and 1)
  82456. */
  82457. gradient: number;
  82458. /**
  82459. * Gets or sets the associated color
  82460. */
  82461. color: Color3;
  82462. }
  82463. /** Class used to store factor gradient */
  82464. export class FactorGradient implements IValueGradient {
  82465. /**
  82466. * Gets or sets the gradient value (between 0 and 1)
  82467. */
  82468. gradient: number;
  82469. /**
  82470. * Gets or sets first associated factor
  82471. */
  82472. factor1: number;
  82473. /**
  82474. * Gets or sets second associated factor
  82475. */
  82476. factor2?: number;
  82477. /**
  82478. * Will get a number picked randomly between factor1 and factor2.
  82479. * If factor2 is undefined then factor1 will be used
  82480. * @returns the picked number
  82481. */
  82482. getFactor(): number;
  82483. }
  82484. /**
  82485. * Helper used to simplify some generic gradient tasks
  82486. */
  82487. export class GradientHelper {
  82488. /**
  82489. * Gets the current gradient from an array of IValueGradient
  82490. * @param ratio defines the current ratio to get
  82491. * @param gradients defines the array of IValueGradient
  82492. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82493. */
  82494. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82495. }
  82496. }
  82497. declare module BABYLON {
  82498. interface ThinEngine {
  82499. /**
  82500. * Creates a dynamic texture
  82501. * @param width defines the width of the texture
  82502. * @param height defines the height of the texture
  82503. * @param generateMipMaps defines if the engine should generate the mip levels
  82504. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82505. * @returns the dynamic texture inside an InternalTexture
  82506. */
  82507. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82508. /**
  82509. * Update the content of a dynamic texture
  82510. * @param texture defines the texture to update
  82511. * @param canvas defines the canvas containing the source
  82512. * @param invertY defines if data must be stored with Y axis inverted
  82513. * @param premulAlpha defines if alpha is stored as premultiplied
  82514. * @param format defines the format of the data
  82515. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82516. */
  82517. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82518. }
  82519. }
  82520. declare module BABYLON {
  82521. /**
  82522. * A class extending Texture allowing drawing on a texture
  82523. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82524. */
  82525. export class DynamicTexture extends Texture {
  82526. private _generateMipMaps;
  82527. private _canvas;
  82528. private _context;
  82529. private _engine;
  82530. /**
  82531. * Creates a DynamicTexture
  82532. * @param name defines the name of the texture
  82533. * @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
  82534. * @param scene defines the scene where you want the texture
  82535. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82536. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82537. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82538. */
  82539. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82540. /**
  82541. * Get the current class name of the texture useful for serialization or dynamic coding.
  82542. * @returns "DynamicTexture"
  82543. */
  82544. getClassName(): string;
  82545. /**
  82546. * Gets the current state of canRescale
  82547. */
  82548. readonly canRescale: boolean;
  82549. private _recreate;
  82550. /**
  82551. * Scales the texture
  82552. * @param ratio the scale factor to apply to both width and height
  82553. */
  82554. scale(ratio: number): void;
  82555. /**
  82556. * Resizes the texture
  82557. * @param width the new width
  82558. * @param height the new height
  82559. */
  82560. scaleTo(width: number, height: number): void;
  82561. /**
  82562. * Gets the context of the canvas used by the texture
  82563. * @returns the canvas context of the dynamic texture
  82564. */
  82565. getContext(): CanvasRenderingContext2D;
  82566. /**
  82567. * Clears the texture
  82568. */
  82569. clear(): void;
  82570. /**
  82571. * Updates the texture
  82572. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82573. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82574. */
  82575. update(invertY?: boolean, premulAlpha?: boolean): void;
  82576. /**
  82577. * Draws text onto the texture
  82578. * @param text defines the text to be drawn
  82579. * @param x defines the placement of the text from the left
  82580. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82581. * @param font defines the font to be used with font-style, font-size, font-name
  82582. * @param color defines the color used for the text
  82583. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82584. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82585. * @param update defines whether texture is immediately update (default is true)
  82586. */
  82587. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82588. /**
  82589. * Clones the texture
  82590. * @returns the clone of the texture.
  82591. */
  82592. clone(): DynamicTexture;
  82593. /**
  82594. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82595. * @returns a serialized dynamic texture object
  82596. */
  82597. serialize(): any;
  82598. /** @hidden */
  82599. _rebuild(): void;
  82600. }
  82601. }
  82602. declare module BABYLON {
  82603. interface AbstractScene {
  82604. /**
  82605. * The list of procedural textures added to the scene
  82606. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82607. */
  82608. proceduralTextures: Array<ProceduralTexture>;
  82609. }
  82610. /**
  82611. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82612. * in a given scene.
  82613. */
  82614. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82615. /**
  82616. * The component name helpfull to identify the component in the list of scene components.
  82617. */
  82618. readonly name: string;
  82619. /**
  82620. * The scene the component belongs to.
  82621. */
  82622. scene: Scene;
  82623. /**
  82624. * Creates a new instance of the component for the given scene
  82625. * @param scene Defines the scene to register the component in
  82626. */
  82627. constructor(scene: Scene);
  82628. /**
  82629. * Registers the component in a given scene
  82630. */
  82631. register(): void;
  82632. /**
  82633. * Rebuilds the elements related to this component in case of
  82634. * context lost for instance.
  82635. */
  82636. rebuild(): void;
  82637. /**
  82638. * Disposes the component and the associated ressources.
  82639. */
  82640. dispose(): void;
  82641. private _beforeClear;
  82642. }
  82643. }
  82644. declare module BABYLON {
  82645. interface ThinEngine {
  82646. /**
  82647. * Creates a new render target cube texture
  82648. * @param size defines the size of the texture
  82649. * @param options defines the options used to create the texture
  82650. * @returns a new render target cube texture stored in an InternalTexture
  82651. */
  82652. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82653. }
  82654. }
  82655. declare module BABYLON {
  82656. /** @hidden */
  82657. export var proceduralVertexShader: {
  82658. name: string;
  82659. shader: string;
  82660. };
  82661. }
  82662. declare module BABYLON {
  82663. /**
  82664. * 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.
  82665. * This is the base class of any Procedural texture and contains most of the shareable code.
  82666. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82667. */
  82668. export class ProceduralTexture extends Texture {
  82669. isCube: boolean;
  82670. /**
  82671. * Define if the texture is enabled or not (disabled texture will not render)
  82672. */
  82673. isEnabled: boolean;
  82674. /**
  82675. * Define if the texture must be cleared before rendering (default is true)
  82676. */
  82677. autoClear: boolean;
  82678. /**
  82679. * Callback called when the texture is generated
  82680. */
  82681. onGenerated: () => void;
  82682. /**
  82683. * Event raised when the texture is generated
  82684. */
  82685. onGeneratedObservable: Observable<ProceduralTexture>;
  82686. /** @hidden */
  82687. _generateMipMaps: boolean;
  82688. /** @hidden **/
  82689. _effect: Effect;
  82690. /** @hidden */
  82691. _textures: {
  82692. [key: string]: Texture;
  82693. };
  82694. private _size;
  82695. private _currentRefreshId;
  82696. private _refreshRate;
  82697. private _vertexBuffers;
  82698. private _indexBuffer;
  82699. private _uniforms;
  82700. private _samplers;
  82701. private _fragment;
  82702. private _floats;
  82703. private _ints;
  82704. private _floatsArrays;
  82705. private _colors3;
  82706. private _colors4;
  82707. private _vectors2;
  82708. private _vectors3;
  82709. private _matrices;
  82710. private _fallbackTexture;
  82711. private _fallbackTextureUsed;
  82712. private _engine;
  82713. private _cachedDefines;
  82714. private _contentUpdateId;
  82715. private _contentData;
  82716. /**
  82717. * Instantiates a new procedural texture.
  82718. * 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.
  82719. * This is the base class of any Procedural texture and contains most of the shareable code.
  82720. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82721. * @param name Define the name of the texture
  82722. * @param size Define the size of the texture to create
  82723. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  82724. * @param scene Define the scene the texture belongs to
  82725. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  82726. * @param generateMipMaps Define if the texture should creates mip maps or not
  82727. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  82728. */
  82729. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  82730. /**
  82731. * The effect that is created when initializing the post process.
  82732. * @returns The created effect corresponding the the postprocess.
  82733. */
  82734. getEffect(): Effect;
  82735. /**
  82736. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  82737. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  82738. */
  82739. getContent(): Nullable<ArrayBufferView>;
  82740. private _createIndexBuffer;
  82741. /** @hidden */
  82742. _rebuild(): void;
  82743. /**
  82744. * Resets the texture in order to recreate its associated resources.
  82745. * This can be called in case of context loss
  82746. */
  82747. reset(): void;
  82748. protected _getDefines(): string;
  82749. /**
  82750. * Is the texture ready to be used ? (rendered at least once)
  82751. * @returns true if ready, otherwise, false.
  82752. */
  82753. isReady(): boolean;
  82754. /**
  82755. * Resets the refresh counter of the texture and start bak from scratch.
  82756. * Could be useful to regenerate the texture if it is setup to render only once.
  82757. */
  82758. resetRefreshCounter(): void;
  82759. /**
  82760. * Set the fragment shader to use in order to render the texture.
  82761. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  82762. */
  82763. setFragment(fragment: any): void;
  82764. /**
  82765. * Define the refresh rate of the texture or the rendering frequency.
  82766. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82767. */
  82768. refreshRate: number;
  82769. /** @hidden */
  82770. _shouldRender(): boolean;
  82771. /**
  82772. * Get the size the texture is rendering at.
  82773. * @returns the size (texture is always squared)
  82774. */
  82775. getRenderSize(): number;
  82776. /**
  82777. * Resize the texture to new value.
  82778. * @param size Define the new size the texture should have
  82779. * @param generateMipMaps Define whether the new texture should create mip maps
  82780. */
  82781. resize(size: number, generateMipMaps: boolean): void;
  82782. private _checkUniform;
  82783. /**
  82784. * Set a texture in the shader program used to render.
  82785. * @param name Define the name of the uniform samplers as defined in the shader
  82786. * @param texture Define the texture to bind to this sampler
  82787. * @return the texture itself allowing "fluent" like uniform updates
  82788. */
  82789. setTexture(name: string, texture: Texture): ProceduralTexture;
  82790. /**
  82791. * Set a float in the shader.
  82792. * @param name Define the name of the uniform as defined in the shader
  82793. * @param value Define the value to give to the uniform
  82794. * @return the texture itself allowing "fluent" like uniform updates
  82795. */
  82796. setFloat(name: string, value: number): ProceduralTexture;
  82797. /**
  82798. * Set a int in the shader.
  82799. * @param name Define the name of the uniform as defined in the shader
  82800. * @param value Define the value to give to the uniform
  82801. * @return the texture itself allowing "fluent" like uniform updates
  82802. */
  82803. setInt(name: string, value: number): ProceduralTexture;
  82804. /**
  82805. * Set an array of floats in the shader.
  82806. * @param name Define the name of the uniform as defined in the shader
  82807. * @param value Define the value to give to the uniform
  82808. * @return the texture itself allowing "fluent" like uniform updates
  82809. */
  82810. setFloats(name: string, value: number[]): ProceduralTexture;
  82811. /**
  82812. * Set a vec3 in the shader from a Color3.
  82813. * @param name Define the name of the uniform as defined in the shader
  82814. * @param value Define the value to give to the uniform
  82815. * @return the texture itself allowing "fluent" like uniform updates
  82816. */
  82817. setColor3(name: string, value: Color3): ProceduralTexture;
  82818. /**
  82819. * Set a vec4 in the shader from a Color4.
  82820. * @param name Define the name of the uniform as defined in the shader
  82821. * @param value Define the value to give to the uniform
  82822. * @return the texture itself allowing "fluent" like uniform updates
  82823. */
  82824. setColor4(name: string, value: Color4): ProceduralTexture;
  82825. /**
  82826. * Set a vec2 in the shader from a Vector2.
  82827. * @param name Define the name of the uniform as defined in the shader
  82828. * @param value Define the value to give to the uniform
  82829. * @return the texture itself allowing "fluent" like uniform updates
  82830. */
  82831. setVector2(name: string, value: Vector2): ProceduralTexture;
  82832. /**
  82833. * Set a vec3 in the shader from a Vector3.
  82834. * @param name Define the name of the uniform as defined in the shader
  82835. * @param value Define the value to give to the uniform
  82836. * @return the texture itself allowing "fluent" like uniform updates
  82837. */
  82838. setVector3(name: string, value: Vector3): ProceduralTexture;
  82839. /**
  82840. * Set a mat4 in the shader from a MAtrix.
  82841. * @param name Define the name of the uniform as defined in the shader
  82842. * @param value Define the value to give to the uniform
  82843. * @return the texture itself allowing "fluent" like uniform updates
  82844. */
  82845. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82846. /**
  82847. * Render the texture to its associated render target.
  82848. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82849. */
  82850. render(useCameraPostProcess?: boolean): void;
  82851. /**
  82852. * Clone the texture.
  82853. * @returns the cloned texture
  82854. */
  82855. clone(): ProceduralTexture;
  82856. /**
  82857. * Dispose the texture and release its asoociated resources.
  82858. */
  82859. dispose(): void;
  82860. }
  82861. }
  82862. declare module BABYLON {
  82863. /**
  82864. * This represents the base class for particle system in Babylon.
  82865. * 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.
  82866. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82867. * @example https://doc.babylonjs.com/babylon101/particles
  82868. */
  82869. export class BaseParticleSystem {
  82870. /**
  82871. * Source color is added to the destination color without alpha affecting the result
  82872. */
  82873. static BLENDMODE_ONEONE: number;
  82874. /**
  82875. * Blend current color and particle color using particle’s alpha
  82876. */
  82877. static BLENDMODE_STANDARD: number;
  82878. /**
  82879. * Add current color and particle color multiplied by particle’s alpha
  82880. */
  82881. static BLENDMODE_ADD: number;
  82882. /**
  82883. * Multiply current color with particle color
  82884. */
  82885. static BLENDMODE_MULTIPLY: number;
  82886. /**
  82887. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82888. */
  82889. static BLENDMODE_MULTIPLYADD: number;
  82890. /**
  82891. * List of animations used by the particle system.
  82892. */
  82893. animations: Animation[];
  82894. /**
  82895. * The id of the Particle system.
  82896. */
  82897. id: string;
  82898. /**
  82899. * The friendly name of the Particle system.
  82900. */
  82901. name: string;
  82902. /**
  82903. * The rendering group used by the Particle system to chose when to render.
  82904. */
  82905. renderingGroupId: number;
  82906. /**
  82907. * The emitter represents the Mesh or position we are attaching the particle system to.
  82908. */
  82909. emitter: Nullable<AbstractMesh | Vector3>;
  82910. /**
  82911. * The maximum number of particles to emit per frame
  82912. */
  82913. emitRate: number;
  82914. /**
  82915. * If you want to launch only a few particles at once, that can be done, as well.
  82916. */
  82917. manualEmitCount: number;
  82918. /**
  82919. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82920. */
  82921. updateSpeed: number;
  82922. /**
  82923. * The amount of time the particle system is running (depends of the overall update speed).
  82924. */
  82925. targetStopDuration: number;
  82926. /**
  82927. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82928. */
  82929. disposeOnStop: boolean;
  82930. /**
  82931. * Minimum power of emitting particles.
  82932. */
  82933. minEmitPower: number;
  82934. /**
  82935. * Maximum power of emitting particles.
  82936. */
  82937. maxEmitPower: number;
  82938. /**
  82939. * Minimum life time of emitting particles.
  82940. */
  82941. minLifeTime: number;
  82942. /**
  82943. * Maximum life time of emitting particles.
  82944. */
  82945. maxLifeTime: number;
  82946. /**
  82947. * Minimum Size of emitting particles.
  82948. */
  82949. minSize: number;
  82950. /**
  82951. * Maximum Size of emitting particles.
  82952. */
  82953. maxSize: number;
  82954. /**
  82955. * Minimum scale of emitting particles on X axis.
  82956. */
  82957. minScaleX: number;
  82958. /**
  82959. * Maximum scale of emitting particles on X axis.
  82960. */
  82961. maxScaleX: number;
  82962. /**
  82963. * Minimum scale of emitting particles on Y axis.
  82964. */
  82965. minScaleY: number;
  82966. /**
  82967. * Maximum scale of emitting particles on Y axis.
  82968. */
  82969. maxScaleY: number;
  82970. /**
  82971. * Gets or sets the minimal initial rotation in radians.
  82972. */
  82973. minInitialRotation: number;
  82974. /**
  82975. * Gets or sets the maximal initial rotation in radians.
  82976. */
  82977. maxInitialRotation: number;
  82978. /**
  82979. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82980. */
  82981. minAngularSpeed: number;
  82982. /**
  82983. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82984. */
  82985. maxAngularSpeed: number;
  82986. /**
  82987. * The texture used to render each particle. (this can be a spritesheet)
  82988. */
  82989. particleTexture: Nullable<Texture>;
  82990. /**
  82991. * The layer mask we are rendering the particles through.
  82992. */
  82993. layerMask: number;
  82994. /**
  82995. * This can help using your own shader to render the particle system.
  82996. * The according effect will be created
  82997. */
  82998. customShader: any;
  82999. /**
  83000. * By default particle system starts as soon as they are created. This prevents the
  83001. * automatic start to happen and let you decide when to start emitting particles.
  83002. */
  83003. preventAutoStart: boolean;
  83004. private _noiseTexture;
  83005. /**
  83006. * Gets or sets a texture used to add random noise to particle positions
  83007. */
  83008. noiseTexture: Nullable<ProceduralTexture>;
  83009. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83010. noiseStrength: Vector3;
  83011. /**
  83012. * Callback triggered when the particle animation is ending.
  83013. */
  83014. onAnimationEnd: Nullable<() => void>;
  83015. /**
  83016. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83017. */
  83018. blendMode: number;
  83019. /**
  83020. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83021. * to override the particles.
  83022. */
  83023. forceDepthWrite: boolean;
  83024. /** 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 */
  83025. preWarmCycles: number;
  83026. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83027. preWarmStepOffset: number;
  83028. /**
  83029. * 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)
  83030. */
  83031. spriteCellChangeSpeed: number;
  83032. /**
  83033. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83034. */
  83035. startSpriteCellID: number;
  83036. /**
  83037. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83038. */
  83039. endSpriteCellID: number;
  83040. /**
  83041. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83042. */
  83043. spriteCellWidth: number;
  83044. /**
  83045. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83046. */
  83047. spriteCellHeight: number;
  83048. /**
  83049. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83050. */
  83051. spriteRandomStartCell: boolean;
  83052. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83053. translationPivot: Vector2;
  83054. /** @hidden */
  83055. protected _isAnimationSheetEnabled: boolean;
  83056. /**
  83057. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83058. */
  83059. beginAnimationOnStart: boolean;
  83060. /**
  83061. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83062. */
  83063. beginAnimationFrom: number;
  83064. /**
  83065. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83066. */
  83067. beginAnimationTo: number;
  83068. /**
  83069. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83070. */
  83071. beginAnimationLoop: boolean;
  83072. /**
  83073. * Gets or sets a world offset applied to all particles
  83074. */
  83075. worldOffset: Vector3;
  83076. /**
  83077. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83078. */
  83079. isAnimationSheetEnabled: boolean;
  83080. /**
  83081. * Get hosting scene
  83082. * @returns the scene
  83083. */
  83084. getScene(): Scene;
  83085. /**
  83086. * You can use gravity if you want to give an orientation to your particles.
  83087. */
  83088. gravity: Vector3;
  83089. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83090. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83091. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83092. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83093. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83094. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83095. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83096. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83097. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83098. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83099. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83100. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83101. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83102. /**
  83103. * Defines the delay in milliseconds before starting the system (0 by default)
  83104. */
  83105. startDelay: number;
  83106. /**
  83107. * Gets the current list of drag gradients.
  83108. * You must use addDragGradient and removeDragGradient to udpate this list
  83109. * @returns the list of drag gradients
  83110. */
  83111. getDragGradients(): Nullable<Array<FactorGradient>>;
  83112. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83113. limitVelocityDamping: number;
  83114. /**
  83115. * Gets the current list of limit velocity gradients.
  83116. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83117. * @returns the list of limit velocity gradients
  83118. */
  83119. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83120. /**
  83121. * Gets the current list of color gradients.
  83122. * You must use addColorGradient and removeColorGradient to udpate this list
  83123. * @returns the list of color gradients
  83124. */
  83125. getColorGradients(): Nullable<Array<ColorGradient>>;
  83126. /**
  83127. * Gets the current list of size gradients.
  83128. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83129. * @returns the list of size gradients
  83130. */
  83131. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83132. /**
  83133. * Gets the current list of color remap gradients.
  83134. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83135. * @returns the list of color remap gradients
  83136. */
  83137. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83138. /**
  83139. * Gets the current list of alpha remap gradients.
  83140. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83141. * @returns the list of alpha remap gradients
  83142. */
  83143. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83144. /**
  83145. * Gets the current list of life time gradients.
  83146. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83147. * @returns the list of life time gradients
  83148. */
  83149. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83150. /**
  83151. * Gets the current list of angular speed gradients.
  83152. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83153. * @returns the list of angular speed gradients
  83154. */
  83155. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83156. /**
  83157. * Gets the current list of velocity gradients.
  83158. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83159. * @returns the list of velocity gradients
  83160. */
  83161. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83162. /**
  83163. * Gets the current list of start size gradients.
  83164. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83165. * @returns the list of start size gradients
  83166. */
  83167. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83168. /**
  83169. * Gets the current list of emit rate gradients.
  83170. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83171. * @returns the list of emit rate gradients
  83172. */
  83173. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83174. /**
  83175. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83176. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83177. */
  83178. direction1: Vector3;
  83179. /**
  83180. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83181. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83182. */
  83183. direction2: Vector3;
  83184. /**
  83185. * 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.
  83186. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83187. */
  83188. minEmitBox: Vector3;
  83189. /**
  83190. * 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.
  83191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83192. */
  83193. maxEmitBox: Vector3;
  83194. /**
  83195. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83196. */
  83197. color1: Color4;
  83198. /**
  83199. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83200. */
  83201. color2: Color4;
  83202. /**
  83203. * Color the particle will have at the end of its lifetime
  83204. */
  83205. colorDead: Color4;
  83206. /**
  83207. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83208. */
  83209. textureMask: Color4;
  83210. /**
  83211. * The particle emitter type defines the emitter used by the particle system.
  83212. * It can be for example box, sphere, or cone...
  83213. */
  83214. particleEmitterType: IParticleEmitterType;
  83215. /** @hidden */
  83216. _isSubEmitter: boolean;
  83217. /**
  83218. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83219. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83220. */
  83221. billboardMode: number;
  83222. protected _isBillboardBased: boolean;
  83223. /**
  83224. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83225. */
  83226. isBillboardBased: boolean;
  83227. /**
  83228. * The scene the particle system belongs to.
  83229. */
  83230. protected _scene: Scene;
  83231. /**
  83232. * Local cache of defines for image processing.
  83233. */
  83234. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83235. /**
  83236. * Default configuration related to image processing available in the standard Material.
  83237. */
  83238. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83239. /**
  83240. * Gets the image processing configuration used either in this material.
  83241. */
  83242. /**
  83243. * Sets the Default image processing configuration used either in the this material.
  83244. *
  83245. * If sets to null, the scene one is in use.
  83246. */
  83247. imageProcessingConfiguration: ImageProcessingConfiguration;
  83248. /**
  83249. * Attaches a new image processing configuration to the Standard Material.
  83250. * @param configuration
  83251. */
  83252. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83253. /** @hidden */
  83254. protected _reset(): void;
  83255. /** @hidden */
  83256. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83257. /**
  83258. * Instantiates a particle system.
  83259. * 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.
  83260. * @param name The name of the particle system
  83261. */
  83262. constructor(name: string);
  83263. /**
  83264. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83265. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83266. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83267. * @returns the emitter
  83268. */
  83269. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83270. /**
  83271. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83272. * @param radius The radius of the hemisphere to emit from
  83273. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83274. * @returns the emitter
  83275. */
  83276. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83277. /**
  83278. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83279. * @param radius The radius of the sphere to emit from
  83280. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83281. * @returns the emitter
  83282. */
  83283. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83284. /**
  83285. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83286. * @param radius The radius of the sphere to emit from
  83287. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83288. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83289. * @returns the emitter
  83290. */
  83291. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83292. /**
  83293. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83294. * @param radius The radius of the emission cylinder
  83295. * @param height The height of the emission cylinder
  83296. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83297. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83298. * @returns the emitter
  83299. */
  83300. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83301. /**
  83302. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83303. * @param radius The radius of the cylinder to emit from
  83304. * @param height The height of the emission cylinder
  83305. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83308. * @returns the emitter
  83309. */
  83310. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83311. /**
  83312. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83313. * @param radius The radius of the cone to emit from
  83314. * @param angle The base angle of the cone
  83315. * @returns the emitter
  83316. */
  83317. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83318. /**
  83319. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83320. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83321. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83322. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83323. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83324. * @returns the emitter
  83325. */
  83326. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83327. }
  83328. }
  83329. declare module BABYLON {
  83330. /**
  83331. * Type of sub emitter
  83332. */
  83333. export enum SubEmitterType {
  83334. /**
  83335. * Attached to the particle over it's lifetime
  83336. */
  83337. ATTACHED = 0,
  83338. /**
  83339. * Created when the particle dies
  83340. */
  83341. END = 1
  83342. }
  83343. /**
  83344. * Sub emitter class used to emit particles from an existing particle
  83345. */
  83346. export class SubEmitter {
  83347. /**
  83348. * the particle system to be used by the sub emitter
  83349. */
  83350. particleSystem: ParticleSystem;
  83351. /**
  83352. * Type of the submitter (Default: END)
  83353. */
  83354. type: SubEmitterType;
  83355. /**
  83356. * 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)
  83357. * Note: This only is supported when using an emitter of type Mesh
  83358. */
  83359. inheritDirection: boolean;
  83360. /**
  83361. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83362. */
  83363. inheritedVelocityAmount: number;
  83364. /**
  83365. * Creates a sub emitter
  83366. * @param particleSystem the particle system to be used by the sub emitter
  83367. */
  83368. constructor(
  83369. /**
  83370. * the particle system to be used by the sub emitter
  83371. */
  83372. particleSystem: ParticleSystem);
  83373. /**
  83374. * Clones the sub emitter
  83375. * @returns the cloned sub emitter
  83376. */
  83377. clone(): SubEmitter;
  83378. /**
  83379. * Serialize current object to a JSON object
  83380. * @returns the serialized object
  83381. */
  83382. serialize(): any;
  83383. /** @hidden */
  83384. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83385. /**
  83386. * Creates a new SubEmitter from a serialized JSON version
  83387. * @param serializationObject defines the JSON object to read from
  83388. * @param scene defines the hosting scene
  83389. * @param rootUrl defines the rootUrl for data loading
  83390. * @returns a new SubEmitter
  83391. */
  83392. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83393. /** Release associated resources */
  83394. dispose(): void;
  83395. }
  83396. }
  83397. declare module BABYLON {
  83398. /** @hidden */
  83399. export var clipPlaneFragmentDeclaration: {
  83400. name: string;
  83401. shader: string;
  83402. };
  83403. }
  83404. declare module BABYLON {
  83405. /** @hidden */
  83406. export var imageProcessingDeclaration: {
  83407. name: string;
  83408. shader: string;
  83409. };
  83410. }
  83411. declare module BABYLON {
  83412. /** @hidden */
  83413. export var imageProcessingFunctions: {
  83414. name: string;
  83415. shader: string;
  83416. };
  83417. }
  83418. declare module BABYLON {
  83419. /** @hidden */
  83420. export var clipPlaneFragment: {
  83421. name: string;
  83422. shader: string;
  83423. };
  83424. }
  83425. declare module BABYLON {
  83426. /** @hidden */
  83427. export var particlesPixelShader: {
  83428. name: string;
  83429. shader: string;
  83430. };
  83431. }
  83432. declare module BABYLON {
  83433. /** @hidden */
  83434. export var clipPlaneVertexDeclaration: {
  83435. name: string;
  83436. shader: string;
  83437. };
  83438. }
  83439. declare module BABYLON {
  83440. /** @hidden */
  83441. export var clipPlaneVertex: {
  83442. name: string;
  83443. shader: string;
  83444. };
  83445. }
  83446. declare module BABYLON {
  83447. /** @hidden */
  83448. export var particlesVertexShader: {
  83449. name: string;
  83450. shader: string;
  83451. };
  83452. }
  83453. declare module BABYLON {
  83454. /**
  83455. * This represents a particle system in Babylon.
  83456. * 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.
  83457. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83458. * @example https://doc.babylonjs.com/babylon101/particles
  83459. */
  83460. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83461. /**
  83462. * Billboard mode will only apply to Y axis
  83463. */
  83464. static readonly BILLBOARDMODE_Y: number;
  83465. /**
  83466. * Billboard mode will apply to all axes
  83467. */
  83468. static readonly BILLBOARDMODE_ALL: number;
  83469. /**
  83470. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83471. */
  83472. static readonly BILLBOARDMODE_STRETCHED: number;
  83473. /**
  83474. * This function can be defined to provide custom update for active particles.
  83475. * This function will be called instead of regular update (age, position, color, etc.).
  83476. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83477. */
  83478. updateFunction: (particles: Particle[]) => void;
  83479. private _emitterWorldMatrix;
  83480. /**
  83481. * This function can be defined to specify initial direction for every new particle.
  83482. * It by default use the emitterType defined function
  83483. */
  83484. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83485. /**
  83486. * This function can be defined to specify initial position for every new particle.
  83487. * It by default use the emitterType defined function
  83488. */
  83489. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83490. /**
  83491. * @hidden
  83492. */
  83493. _inheritedVelocityOffset: Vector3;
  83494. /**
  83495. * An event triggered when the system is disposed
  83496. */
  83497. onDisposeObservable: Observable<ParticleSystem>;
  83498. private _onDisposeObserver;
  83499. /**
  83500. * Sets a callback that will be triggered when the system is disposed
  83501. */
  83502. onDispose: () => void;
  83503. private _particles;
  83504. private _epsilon;
  83505. private _capacity;
  83506. private _stockParticles;
  83507. private _newPartsExcess;
  83508. private _vertexData;
  83509. private _vertexBuffer;
  83510. private _vertexBuffers;
  83511. private _spriteBuffer;
  83512. private _indexBuffer;
  83513. private _effect;
  83514. private _customEffect;
  83515. private _cachedDefines;
  83516. private _scaledColorStep;
  83517. private _colorDiff;
  83518. private _scaledDirection;
  83519. private _scaledGravity;
  83520. private _currentRenderId;
  83521. private _alive;
  83522. private _useInstancing;
  83523. private _started;
  83524. private _stopped;
  83525. private _actualFrame;
  83526. private _scaledUpdateSpeed;
  83527. private _vertexBufferSize;
  83528. /** @hidden */
  83529. _currentEmitRateGradient: Nullable<FactorGradient>;
  83530. /** @hidden */
  83531. _currentEmitRate1: number;
  83532. /** @hidden */
  83533. _currentEmitRate2: number;
  83534. /** @hidden */
  83535. _currentStartSizeGradient: Nullable<FactorGradient>;
  83536. /** @hidden */
  83537. _currentStartSize1: number;
  83538. /** @hidden */
  83539. _currentStartSize2: number;
  83540. private readonly _rawTextureWidth;
  83541. private _rampGradientsTexture;
  83542. private _useRampGradients;
  83543. /** Gets or sets a boolean indicating that ramp gradients must be used
  83544. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83545. */
  83546. useRampGradients: boolean;
  83547. /**
  83548. * 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.
  83549. * 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: [])
  83550. */
  83551. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83552. private _subEmitters;
  83553. /**
  83554. * @hidden
  83555. * If the particle systems emitter should be disposed when the particle system is disposed
  83556. */
  83557. _disposeEmitterOnDispose: boolean;
  83558. /**
  83559. * The current active Sub-systems, this property is used by the root particle system only.
  83560. */
  83561. activeSubSystems: Array<ParticleSystem>;
  83562. private _rootParticleSystem;
  83563. /**
  83564. * Gets the current list of active particles
  83565. */
  83566. readonly particles: Particle[];
  83567. /**
  83568. * Returns the string "ParticleSystem"
  83569. * @returns a string containing the class name
  83570. */
  83571. getClassName(): string;
  83572. /**
  83573. * Instantiates a particle system.
  83574. * 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.
  83575. * @param name The name of the particle system
  83576. * @param capacity The max number of particles alive at the same time
  83577. * @param scene The scene the particle system belongs to
  83578. * @param customEffect a custom effect used to change the way particles are rendered by default
  83579. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83580. * @param epsilon Offset used to render the particles
  83581. */
  83582. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83583. private _addFactorGradient;
  83584. private _removeFactorGradient;
  83585. /**
  83586. * Adds a new life time gradient
  83587. * @param gradient defines the gradient to use (between 0 and 1)
  83588. * @param factor defines the life time factor to affect to the specified gradient
  83589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83590. * @returns the current particle system
  83591. */
  83592. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83593. /**
  83594. * Remove a specific life time gradient
  83595. * @param gradient defines the gradient to remove
  83596. * @returns the current particle system
  83597. */
  83598. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83599. /**
  83600. * Adds a new size gradient
  83601. * @param gradient defines the gradient to use (between 0 and 1)
  83602. * @param factor defines the size factor to affect to the specified gradient
  83603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83604. * @returns the current particle system
  83605. */
  83606. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83607. /**
  83608. * Remove a specific size gradient
  83609. * @param gradient defines the gradient to remove
  83610. * @returns the current particle system
  83611. */
  83612. removeSizeGradient(gradient: number): IParticleSystem;
  83613. /**
  83614. * Adds a new color remap gradient
  83615. * @param gradient defines the gradient to use (between 0 and 1)
  83616. * @param min defines the color remap minimal range
  83617. * @param max defines the color remap maximal range
  83618. * @returns the current particle system
  83619. */
  83620. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83621. /**
  83622. * Remove a specific color remap gradient
  83623. * @param gradient defines the gradient to remove
  83624. * @returns the current particle system
  83625. */
  83626. removeColorRemapGradient(gradient: number): IParticleSystem;
  83627. /**
  83628. * Adds a new alpha remap gradient
  83629. * @param gradient defines the gradient to use (between 0 and 1)
  83630. * @param min defines the alpha remap minimal range
  83631. * @param max defines the alpha remap maximal range
  83632. * @returns the current particle system
  83633. */
  83634. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83635. /**
  83636. * Remove a specific alpha remap gradient
  83637. * @param gradient defines the gradient to remove
  83638. * @returns the current particle system
  83639. */
  83640. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83641. /**
  83642. * Adds a new angular speed gradient
  83643. * @param gradient defines the gradient to use (between 0 and 1)
  83644. * @param factor defines the angular speed to affect to the specified gradient
  83645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83646. * @returns the current particle system
  83647. */
  83648. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83649. /**
  83650. * Remove a specific angular speed gradient
  83651. * @param gradient defines the gradient to remove
  83652. * @returns the current particle system
  83653. */
  83654. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83655. /**
  83656. * Adds a new velocity gradient
  83657. * @param gradient defines the gradient to use (between 0 and 1)
  83658. * @param factor defines the velocity to affect to the specified gradient
  83659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83660. * @returns the current particle system
  83661. */
  83662. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83663. /**
  83664. * Remove a specific velocity gradient
  83665. * @param gradient defines the gradient to remove
  83666. * @returns the current particle system
  83667. */
  83668. removeVelocityGradient(gradient: number): IParticleSystem;
  83669. /**
  83670. * Adds a new limit velocity gradient
  83671. * @param gradient defines the gradient to use (between 0 and 1)
  83672. * @param factor defines the limit velocity value to affect to the specified gradient
  83673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83674. * @returns the current particle system
  83675. */
  83676. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83677. /**
  83678. * Remove a specific limit velocity gradient
  83679. * @param gradient defines the gradient to remove
  83680. * @returns the current particle system
  83681. */
  83682. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83683. /**
  83684. * Adds a new drag gradient
  83685. * @param gradient defines the gradient to use (between 0 and 1)
  83686. * @param factor defines the drag value to affect to the specified gradient
  83687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83688. * @returns the current particle system
  83689. */
  83690. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83691. /**
  83692. * Remove a specific drag gradient
  83693. * @param gradient defines the gradient to remove
  83694. * @returns the current particle system
  83695. */
  83696. removeDragGradient(gradient: number): IParticleSystem;
  83697. /**
  83698. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83699. * @param gradient defines the gradient to use (between 0 and 1)
  83700. * @param factor defines the emit rate value to affect to the specified gradient
  83701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83702. * @returns the current particle system
  83703. */
  83704. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83705. /**
  83706. * Remove a specific emit rate gradient
  83707. * @param gradient defines the gradient to remove
  83708. * @returns the current particle system
  83709. */
  83710. removeEmitRateGradient(gradient: number): IParticleSystem;
  83711. /**
  83712. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83713. * @param gradient defines the gradient to use (between 0 and 1)
  83714. * @param factor defines the start size value to affect to the specified gradient
  83715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83716. * @returns the current particle system
  83717. */
  83718. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83719. /**
  83720. * Remove a specific start size gradient
  83721. * @param gradient defines the gradient to remove
  83722. * @returns the current particle system
  83723. */
  83724. removeStartSizeGradient(gradient: number): IParticleSystem;
  83725. private _createRampGradientTexture;
  83726. /**
  83727. * Gets the current list of ramp gradients.
  83728. * You must use addRampGradient and removeRampGradient to udpate this list
  83729. * @returns the list of ramp gradients
  83730. */
  83731. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83732. /**
  83733. * Adds a new ramp gradient used to remap particle colors
  83734. * @param gradient defines the gradient to use (between 0 and 1)
  83735. * @param color defines the color to affect to the specified gradient
  83736. * @returns the current particle system
  83737. */
  83738. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  83739. /**
  83740. * Remove a specific ramp gradient
  83741. * @param gradient defines the gradient to remove
  83742. * @returns the current particle system
  83743. */
  83744. removeRampGradient(gradient: number): ParticleSystem;
  83745. /**
  83746. * Adds a new color gradient
  83747. * @param gradient defines the gradient to use (between 0 and 1)
  83748. * @param color1 defines the color to affect to the specified gradient
  83749. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83750. * @returns this particle system
  83751. */
  83752. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83753. /**
  83754. * Remove a specific color gradient
  83755. * @param gradient defines the gradient to remove
  83756. * @returns this particle system
  83757. */
  83758. removeColorGradient(gradient: number): IParticleSystem;
  83759. private _fetchR;
  83760. protected _reset(): void;
  83761. private _resetEffect;
  83762. private _createVertexBuffers;
  83763. private _createIndexBuffer;
  83764. /**
  83765. * Gets the maximum number of particles active at the same time.
  83766. * @returns The max number of active particles.
  83767. */
  83768. getCapacity(): number;
  83769. /**
  83770. * Gets whether there are still active particles in the system.
  83771. * @returns True if it is alive, otherwise false.
  83772. */
  83773. isAlive(): boolean;
  83774. /**
  83775. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83776. * @returns True if it has been started, otherwise false.
  83777. */
  83778. isStarted(): boolean;
  83779. private _prepareSubEmitterInternalArray;
  83780. /**
  83781. * Starts the particle system and begins to emit
  83782. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83783. */
  83784. start(delay?: number): void;
  83785. /**
  83786. * Stops the particle system.
  83787. * @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.
  83788. */
  83789. stop(stopSubEmitters?: boolean): void;
  83790. /**
  83791. * Remove all active particles
  83792. */
  83793. reset(): void;
  83794. /**
  83795. * @hidden (for internal use only)
  83796. */
  83797. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83798. /**
  83799. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83800. * Its lifetime will start back at 0.
  83801. */
  83802. recycleParticle: (particle: Particle) => void;
  83803. private _stopSubEmitters;
  83804. private _createParticle;
  83805. private _removeFromRoot;
  83806. private _emitFromParticle;
  83807. private _update;
  83808. /** @hidden */
  83809. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83810. /** @hidden */
  83811. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83812. /** @hidden */
  83813. private _getEffect;
  83814. /**
  83815. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83816. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83817. */
  83818. animate(preWarmOnly?: boolean): void;
  83819. private _appendParticleVertices;
  83820. /**
  83821. * Rebuilds the particle system.
  83822. */
  83823. rebuild(): void;
  83824. /**
  83825. * Is this system ready to be used/rendered
  83826. * @return true if the system is ready
  83827. */
  83828. isReady(): boolean;
  83829. private _render;
  83830. /**
  83831. * Renders the particle system in its current state.
  83832. * @returns the current number of particles
  83833. */
  83834. render(): number;
  83835. /**
  83836. * Disposes the particle system and free the associated resources
  83837. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83838. */
  83839. dispose(disposeTexture?: boolean): void;
  83840. /**
  83841. * Clones the particle system.
  83842. * @param name The name of the cloned object
  83843. * @param newEmitter The new emitter to use
  83844. * @returns the cloned particle system
  83845. */
  83846. clone(name: string, newEmitter: any): ParticleSystem;
  83847. /**
  83848. * Serializes the particle system to a JSON object.
  83849. * @returns the JSON object
  83850. */
  83851. serialize(): any;
  83852. /** @hidden */
  83853. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83854. /** @hidden */
  83855. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83856. /**
  83857. * Parses a JSON object to create a particle system.
  83858. * @param parsedParticleSystem The JSON object to parse
  83859. * @param scene The scene to create the particle system in
  83860. * @param rootUrl The root url to use to load external dependencies like texture
  83861. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83862. * @returns the Parsed particle system
  83863. */
  83864. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83865. }
  83866. }
  83867. declare module BABYLON {
  83868. /**
  83869. * A particle represents one of the element emitted by a particle system.
  83870. * This is mainly define by its coordinates, direction, velocity and age.
  83871. */
  83872. export class Particle {
  83873. /**
  83874. * The particle system the particle belongs to.
  83875. */
  83876. particleSystem: ParticleSystem;
  83877. private static _Count;
  83878. /**
  83879. * Unique ID of the particle
  83880. */
  83881. id: number;
  83882. /**
  83883. * The world position of the particle in the scene.
  83884. */
  83885. position: Vector3;
  83886. /**
  83887. * The world direction of the particle in the scene.
  83888. */
  83889. direction: Vector3;
  83890. /**
  83891. * The color of the particle.
  83892. */
  83893. color: Color4;
  83894. /**
  83895. * The color change of the particle per step.
  83896. */
  83897. colorStep: Color4;
  83898. /**
  83899. * Defines how long will the life of the particle be.
  83900. */
  83901. lifeTime: number;
  83902. /**
  83903. * The current age of the particle.
  83904. */
  83905. age: number;
  83906. /**
  83907. * The current size of the particle.
  83908. */
  83909. size: number;
  83910. /**
  83911. * The current scale of the particle.
  83912. */
  83913. scale: Vector2;
  83914. /**
  83915. * The current angle of the particle.
  83916. */
  83917. angle: number;
  83918. /**
  83919. * Defines how fast is the angle changing.
  83920. */
  83921. angularSpeed: number;
  83922. /**
  83923. * Defines the cell index used by the particle to be rendered from a sprite.
  83924. */
  83925. cellIndex: number;
  83926. /**
  83927. * The information required to support color remapping
  83928. */
  83929. remapData: Vector4;
  83930. /** @hidden */
  83931. _randomCellOffset?: number;
  83932. /** @hidden */
  83933. _initialDirection: Nullable<Vector3>;
  83934. /** @hidden */
  83935. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83936. /** @hidden */
  83937. _initialStartSpriteCellID: number;
  83938. /** @hidden */
  83939. _initialEndSpriteCellID: number;
  83940. /** @hidden */
  83941. _currentColorGradient: Nullable<ColorGradient>;
  83942. /** @hidden */
  83943. _currentColor1: Color4;
  83944. /** @hidden */
  83945. _currentColor2: Color4;
  83946. /** @hidden */
  83947. _currentSizeGradient: Nullable<FactorGradient>;
  83948. /** @hidden */
  83949. _currentSize1: number;
  83950. /** @hidden */
  83951. _currentSize2: number;
  83952. /** @hidden */
  83953. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83954. /** @hidden */
  83955. _currentAngularSpeed1: number;
  83956. /** @hidden */
  83957. _currentAngularSpeed2: number;
  83958. /** @hidden */
  83959. _currentVelocityGradient: Nullable<FactorGradient>;
  83960. /** @hidden */
  83961. _currentVelocity1: number;
  83962. /** @hidden */
  83963. _currentVelocity2: number;
  83964. /** @hidden */
  83965. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83966. /** @hidden */
  83967. _currentLimitVelocity1: number;
  83968. /** @hidden */
  83969. _currentLimitVelocity2: number;
  83970. /** @hidden */
  83971. _currentDragGradient: Nullable<FactorGradient>;
  83972. /** @hidden */
  83973. _currentDrag1: number;
  83974. /** @hidden */
  83975. _currentDrag2: number;
  83976. /** @hidden */
  83977. _randomNoiseCoordinates1: Vector3;
  83978. /** @hidden */
  83979. _randomNoiseCoordinates2: Vector3;
  83980. /**
  83981. * Creates a new instance Particle
  83982. * @param particleSystem the particle system the particle belongs to
  83983. */
  83984. constructor(
  83985. /**
  83986. * The particle system the particle belongs to.
  83987. */
  83988. particleSystem: ParticleSystem);
  83989. private updateCellInfoFromSystem;
  83990. /**
  83991. * Defines how the sprite cell index is updated for the particle
  83992. */
  83993. updateCellIndex(): void;
  83994. /** @hidden */
  83995. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83996. /** @hidden */
  83997. _inheritParticleInfoToSubEmitters(): void;
  83998. /** @hidden */
  83999. _reset(): void;
  84000. /**
  84001. * Copy the properties of particle to another one.
  84002. * @param other the particle to copy the information to.
  84003. */
  84004. copyTo(other: Particle): void;
  84005. }
  84006. }
  84007. declare module BABYLON {
  84008. /**
  84009. * Particle emitter represents a volume emitting particles.
  84010. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84011. */
  84012. export interface IParticleEmitterType {
  84013. /**
  84014. * Called by the particle System when the direction is computed for the created particle.
  84015. * @param worldMatrix is the world matrix of the particle system
  84016. * @param directionToUpdate is the direction vector to update with the result
  84017. * @param particle is the particle we are computed the direction for
  84018. */
  84019. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84020. /**
  84021. * Called by the particle System when the position is computed for the created particle.
  84022. * @param worldMatrix is the world matrix of the particle system
  84023. * @param positionToUpdate is the position vector to update with the result
  84024. * @param particle is the particle we are computed the position for
  84025. */
  84026. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84027. /**
  84028. * Clones the current emitter and returns a copy of it
  84029. * @returns the new emitter
  84030. */
  84031. clone(): IParticleEmitterType;
  84032. /**
  84033. * Called by the GPUParticleSystem to setup the update shader
  84034. * @param effect defines the update shader
  84035. */
  84036. applyToShader(effect: Effect): void;
  84037. /**
  84038. * Returns a string to use to update the GPU particles update shader
  84039. * @returns the effect defines string
  84040. */
  84041. getEffectDefines(): string;
  84042. /**
  84043. * Returns a string representing the class name
  84044. * @returns a string containing the class name
  84045. */
  84046. getClassName(): string;
  84047. /**
  84048. * Serializes the particle system to a JSON object.
  84049. * @returns the JSON object
  84050. */
  84051. serialize(): any;
  84052. /**
  84053. * Parse properties from a JSON object
  84054. * @param serializationObject defines the JSON object
  84055. */
  84056. parse(serializationObject: any): void;
  84057. }
  84058. }
  84059. declare module BABYLON {
  84060. /**
  84061. * Particle emitter emitting particles from the inside of a box.
  84062. * It emits the particles randomly between 2 given directions.
  84063. */
  84064. export class BoxParticleEmitter implements IParticleEmitterType {
  84065. /**
  84066. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84067. */
  84068. direction1: Vector3;
  84069. /**
  84070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84071. */
  84072. direction2: Vector3;
  84073. /**
  84074. * 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.
  84075. */
  84076. minEmitBox: Vector3;
  84077. /**
  84078. * 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.
  84079. */
  84080. maxEmitBox: Vector3;
  84081. /**
  84082. * Creates a new instance BoxParticleEmitter
  84083. */
  84084. constructor();
  84085. /**
  84086. * Called by the particle System when the direction is computed for the created particle.
  84087. * @param worldMatrix is the world matrix of the particle system
  84088. * @param directionToUpdate is the direction vector to update with the result
  84089. * @param particle is the particle we are computed the direction for
  84090. */
  84091. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84092. /**
  84093. * Called by the particle System when the position is computed for the created particle.
  84094. * @param worldMatrix is the world matrix of the particle system
  84095. * @param positionToUpdate is the position vector to update with the result
  84096. * @param particle is the particle we are computed the position for
  84097. */
  84098. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84099. /**
  84100. * Clones the current emitter and returns a copy of it
  84101. * @returns the new emitter
  84102. */
  84103. clone(): BoxParticleEmitter;
  84104. /**
  84105. * Called by the GPUParticleSystem to setup the update shader
  84106. * @param effect defines the update shader
  84107. */
  84108. applyToShader(effect: Effect): void;
  84109. /**
  84110. * Returns a string to use to update the GPU particles update shader
  84111. * @returns a string containng the defines string
  84112. */
  84113. getEffectDefines(): string;
  84114. /**
  84115. * Returns the string "BoxParticleEmitter"
  84116. * @returns a string containing the class name
  84117. */
  84118. getClassName(): string;
  84119. /**
  84120. * Serializes the particle system to a JSON object.
  84121. * @returns the JSON object
  84122. */
  84123. serialize(): any;
  84124. /**
  84125. * Parse properties from a JSON object
  84126. * @param serializationObject defines the JSON object
  84127. */
  84128. parse(serializationObject: any): void;
  84129. }
  84130. }
  84131. declare module BABYLON {
  84132. /**
  84133. * Particle emitter emitting particles from the inside of a cone.
  84134. * It emits the particles alongside the cone volume from the base to the particle.
  84135. * The emission direction might be randomized.
  84136. */
  84137. export class ConeParticleEmitter implements IParticleEmitterType {
  84138. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84139. directionRandomizer: number;
  84140. private _radius;
  84141. private _angle;
  84142. private _height;
  84143. /**
  84144. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84145. */
  84146. radiusRange: number;
  84147. /**
  84148. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84149. */
  84150. heightRange: number;
  84151. /**
  84152. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84153. */
  84154. emitFromSpawnPointOnly: boolean;
  84155. /**
  84156. * Gets or sets the radius of the emission cone
  84157. */
  84158. radius: number;
  84159. /**
  84160. * Gets or sets the angle of the emission cone
  84161. */
  84162. angle: number;
  84163. private _buildHeight;
  84164. /**
  84165. * Creates a new instance ConeParticleEmitter
  84166. * @param radius the radius of the emission cone (1 by default)
  84167. * @param angle the cone base angle (PI by default)
  84168. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84169. */
  84170. constructor(radius?: number, angle?: number,
  84171. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84172. directionRandomizer?: number);
  84173. /**
  84174. * Called by the particle System when the direction is computed for the created particle.
  84175. * @param worldMatrix is the world matrix of the particle system
  84176. * @param directionToUpdate is the direction vector to update with the result
  84177. * @param particle is the particle we are computed the direction for
  84178. */
  84179. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84180. /**
  84181. * Called by the particle System when the position is computed for the created particle.
  84182. * @param worldMatrix is the world matrix of the particle system
  84183. * @param positionToUpdate is the position vector to update with the result
  84184. * @param particle is the particle we are computed the position for
  84185. */
  84186. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84187. /**
  84188. * Clones the current emitter and returns a copy of it
  84189. * @returns the new emitter
  84190. */
  84191. clone(): ConeParticleEmitter;
  84192. /**
  84193. * Called by the GPUParticleSystem to setup the update shader
  84194. * @param effect defines the update shader
  84195. */
  84196. applyToShader(effect: Effect): void;
  84197. /**
  84198. * Returns a string to use to update the GPU particles update shader
  84199. * @returns a string containng the defines string
  84200. */
  84201. getEffectDefines(): string;
  84202. /**
  84203. * Returns the string "ConeParticleEmitter"
  84204. * @returns a string containing the class name
  84205. */
  84206. getClassName(): string;
  84207. /**
  84208. * Serializes the particle system to a JSON object.
  84209. * @returns the JSON object
  84210. */
  84211. serialize(): any;
  84212. /**
  84213. * Parse properties from a JSON object
  84214. * @param serializationObject defines the JSON object
  84215. */
  84216. parse(serializationObject: any): void;
  84217. }
  84218. }
  84219. declare module BABYLON {
  84220. /**
  84221. * Particle emitter emitting particles from the inside of a cylinder.
  84222. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84223. */
  84224. export class CylinderParticleEmitter implements IParticleEmitterType {
  84225. /**
  84226. * The radius of the emission cylinder.
  84227. */
  84228. radius: number;
  84229. /**
  84230. * The height of the emission cylinder.
  84231. */
  84232. height: number;
  84233. /**
  84234. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84235. */
  84236. radiusRange: number;
  84237. /**
  84238. * How much to randomize the particle direction [0-1].
  84239. */
  84240. directionRandomizer: number;
  84241. /**
  84242. * Creates a new instance CylinderParticleEmitter
  84243. * @param radius the radius of the emission cylinder (1 by default)
  84244. * @param height the height of the emission cylinder (1 by default)
  84245. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84246. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84247. */
  84248. constructor(
  84249. /**
  84250. * The radius of the emission cylinder.
  84251. */
  84252. radius?: number,
  84253. /**
  84254. * The height of the emission cylinder.
  84255. */
  84256. height?: number,
  84257. /**
  84258. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84259. */
  84260. radiusRange?: number,
  84261. /**
  84262. * How much to randomize the particle direction [0-1].
  84263. */
  84264. directionRandomizer?: number);
  84265. /**
  84266. * Called by the particle System when the direction is computed for the created particle.
  84267. * @param worldMatrix is the world matrix of the particle system
  84268. * @param directionToUpdate is the direction vector to update with the result
  84269. * @param particle is the particle we are computed the direction for
  84270. */
  84271. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84272. /**
  84273. * Called by the particle System when the position is computed for the created particle.
  84274. * @param worldMatrix is the world matrix of the particle system
  84275. * @param positionToUpdate is the position vector to update with the result
  84276. * @param particle is the particle we are computed the position for
  84277. */
  84278. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84279. /**
  84280. * Clones the current emitter and returns a copy of it
  84281. * @returns the new emitter
  84282. */
  84283. clone(): CylinderParticleEmitter;
  84284. /**
  84285. * Called by the GPUParticleSystem to setup the update shader
  84286. * @param effect defines the update shader
  84287. */
  84288. applyToShader(effect: Effect): void;
  84289. /**
  84290. * Returns a string to use to update the GPU particles update shader
  84291. * @returns a string containng the defines string
  84292. */
  84293. getEffectDefines(): string;
  84294. /**
  84295. * Returns the string "CylinderParticleEmitter"
  84296. * @returns a string containing the class name
  84297. */
  84298. getClassName(): string;
  84299. /**
  84300. * Serializes the particle system to a JSON object.
  84301. * @returns the JSON object
  84302. */
  84303. serialize(): any;
  84304. /**
  84305. * Parse properties from a JSON object
  84306. * @param serializationObject defines the JSON object
  84307. */
  84308. parse(serializationObject: any): void;
  84309. }
  84310. /**
  84311. * Particle emitter emitting particles from the inside of a cylinder.
  84312. * It emits the particles randomly between two vectors.
  84313. */
  84314. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84315. /**
  84316. * The min limit of the emission direction.
  84317. */
  84318. direction1: Vector3;
  84319. /**
  84320. * The max limit of the emission direction.
  84321. */
  84322. direction2: Vector3;
  84323. /**
  84324. * Creates a new instance CylinderDirectedParticleEmitter
  84325. * @param radius the radius of the emission cylinder (1 by default)
  84326. * @param height the height of the emission cylinder (1 by default)
  84327. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84328. * @param direction1 the min limit of the emission direction (up vector by default)
  84329. * @param direction2 the max limit of the emission direction (up vector by default)
  84330. */
  84331. constructor(radius?: number, height?: number, radiusRange?: number,
  84332. /**
  84333. * The min limit of the emission direction.
  84334. */
  84335. direction1?: Vector3,
  84336. /**
  84337. * The max limit of the emission direction.
  84338. */
  84339. direction2?: Vector3);
  84340. /**
  84341. * Called by the particle System when the direction is computed for the created particle.
  84342. * @param worldMatrix is the world matrix of the particle system
  84343. * @param directionToUpdate is the direction vector to update with the result
  84344. * @param particle is the particle we are computed the direction for
  84345. */
  84346. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84347. /**
  84348. * Clones the current emitter and returns a copy of it
  84349. * @returns the new emitter
  84350. */
  84351. clone(): CylinderDirectedParticleEmitter;
  84352. /**
  84353. * Called by the GPUParticleSystem to setup the update shader
  84354. * @param effect defines the update shader
  84355. */
  84356. applyToShader(effect: Effect): void;
  84357. /**
  84358. * Returns a string to use to update the GPU particles update shader
  84359. * @returns a string containng the defines string
  84360. */
  84361. getEffectDefines(): string;
  84362. /**
  84363. * Returns the string "CylinderDirectedParticleEmitter"
  84364. * @returns a string containing the class name
  84365. */
  84366. getClassName(): string;
  84367. /**
  84368. * Serializes the particle system to a JSON object.
  84369. * @returns the JSON object
  84370. */
  84371. serialize(): any;
  84372. /**
  84373. * Parse properties from a JSON object
  84374. * @param serializationObject defines the JSON object
  84375. */
  84376. parse(serializationObject: any): void;
  84377. }
  84378. }
  84379. declare module BABYLON {
  84380. /**
  84381. * Particle emitter emitting particles from the inside of a hemisphere.
  84382. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84383. */
  84384. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84385. /**
  84386. * The radius of the emission hemisphere.
  84387. */
  84388. radius: number;
  84389. /**
  84390. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84391. */
  84392. radiusRange: number;
  84393. /**
  84394. * How much to randomize the particle direction [0-1].
  84395. */
  84396. directionRandomizer: number;
  84397. /**
  84398. * Creates a new instance HemisphericParticleEmitter
  84399. * @param radius the radius of the emission hemisphere (1 by default)
  84400. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84401. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84402. */
  84403. constructor(
  84404. /**
  84405. * The radius of the emission hemisphere.
  84406. */
  84407. radius?: number,
  84408. /**
  84409. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84410. */
  84411. radiusRange?: number,
  84412. /**
  84413. * How much to randomize the particle direction [0-1].
  84414. */
  84415. directionRandomizer?: number);
  84416. /**
  84417. * Called by the particle System when the direction is computed for the created particle.
  84418. * @param worldMatrix is the world matrix of the particle system
  84419. * @param directionToUpdate is the direction vector to update with the result
  84420. * @param particle is the particle we are computed the direction for
  84421. */
  84422. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84423. /**
  84424. * Called by the particle System when the position is computed for the created particle.
  84425. * @param worldMatrix is the world matrix of the particle system
  84426. * @param positionToUpdate is the position vector to update with the result
  84427. * @param particle is the particle we are computed the position for
  84428. */
  84429. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84430. /**
  84431. * Clones the current emitter and returns a copy of it
  84432. * @returns the new emitter
  84433. */
  84434. clone(): HemisphericParticleEmitter;
  84435. /**
  84436. * Called by the GPUParticleSystem to setup the update shader
  84437. * @param effect defines the update shader
  84438. */
  84439. applyToShader(effect: Effect): void;
  84440. /**
  84441. * Returns a string to use to update the GPU particles update shader
  84442. * @returns a string containng the defines string
  84443. */
  84444. getEffectDefines(): string;
  84445. /**
  84446. * Returns the string "HemisphericParticleEmitter"
  84447. * @returns a string containing the class name
  84448. */
  84449. getClassName(): string;
  84450. /**
  84451. * Serializes the particle system to a JSON object.
  84452. * @returns the JSON object
  84453. */
  84454. serialize(): any;
  84455. /**
  84456. * Parse properties from a JSON object
  84457. * @param serializationObject defines the JSON object
  84458. */
  84459. parse(serializationObject: any): void;
  84460. }
  84461. }
  84462. declare module BABYLON {
  84463. /**
  84464. * Particle emitter emitting particles from a point.
  84465. * It emits the particles randomly between 2 given directions.
  84466. */
  84467. export class PointParticleEmitter implements IParticleEmitterType {
  84468. /**
  84469. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84470. */
  84471. direction1: Vector3;
  84472. /**
  84473. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84474. */
  84475. direction2: Vector3;
  84476. /**
  84477. * Creates a new instance PointParticleEmitter
  84478. */
  84479. constructor();
  84480. /**
  84481. * Called by the particle System when the direction is computed for the created particle.
  84482. * @param worldMatrix is the world matrix of the particle system
  84483. * @param directionToUpdate is the direction vector to update with the result
  84484. * @param particle is the particle we are computed the direction for
  84485. */
  84486. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84487. /**
  84488. * Called by the particle System when the position is computed for the created particle.
  84489. * @param worldMatrix is the world matrix of the particle system
  84490. * @param positionToUpdate is the position vector to update with the result
  84491. * @param particle is the particle we are computed the position for
  84492. */
  84493. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84494. /**
  84495. * Clones the current emitter and returns a copy of it
  84496. * @returns the new emitter
  84497. */
  84498. clone(): PointParticleEmitter;
  84499. /**
  84500. * Called by the GPUParticleSystem to setup the update shader
  84501. * @param effect defines the update shader
  84502. */
  84503. applyToShader(effect: Effect): void;
  84504. /**
  84505. * Returns a string to use to update the GPU particles update shader
  84506. * @returns a string containng the defines string
  84507. */
  84508. getEffectDefines(): string;
  84509. /**
  84510. * Returns the string "PointParticleEmitter"
  84511. * @returns a string containing the class name
  84512. */
  84513. getClassName(): string;
  84514. /**
  84515. * Serializes the particle system to a JSON object.
  84516. * @returns the JSON object
  84517. */
  84518. serialize(): any;
  84519. /**
  84520. * Parse properties from a JSON object
  84521. * @param serializationObject defines the JSON object
  84522. */
  84523. parse(serializationObject: any): void;
  84524. }
  84525. }
  84526. declare module BABYLON {
  84527. /**
  84528. * Particle emitter emitting particles from the inside of a sphere.
  84529. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84530. */
  84531. export class SphereParticleEmitter implements IParticleEmitterType {
  84532. /**
  84533. * The radius of the emission sphere.
  84534. */
  84535. radius: number;
  84536. /**
  84537. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84538. */
  84539. radiusRange: number;
  84540. /**
  84541. * How much to randomize the particle direction [0-1].
  84542. */
  84543. directionRandomizer: number;
  84544. /**
  84545. * Creates a new instance SphereParticleEmitter
  84546. * @param radius the radius of the emission sphere (1 by default)
  84547. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84548. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84549. */
  84550. constructor(
  84551. /**
  84552. * The radius of the emission sphere.
  84553. */
  84554. radius?: number,
  84555. /**
  84556. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84557. */
  84558. radiusRange?: number,
  84559. /**
  84560. * How much to randomize the particle direction [0-1].
  84561. */
  84562. directionRandomizer?: number);
  84563. /**
  84564. * Called by the particle System when the direction is computed for the created particle.
  84565. * @param worldMatrix is the world matrix of the particle system
  84566. * @param directionToUpdate is the direction vector to update with the result
  84567. * @param particle is the particle we are computed the direction for
  84568. */
  84569. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84570. /**
  84571. * Called by the particle System when the position is computed for the created particle.
  84572. * @param worldMatrix is the world matrix of the particle system
  84573. * @param positionToUpdate is the position vector to update with the result
  84574. * @param particle is the particle we are computed the position for
  84575. */
  84576. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84577. /**
  84578. * Clones the current emitter and returns a copy of it
  84579. * @returns the new emitter
  84580. */
  84581. clone(): SphereParticleEmitter;
  84582. /**
  84583. * Called by the GPUParticleSystem to setup the update shader
  84584. * @param effect defines the update shader
  84585. */
  84586. applyToShader(effect: Effect): void;
  84587. /**
  84588. * Returns a string to use to update the GPU particles update shader
  84589. * @returns a string containng the defines string
  84590. */
  84591. getEffectDefines(): string;
  84592. /**
  84593. * Returns the string "SphereParticleEmitter"
  84594. * @returns a string containing the class name
  84595. */
  84596. getClassName(): string;
  84597. /**
  84598. * Serializes the particle system to a JSON object.
  84599. * @returns the JSON object
  84600. */
  84601. serialize(): any;
  84602. /**
  84603. * Parse properties from a JSON object
  84604. * @param serializationObject defines the JSON object
  84605. */
  84606. parse(serializationObject: any): void;
  84607. }
  84608. /**
  84609. * Particle emitter emitting particles from the inside of a sphere.
  84610. * It emits the particles randomly between two vectors.
  84611. */
  84612. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84613. /**
  84614. * The min limit of the emission direction.
  84615. */
  84616. direction1: Vector3;
  84617. /**
  84618. * The max limit of the emission direction.
  84619. */
  84620. direction2: Vector3;
  84621. /**
  84622. * Creates a new instance SphereDirectedParticleEmitter
  84623. * @param radius the radius of the emission sphere (1 by default)
  84624. * @param direction1 the min limit of the emission direction (up vector by default)
  84625. * @param direction2 the max limit of the emission direction (up vector by default)
  84626. */
  84627. constructor(radius?: number,
  84628. /**
  84629. * The min limit of the emission direction.
  84630. */
  84631. direction1?: Vector3,
  84632. /**
  84633. * The max limit of the emission direction.
  84634. */
  84635. direction2?: Vector3);
  84636. /**
  84637. * Called by the particle System when the direction is computed for the created particle.
  84638. * @param worldMatrix is the world matrix of the particle system
  84639. * @param directionToUpdate is the direction vector to update with the result
  84640. * @param particle is the particle we are computed the direction for
  84641. */
  84642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84643. /**
  84644. * Clones the current emitter and returns a copy of it
  84645. * @returns the new emitter
  84646. */
  84647. clone(): SphereDirectedParticleEmitter;
  84648. /**
  84649. * Called by the GPUParticleSystem to setup the update shader
  84650. * @param effect defines the update shader
  84651. */
  84652. applyToShader(effect: Effect): void;
  84653. /**
  84654. * Returns a string to use to update the GPU particles update shader
  84655. * @returns a string containng the defines string
  84656. */
  84657. getEffectDefines(): string;
  84658. /**
  84659. * Returns the string "SphereDirectedParticleEmitter"
  84660. * @returns a string containing the class name
  84661. */
  84662. getClassName(): string;
  84663. /**
  84664. * Serializes the particle system to a JSON object.
  84665. * @returns the JSON object
  84666. */
  84667. serialize(): any;
  84668. /**
  84669. * Parse properties from a JSON object
  84670. * @param serializationObject defines the JSON object
  84671. */
  84672. parse(serializationObject: any): void;
  84673. }
  84674. }
  84675. declare module BABYLON {
  84676. /**
  84677. * Interface representing a particle system in Babylon.js.
  84678. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84679. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84680. */
  84681. export interface IParticleSystem {
  84682. /**
  84683. * List of animations used by the particle system.
  84684. */
  84685. animations: Animation[];
  84686. /**
  84687. * The id of the Particle system.
  84688. */
  84689. id: string;
  84690. /**
  84691. * The name of the Particle system.
  84692. */
  84693. name: string;
  84694. /**
  84695. * The emitter represents the Mesh or position we are attaching the particle system to.
  84696. */
  84697. emitter: Nullable<AbstractMesh | Vector3>;
  84698. /**
  84699. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84700. */
  84701. isBillboardBased: boolean;
  84702. /**
  84703. * The rendering group used by the Particle system to chose when to render.
  84704. */
  84705. renderingGroupId: number;
  84706. /**
  84707. * The layer mask we are rendering the particles through.
  84708. */
  84709. layerMask: number;
  84710. /**
  84711. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84712. */
  84713. updateSpeed: number;
  84714. /**
  84715. * The amount of time the particle system is running (depends of the overall update speed).
  84716. */
  84717. targetStopDuration: number;
  84718. /**
  84719. * The texture used to render each particle. (this can be a spritesheet)
  84720. */
  84721. particleTexture: Nullable<Texture>;
  84722. /**
  84723. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  84724. */
  84725. blendMode: number;
  84726. /**
  84727. * Minimum life time of emitting particles.
  84728. */
  84729. minLifeTime: number;
  84730. /**
  84731. * Maximum life time of emitting particles.
  84732. */
  84733. maxLifeTime: number;
  84734. /**
  84735. * Minimum Size of emitting particles.
  84736. */
  84737. minSize: number;
  84738. /**
  84739. * Maximum Size of emitting particles.
  84740. */
  84741. maxSize: number;
  84742. /**
  84743. * Minimum scale of emitting particles on X axis.
  84744. */
  84745. minScaleX: number;
  84746. /**
  84747. * Maximum scale of emitting particles on X axis.
  84748. */
  84749. maxScaleX: number;
  84750. /**
  84751. * Minimum scale of emitting particles on Y axis.
  84752. */
  84753. minScaleY: number;
  84754. /**
  84755. * Maximum scale of emitting particles on Y axis.
  84756. */
  84757. maxScaleY: number;
  84758. /**
  84759. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84760. */
  84761. color1: Color4;
  84762. /**
  84763. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84764. */
  84765. color2: Color4;
  84766. /**
  84767. * Color the particle will have at the end of its lifetime.
  84768. */
  84769. colorDead: Color4;
  84770. /**
  84771. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84772. */
  84773. emitRate: number;
  84774. /**
  84775. * You can use gravity if you want to give an orientation to your particles.
  84776. */
  84777. gravity: Vector3;
  84778. /**
  84779. * Minimum power of emitting particles.
  84780. */
  84781. minEmitPower: number;
  84782. /**
  84783. * Maximum power of emitting particles.
  84784. */
  84785. maxEmitPower: number;
  84786. /**
  84787. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84788. */
  84789. minAngularSpeed: number;
  84790. /**
  84791. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84792. */
  84793. maxAngularSpeed: number;
  84794. /**
  84795. * Gets or sets the minimal initial rotation in radians.
  84796. */
  84797. minInitialRotation: number;
  84798. /**
  84799. * Gets or sets the maximal initial rotation in radians.
  84800. */
  84801. maxInitialRotation: number;
  84802. /**
  84803. * The particle emitter type defines the emitter used by the particle system.
  84804. * It can be for example box, sphere, or cone...
  84805. */
  84806. particleEmitterType: Nullable<IParticleEmitterType>;
  84807. /**
  84808. * Defines the delay in milliseconds before starting the system (0 by default)
  84809. */
  84810. startDelay: number;
  84811. /**
  84812. * 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
  84813. */
  84814. preWarmCycles: number;
  84815. /**
  84816. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84817. */
  84818. preWarmStepOffset: number;
  84819. /**
  84820. * 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)
  84821. */
  84822. spriteCellChangeSpeed: number;
  84823. /**
  84824. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84825. */
  84826. startSpriteCellID: number;
  84827. /**
  84828. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84829. */
  84830. endSpriteCellID: number;
  84831. /**
  84832. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84833. */
  84834. spriteCellWidth: number;
  84835. /**
  84836. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84837. */
  84838. spriteCellHeight: number;
  84839. /**
  84840. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84841. */
  84842. spriteRandomStartCell: boolean;
  84843. /**
  84844. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84845. */
  84846. isAnimationSheetEnabled: boolean;
  84847. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84848. translationPivot: Vector2;
  84849. /**
  84850. * Gets or sets a texture used to add random noise to particle positions
  84851. */
  84852. noiseTexture: Nullable<BaseTexture>;
  84853. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84854. noiseStrength: Vector3;
  84855. /**
  84856. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84857. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84858. */
  84859. billboardMode: number;
  84860. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84861. limitVelocityDamping: number;
  84862. /**
  84863. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84864. */
  84865. beginAnimationOnStart: boolean;
  84866. /**
  84867. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84868. */
  84869. beginAnimationFrom: number;
  84870. /**
  84871. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84872. */
  84873. beginAnimationTo: number;
  84874. /**
  84875. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84876. */
  84877. beginAnimationLoop: boolean;
  84878. /**
  84879. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84880. */
  84881. disposeOnStop: boolean;
  84882. /**
  84883. * Gets the maximum number of particles active at the same time.
  84884. * @returns The max number of active particles.
  84885. */
  84886. getCapacity(): number;
  84887. /**
  84888. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84889. * @returns True if it has been started, otherwise false.
  84890. */
  84891. isStarted(): boolean;
  84892. /**
  84893. * Animates the particle system for this frame.
  84894. */
  84895. animate(): void;
  84896. /**
  84897. * Renders the particle system in its current state.
  84898. * @returns the current number of particles
  84899. */
  84900. render(): number;
  84901. /**
  84902. * Dispose the particle system and frees its associated resources.
  84903. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84904. */
  84905. dispose(disposeTexture?: boolean): void;
  84906. /**
  84907. * Clones the particle system.
  84908. * @param name The name of the cloned object
  84909. * @param newEmitter The new emitter to use
  84910. * @returns the cloned particle system
  84911. */
  84912. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84913. /**
  84914. * Serializes the particle system to a JSON object.
  84915. * @returns the JSON object
  84916. */
  84917. serialize(): any;
  84918. /**
  84919. * Rebuild the particle system
  84920. */
  84921. rebuild(): void;
  84922. /**
  84923. * Starts the particle system and begins to emit
  84924. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84925. */
  84926. start(delay?: number): void;
  84927. /**
  84928. * Stops the particle system.
  84929. */
  84930. stop(): void;
  84931. /**
  84932. * Remove all active particles
  84933. */
  84934. reset(): void;
  84935. /**
  84936. * Is this system ready to be used/rendered
  84937. * @return true if the system is ready
  84938. */
  84939. isReady(): boolean;
  84940. /**
  84941. * Adds a new color gradient
  84942. * @param gradient defines the gradient to use (between 0 and 1)
  84943. * @param color1 defines the color to affect to the specified gradient
  84944. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84945. * @returns the current particle system
  84946. */
  84947. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84948. /**
  84949. * Remove a specific color gradient
  84950. * @param gradient defines the gradient to remove
  84951. * @returns the current particle system
  84952. */
  84953. removeColorGradient(gradient: number): IParticleSystem;
  84954. /**
  84955. * Adds a new size gradient
  84956. * @param gradient defines the gradient to use (between 0 and 1)
  84957. * @param factor defines the size factor to affect to the specified gradient
  84958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84959. * @returns the current particle system
  84960. */
  84961. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84962. /**
  84963. * Remove a specific size gradient
  84964. * @param gradient defines the gradient to remove
  84965. * @returns the current particle system
  84966. */
  84967. removeSizeGradient(gradient: number): IParticleSystem;
  84968. /**
  84969. * Gets the current list of color gradients.
  84970. * You must use addColorGradient and removeColorGradient to udpate this list
  84971. * @returns the list of color gradients
  84972. */
  84973. getColorGradients(): Nullable<Array<ColorGradient>>;
  84974. /**
  84975. * Gets the current list of size gradients.
  84976. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84977. * @returns the list of size gradients
  84978. */
  84979. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84980. /**
  84981. * Gets the current list of angular speed gradients.
  84982. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84983. * @returns the list of angular speed gradients
  84984. */
  84985. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84986. /**
  84987. * Adds a new angular speed gradient
  84988. * @param gradient defines the gradient to use (between 0 and 1)
  84989. * @param factor defines the angular speed to affect to the specified gradient
  84990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84991. * @returns the current particle system
  84992. */
  84993. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84994. /**
  84995. * Remove a specific angular speed gradient
  84996. * @param gradient defines the gradient to remove
  84997. * @returns the current particle system
  84998. */
  84999. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85000. /**
  85001. * Gets the current list of velocity gradients.
  85002. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85003. * @returns the list of velocity gradients
  85004. */
  85005. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85006. /**
  85007. * Adds a new velocity gradient
  85008. * @param gradient defines the gradient to use (between 0 and 1)
  85009. * @param factor defines the velocity to affect to the specified gradient
  85010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85011. * @returns the current particle system
  85012. */
  85013. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85014. /**
  85015. * Remove a specific velocity gradient
  85016. * @param gradient defines the gradient to remove
  85017. * @returns the current particle system
  85018. */
  85019. removeVelocityGradient(gradient: number): IParticleSystem;
  85020. /**
  85021. * Gets the current list of limit velocity gradients.
  85022. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85023. * @returns the list of limit velocity gradients
  85024. */
  85025. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85026. /**
  85027. * Adds a new limit velocity gradient
  85028. * @param gradient defines the gradient to use (between 0 and 1)
  85029. * @param factor defines the limit velocity to affect to the specified gradient
  85030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85031. * @returns the current particle system
  85032. */
  85033. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85034. /**
  85035. * Remove a specific limit velocity gradient
  85036. * @param gradient defines the gradient to remove
  85037. * @returns the current particle system
  85038. */
  85039. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85040. /**
  85041. * Adds a new drag gradient
  85042. * @param gradient defines the gradient to use (between 0 and 1)
  85043. * @param factor defines the drag to affect to the specified gradient
  85044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85045. * @returns the current particle system
  85046. */
  85047. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85048. /**
  85049. * Remove a specific drag gradient
  85050. * @param gradient defines the gradient to remove
  85051. * @returns the current particle system
  85052. */
  85053. removeDragGradient(gradient: number): IParticleSystem;
  85054. /**
  85055. * Gets the current list of drag gradients.
  85056. * You must use addDragGradient and removeDragGradient to udpate this list
  85057. * @returns the list of drag gradients
  85058. */
  85059. getDragGradients(): Nullable<Array<FactorGradient>>;
  85060. /**
  85061. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85062. * @param gradient defines the gradient to use (between 0 and 1)
  85063. * @param factor defines the emit rate to affect to the specified gradient
  85064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85065. * @returns the current particle system
  85066. */
  85067. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85068. /**
  85069. * Remove a specific emit rate gradient
  85070. * @param gradient defines the gradient to remove
  85071. * @returns the current particle system
  85072. */
  85073. removeEmitRateGradient(gradient: number): IParticleSystem;
  85074. /**
  85075. * Gets the current list of emit rate gradients.
  85076. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85077. * @returns the list of emit rate gradients
  85078. */
  85079. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85080. /**
  85081. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85082. * @param gradient defines the gradient to use (between 0 and 1)
  85083. * @param factor defines the start size to affect to the specified gradient
  85084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85085. * @returns the current particle system
  85086. */
  85087. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85088. /**
  85089. * Remove a specific start size gradient
  85090. * @param gradient defines the gradient to remove
  85091. * @returns the current particle system
  85092. */
  85093. removeStartSizeGradient(gradient: number): IParticleSystem;
  85094. /**
  85095. * Gets the current list of start size gradients.
  85096. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85097. * @returns the list of start size gradients
  85098. */
  85099. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85100. /**
  85101. * Adds a new life time gradient
  85102. * @param gradient defines the gradient to use (between 0 and 1)
  85103. * @param factor defines the life time factor to affect to the specified gradient
  85104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85105. * @returns the current particle system
  85106. */
  85107. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85108. /**
  85109. * Remove a specific life time gradient
  85110. * @param gradient defines the gradient to remove
  85111. * @returns the current particle system
  85112. */
  85113. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85114. /**
  85115. * Gets the current list of life time gradients.
  85116. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85117. * @returns the list of life time gradients
  85118. */
  85119. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85120. /**
  85121. * Gets the current list of color gradients.
  85122. * You must use addColorGradient and removeColorGradient to udpate this list
  85123. * @returns the list of color gradients
  85124. */
  85125. getColorGradients(): Nullable<Array<ColorGradient>>;
  85126. /**
  85127. * Adds a new ramp gradient used to remap particle colors
  85128. * @param gradient defines the gradient to use (between 0 and 1)
  85129. * @param color defines the color to affect to the specified gradient
  85130. * @returns the current particle system
  85131. */
  85132. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85133. /**
  85134. * Gets the current list of ramp gradients.
  85135. * You must use addRampGradient and removeRampGradient to udpate this list
  85136. * @returns the list of ramp gradients
  85137. */
  85138. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85139. /** Gets or sets a boolean indicating that ramp gradients must be used
  85140. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85141. */
  85142. useRampGradients: boolean;
  85143. /**
  85144. * Adds a new color remap gradient
  85145. * @param gradient defines the gradient to use (between 0 and 1)
  85146. * @param min defines the color remap minimal range
  85147. * @param max defines the color remap maximal range
  85148. * @returns the current particle system
  85149. */
  85150. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85151. /**
  85152. * Gets the current list of color remap gradients.
  85153. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85154. * @returns the list of color remap gradients
  85155. */
  85156. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85157. /**
  85158. * Adds a new alpha remap gradient
  85159. * @param gradient defines the gradient to use (between 0 and 1)
  85160. * @param min defines the alpha remap minimal range
  85161. * @param max defines the alpha remap maximal range
  85162. * @returns the current particle system
  85163. */
  85164. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85165. /**
  85166. * Gets the current list of alpha remap gradients.
  85167. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85168. * @returns the list of alpha remap gradients
  85169. */
  85170. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85171. /**
  85172. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85173. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85174. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85175. * @returns the emitter
  85176. */
  85177. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85178. /**
  85179. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85180. * @param radius The radius of the hemisphere to emit from
  85181. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85182. * @returns the emitter
  85183. */
  85184. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85185. /**
  85186. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85187. * @param radius The radius of the sphere to emit from
  85188. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85189. * @returns the emitter
  85190. */
  85191. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85192. /**
  85193. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85194. * @param radius The radius of the sphere to emit from
  85195. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85196. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85197. * @returns the emitter
  85198. */
  85199. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85200. /**
  85201. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85202. * @param radius The radius of the emission cylinder
  85203. * @param height The height of the emission cylinder
  85204. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85205. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85206. * @returns the emitter
  85207. */
  85208. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85209. /**
  85210. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85211. * @param radius The radius of the cylinder to emit from
  85212. * @param height The height of the emission cylinder
  85213. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85214. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85215. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85216. * @returns the emitter
  85217. */
  85218. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85219. /**
  85220. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85221. * @param radius The radius of the cone to emit from
  85222. * @param angle The base angle of the cone
  85223. * @returns the emitter
  85224. */
  85225. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85226. /**
  85227. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85228. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85229. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85230. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85231. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85232. * @returns the emitter
  85233. */
  85234. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85235. /**
  85236. * Get hosting scene
  85237. * @returns the scene
  85238. */
  85239. getScene(): Scene;
  85240. }
  85241. }
  85242. declare module BABYLON {
  85243. /**
  85244. * Creates an instance based on a source mesh.
  85245. */
  85246. export class InstancedMesh extends AbstractMesh {
  85247. private _sourceMesh;
  85248. private _currentLOD;
  85249. /** @hidden */
  85250. _indexInSourceMeshInstanceArray: number;
  85251. constructor(name: string, source: Mesh);
  85252. /**
  85253. * Returns the string "InstancedMesh".
  85254. */
  85255. getClassName(): string;
  85256. /** Gets the list of lights affecting that mesh */
  85257. readonly lightSources: Light[];
  85258. _resyncLightSources(): void;
  85259. _resyncLighSource(light: Light): void;
  85260. _removeLightSource(light: Light, dispose: boolean): void;
  85261. /**
  85262. * If the source mesh receives shadows
  85263. */
  85264. readonly receiveShadows: boolean;
  85265. /**
  85266. * The material of the source mesh
  85267. */
  85268. readonly material: Nullable<Material>;
  85269. /**
  85270. * Visibility of the source mesh
  85271. */
  85272. readonly visibility: number;
  85273. /**
  85274. * Skeleton of the source mesh
  85275. */
  85276. readonly skeleton: Nullable<Skeleton>;
  85277. /**
  85278. * Rendering ground id of the source mesh
  85279. */
  85280. renderingGroupId: number;
  85281. /**
  85282. * Returns the total number of vertices (integer).
  85283. */
  85284. getTotalVertices(): number;
  85285. /**
  85286. * Returns a positive integer : the total number of indices in this mesh geometry.
  85287. * @returns the numner of indices or zero if the mesh has no geometry.
  85288. */
  85289. getTotalIndices(): number;
  85290. /**
  85291. * The source mesh of the instance
  85292. */
  85293. readonly sourceMesh: Mesh;
  85294. /**
  85295. * Is this node ready to be used/rendered
  85296. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85297. * @return {boolean} is it ready
  85298. */
  85299. isReady(completeCheck?: boolean): boolean;
  85300. /**
  85301. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85302. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85303. * @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.
  85304. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85305. */
  85306. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85307. /**
  85308. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85309. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85310. * The `data` are either a numeric array either a Float32Array.
  85311. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85312. * 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).
  85313. * Note that a new underlying VertexBuffer object is created each call.
  85314. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85315. *
  85316. * Possible `kind` values :
  85317. * - VertexBuffer.PositionKind
  85318. * - VertexBuffer.UVKind
  85319. * - VertexBuffer.UV2Kind
  85320. * - VertexBuffer.UV3Kind
  85321. * - VertexBuffer.UV4Kind
  85322. * - VertexBuffer.UV5Kind
  85323. * - VertexBuffer.UV6Kind
  85324. * - VertexBuffer.ColorKind
  85325. * - VertexBuffer.MatricesIndicesKind
  85326. * - VertexBuffer.MatricesIndicesExtraKind
  85327. * - VertexBuffer.MatricesWeightsKind
  85328. * - VertexBuffer.MatricesWeightsExtraKind
  85329. *
  85330. * Returns the Mesh.
  85331. */
  85332. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85333. /**
  85334. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85335. * If the mesh has no geometry, it is simply returned as it is.
  85336. * The `data` are either a numeric array either a Float32Array.
  85337. * No new underlying VertexBuffer object is created.
  85338. * 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.
  85339. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85340. *
  85341. * Possible `kind` values :
  85342. * - VertexBuffer.PositionKind
  85343. * - VertexBuffer.UVKind
  85344. * - VertexBuffer.UV2Kind
  85345. * - VertexBuffer.UV3Kind
  85346. * - VertexBuffer.UV4Kind
  85347. * - VertexBuffer.UV5Kind
  85348. * - VertexBuffer.UV6Kind
  85349. * - VertexBuffer.ColorKind
  85350. * - VertexBuffer.MatricesIndicesKind
  85351. * - VertexBuffer.MatricesIndicesExtraKind
  85352. * - VertexBuffer.MatricesWeightsKind
  85353. * - VertexBuffer.MatricesWeightsExtraKind
  85354. *
  85355. * Returns the Mesh.
  85356. */
  85357. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85358. /**
  85359. * Sets the mesh indices.
  85360. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85361. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85362. * This method creates a new index buffer each call.
  85363. * Returns the Mesh.
  85364. */
  85365. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85366. /**
  85367. * Boolean : True if the mesh owns the requested kind of data.
  85368. */
  85369. isVerticesDataPresent(kind: string): boolean;
  85370. /**
  85371. * Returns an array of indices (IndicesArray).
  85372. */
  85373. getIndices(): Nullable<IndicesArray>;
  85374. readonly _positions: Nullable<Vector3[]>;
  85375. /**
  85376. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85377. * This means the mesh underlying bounding box and sphere are recomputed.
  85378. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85379. * @returns the current mesh
  85380. */
  85381. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85382. /** @hidden */
  85383. _preActivate(): InstancedMesh;
  85384. /** @hidden */
  85385. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85386. /** @hidden */
  85387. _postActivate(): void;
  85388. getWorldMatrix(): Matrix;
  85389. readonly isAnInstance: boolean;
  85390. /**
  85391. * Returns the current associated LOD AbstractMesh.
  85392. */
  85393. getLOD(camera: Camera): AbstractMesh;
  85394. /** @hidden */
  85395. _syncSubMeshes(): InstancedMesh;
  85396. /** @hidden */
  85397. _generatePointsArray(): boolean;
  85398. /**
  85399. * Creates a new InstancedMesh from the current mesh.
  85400. * - name (string) : the cloned mesh name
  85401. * - newParent (optional Node) : the optional Node to parent the clone to.
  85402. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85403. *
  85404. * Returns the clone.
  85405. */
  85406. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85407. /**
  85408. * Disposes the InstancedMesh.
  85409. * Returns nothing.
  85410. */
  85411. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85412. }
  85413. }
  85414. declare module BABYLON {
  85415. /**
  85416. * Defines the options associated with the creation of a shader material.
  85417. */
  85418. export interface IShaderMaterialOptions {
  85419. /**
  85420. * Does the material work in alpha blend mode
  85421. */
  85422. needAlphaBlending: boolean;
  85423. /**
  85424. * Does the material work in alpha test mode
  85425. */
  85426. needAlphaTesting: boolean;
  85427. /**
  85428. * The list of attribute names used in the shader
  85429. */
  85430. attributes: string[];
  85431. /**
  85432. * The list of unifrom names used in the shader
  85433. */
  85434. uniforms: string[];
  85435. /**
  85436. * The list of UBO names used in the shader
  85437. */
  85438. uniformBuffers: string[];
  85439. /**
  85440. * The list of sampler names used in the shader
  85441. */
  85442. samplers: string[];
  85443. /**
  85444. * The list of defines used in the shader
  85445. */
  85446. defines: string[];
  85447. }
  85448. /**
  85449. * 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.
  85450. *
  85451. * This returned material effects how the mesh will look based on the code in the shaders.
  85452. *
  85453. * @see http://doc.babylonjs.com/how_to/shader_material
  85454. */
  85455. export class ShaderMaterial extends Material {
  85456. private _shaderPath;
  85457. private _options;
  85458. private _textures;
  85459. private _textureArrays;
  85460. private _floats;
  85461. private _ints;
  85462. private _floatsArrays;
  85463. private _colors3;
  85464. private _colors3Arrays;
  85465. private _colors4;
  85466. private _colors4Arrays;
  85467. private _vectors2;
  85468. private _vectors3;
  85469. private _vectors4;
  85470. private _matrices;
  85471. private _matrices3x3;
  85472. private _matrices2x2;
  85473. private _vectors2Arrays;
  85474. private _vectors3Arrays;
  85475. private _vectors4Arrays;
  85476. private _cachedWorldViewMatrix;
  85477. private _cachedWorldViewProjectionMatrix;
  85478. private _renderId;
  85479. /**
  85480. * Instantiate a new shader material.
  85481. * 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.
  85482. * This returned material effects how the mesh will look based on the code in the shaders.
  85483. * @see http://doc.babylonjs.com/how_to/shader_material
  85484. * @param name Define the name of the material in the scene
  85485. * @param scene Define the scene the material belongs to
  85486. * @param shaderPath Defines the route to the shader code in one of three ways:
  85487. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85488. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85489. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85490. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85491. * @param options Define the options used to create the shader
  85492. */
  85493. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85494. /**
  85495. * Gets the options used to compile the shader.
  85496. * They can be modified to trigger a new compilation
  85497. */
  85498. readonly options: IShaderMaterialOptions;
  85499. /**
  85500. * Gets the current class name of the material e.g. "ShaderMaterial"
  85501. * Mainly use in serialization.
  85502. * @returns the class name
  85503. */
  85504. getClassName(): string;
  85505. /**
  85506. * Specifies if the material will require alpha blending
  85507. * @returns a boolean specifying if alpha blending is needed
  85508. */
  85509. needAlphaBlending(): boolean;
  85510. /**
  85511. * Specifies if this material should be rendered in alpha test mode
  85512. * @returns a boolean specifying if an alpha test is needed.
  85513. */
  85514. needAlphaTesting(): boolean;
  85515. private _checkUniform;
  85516. /**
  85517. * Set a texture in the shader.
  85518. * @param name Define the name of the uniform samplers as defined in the shader
  85519. * @param texture Define the texture to bind to this sampler
  85520. * @return the material itself allowing "fluent" like uniform updates
  85521. */
  85522. setTexture(name: string, texture: Texture): ShaderMaterial;
  85523. /**
  85524. * Set a texture array in the shader.
  85525. * @param name Define the name of the uniform sampler array as defined in the shader
  85526. * @param textures Define the list of textures to bind to this sampler
  85527. * @return the material itself allowing "fluent" like uniform updates
  85528. */
  85529. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85530. /**
  85531. * Set a float in the shader.
  85532. * @param name Define the name of the uniform as defined in the shader
  85533. * @param value Define the value to give to the uniform
  85534. * @return the material itself allowing "fluent" like uniform updates
  85535. */
  85536. setFloat(name: string, value: number): ShaderMaterial;
  85537. /**
  85538. * Set a int in the shader.
  85539. * @param name Define the name of the uniform as defined in the shader
  85540. * @param value Define the value to give to the uniform
  85541. * @return the material itself allowing "fluent" like uniform updates
  85542. */
  85543. setInt(name: string, value: number): ShaderMaterial;
  85544. /**
  85545. * Set an array of floats in the shader.
  85546. * @param name Define the name of the uniform as defined in the shader
  85547. * @param value Define the value to give to the uniform
  85548. * @return the material itself allowing "fluent" like uniform updates
  85549. */
  85550. setFloats(name: string, value: number[]): ShaderMaterial;
  85551. /**
  85552. * Set a vec3 in the shader from a Color3.
  85553. * @param name Define the name of the uniform as defined in the shader
  85554. * @param value Define the value to give to the uniform
  85555. * @return the material itself allowing "fluent" like uniform updates
  85556. */
  85557. setColor3(name: string, value: Color3): ShaderMaterial;
  85558. /**
  85559. * Set a vec3 array in the shader from a Color3 array.
  85560. * @param name Define the name of the uniform as defined in the shader
  85561. * @param value Define the value to give to the uniform
  85562. * @return the material itself allowing "fluent" like uniform updates
  85563. */
  85564. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85565. /**
  85566. * Set a vec4 in the shader from a Color4.
  85567. * @param name Define the name of the uniform as defined in the shader
  85568. * @param value Define the value to give to the uniform
  85569. * @return the material itself allowing "fluent" like uniform updates
  85570. */
  85571. setColor4(name: string, value: Color4): ShaderMaterial;
  85572. /**
  85573. * Set a vec4 array in the shader from a Color4 array.
  85574. * @param name Define the name of the uniform as defined in the shader
  85575. * @param value Define the value to give to the uniform
  85576. * @return the material itself allowing "fluent" like uniform updates
  85577. */
  85578. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85579. /**
  85580. * Set a vec2 in the shader from a Vector2.
  85581. * @param name Define the name of the uniform as defined in the shader
  85582. * @param value Define the value to give to the uniform
  85583. * @return the material itself allowing "fluent" like uniform updates
  85584. */
  85585. setVector2(name: string, value: Vector2): ShaderMaterial;
  85586. /**
  85587. * Set a vec3 in the shader from a Vector3.
  85588. * @param name Define the name of the uniform as defined in the shader
  85589. * @param value Define the value to give to the uniform
  85590. * @return the material itself allowing "fluent" like uniform updates
  85591. */
  85592. setVector3(name: string, value: Vector3): ShaderMaterial;
  85593. /**
  85594. * Set a vec4 in the shader from a Vector4.
  85595. * @param name Define the name of the uniform as defined in the shader
  85596. * @param value Define the value to give to the uniform
  85597. * @return the material itself allowing "fluent" like uniform updates
  85598. */
  85599. setVector4(name: string, value: Vector4): ShaderMaterial;
  85600. /**
  85601. * Set a mat4 in the shader from a Matrix.
  85602. * @param name Define the name of the uniform as defined in the shader
  85603. * @param value Define the value to give to the uniform
  85604. * @return the material itself allowing "fluent" like uniform updates
  85605. */
  85606. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85607. /**
  85608. * Set a mat3 in the shader from a Float32Array.
  85609. * @param name Define the name of the uniform as defined in the shader
  85610. * @param value Define the value to give to the uniform
  85611. * @return the material itself allowing "fluent" like uniform updates
  85612. */
  85613. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85614. /**
  85615. * Set a mat2 in the shader from a Float32Array.
  85616. * @param name Define the name of the uniform as defined in the shader
  85617. * @param value Define the value to give to the uniform
  85618. * @return the material itself allowing "fluent" like uniform updates
  85619. */
  85620. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85621. /**
  85622. * Set a vec2 array in the shader from a number array.
  85623. * @param name Define the name of the uniform as defined in the shader
  85624. * @param value Define the value to give to the uniform
  85625. * @return the material itself allowing "fluent" like uniform updates
  85626. */
  85627. setArray2(name: string, value: number[]): ShaderMaterial;
  85628. /**
  85629. * Set a vec3 array in the shader from a number array.
  85630. * @param name Define the name of the uniform as defined in the shader
  85631. * @param value Define the value to give to the uniform
  85632. * @return the material itself allowing "fluent" like uniform updates
  85633. */
  85634. setArray3(name: string, value: number[]): ShaderMaterial;
  85635. /**
  85636. * Set a vec4 array in the shader from a number array.
  85637. * @param name Define the name of the uniform as defined in the shader
  85638. * @param value Define the value to give to the uniform
  85639. * @return the material itself allowing "fluent" like uniform updates
  85640. */
  85641. setArray4(name: string, value: number[]): ShaderMaterial;
  85642. private _checkCache;
  85643. /**
  85644. * Specifies that the submesh is ready to be used
  85645. * @param mesh defines the mesh to check
  85646. * @param subMesh defines which submesh to check
  85647. * @param useInstances specifies that instances should be used
  85648. * @returns a boolean indicating that the submesh is ready or not
  85649. */
  85650. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85651. /**
  85652. * Checks if the material is ready to render the requested mesh
  85653. * @param mesh Define the mesh to render
  85654. * @param useInstances Define whether or not the material is used with instances
  85655. * @returns true if ready, otherwise false
  85656. */
  85657. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85658. /**
  85659. * Binds the world matrix to the material
  85660. * @param world defines the world transformation matrix
  85661. */
  85662. bindOnlyWorldMatrix(world: Matrix): void;
  85663. /**
  85664. * Binds the material to the mesh
  85665. * @param world defines the world transformation matrix
  85666. * @param mesh defines the mesh to bind the material to
  85667. */
  85668. bind(world: Matrix, mesh?: Mesh): void;
  85669. /**
  85670. * Gets the active textures from the material
  85671. * @returns an array of textures
  85672. */
  85673. getActiveTextures(): BaseTexture[];
  85674. /**
  85675. * Specifies if the material uses a texture
  85676. * @param texture defines the texture to check against the material
  85677. * @returns a boolean specifying if the material uses the texture
  85678. */
  85679. hasTexture(texture: BaseTexture): boolean;
  85680. /**
  85681. * Makes a duplicate of the material, and gives it a new name
  85682. * @param name defines the new name for the duplicated material
  85683. * @returns the cloned material
  85684. */
  85685. clone(name: string): ShaderMaterial;
  85686. /**
  85687. * Disposes the material
  85688. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85689. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85690. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85691. */
  85692. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85693. /**
  85694. * Serializes this material in a JSON representation
  85695. * @returns the serialized material object
  85696. */
  85697. serialize(): any;
  85698. /**
  85699. * Creates a shader material from parsed shader material data
  85700. * @param source defines the JSON represnetation of the material
  85701. * @param scene defines the hosting scene
  85702. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85703. * @returns a new material
  85704. */
  85705. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85706. }
  85707. }
  85708. declare module BABYLON {
  85709. /** @hidden */
  85710. export var colorPixelShader: {
  85711. name: string;
  85712. shader: string;
  85713. };
  85714. }
  85715. declare module BABYLON {
  85716. /** @hidden */
  85717. export var colorVertexShader: {
  85718. name: string;
  85719. shader: string;
  85720. };
  85721. }
  85722. declare module BABYLON {
  85723. /**
  85724. * Line mesh
  85725. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85726. */
  85727. export class LinesMesh extends Mesh {
  85728. /**
  85729. * If vertex color should be applied to the mesh
  85730. */
  85731. readonly useVertexColor?: boolean | undefined;
  85732. /**
  85733. * If vertex alpha should be applied to the mesh
  85734. */
  85735. readonly useVertexAlpha?: boolean | undefined;
  85736. /**
  85737. * Color of the line (Default: White)
  85738. */
  85739. color: Color3;
  85740. /**
  85741. * Alpha of the line (Default: 1)
  85742. */
  85743. alpha: number;
  85744. /**
  85745. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85746. * This margin is expressed in world space coordinates, so its value may vary.
  85747. * Default value is 0.1
  85748. */
  85749. intersectionThreshold: number;
  85750. private _colorShader;
  85751. private color4;
  85752. /**
  85753. * Creates a new LinesMesh
  85754. * @param name defines the name
  85755. * @param scene defines the hosting scene
  85756. * @param parent defines the parent mesh if any
  85757. * @param source defines the optional source LinesMesh used to clone data from
  85758. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85759. * When false, achieved by calling a clone(), also passing False.
  85760. * This will make creation of children, recursive.
  85761. * @param useVertexColor defines if this LinesMesh supports vertex color
  85762. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85763. */
  85764. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85765. /**
  85766. * If vertex color should be applied to the mesh
  85767. */
  85768. useVertexColor?: boolean | undefined,
  85769. /**
  85770. * If vertex alpha should be applied to the mesh
  85771. */
  85772. useVertexAlpha?: boolean | undefined);
  85773. private _addClipPlaneDefine;
  85774. private _removeClipPlaneDefine;
  85775. isReady(): boolean;
  85776. /**
  85777. * Returns the string "LineMesh"
  85778. */
  85779. getClassName(): string;
  85780. /**
  85781. * @hidden
  85782. */
  85783. /**
  85784. * @hidden
  85785. */
  85786. material: Material;
  85787. /**
  85788. * @hidden
  85789. */
  85790. readonly checkCollisions: boolean;
  85791. /** @hidden */
  85792. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85793. /** @hidden */
  85794. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85795. /**
  85796. * Disposes of the line mesh
  85797. * @param doNotRecurse If children should be disposed
  85798. */
  85799. dispose(doNotRecurse?: boolean): void;
  85800. /**
  85801. * Returns a new LineMesh object cloned from the current one.
  85802. */
  85803. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85804. /**
  85805. * Creates a new InstancedLinesMesh object from the mesh model.
  85806. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85807. * @param name defines the name of the new instance
  85808. * @returns a new InstancedLinesMesh
  85809. */
  85810. createInstance(name: string): InstancedLinesMesh;
  85811. }
  85812. /**
  85813. * Creates an instance based on a source LinesMesh
  85814. */
  85815. export class InstancedLinesMesh extends InstancedMesh {
  85816. /**
  85817. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85818. * This margin is expressed in world space coordinates, so its value may vary.
  85819. * Initilized with the intersectionThreshold value of the source LinesMesh
  85820. */
  85821. intersectionThreshold: number;
  85822. constructor(name: string, source: LinesMesh);
  85823. /**
  85824. * Returns the string "InstancedLinesMesh".
  85825. */
  85826. getClassName(): string;
  85827. }
  85828. }
  85829. declare module BABYLON {
  85830. /** @hidden */
  85831. export var linePixelShader: {
  85832. name: string;
  85833. shader: string;
  85834. };
  85835. }
  85836. declare module BABYLON {
  85837. /** @hidden */
  85838. export var lineVertexShader: {
  85839. name: string;
  85840. shader: string;
  85841. };
  85842. }
  85843. declare module BABYLON {
  85844. interface AbstractMesh {
  85845. /**
  85846. * Gets the edgesRenderer associated with the mesh
  85847. */
  85848. edgesRenderer: Nullable<EdgesRenderer>;
  85849. }
  85850. interface LinesMesh {
  85851. /**
  85852. * Enables the edge rendering mode on the mesh.
  85853. * This mode makes the mesh edges visible
  85854. * @param epsilon defines the maximal distance between two angles to detect a face
  85855. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85856. * @returns the currentAbstractMesh
  85857. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85858. */
  85859. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85860. }
  85861. interface InstancedLinesMesh {
  85862. /**
  85863. * Enables the edge rendering mode on the mesh.
  85864. * This mode makes the mesh edges visible
  85865. * @param epsilon defines the maximal distance between two angles to detect a face
  85866. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85867. * @returns the current InstancedLinesMesh
  85868. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85869. */
  85870. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85871. }
  85872. /**
  85873. * Defines the minimum contract an Edges renderer should follow.
  85874. */
  85875. export interface IEdgesRenderer extends IDisposable {
  85876. /**
  85877. * Gets or sets a boolean indicating if the edgesRenderer is active
  85878. */
  85879. isEnabled: boolean;
  85880. /**
  85881. * Renders the edges of the attached mesh,
  85882. */
  85883. render(): void;
  85884. /**
  85885. * Checks wether or not the edges renderer is ready to render.
  85886. * @return true if ready, otherwise false.
  85887. */
  85888. isReady(): boolean;
  85889. }
  85890. /**
  85891. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85892. */
  85893. export class EdgesRenderer implements IEdgesRenderer {
  85894. /**
  85895. * Define the size of the edges with an orthographic camera
  85896. */
  85897. edgesWidthScalerForOrthographic: number;
  85898. /**
  85899. * Define the size of the edges with a perspective camera
  85900. */
  85901. edgesWidthScalerForPerspective: number;
  85902. protected _source: AbstractMesh;
  85903. protected _linesPositions: number[];
  85904. protected _linesNormals: number[];
  85905. protected _linesIndices: number[];
  85906. protected _epsilon: number;
  85907. protected _indicesCount: number;
  85908. protected _lineShader: ShaderMaterial;
  85909. protected _ib: DataBuffer;
  85910. protected _buffers: {
  85911. [key: string]: Nullable<VertexBuffer>;
  85912. };
  85913. protected _checkVerticesInsteadOfIndices: boolean;
  85914. private _meshRebuildObserver;
  85915. private _meshDisposeObserver;
  85916. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85917. isEnabled: boolean;
  85918. /**
  85919. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85920. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85921. * @param source Mesh used to create edges
  85922. * @param epsilon sum of angles in adjacency to check for edge
  85923. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85924. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85925. */
  85926. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85927. protected _prepareRessources(): void;
  85928. /** @hidden */
  85929. _rebuild(): void;
  85930. /**
  85931. * Releases the required resources for the edges renderer
  85932. */
  85933. dispose(): void;
  85934. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85935. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85936. /**
  85937. * Checks if the pair of p0 and p1 is en edge
  85938. * @param faceIndex
  85939. * @param edge
  85940. * @param faceNormals
  85941. * @param p0
  85942. * @param p1
  85943. * @private
  85944. */
  85945. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85946. /**
  85947. * push line into the position, normal and index buffer
  85948. * @protected
  85949. */
  85950. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85951. /**
  85952. * Generates lines edges from adjacencjes
  85953. * @private
  85954. */
  85955. _generateEdgesLines(): void;
  85956. /**
  85957. * Checks wether or not the edges renderer is ready to render.
  85958. * @return true if ready, otherwise false.
  85959. */
  85960. isReady(): boolean;
  85961. /**
  85962. * Renders the edges of the attached mesh,
  85963. */
  85964. render(): void;
  85965. }
  85966. /**
  85967. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85968. */
  85969. export class LineEdgesRenderer extends EdgesRenderer {
  85970. /**
  85971. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85972. * @param source LineMesh used to generate edges
  85973. * @param epsilon not important (specified angle for edge detection)
  85974. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85975. */
  85976. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85977. /**
  85978. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85979. */
  85980. _generateEdgesLines(): void;
  85981. }
  85982. }
  85983. declare module BABYLON {
  85984. /**
  85985. * This represents the object necessary to create a rendering group.
  85986. * This is exclusively used and created by the rendering manager.
  85987. * To modify the behavior, you use the available helpers in your scene or meshes.
  85988. * @hidden
  85989. */
  85990. export class RenderingGroup {
  85991. index: number;
  85992. private static _zeroVector;
  85993. private _scene;
  85994. private _opaqueSubMeshes;
  85995. private _transparentSubMeshes;
  85996. private _alphaTestSubMeshes;
  85997. private _depthOnlySubMeshes;
  85998. private _particleSystems;
  85999. private _spriteManagers;
  86000. private _opaqueSortCompareFn;
  86001. private _alphaTestSortCompareFn;
  86002. private _transparentSortCompareFn;
  86003. private _renderOpaque;
  86004. private _renderAlphaTest;
  86005. private _renderTransparent;
  86006. /** @hidden */
  86007. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86008. onBeforeTransparentRendering: () => void;
  86009. /**
  86010. * Set the opaque sort comparison function.
  86011. * If null the sub meshes will be render in the order they were created
  86012. */
  86013. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86014. /**
  86015. * Set the alpha test sort comparison function.
  86016. * If null the sub meshes will be render in the order they were created
  86017. */
  86018. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86019. /**
  86020. * Set the transparent sort comparison function.
  86021. * If null the sub meshes will be render in the order they were created
  86022. */
  86023. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86024. /**
  86025. * Creates a new rendering group.
  86026. * @param index The rendering group index
  86027. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86028. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86029. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86030. */
  86031. 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>);
  86032. /**
  86033. * Render all the sub meshes contained in the group.
  86034. * @param customRenderFunction Used to override the default render behaviour of the group.
  86035. * @returns true if rendered some submeshes.
  86036. */
  86037. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86038. /**
  86039. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86040. * @param subMeshes The submeshes to render
  86041. */
  86042. private renderOpaqueSorted;
  86043. /**
  86044. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86045. * @param subMeshes The submeshes to render
  86046. */
  86047. private renderAlphaTestSorted;
  86048. /**
  86049. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86050. * @param subMeshes The submeshes to render
  86051. */
  86052. private renderTransparentSorted;
  86053. /**
  86054. * Renders the submeshes in a specified order.
  86055. * @param subMeshes The submeshes to sort before render
  86056. * @param sortCompareFn The comparison function use to sort
  86057. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86058. * @param transparent Specifies to activate blending if true
  86059. */
  86060. private static renderSorted;
  86061. /**
  86062. * Renders the submeshes in the order they were dispatched (no sort applied).
  86063. * @param subMeshes The submeshes to render
  86064. */
  86065. private static renderUnsorted;
  86066. /**
  86067. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86068. * are rendered back to front if in the same alpha index.
  86069. *
  86070. * @param a The first submesh
  86071. * @param b The second submesh
  86072. * @returns The result of the comparison
  86073. */
  86074. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86075. /**
  86076. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86077. * are rendered back to front.
  86078. *
  86079. * @param a The first submesh
  86080. * @param b The second submesh
  86081. * @returns The result of the comparison
  86082. */
  86083. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86084. /**
  86085. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86086. * are rendered front to back (prevent overdraw).
  86087. *
  86088. * @param a The first submesh
  86089. * @param b The second submesh
  86090. * @returns The result of the comparison
  86091. */
  86092. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86093. /**
  86094. * Resets the different lists of submeshes to prepare a new frame.
  86095. */
  86096. prepare(): void;
  86097. dispose(): void;
  86098. /**
  86099. * Inserts the submesh in its correct queue depending on its material.
  86100. * @param subMesh The submesh to dispatch
  86101. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86102. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86103. */
  86104. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86105. dispatchSprites(spriteManager: ISpriteManager): void;
  86106. dispatchParticles(particleSystem: IParticleSystem): void;
  86107. private _renderParticles;
  86108. private _renderSprites;
  86109. }
  86110. }
  86111. declare module BABYLON {
  86112. /**
  86113. * Interface describing the different options available in the rendering manager
  86114. * regarding Auto Clear between groups.
  86115. */
  86116. export interface IRenderingManagerAutoClearSetup {
  86117. /**
  86118. * Defines whether or not autoclear is enable.
  86119. */
  86120. autoClear: boolean;
  86121. /**
  86122. * Defines whether or not to autoclear the depth buffer.
  86123. */
  86124. depth: boolean;
  86125. /**
  86126. * Defines whether or not to autoclear the stencil buffer.
  86127. */
  86128. stencil: boolean;
  86129. }
  86130. /**
  86131. * This class is used by the onRenderingGroupObservable
  86132. */
  86133. export class RenderingGroupInfo {
  86134. /**
  86135. * The Scene that being rendered
  86136. */
  86137. scene: Scene;
  86138. /**
  86139. * The camera currently used for the rendering pass
  86140. */
  86141. camera: Nullable<Camera>;
  86142. /**
  86143. * The ID of the renderingGroup being processed
  86144. */
  86145. renderingGroupId: number;
  86146. }
  86147. /**
  86148. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86149. * It is enable to manage the different groups as well as the different necessary sort functions.
  86150. * This should not be used directly aside of the few static configurations
  86151. */
  86152. export class RenderingManager {
  86153. /**
  86154. * The max id used for rendering groups (not included)
  86155. */
  86156. static MAX_RENDERINGGROUPS: number;
  86157. /**
  86158. * The min id used for rendering groups (included)
  86159. */
  86160. static MIN_RENDERINGGROUPS: number;
  86161. /**
  86162. * Used to globally prevent autoclearing scenes.
  86163. */
  86164. static AUTOCLEAR: boolean;
  86165. /**
  86166. * @hidden
  86167. */
  86168. _useSceneAutoClearSetup: boolean;
  86169. private _scene;
  86170. private _renderingGroups;
  86171. private _depthStencilBufferAlreadyCleaned;
  86172. private _autoClearDepthStencil;
  86173. private _customOpaqueSortCompareFn;
  86174. private _customAlphaTestSortCompareFn;
  86175. private _customTransparentSortCompareFn;
  86176. private _renderingGroupInfo;
  86177. /**
  86178. * Instantiates a new rendering group for a particular scene
  86179. * @param scene Defines the scene the groups belongs to
  86180. */
  86181. constructor(scene: Scene);
  86182. private _clearDepthStencilBuffer;
  86183. /**
  86184. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86185. * @hidden
  86186. */
  86187. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86188. /**
  86189. * Resets the different information of the group to prepare a new frame
  86190. * @hidden
  86191. */
  86192. reset(): void;
  86193. /**
  86194. * Dispose and release the group and its associated resources.
  86195. * @hidden
  86196. */
  86197. dispose(): void;
  86198. /**
  86199. * Clear the info related to rendering groups preventing retention points during dispose.
  86200. */
  86201. freeRenderingGroups(): void;
  86202. private _prepareRenderingGroup;
  86203. /**
  86204. * Add a sprite manager to the rendering manager in order to render it this frame.
  86205. * @param spriteManager Define the sprite manager to render
  86206. */
  86207. dispatchSprites(spriteManager: ISpriteManager): void;
  86208. /**
  86209. * Add a particle system to the rendering manager in order to render it this frame.
  86210. * @param particleSystem Define the particle system to render
  86211. */
  86212. dispatchParticles(particleSystem: IParticleSystem): void;
  86213. /**
  86214. * Add a submesh to the manager in order to render it this frame
  86215. * @param subMesh The submesh to dispatch
  86216. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86217. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86218. */
  86219. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86220. /**
  86221. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86222. * This allowed control for front to back rendering or reversly depending of the special needs.
  86223. *
  86224. * @param renderingGroupId The rendering group id corresponding to its index
  86225. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86226. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86227. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86228. */
  86229. 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;
  86230. /**
  86231. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86232. *
  86233. * @param renderingGroupId The rendering group id corresponding to its index
  86234. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86235. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86236. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86237. */
  86238. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86239. /**
  86240. * Gets the current auto clear configuration for one rendering group of the rendering
  86241. * manager.
  86242. * @param index the rendering group index to get the information for
  86243. * @returns The auto clear setup for the requested rendering group
  86244. */
  86245. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86246. }
  86247. }
  86248. declare module BABYLON {
  86249. /**
  86250. * This Helps creating a texture that will be created from a camera in your scene.
  86251. * It is basically a dynamic texture that could be used to create special effects for instance.
  86252. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86253. */
  86254. export class RenderTargetTexture extends Texture {
  86255. isCube: boolean;
  86256. /**
  86257. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86258. */
  86259. static readonly REFRESHRATE_RENDER_ONCE: number;
  86260. /**
  86261. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86262. */
  86263. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86264. /**
  86265. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86266. * the central point of your effect and can save a lot of performances.
  86267. */
  86268. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86269. /**
  86270. * Use this predicate to dynamically define the list of mesh you want to render.
  86271. * If set, the renderList property will be overwritten.
  86272. */
  86273. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86274. private _renderList;
  86275. /**
  86276. * Use this list to define the list of mesh you want to render.
  86277. */
  86278. renderList: Nullable<Array<AbstractMesh>>;
  86279. private _hookArray;
  86280. /**
  86281. * Define if particles should be rendered in your texture.
  86282. */
  86283. renderParticles: boolean;
  86284. /**
  86285. * Define if sprites should be rendered in your texture.
  86286. */
  86287. renderSprites: boolean;
  86288. /**
  86289. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86290. */
  86291. coordinatesMode: number;
  86292. /**
  86293. * Define the camera used to render the texture.
  86294. */
  86295. activeCamera: Nullable<Camera>;
  86296. /**
  86297. * Override the render function of the texture with your own one.
  86298. */
  86299. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86300. /**
  86301. * Define if camera post processes should be use while rendering the texture.
  86302. */
  86303. useCameraPostProcesses: boolean;
  86304. /**
  86305. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86306. */
  86307. ignoreCameraViewport: boolean;
  86308. private _postProcessManager;
  86309. private _postProcesses;
  86310. private _resizeObserver;
  86311. /**
  86312. * An event triggered when the texture is unbind.
  86313. */
  86314. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86315. /**
  86316. * An event triggered when the texture is unbind.
  86317. */
  86318. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86319. private _onAfterUnbindObserver;
  86320. /**
  86321. * Set a after unbind callback in the texture.
  86322. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86323. */
  86324. onAfterUnbind: () => void;
  86325. /**
  86326. * An event triggered before rendering the texture
  86327. */
  86328. onBeforeRenderObservable: Observable<number>;
  86329. private _onBeforeRenderObserver;
  86330. /**
  86331. * Set a before render callback in the texture.
  86332. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86333. */
  86334. onBeforeRender: (faceIndex: number) => void;
  86335. /**
  86336. * An event triggered after rendering the texture
  86337. */
  86338. onAfterRenderObservable: Observable<number>;
  86339. private _onAfterRenderObserver;
  86340. /**
  86341. * Set a after render callback in the texture.
  86342. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86343. */
  86344. onAfterRender: (faceIndex: number) => void;
  86345. /**
  86346. * An event triggered after the texture clear
  86347. */
  86348. onClearObservable: Observable<Engine>;
  86349. private _onClearObserver;
  86350. /**
  86351. * Set a clear callback in the texture.
  86352. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86353. */
  86354. onClear: (Engine: Engine) => void;
  86355. /**
  86356. * An event triggered when the texture is resized.
  86357. */
  86358. onResizeObservable: Observable<RenderTargetTexture>;
  86359. /**
  86360. * Define the clear color of the Render Target if it should be different from the scene.
  86361. */
  86362. clearColor: Color4;
  86363. protected _size: number | {
  86364. width: number;
  86365. height: number;
  86366. };
  86367. protected _initialSizeParameter: number | {
  86368. width: number;
  86369. height: number;
  86370. } | {
  86371. ratio: number;
  86372. };
  86373. protected _sizeRatio: Nullable<number>;
  86374. /** @hidden */
  86375. _generateMipMaps: boolean;
  86376. protected _renderingManager: RenderingManager;
  86377. /** @hidden */
  86378. _waitingRenderList: string[];
  86379. protected _doNotChangeAspectRatio: boolean;
  86380. protected _currentRefreshId: number;
  86381. protected _refreshRate: number;
  86382. protected _textureMatrix: Matrix;
  86383. protected _samples: number;
  86384. protected _renderTargetOptions: RenderTargetCreationOptions;
  86385. /**
  86386. * Gets render target creation options that were used.
  86387. */
  86388. readonly renderTargetOptions: RenderTargetCreationOptions;
  86389. protected _engine: Engine;
  86390. protected _onRatioRescale(): void;
  86391. /**
  86392. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86393. * It must define where the camera used to render the texture is set
  86394. */
  86395. boundingBoxPosition: Vector3;
  86396. private _boundingBoxSize;
  86397. /**
  86398. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86399. * When defined, the cubemap will switch to local mode
  86400. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86401. * @example https://www.babylonjs-playground.com/#RNASML
  86402. */
  86403. boundingBoxSize: Vector3;
  86404. /**
  86405. * In case the RTT has been created with a depth texture, get the associated
  86406. * depth texture.
  86407. * Otherwise, return null.
  86408. */
  86409. depthStencilTexture: Nullable<InternalTexture>;
  86410. /**
  86411. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86412. * or used a shadow, depth texture...
  86413. * @param name The friendly name of the texture
  86414. * @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)
  86415. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86416. * @param generateMipMaps True if mip maps need to be generated after render.
  86417. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86418. * @param type The type of the buffer in the RTT (int, half float, float...)
  86419. * @param isCube True if a cube texture needs to be created
  86420. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86421. * @param generateDepthBuffer True to generate a depth buffer
  86422. * @param generateStencilBuffer True to generate a stencil buffer
  86423. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86424. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86425. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86426. */
  86427. constructor(name: string, size: number | {
  86428. width: number;
  86429. height: number;
  86430. } | {
  86431. ratio: number;
  86432. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86433. /**
  86434. * Creates a depth stencil texture.
  86435. * This is only available in WebGL 2 or with the depth texture extension available.
  86436. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86437. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86438. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86439. */
  86440. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86441. private _processSizeParameter;
  86442. /**
  86443. * Define the number of samples to use in case of MSAA.
  86444. * It defaults to one meaning no MSAA has been enabled.
  86445. */
  86446. samples: number;
  86447. /**
  86448. * Resets the refresh counter of the texture and start bak from scratch.
  86449. * Could be useful to regenerate the texture if it is setup to render only once.
  86450. */
  86451. resetRefreshCounter(): void;
  86452. /**
  86453. * Define the refresh rate of the texture or the rendering frequency.
  86454. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86455. */
  86456. refreshRate: number;
  86457. /**
  86458. * Adds a post process to the render target rendering passes.
  86459. * @param postProcess define the post process to add
  86460. */
  86461. addPostProcess(postProcess: PostProcess): void;
  86462. /**
  86463. * Clear all the post processes attached to the render target
  86464. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86465. */
  86466. clearPostProcesses(dispose?: boolean): void;
  86467. /**
  86468. * Remove one of the post process from the list of attached post processes to the texture
  86469. * @param postProcess define the post process to remove from the list
  86470. */
  86471. removePostProcess(postProcess: PostProcess): void;
  86472. /** @hidden */
  86473. _shouldRender(): boolean;
  86474. /**
  86475. * Gets the actual render size of the texture.
  86476. * @returns the width of the render size
  86477. */
  86478. getRenderSize(): number;
  86479. /**
  86480. * Gets the actual render width of the texture.
  86481. * @returns the width of the render size
  86482. */
  86483. getRenderWidth(): number;
  86484. /**
  86485. * Gets the actual render height of the texture.
  86486. * @returns the height of the render size
  86487. */
  86488. getRenderHeight(): number;
  86489. /**
  86490. * Get if the texture can be rescaled or not.
  86491. */
  86492. readonly canRescale: boolean;
  86493. /**
  86494. * Resize the texture using a ratio.
  86495. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86496. */
  86497. scale(ratio: number): void;
  86498. /**
  86499. * Get the texture reflection matrix used to rotate/transform the reflection.
  86500. * @returns the reflection matrix
  86501. */
  86502. getReflectionTextureMatrix(): Matrix;
  86503. /**
  86504. * Resize the texture to a new desired size.
  86505. * Be carrefull as it will recreate all the data in the new texture.
  86506. * @param size Define the new size. It can be:
  86507. * - a number for squared texture,
  86508. * - an object containing { width: number, height: number }
  86509. * - or an object containing a ratio { ratio: number }
  86510. */
  86511. resize(size: number | {
  86512. width: number;
  86513. height: number;
  86514. } | {
  86515. ratio: number;
  86516. }): void;
  86517. /**
  86518. * Renders all the objects from the render list into the texture.
  86519. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86520. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86521. */
  86522. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86523. private _bestReflectionRenderTargetDimension;
  86524. /**
  86525. * @hidden
  86526. * @param faceIndex face index to bind to if this is a cubetexture
  86527. */
  86528. _bindFrameBuffer(faceIndex?: number): void;
  86529. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86530. private renderToTarget;
  86531. /**
  86532. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86533. * This allowed control for front to back rendering or reversly depending of the special needs.
  86534. *
  86535. * @param renderingGroupId The rendering group id corresponding to its index
  86536. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86537. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86538. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86539. */
  86540. 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;
  86541. /**
  86542. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86543. *
  86544. * @param renderingGroupId The rendering group id corresponding to its index
  86545. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86546. */
  86547. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86548. /**
  86549. * Clones the texture.
  86550. * @returns the cloned texture
  86551. */
  86552. clone(): RenderTargetTexture;
  86553. /**
  86554. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86555. * @returns The JSON representation of the texture
  86556. */
  86557. serialize(): any;
  86558. /**
  86559. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86560. */
  86561. disposeFramebufferObjects(): void;
  86562. /**
  86563. * Dispose the texture and release its associated resources.
  86564. */
  86565. dispose(): void;
  86566. /** @hidden */
  86567. _rebuild(): void;
  86568. /**
  86569. * Clear the info related to rendering groups preventing retention point in material dispose.
  86570. */
  86571. freeRenderingGroups(): void;
  86572. /**
  86573. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86574. * @returns the view count
  86575. */
  86576. getViewCount(): number;
  86577. }
  86578. }
  86579. declare module BABYLON {
  86580. /**
  86581. * Base class for the main features of a material in Babylon.js
  86582. */
  86583. export class Material implements IAnimatable {
  86584. /**
  86585. * Returns the triangle fill mode
  86586. */
  86587. static readonly TriangleFillMode: number;
  86588. /**
  86589. * Returns the wireframe mode
  86590. */
  86591. static readonly WireFrameFillMode: number;
  86592. /**
  86593. * Returns the point fill mode
  86594. */
  86595. static readonly PointFillMode: number;
  86596. /**
  86597. * Returns the point list draw mode
  86598. */
  86599. static readonly PointListDrawMode: number;
  86600. /**
  86601. * Returns the line list draw mode
  86602. */
  86603. static readonly LineListDrawMode: number;
  86604. /**
  86605. * Returns the line loop draw mode
  86606. */
  86607. static readonly LineLoopDrawMode: number;
  86608. /**
  86609. * Returns the line strip draw mode
  86610. */
  86611. static readonly LineStripDrawMode: number;
  86612. /**
  86613. * Returns the triangle strip draw mode
  86614. */
  86615. static readonly TriangleStripDrawMode: number;
  86616. /**
  86617. * Returns the triangle fan draw mode
  86618. */
  86619. static readonly TriangleFanDrawMode: number;
  86620. /**
  86621. * Stores the clock-wise side orientation
  86622. */
  86623. static readonly ClockWiseSideOrientation: number;
  86624. /**
  86625. * Stores the counter clock-wise side orientation
  86626. */
  86627. static readonly CounterClockWiseSideOrientation: number;
  86628. /**
  86629. * The dirty texture flag value
  86630. */
  86631. static readonly TextureDirtyFlag: number;
  86632. /**
  86633. * The dirty light flag value
  86634. */
  86635. static readonly LightDirtyFlag: number;
  86636. /**
  86637. * The dirty fresnel flag value
  86638. */
  86639. static readonly FresnelDirtyFlag: number;
  86640. /**
  86641. * The dirty attribute flag value
  86642. */
  86643. static readonly AttributesDirtyFlag: number;
  86644. /**
  86645. * The dirty misc flag value
  86646. */
  86647. static readonly MiscDirtyFlag: number;
  86648. /**
  86649. * The all dirty flag value
  86650. */
  86651. static readonly AllDirtyFlag: number;
  86652. /**
  86653. * The ID of the material
  86654. */
  86655. id: string;
  86656. /**
  86657. * Gets or sets the unique id of the material
  86658. */
  86659. uniqueId: number;
  86660. /**
  86661. * The name of the material
  86662. */
  86663. name: string;
  86664. /**
  86665. * Gets or sets user defined metadata
  86666. */
  86667. metadata: any;
  86668. /**
  86669. * For internal use only. Please do not use.
  86670. */
  86671. reservedDataStore: any;
  86672. /**
  86673. * Specifies if the ready state should be checked on each call
  86674. */
  86675. checkReadyOnEveryCall: boolean;
  86676. /**
  86677. * Specifies if the ready state should be checked once
  86678. */
  86679. checkReadyOnlyOnce: boolean;
  86680. /**
  86681. * The state of the material
  86682. */
  86683. state: string;
  86684. /**
  86685. * The alpha value of the material
  86686. */
  86687. protected _alpha: number;
  86688. /**
  86689. * List of inspectable custom properties (used by the Inspector)
  86690. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86691. */
  86692. inspectableCustomProperties: IInspectable[];
  86693. /**
  86694. * Sets the alpha value of the material
  86695. */
  86696. /**
  86697. * Gets the alpha value of the material
  86698. */
  86699. alpha: number;
  86700. /**
  86701. * Specifies if back face culling is enabled
  86702. */
  86703. protected _backFaceCulling: boolean;
  86704. /**
  86705. * Sets the back-face culling state
  86706. */
  86707. /**
  86708. * Gets the back-face culling state
  86709. */
  86710. backFaceCulling: boolean;
  86711. /**
  86712. * Stores the value for side orientation
  86713. */
  86714. sideOrientation: number;
  86715. /**
  86716. * Callback triggered when the material is compiled
  86717. */
  86718. onCompiled: Nullable<(effect: Effect) => void>;
  86719. /**
  86720. * Callback triggered when an error occurs
  86721. */
  86722. onError: Nullable<(effect: Effect, errors: string) => void>;
  86723. /**
  86724. * Callback triggered to get the render target textures
  86725. */
  86726. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  86727. /**
  86728. * Gets a boolean indicating that current material needs to register RTT
  86729. */
  86730. readonly hasRenderTargetTextures: boolean;
  86731. /**
  86732. * Specifies if the material should be serialized
  86733. */
  86734. doNotSerialize: boolean;
  86735. /**
  86736. * @hidden
  86737. */
  86738. _storeEffectOnSubMeshes: boolean;
  86739. /**
  86740. * Stores the animations for the material
  86741. */
  86742. animations: Nullable<Array<Animation>>;
  86743. /**
  86744. * An event triggered when the material is disposed
  86745. */
  86746. onDisposeObservable: Observable<Material>;
  86747. /**
  86748. * An observer which watches for dispose events
  86749. */
  86750. private _onDisposeObserver;
  86751. private _onUnBindObservable;
  86752. /**
  86753. * Called during a dispose event
  86754. */
  86755. onDispose: () => void;
  86756. private _onBindObservable;
  86757. /**
  86758. * An event triggered when the material is bound
  86759. */
  86760. readonly onBindObservable: Observable<AbstractMesh>;
  86761. /**
  86762. * An observer which watches for bind events
  86763. */
  86764. private _onBindObserver;
  86765. /**
  86766. * Called during a bind event
  86767. */
  86768. onBind: (Mesh: AbstractMesh) => void;
  86769. /**
  86770. * An event triggered when the material is unbound
  86771. */
  86772. readonly onUnBindObservable: Observable<Material>;
  86773. /**
  86774. * Stores the value of the alpha mode
  86775. */
  86776. private _alphaMode;
  86777. /**
  86778. * Sets the value of the alpha mode.
  86779. *
  86780. * | Value | Type | Description |
  86781. * | --- | --- | --- |
  86782. * | 0 | ALPHA_DISABLE | |
  86783. * | 1 | ALPHA_ADD | |
  86784. * | 2 | ALPHA_COMBINE | |
  86785. * | 3 | ALPHA_SUBTRACT | |
  86786. * | 4 | ALPHA_MULTIPLY | |
  86787. * | 5 | ALPHA_MAXIMIZED | |
  86788. * | 6 | ALPHA_ONEONE | |
  86789. * | 7 | ALPHA_PREMULTIPLIED | |
  86790. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86791. * | 9 | ALPHA_INTERPOLATE | |
  86792. * | 10 | ALPHA_SCREENMODE | |
  86793. *
  86794. */
  86795. /**
  86796. * Gets the value of the alpha mode
  86797. */
  86798. alphaMode: number;
  86799. /**
  86800. * Stores the state of the need depth pre-pass value
  86801. */
  86802. private _needDepthPrePass;
  86803. /**
  86804. * Sets the need depth pre-pass value
  86805. */
  86806. /**
  86807. * Gets the depth pre-pass value
  86808. */
  86809. needDepthPrePass: boolean;
  86810. /**
  86811. * Specifies if depth writing should be disabled
  86812. */
  86813. disableDepthWrite: boolean;
  86814. /**
  86815. * Specifies if depth writing should be forced
  86816. */
  86817. forceDepthWrite: boolean;
  86818. /**
  86819. * Specifies if there should be a separate pass for culling
  86820. */
  86821. separateCullingPass: boolean;
  86822. /**
  86823. * Stores the state specifing if fog should be enabled
  86824. */
  86825. private _fogEnabled;
  86826. /**
  86827. * Sets the state for enabling fog
  86828. */
  86829. /**
  86830. * Gets the value of the fog enabled state
  86831. */
  86832. fogEnabled: boolean;
  86833. /**
  86834. * Stores the size of points
  86835. */
  86836. pointSize: number;
  86837. /**
  86838. * Stores the z offset value
  86839. */
  86840. zOffset: number;
  86841. /**
  86842. * Gets a value specifying if wireframe mode is enabled
  86843. */
  86844. /**
  86845. * Sets the state of wireframe mode
  86846. */
  86847. wireframe: boolean;
  86848. /**
  86849. * Gets the value specifying if point clouds are enabled
  86850. */
  86851. /**
  86852. * Sets the state of point cloud mode
  86853. */
  86854. pointsCloud: boolean;
  86855. /**
  86856. * Gets the material fill mode
  86857. */
  86858. /**
  86859. * Sets the material fill mode
  86860. */
  86861. fillMode: number;
  86862. /**
  86863. * @hidden
  86864. * Stores the effects for the material
  86865. */
  86866. _effect: Nullable<Effect>;
  86867. /**
  86868. * @hidden
  86869. * Specifies if the material was previously ready
  86870. */
  86871. _wasPreviouslyReady: boolean;
  86872. /**
  86873. * Specifies if uniform buffers should be used
  86874. */
  86875. private _useUBO;
  86876. /**
  86877. * Stores a reference to the scene
  86878. */
  86879. private _scene;
  86880. /**
  86881. * Stores the fill mode state
  86882. */
  86883. private _fillMode;
  86884. /**
  86885. * Specifies if the depth write state should be cached
  86886. */
  86887. private _cachedDepthWriteState;
  86888. /**
  86889. * Stores the uniform buffer
  86890. */
  86891. protected _uniformBuffer: UniformBuffer;
  86892. /** @hidden */
  86893. _indexInSceneMaterialArray: number;
  86894. /** @hidden */
  86895. meshMap: Nullable<{
  86896. [id: string]: AbstractMesh | undefined;
  86897. }>;
  86898. /**
  86899. * Creates a material instance
  86900. * @param name defines the name of the material
  86901. * @param scene defines the scene to reference
  86902. * @param doNotAdd specifies if the material should be added to the scene
  86903. */
  86904. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86905. /**
  86906. * Returns a string representation of the current material
  86907. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86908. * @returns a string with material information
  86909. */
  86910. toString(fullDetails?: boolean): string;
  86911. /**
  86912. * Gets the class name of the material
  86913. * @returns a string with the class name of the material
  86914. */
  86915. getClassName(): string;
  86916. /**
  86917. * Specifies if updates for the material been locked
  86918. */
  86919. readonly isFrozen: boolean;
  86920. /**
  86921. * Locks updates for the material
  86922. */
  86923. freeze(): void;
  86924. /**
  86925. * Unlocks updates for the material
  86926. */
  86927. unfreeze(): void;
  86928. /**
  86929. * Specifies if the material is ready to be used
  86930. * @param mesh defines the mesh to check
  86931. * @param useInstances specifies if instances should be used
  86932. * @returns a boolean indicating if the material is ready to be used
  86933. */
  86934. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86935. /**
  86936. * Specifies that the submesh is ready to be used
  86937. * @param mesh defines the mesh to check
  86938. * @param subMesh defines which submesh to check
  86939. * @param useInstances specifies that instances should be used
  86940. * @returns a boolean indicating that the submesh is ready or not
  86941. */
  86942. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86943. /**
  86944. * Returns the material effect
  86945. * @returns the effect associated with the material
  86946. */
  86947. getEffect(): Nullable<Effect>;
  86948. /**
  86949. * Returns the current scene
  86950. * @returns a Scene
  86951. */
  86952. getScene(): Scene;
  86953. /**
  86954. * Specifies if the material will require alpha blending
  86955. * @returns a boolean specifying if alpha blending is needed
  86956. */
  86957. needAlphaBlending(): boolean;
  86958. /**
  86959. * Specifies if the mesh will require alpha blending
  86960. * @param mesh defines the mesh to check
  86961. * @returns a boolean specifying if alpha blending is needed for the mesh
  86962. */
  86963. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86964. /**
  86965. * Specifies if this material should be rendered in alpha test mode
  86966. * @returns a boolean specifying if an alpha test is needed.
  86967. */
  86968. needAlphaTesting(): boolean;
  86969. /**
  86970. * Gets the texture used for the alpha test
  86971. * @returns the texture to use for alpha testing
  86972. */
  86973. getAlphaTestTexture(): Nullable<BaseTexture>;
  86974. /**
  86975. * Marks the material to indicate that it needs to be re-calculated
  86976. */
  86977. markDirty(): void;
  86978. /** @hidden */
  86979. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86980. /**
  86981. * Binds the material to the mesh
  86982. * @param world defines the world transformation matrix
  86983. * @param mesh defines the mesh to bind the material to
  86984. */
  86985. bind(world: Matrix, mesh?: Mesh): void;
  86986. /**
  86987. * Binds the submesh to the material
  86988. * @param world defines the world transformation matrix
  86989. * @param mesh defines the mesh containing the submesh
  86990. * @param subMesh defines the submesh to bind the material to
  86991. */
  86992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86993. /**
  86994. * Binds the world matrix to the material
  86995. * @param world defines the world transformation matrix
  86996. */
  86997. bindOnlyWorldMatrix(world: Matrix): void;
  86998. /**
  86999. * Binds the scene's uniform buffer to the effect.
  87000. * @param effect defines the effect to bind to the scene uniform buffer
  87001. * @param sceneUbo defines the uniform buffer storing scene data
  87002. */
  87003. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87004. /**
  87005. * Binds the view matrix to the effect
  87006. * @param effect defines the effect to bind the view matrix to
  87007. */
  87008. bindView(effect: Effect): void;
  87009. /**
  87010. * Binds the view projection matrix to the effect
  87011. * @param effect defines the effect to bind the view projection matrix to
  87012. */
  87013. bindViewProjection(effect: Effect): void;
  87014. /**
  87015. * Specifies if material alpha testing should be turned on for the mesh
  87016. * @param mesh defines the mesh to check
  87017. */
  87018. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87019. /**
  87020. * Processes to execute after binding the material to a mesh
  87021. * @param mesh defines the rendered mesh
  87022. */
  87023. protected _afterBind(mesh?: Mesh): void;
  87024. /**
  87025. * Unbinds the material from the mesh
  87026. */
  87027. unbind(): void;
  87028. /**
  87029. * Gets the active textures from the material
  87030. * @returns an array of textures
  87031. */
  87032. getActiveTextures(): BaseTexture[];
  87033. /**
  87034. * Specifies if the material uses a texture
  87035. * @param texture defines the texture to check against the material
  87036. * @returns a boolean specifying if the material uses the texture
  87037. */
  87038. hasTexture(texture: BaseTexture): boolean;
  87039. /**
  87040. * Makes a duplicate of the material, and gives it a new name
  87041. * @param name defines the new name for the duplicated material
  87042. * @returns the cloned material
  87043. */
  87044. clone(name: string): Nullable<Material>;
  87045. /**
  87046. * Gets the meshes bound to the material
  87047. * @returns an array of meshes bound to the material
  87048. */
  87049. getBindedMeshes(): AbstractMesh[];
  87050. /**
  87051. * Force shader compilation
  87052. * @param mesh defines the mesh associated with this material
  87053. * @param onCompiled defines a function to execute once the material is compiled
  87054. * @param options defines the options to configure the compilation
  87055. */
  87056. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87057. clipPlane: boolean;
  87058. }>): void;
  87059. /**
  87060. * Force shader compilation
  87061. * @param mesh defines the mesh that will use this material
  87062. * @param options defines additional options for compiling the shaders
  87063. * @returns a promise that resolves when the compilation completes
  87064. */
  87065. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87066. clipPlane: boolean;
  87067. }>): Promise<void>;
  87068. private static readonly _AllDirtyCallBack;
  87069. private static readonly _ImageProcessingDirtyCallBack;
  87070. private static readonly _TextureDirtyCallBack;
  87071. private static readonly _FresnelDirtyCallBack;
  87072. private static readonly _MiscDirtyCallBack;
  87073. private static readonly _LightsDirtyCallBack;
  87074. private static readonly _AttributeDirtyCallBack;
  87075. private static _FresnelAndMiscDirtyCallBack;
  87076. private static _TextureAndMiscDirtyCallBack;
  87077. private static readonly _DirtyCallbackArray;
  87078. private static readonly _RunDirtyCallBacks;
  87079. /**
  87080. * Marks a define in the material to indicate that it needs to be re-computed
  87081. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87082. */
  87083. markAsDirty(flag: number): void;
  87084. /**
  87085. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87086. * @param func defines a function which checks material defines against the submeshes
  87087. */
  87088. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87089. /**
  87090. * Indicates that we need to re-calculated for all submeshes
  87091. */
  87092. protected _markAllSubMeshesAsAllDirty(): void;
  87093. /**
  87094. * Indicates that image processing needs to be re-calculated for all submeshes
  87095. */
  87096. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87097. /**
  87098. * Indicates that textures need to be re-calculated for all submeshes
  87099. */
  87100. protected _markAllSubMeshesAsTexturesDirty(): void;
  87101. /**
  87102. * Indicates that fresnel needs to be re-calculated for all submeshes
  87103. */
  87104. protected _markAllSubMeshesAsFresnelDirty(): void;
  87105. /**
  87106. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87107. */
  87108. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87109. /**
  87110. * Indicates that lights need to be re-calculated for all submeshes
  87111. */
  87112. protected _markAllSubMeshesAsLightsDirty(): void;
  87113. /**
  87114. * Indicates that attributes need to be re-calculated for all submeshes
  87115. */
  87116. protected _markAllSubMeshesAsAttributesDirty(): void;
  87117. /**
  87118. * Indicates that misc needs to be re-calculated for all submeshes
  87119. */
  87120. protected _markAllSubMeshesAsMiscDirty(): void;
  87121. /**
  87122. * Indicates that textures and misc need to be re-calculated for all submeshes
  87123. */
  87124. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87125. /**
  87126. * Disposes the material
  87127. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87128. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87129. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87130. */
  87131. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87132. /** @hidden */
  87133. private releaseVertexArrayObject;
  87134. /**
  87135. * Serializes this material
  87136. * @returns the serialized material object
  87137. */
  87138. serialize(): any;
  87139. /**
  87140. * Creates a material from parsed material data
  87141. * @param parsedMaterial defines parsed material data
  87142. * @param scene defines the hosting scene
  87143. * @param rootUrl defines the root URL to use to load textures
  87144. * @returns a new material
  87145. */
  87146. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87147. }
  87148. }
  87149. declare module BABYLON {
  87150. /**
  87151. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87152. * separate meshes. This can be use to improve performances.
  87153. * @see http://doc.babylonjs.com/how_to/multi_materials
  87154. */
  87155. export class MultiMaterial extends Material {
  87156. private _subMaterials;
  87157. /**
  87158. * Gets or Sets the list of Materials used within the multi material.
  87159. * They need to be ordered according to the submeshes order in the associated mesh
  87160. */
  87161. subMaterials: Nullable<Material>[];
  87162. /**
  87163. * Function used to align with Node.getChildren()
  87164. * @returns the list of Materials used within the multi material
  87165. */
  87166. getChildren(): Nullable<Material>[];
  87167. /**
  87168. * Instantiates a new Multi Material
  87169. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87170. * separate meshes. This can be use to improve performances.
  87171. * @see http://doc.babylonjs.com/how_to/multi_materials
  87172. * @param name Define the name in the scene
  87173. * @param scene Define the scene the material belongs to
  87174. */
  87175. constructor(name: string, scene: Scene);
  87176. private _hookArray;
  87177. /**
  87178. * Get one of the submaterial by its index in the submaterials array
  87179. * @param index The index to look the sub material at
  87180. * @returns The Material if the index has been defined
  87181. */
  87182. getSubMaterial(index: number): Nullable<Material>;
  87183. /**
  87184. * Get the list of active textures for the whole sub materials list.
  87185. * @returns All the textures that will be used during the rendering
  87186. */
  87187. getActiveTextures(): BaseTexture[];
  87188. /**
  87189. * Gets the current class name of the material e.g. "MultiMaterial"
  87190. * Mainly use in serialization.
  87191. * @returns the class name
  87192. */
  87193. getClassName(): string;
  87194. /**
  87195. * Checks if the material is ready to render the requested sub mesh
  87196. * @param mesh Define the mesh the submesh belongs to
  87197. * @param subMesh Define the sub mesh to look readyness for
  87198. * @param useInstances Define whether or not the material is used with instances
  87199. * @returns true if ready, otherwise false
  87200. */
  87201. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87202. /**
  87203. * Clones the current material and its related sub materials
  87204. * @param name Define the name of the newly cloned material
  87205. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87206. * @returns the cloned material
  87207. */
  87208. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87209. /**
  87210. * Serializes the materials into a JSON representation.
  87211. * @returns the JSON representation
  87212. */
  87213. serialize(): any;
  87214. /**
  87215. * Dispose the material and release its associated resources
  87216. * @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)
  87217. * @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)
  87218. * @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)
  87219. */
  87220. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87221. /**
  87222. * Creates a MultiMaterial from parsed MultiMaterial data.
  87223. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87224. * @param scene defines the hosting scene
  87225. * @returns a new MultiMaterial
  87226. */
  87227. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87228. }
  87229. }
  87230. declare module BABYLON {
  87231. /**
  87232. * Base class for submeshes
  87233. */
  87234. export class BaseSubMesh {
  87235. /** @hidden */
  87236. _materialDefines: Nullable<MaterialDefines>;
  87237. /** @hidden */
  87238. _materialEffect: Nullable<Effect>;
  87239. /**
  87240. * Gets associated effect
  87241. */
  87242. readonly effect: Nullable<Effect>;
  87243. /**
  87244. * Sets associated effect (effect used to render this submesh)
  87245. * @param effect defines the effect to associate with
  87246. * @param defines defines the set of defines used to compile this effect
  87247. */
  87248. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87249. }
  87250. /**
  87251. * Defines a subdivision inside a mesh
  87252. */
  87253. export class SubMesh extends BaseSubMesh implements ICullable {
  87254. /** the material index to use */
  87255. materialIndex: number;
  87256. /** vertex index start */
  87257. verticesStart: number;
  87258. /** vertices count */
  87259. verticesCount: number;
  87260. /** index start */
  87261. indexStart: number;
  87262. /** indices count */
  87263. indexCount: number;
  87264. /** @hidden */
  87265. _linesIndexCount: number;
  87266. private _mesh;
  87267. private _renderingMesh;
  87268. private _boundingInfo;
  87269. private _linesIndexBuffer;
  87270. /** @hidden */
  87271. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87272. /** @hidden */
  87273. _trianglePlanes: Plane[];
  87274. /** @hidden */
  87275. _lastColliderTransformMatrix: Nullable<Matrix>;
  87276. /** @hidden */
  87277. _renderId: number;
  87278. /** @hidden */
  87279. _alphaIndex: number;
  87280. /** @hidden */
  87281. _distanceToCamera: number;
  87282. /** @hidden */
  87283. _id: number;
  87284. private _currentMaterial;
  87285. /**
  87286. * Add a new submesh to a mesh
  87287. * @param materialIndex defines the material index to use
  87288. * @param verticesStart defines vertex index start
  87289. * @param verticesCount defines vertices count
  87290. * @param indexStart defines index start
  87291. * @param indexCount defines indices count
  87292. * @param mesh defines the parent mesh
  87293. * @param renderingMesh defines an optional rendering mesh
  87294. * @param createBoundingBox defines if bounding box should be created for this submesh
  87295. * @returns the new submesh
  87296. */
  87297. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87298. /**
  87299. * Creates a new submesh
  87300. * @param materialIndex defines the material index to use
  87301. * @param verticesStart defines vertex index start
  87302. * @param verticesCount defines vertices count
  87303. * @param indexStart defines index start
  87304. * @param indexCount defines indices count
  87305. * @param mesh defines the parent mesh
  87306. * @param renderingMesh defines an optional rendering mesh
  87307. * @param createBoundingBox defines if bounding box should be created for this submesh
  87308. */
  87309. constructor(
  87310. /** the material index to use */
  87311. materialIndex: number,
  87312. /** vertex index start */
  87313. verticesStart: number,
  87314. /** vertices count */
  87315. verticesCount: number,
  87316. /** index start */
  87317. indexStart: number,
  87318. /** indices count */
  87319. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87320. /**
  87321. * Returns true if this submesh covers the entire parent mesh
  87322. * @ignorenaming
  87323. */
  87324. readonly IsGlobal: boolean;
  87325. /**
  87326. * Returns the submesh BoudingInfo object
  87327. * @returns current bounding info (or mesh's one if the submesh is global)
  87328. */
  87329. getBoundingInfo(): BoundingInfo;
  87330. /**
  87331. * Sets the submesh BoundingInfo
  87332. * @param boundingInfo defines the new bounding info to use
  87333. * @returns the SubMesh
  87334. */
  87335. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87336. /**
  87337. * Returns the mesh of the current submesh
  87338. * @return the parent mesh
  87339. */
  87340. getMesh(): AbstractMesh;
  87341. /**
  87342. * Returns the rendering mesh of the submesh
  87343. * @returns the rendering mesh (could be different from parent mesh)
  87344. */
  87345. getRenderingMesh(): Mesh;
  87346. /**
  87347. * Returns the submesh material
  87348. * @returns null or the current material
  87349. */
  87350. getMaterial(): Nullable<Material>;
  87351. /**
  87352. * Sets a new updated BoundingInfo object to the submesh
  87353. * @param data defines an optional position array to use to determine the bounding info
  87354. * @returns the SubMesh
  87355. */
  87356. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87357. /** @hidden */
  87358. _checkCollision(collider: Collider): boolean;
  87359. /**
  87360. * Updates the submesh BoundingInfo
  87361. * @param world defines the world matrix to use to update the bounding info
  87362. * @returns the submesh
  87363. */
  87364. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87365. /**
  87366. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87367. * @param frustumPlanes defines the frustum planes
  87368. * @returns true if the submesh is intersecting with the frustum
  87369. */
  87370. isInFrustum(frustumPlanes: Plane[]): boolean;
  87371. /**
  87372. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87373. * @param frustumPlanes defines the frustum planes
  87374. * @returns true if the submesh is inside the frustum
  87375. */
  87376. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87377. /**
  87378. * Renders the submesh
  87379. * @param enableAlphaMode defines if alpha needs to be used
  87380. * @returns the submesh
  87381. */
  87382. render(enableAlphaMode: boolean): SubMesh;
  87383. /**
  87384. * @hidden
  87385. */
  87386. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87387. /**
  87388. * Checks if the submesh intersects with a ray
  87389. * @param ray defines the ray to test
  87390. * @returns true is the passed ray intersects the submesh bounding box
  87391. */
  87392. canIntersects(ray: Ray): boolean;
  87393. /**
  87394. * Intersects current submesh with a ray
  87395. * @param ray defines the ray to test
  87396. * @param positions defines mesh's positions array
  87397. * @param indices defines mesh's indices array
  87398. * @param fastCheck defines if only bounding info should be used
  87399. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87400. * @returns intersection info or null if no intersection
  87401. */
  87402. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87403. /** @hidden */
  87404. private _intersectLines;
  87405. /** @hidden */
  87406. private _intersectUnIndexedLines;
  87407. /** @hidden */
  87408. private _intersectTriangles;
  87409. /** @hidden */
  87410. private _intersectUnIndexedTriangles;
  87411. /** @hidden */
  87412. _rebuild(): void;
  87413. /**
  87414. * Creates a new submesh from the passed mesh
  87415. * @param newMesh defines the new hosting mesh
  87416. * @param newRenderingMesh defines an optional rendering mesh
  87417. * @returns the new submesh
  87418. */
  87419. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87420. /**
  87421. * Release associated resources
  87422. */
  87423. dispose(): void;
  87424. /**
  87425. * Gets the class name
  87426. * @returns the string "SubMesh".
  87427. */
  87428. getClassName(): string;
  87429. /**
  87430. * Creates a new submesh from indices data
  87431. * @param materialIndex the index of the main mesh material
  87432. * @param startIndex the index where to start the copy in the mesh indices array
  87433. * @param indexCount the number of indices to copy then from the startIndex
  87434. * @param mesh the main mesh to create the submesh from
  87435. * @param renderingMesh the optional rendering mesh
  87436. * @returns a new submesh
  87437. */
  87438. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87439. }
  87440. }
  87441. declare module BABYLON {
  87442. /**
  87443. * Class used to represent data loading progression
  87444. */
  87445. export class SceneLoaderFlags {
  87446. private static _ForceFullSceneLoadingForIncremental;
  87447. private static _ShowLoadingScreen;
  87448. private static _CleanBoneMatrixWeights;
  87449. private static _loggingLevel;
  87450. /**
  87451. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87452. */
  87453. static ForceFullSceneLoadingForIncremental: boolean;
  87454. /**
  87455. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87456. */
  87457. static ShowLoadingScreen: boolean;
  87458. /**
  87459. * Defines the current logging level (while loading the scene)
  87460. * @ignorenaming
  87461. */
  87462. static loggingLevel: number;
  87463. /**
  87464. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87465. */
  87466. static CleanBoneMatrixWeights: boolean;
  87467. }
  87468. }
  87469. declare module BABYLON {
  87470. /**
  87471. * Class used to store geometry data (vertex buffers + index buffer)
  87472. */
  87473. export class Geometry implements IGetSetVerticesData {
  87474. /**
  87475. * Gets or sets the ID of the geometry
  87476. */
  87477. id: string;
  87478. /**
  87479. * Gets or sets the unique ID of the geometry
  87480. */
  87481. uniqueId: number;
  87482. /**
  87483. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87484. */
  87485. delayLoadState: number;
  87486. /**
  87487. * Gets the file containing the data to load when running in delay load state
  87488. */
  87489. delayLoadingFile: Nullable<string>;
  87490. /**
  87491. * Callback called when the geometry is updated
  87492. */
  87493. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87494. private _scene;
  87495. private _engine;
  87496. private _meshes;
  87497. private _totalVertices;
  87498. /** @hidden */
  87499. _indices: IndicesArray;
  87500. /** @hidden */
  87501. _vertexBuffers: {
  87502. [key: string]: VertexBuffer;
  87503. };
  87504. private _isDisposed;
  87505. private _extend;
  87506. private _boundingBias;
  87507. /** @hidden */
  87508. _delayInfo: Array<string>;
  87509. private _indexBuffer;
  87510. private _indexBufferIsUpdatable;
  87511. /** @hidden */
  87512. _boundingInfo: Nullable<BoundingInfo>;
  87513. /** @hidden */
  87514. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87515. /** @hidden */
  87516. _softwareSkinningFrameId: number;
  87517. private _vertexArrayObjects;
  87518. private _updatable;
  87519. /** @hidden */
  87520. _positions: Nullable<Vector3[]>;
  87521. /**
  87522. * 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
  87523. */
  87524. /**
  87525. * 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
  87526. */
  87527. boundingBias: Vector2;
  87528. /**
  87529. * Static function used to attach a new empty geometry to a mesh
  87530. * @param mesh defines the mesh to attach the geometry to
  87531. * @returns the new Geometry
  87532. */
  87533. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87534. /**
  87535. * Creates a new geometry
  87536. * @param id defines the unique ID
  87537. * @param scene defines the hosting scene
  87538. * @param vertexData defines the VertexData used to get geometry data
  87539. * @param updatable defines if geometry must be updatable (false by default)
  87540. * @param mesh defines the mesh that will be associated with the geometry
  87541. */
  87542. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87543. /**
  87544. * Gets the current extend of the geometry
  87545. */
  87546. readonly extend: {
  87547. minimum: Vector3;
  87548. maximum: Vector3;
  87549. };
  87550. /**
  87551. * Gets the hosting scene
  87552. * @returns the hosting Scene
  87553. */
  87554. getScene(): Scene;
  87555. /**
  87556. * Gets the hosting engine
  87557. * @returns the hosting Engine
  87558. */
  87559. getEngine(): Engine;
  87560. /**
  87561. * Defines if the geometry is ready to use
  87562. * @returns true if the geometry is ready to be used
  87563. */
  87564. isReady(): boolean;
  87565. /**
  87566. * Gets a value indicating that the geometry should not be serialized
  87567. */
  87568. readonly doNotSerialize: boolean;
  87569. /** @hidden */
  87570. _rebuild(): void;
  87571. /**
  87572. * Affects all geometry data in one call
  87573. * @param vertexData defines the geometry data
  87574. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87575. */
  87576. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87577. /**
  87578. * Set specific vertex data
  87579. * @param kind defines the data kind (Position, normal, etc...)
  87580. * @param data defines the vertex data to use
  87581. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87582. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87583. */
  87584. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87585. /**
  87586. * Removes a specific vertex data
  87587. * @param kind defines the data kind (Position, normal, etc...)
  87588. */
  87589. removeVerticesData(kind: string): void;
  87590. /**
  87591. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87592. * @param buffer defines the vertex buffer to use
  87593. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87594. */
  87595. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87596. /**
  87597. * Update a specific vertex buffer
  87598. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87599. * It will do nothing if the buffer is not updatable
  87600. * @param kind defines the data kind (Position, normal, etc...)
  87601. * @param data defines the data to use
  87602. * @param offset defines the offset in the target buffer where to store the data
  87603. * @param useBytes set to true if the offset is in bytes
  87604. */
  87605. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87606. /**
  87607. * Update a specific vertex buffer
  87608. * This function will create a new buffer if the current one is not updatable
  87609. * @param kind defines the data kind (Position, normal, etc...)
  87610. * @param data defines the data to use
  87611. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87612. */
  87613. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87614. private _updateBoundingInfo;
  87615. /** @hidden */
  87616. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87617. /**
  87618. * Gets total number of vertices
  87619. * @returns the total number of vertices
  87620. */
  87621. getTotalVertices(): number;
  87622. /**
  87623. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87624. * @param kind defines the data kind (Position, normal, etc...)
  87625. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87626. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87627. * @returns a float array containing vertex data
  87628. */
  87629. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87630. /**
  87631. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87632. * @param kind defines the data kind (Position, normal, etc...)
  87633. * @returns true if the vertex buffer with the specified kind is updatable
  87634. */
  87635. isVertexBufferUpdatable(kind: string): boolean;
  87636. /**
  87637. * Gets a specific vertex buffer
  87638. * @param kind defines the data kind (Position, normal, etc...)
  87639. * @returns a VertexBuffer
  87640. */
  87641. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87642. /**
  87643. * Returns all vertex buffers
  87644. * @return an object holding all vertex buffers indexed by kind
  87645. */
  87646. getVertexBuffers(): Nullable<{
  87647. [key: string]: VertexBuffer;
  87648. }>;
  87649. /**
  87650. * Gets a boolean indicating if specific vertex buffer is present
  87651. * @param kind defines the data kind (Position, normal, etc...)
  87652. * @returns true if data is present
  87653. */
  87654. isVerticesDataPresent(kind: string): boolean;
  87655. /**
  87656. * Gets a list of all attached data kinds (Position, normal, etc...)
  87657. * @returns a list of string containing all kinds
  87658. */
  87659. getVerticesDataKinds(): string[];
  87660. /**
  87661. * Update index buffer
  87662. * @param indices defines the indices to store in the index buffer
  87663. * @param offset defines the offset in the target buffer where to store the data
  87664. * @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)
  87665. */
  87666. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87667. /**
  87668. * Creates a new index buffer
  87669. * @param indices defines the indices to store in the index buffer
  87670. * @param totalVertices defines the total number of vertices (could be null)
  87671. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87672. */
  87673. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87674. /**
  87675. * Return the total number of indices
  87676. * @returns the total number of indices
  87677. */
  87678. getTotalIndices(): number;
  87679. /**
  87680. * Gets the index buffer array
  87681. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87682. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87683. * @returns the index buffer array
  87684. */
  87685. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87686. /**
  87687. * Gets the index buffer
  87688. * @return the index buffer
  87689. */
  87690. getIndexBuffer(): Nullable<DataBuffer>;
  87691. /** @hidden */
  87692. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87693. /**
  87694. * Release the associated resources for a specific mesh
  87695. * @param mesh defines the source mesh
  87696. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87697. */
  87698. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  87699. /**
  87700. * Apply current geometry to a given mesh
  87701. * @param mesh defines the mesh to apply geometry to
  87702. */
  87703. applyToMesh(mesh: Mesh): void;
  87704. private _updateExtend;
  87705. private _applyToMesh;
  87706. private notifyUpdate;
  87707. /**
  87708. * Load the geometry if it was flagged as delay loaded
  87709. * @param scene defines the hosting scene
  87710. * @param onLoaded defines a callback called when the geometry is loaded
  87711. */
  87712. load(scene: Scene, onLoaded?: () => void): void;
  87713. private _queueLoad;
  87714. /**
  87715. * Invert the geometry to move from a right handed system to a left handed one.
  87716. */
  87717. toLeftHanded(): void;
  87718. /** @hidden */
  87719. _resetPointsArrayCache(): void;
  87720. /** @hidden */
  87721. _generatePointsArray(): boolean;
  87722. /**
  87723. * Gets a value indicating if the geometry is disposed
  87724. * @returns true if the geometry was disposed
  87725. */
  87726. isDisposed(): boolean;
  87727. private _disposeVertexArrayObjects;
  87728. /**
  87729. * Free all associated resources
  87730. */
  87731. dispose(): void;
  87732. /**
  87733. * Clone the current geometry into a new geometry
  87734. * @param id defines the unique ID of the new geometry
  87735. * @returns a new geometry object
  87736. */
  87737. copy(id: string): Geometry;
  87738. /**
  87739. * Serialize the current geometry info (and not the vertices data) into a JSON object
  87740. * @return a JSON representation of the current geometry data (without the vertices data)
  87741. */
  87742. serialize(): any;
  87743. private toNumberArray;
  87744. /**
  87745. * Serialize all vertices data into a JSON oject
  87746. * @returns a JSON representation of the current geometry data
  87747. */
  87748. serializeVerticeData(): any;
  87749. /**
  87750. * Extracts a clone of a mesh geometry
  87751. * @param mesh defines the source mesh
  87752. * @param id defines the unique ID of the new geometry object
  87753. * @returns the new geometry object
  87754. */
  87755. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  87756. /**
  87757. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87758. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87759. * Be aware Math.random() could cause collisions, but:
  87760. * "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"
  87761. * @returns a string containing a new GUID
  87762. */
  87763. static RandomId(): string;
  87764. /** @hidden */
  87765. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87766. private static _CleanMatricesWeights;
  87767. /**
  87768. * Create a new geometry from persisted data (Using .babylon file format)
  87769. * @param parsedVertexData defines the persisted data
  87770. * @param scene defines the hosting scene
  87771. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87772. * @returns the new geometry object
  87773. */
  87774. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87775. }
  87776. }
  87777. declare module BABYLON {
  87778. /**
  87779. * Define an interface for all classes that will get and set the data on vertices
  87780. */
  87781. export interface IGetSetVerticesData {
  87782. /**
  87783. * Gets a boolean indicating if specific vertex data is present
  87784. * @param kind defines the vertex data kind to use
  87785. * @returns true is data kind is present
  87786. */
  87787. isVerticesDataPresent(kind: string): boolean;
  87788. /**
  87789. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87790. * @param kind defines the data kind (Position, normal, etc...)
  87791. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87792. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87793. * @returns a float array containing vertex data
  87794. */
  87795. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87796. /**
  87797. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87798. * @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.
  87799. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87800. * @returns the indices array or an empty array if the mesh has no geometry
  87801. */
  87802. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87803. /**
  87804. * Set specific vertex data
  87805. * @param kind defines the data kind (Position, normal, etc...)
  87806. * @param data defines the vertex data to use
  87807. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87808. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87809. */
  87810. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87811. /**
  87812. * Update a specific associated vertex buffer
  87813. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87814. * - VertexBuffer.PositionKind
  87815. * - VertexBuffer.UVKind
  87816. * - VertexBuffer.UV2Kind
  87817. * - VertexBuffer.UV3Kind
  87818. * - VertexBuffer.UV4Kind
  87819. * - VertexBuffer.UV5Kind
  87820. * - VertexBuffer.UV6Kind
  87821. * - VertexBuffer.ColorKind
  87822. * - VertexBuffer.MatricesIndicesKind
  87823. * - VertexBuffer.MatricesIndicesExtraKind
  87824. * - VertexBuffer.MatricesWeightsKind
  87825. * - VertexBuffer.MatricesWeightsExtraKind
  87826. * @param data defines the data source
  87827. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87828. * @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)
  87829. */
  87830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87831. /**
  87832. * Creates a new index buffer
  87833. * @param indices defines the indices to store in the index buffer
  87834. * @param totalVertices defines the total number of vertices (could be null)
  87835. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87836. */
  87837. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87838. }
  87839. /**
  87840. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87841. */
  87842. export class VertexData {
  87843. /**
  87844. * Mesh side orientation : usually the external or front surface
  87845. */
  87846. static readonly FRONTSIDE: number;
  87847. /**
  87848. * Mesh side orientation : usually the internal or back surface
  87849. */
  87850. static readonly BACKSIDE: number;
  87851. /**
  87852. * Mesh side orientation : both internal and external or front and back surfaces
  87853. */
  87854. static readonly DOUBLESIDE: number;
  87855. /**
  87856. * Mesh side orientation : by default, `FRONTSIDE`
  87857. */
  87858. static readonly DEFAULTSIDE: number;
  87859. /**
  87860. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87861. */
  87862. positions: Nullable<FloatArray>;
  87863. /**
  87864. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87865. */
  87866. normals: Nullable<FloatArray>;
  87867. /**
  87868. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87869. */
  87870. tangents: Nullable<FloatArray>;
  87871. /**
  87872. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87873. */
  87874. uvs: Nullable<FloatArray>;
  87875. /**
  87876. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87877. */
  87878. uvs2: Nullable<FloatArray>;
  87879. /**
  87880. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87881. */
  87882. uvs3: Nullable<FloatArray>;
  87883. /**
  87884. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87885. */
  87886. uvs4: Nullable<FloatArray>;
  87887. /**
  87888. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87889. */
  87890. uvs5: Nullable<FloatArray>;
  87891. /**
  87892. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87893. */
  87894. uvs6: Nullable<FloatArray>;
  87895. /**
  87896. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87897. */
  87898. colors: Nullable<FloatArray>;
  87899. /**
  87900. * 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).
  87901. */
  87902. matricesIndices: Nullable<FloatArray>;
  87903. /**
  87904. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87905. */
  87906. matricesWeights: Nullable<FloatArray>;
  87907. /**
  87908. * An array extending the number of possible indices
  87909. */
  87910. matricesIndicesExtra: Nullable<FloatArray>;
  87911. /**
  87912. * An array extending the number of possible weights when the number of indices is extended
  87913. */
  87914. matricesWeightsExtra: Nullable<FloatArray>;
  87915. /**
  87916. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87917. */
  87918. indices: Nullable<IndicesArray>;
  87919. /**
  87920. * Uses the passed data array to set the set the values for the specified kind of data
  87921. * @param data a linear array of floating numbers
  87922. * @param kind the type of data that is being set, eg positions, colors etc
  87923. */
  87924. set(data: FloatArray, kind: string): void;
  87925. /**
  87926. * Associates the vertexData to the passed Mesh.
  87927. * Sets it as updatable or not (default `false`)
  87928. * @param mesh the mesh the vertexData is applied to
  87929. * @param updatable when used and having the value true allows new data to update the vertexData
  87930. * @returns the VertexData
  87931. */
  87932. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87933. /**
  87934. * Associates the vertexData to the passed Geometry.
  87935. * Sets it as updatable or not (default `false`)
  87936. * @param geometry the geometry the vertexData is applied to
  87937. * @param updatable when used and having the value true allows new data to update the vertexData
  87938. * @returns VertexData
  87939. */
  87940. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87941. /**
  87942. * Updates the associated mesh
  87943. * @param mesh the mesh to be updated
  87944. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87945. * @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
  87946. * @returns VertexData
  87947. */
  87948. updateMesh(mesh: Mesh): VertexData;
  87949. /**
  87950. * Updates the associated geometry
  87951. * @param geometry the geometry to be updated
  87952. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87953. * @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
  87954. * @returns VertexData.
  87955. */
  87956. updateGeometry(geometry: Geometry): VertexData;
  87957. private _applyTo;
  87958. private _update;
  87959. /**
  87960. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87961. * @param matrix the transforming matrix
  87962. * @returns the VertexData
  87963. */
  87964. transform(matrix: Matrix): VertexData;
  87965. /**
  87966. * Merges the passed VertexData into the current one
  87967. * @param other the VertexData to be merged into the current one
  87968. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87969. * @returns the modified VertexData
  87970. */
  87971. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87972. private _mergeElement;
  87973. private _validate;
  87974. /**
  87975. * Serializes the VertexData
  87976. * @returns a serialized object
  87977. */
  87978. serialize(): any;
  87979. /**
  87980. * Extracts the vertexData from a mesh
  87981. * @param mesh the mesh from which to extract the VertexData
  87982. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87983. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87984. * @returns the object VertexData associated to the passed mesh
  87985. */
  87986. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87987. /**
  87988. * Extracts the vertexData from the geometry
  87989. * @param geometry the geometry from which to extract the VertexData
  87990. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87991. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87992. * @returns the object VertexData associated to the passed mesh
  87993. */
  87994. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87995. private static _ExtractFrom;
  87996. /**
  87997. * Creates the VertexData for a Ribbon
  87998. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87999. * * pathArray array of paths, each of which an array of successive Vector3
  88000. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88001. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88002. * * 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
  88003. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88004. * * 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)
  88005. * * 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)
  88006. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88007. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88008. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88009. * @returns the VertexData of the ribbon
  88010. */
  88011. static CreateRibbon(options: {
  88012. pathArray: Vector3[][];
  88013. closeArray?: boolean;
  88014. closePath?: boolean;
  88015. offset?: number;
  88016. sideOrientation?: number;
  88017. frontUVs?: Vector4;
  88018. backUVs?: Vector4;
  88019. invertUV?: boolean;
  88020. uvs?: Vector2[];
  88021. colors?: Color4[];
  88022. }): VertexData;
  88023. /**
  88024. * Creates the VertexData for a box
  88025. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88026. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88027. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88028. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88029. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88030. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88031. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88033. * * 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)
  88034. * * 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)
  88035. * @returns the VertexData of the box
  88036. */
  88037. static CreateBox(options: {
  88038. size?: number;
  88039. width?: number;
  88040. height?: number;
  88041. depth?: number;
  88042. faceUV?: Vector4[];
  88043. faceColors?: Color4[];
  88044. sideOrientation?: number;
  88045. frontUVs?: Vector4;
  88046. backUVs?: Vector4;
  88047. }): VertexData;
  88048. /**
  88049. * Creates the VertexData for a tiled box
  88050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88051. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88052. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88053. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88055. * @returns the VertexData of the box
  88056. */
  88057. static CreateTiledBox(options: {
  88058. pattern?: number;
  88059. width?: number;
  88060. height?: number;
  88061. depth?: number;
  88062. tileSize?: number;
  88063. tileWidth?: number;
  88064. tileHeight?: number;
  88065. alignHorizontal?: number;
  88066. alignVertical?: number;
  88067. faceUV?: Vector4[];
  88068. faceColors?: Color4[];
  88069. sideOrientation?: number;
  88070. }): VertexData;
  88071. /**
  88072. * Creates the VertexData for a tiled plane
  88073. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88074. * * pattern a limited pattern arrangement depending on the number
  88075. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88076. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88077. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88079. * * 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)
  88080. * * 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)
  88081. * @returns the VertexData of the tiled plane
  88082. */
  88083. static CreateTiledPlane(options: {
  88084. pattern?: number;
  88085. tileSize?: number;
  88086. tileWidth?: number;
  88087. tileHeight?: number;
  88088. size?: number;
  88089. width?: number;
  88090. height?: number;
  88091. alignHorizontal?: number;
  88092. alignVertical?: number;
  88093. sideOrientation?: number;
  88094. frontUVs?: Vector4;
  88095. backUVs?: Vector4;
  88096. }): VertexData;
  88097. /**
  88098. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88100. * * segments sets the number of horizontal strips optional, default 32
  88101. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88102. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88103. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88104. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88105. * * 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
  88106. * * 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
  88107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88108. * * 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)
  88109. * * 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)
  88110. * @returns the VertexData of the ellipsoid
  88111. */
  88112. static CreateSphere(options: {
  88113. segments?: number;
  88114. diameter?: number;
  88115. diameterX?: number;
  88116. diameterY?: number;
  88117. diameterZ?: number;
  88118. arc?: number;
  88119. slice?: number;
  88120. sideOrientation?: number;
  88121. frontUVs?: Vector4;
  88122. backUVs?: Vector4;
  88123. }): VertexData;
  88124. /**
  88125. * Creates the VertexData for a cylinder, cone or prism
  88126. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88127. * * height sets the height (y direction) of the cylinder, optional, default 2
  88128. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88129. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88130. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88131. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88132. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88133. * * 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
  88134. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88135. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88136. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88137. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88139. * * 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)
  88140. * * 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)
  88141. * @returns the VertexData of the cylinder, cone or prism
  88142. */
  88143. static CreateCylinder(options: {
  88144. height?: number;
  88145. diameterTop?: number;
  88146. diameterBottom?: number;
  88147. diameter?: number;
  88148. tessellation?: number;
  88149. subdivisions?: number;
  88150. arc?: number;
  88151. faceColors?: Color4[];
  88152. faceUV?: Vector4[];
  88153. hasRings?: boolean;
  88154. enclose?: boolean;
  88155. sideOrientation?: number;
  88156. frontUVs?: Vector4;
  88157. backUVs?: Vector4;
  88158. }): VertexData;
  88159. /**
  88160. * Creates the VertexData for a torus
  88161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88162. * * diameter the diameter of the torus, optional default 1
  88163. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88164. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88166. * * 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)
  88167. * * 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)
  88168. * @returns the VertexData of the torus
  88169. */
  88170. static CreateTorus(options: {
  88171. diameter?: number;
  88172. thickness?: number;
  88173. tessellation?: number;
  88174. sideOrientation?: number;
  88175. frontUVs?: Vector4;
  88176. backUVs?: Vector4;
  88177. }): VertexData;
  88178. /**
  88179. * Creates the VertexData of the LineSystem
  88180. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88181. * - lines an array of lines, each line being an array of successive Vector3
  88182. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88183. * @returns the VertexData of the LineSystem
  88184. */
  88185. static CreateLineSystem(options: {
  88186. lines: Vector3[][];
  88187. colors?: Nullable<Color4[][]>;
  88188. }): VertexData;
  88189. /**
  88190. * Create the VertexData for a DashedLines
  88191. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88192. * - points an array successive Vector3
  88193. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88194. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88195. * - dashNb the intended total number of dashes, optional, default 200
  88196. * @returns the VertexData for the DashedLines
  88197. */
  88198. static CreateDashedLines(options: {
  88199. points: Vector3[];
  88200. dashSize?: number;
  88201. gapSize?: number;
  88202. dashNb?: number;
  88203. }): VertexData;
  88204. /**
  88205. * Creates the VertexData for a Ground
  88206. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88207. * - width the width (x direction) of the ground, optional, default 1
  88208. * - height the height (z direction) of the ground, optional, default 1
  88209. * - subdivisions the number of subdivisions per side, optional, default 1
  88210. * @returns the VertexData of the Ground
  88211. */
  88212. static CreateGround(options: {
  88213. width?: number;
  88214. height?: number;
  88215. subdivisions?: number;
  88216. subdivisionsX?: number;
  88217. subdivisionsY?: number;
  88218. }): VertexData;
  88219. /**
  88220. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88221. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88222. * * xmin the ground minimum X coordinate, optional, default -1
  88223. * * zmin the ground minimum Z coordinate, optional, default -1
  88224. * * xmax the ground maximum X coordinate, optional, default 1
  88225. * * zmax the ground maximum Z coordinate, optional, default 1
  88226. * * 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}
  88227. * * 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}
  88228. * @returns the VertexData of the TiledGround
  88229. */
  88230. static CreateTiledGround(options: {
  88231. xmin: number;
  88232. zmin: number;
  88233. xmax: number;
  88234. zmax: number;
  88235. subdivisions?: {
  88236. w: number;
  88237. h: number;
  88238. };
  88239. precision?: {
  88240. w: number;
  88241. h: number;
  88242. };
  88243. }): VertexData;
  88244. /**
  88245. * Creates the VertexData of the Ground designed from a heightmap
  88246. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88247. * * width the width (x direction) of the ground
  88248. * * height the height (z direction) of the ground
  88249. * * subdivisions the number of subdivisions per side
  88250. * * minHeight the minimum altitude on the ground, optional, default 0
  88251. * * maxHeight the maximum altitude on the ground, optional default 1
  88252. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88253. * * buffer the array holding the image color data
  88254. * * bufferWidth the width of image
  88255. * * bufferHeight the height of image
  88256. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88257. * @returns the VertexData of the Ground designed from a heightmap
  88258. */
  88259. static CreateGroundFromHeightMap(options: {
  88260. width: number;
  88261. height: number;
  88262. subdivisions: number;
  88263. minHeight: number;
  88264. maxHeight: number;
  88265. colorFilter: Color3;
  88266. buffer: Uint8Array;
  88267. bufferWidth: number;
  88268. bufferHeight: number;
  88269. alphaFilter: number;
  88270. }): VertexData;
  88271. /**
  88272. * Creates the VertexData for a Plane
  88273. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88274. * * size sets the width and height of the plane to the value of size, optional default 1
  88275. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88276. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88278. * * 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)
  88279. * * 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)
  88280. * @returns the VertexData of the box
  88281. */
  88282. static CreatePlane(options: {
  88283. size?: number;
  88284. width?: number;
  88285. height?: number;
  88286. sideOrientation?: number;
  88287. frontUVs?: Vector4;
  88288. backUVs?: Vector4;
  88289. }): VertexData;
  88290. /**
  88291. * Creates the VertexData of the Disc or regular Polygon
  88292. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88293. * * radius the radius of the disc, optional default 0.5
  88294. * * tessellation the number of polygon sides, optional, default 64
  88295. * * 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
  88296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88297. * * 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)
  88298. * * 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)
  88299. * @returns the VertexData of the box
  88300. */
  88301. static CreateDisc(options: {
  88302. radius?: number;
  88303. tessellation?: number;
  88304. arc?: number;
  88305. sideOrientation?: number;
  88306. frontUVs?: Vector4;
  88307. backUVs?: Vector4;
  88308. }): VertexData;
  88309. /**
  88310. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88311. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88312. * @param polygon a mesh built from polygonTriangulation.build()
  88313. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88314. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88315. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88316. * @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)
  88317. * @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)
  88318. * @returns the VertexData of the Polygon
  88319. */
  88320. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88321. /**
  88322. * Creates the VertexData of the IcoSphere
  88323. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88324. * * radius the radius of the IcoSphere, optional default 1
  88325. * * radiusX allows stretching in the x direction, optional, default radius
  88326. * * radiusY allows stretching in the y direction, optional, default radius
  88327. * * radiusZ allows stretching in the z direction, optional, default radius
  88328. * * flat when true creates a flat shaded mesh, optional, default true
  88329. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88331. * * 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)
  88332. * * 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)
  88333. * @returns the VertexData of the IcoSphere
  88334. */
  88335. static CreateIcoSphere(options: {
  88336. radius?: number;
  88337. radiusX?: number;
  88338. radiusY?: number;
  88339. radiusZ?: number;
  88340. flat?: boolean;
  88341. subdivisions?: number;
  88342. sideOrientation?: number;
  88343. frontUVs?: Vector4;
  88344. backUVs?: Vector4;
  88345. }): VertexData;
  88346. /**
  88347. * Creates the VertexData for a Polyhedron
  88348. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88349. * * type provided types are:
  88350. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88351. * * 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)
  88352. * * size the size of the IcoSphere, optional default 1
  88353. * * sizeX allows stretching in the x direction, optional, default size
  88354. * * sizeY allows stretching in the y direction, optional, default size
  88355. * * sizeZ allows stretching in the z direction, optional, default size
  88356. * * 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
  88357. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88358. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88359. * * flat when true creates a flat shaded mesh, optional, default true
  88360. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88362. * * 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)
  88363. * * 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)
  88364. * @returns the VertexData of the Polyhedron
  88365. */
  88366. static CreatePolyhedron(options: {
  88367. type?: number;
  88368. size?: number;
  88369. sizeX?: number;
  88370. sizeY?: number;
  88371. sizeZ?: number;
  88372. custom?: any;
  88373. faceUV?: Vector4[];
  88374. faceColors?: Color4[];
  88375. flat?: boolean;
  88376. sideOrientation?: number;
  88377. frontUVs?: Vector4;
  88378. backUVs?: Vector4;
  88379. }): VertexData;
  88380. /**
  88381. * Creates the VertexData for a TorusKnot
  88382. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88383. * * radius the radius of the torus knot, optional, default 2
  88384. * * tube the thickness of the tube, optional, default 0.5
  88385. * * radialSegments the number of sides on each tube segments, optional, default 32
  88386. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88387. * * p the number of windings around the z axis, optional, default 2
  88388. * * q the number of windings around the x axis, optional, default 3
  88389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88390. * * 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)
  88391. * * 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)
  88392. * @returns the VertexData of the Torus Knot
  88393. */
  88394. static CreateTorusKnot(options: {
  88395. radius?: number;
  88396. tube?: number;
  88397. radialSegments?: number;
  88398. tubularSegments?: number;
  88399. p?: number;
  88400. q?: number;
  88401. sideOrientation?: number;
  88402. frontUVs?: Vector4;
  88403. backUVs?: Vector4;
  88404. }): VertexData;
  88405. /**
  88406. * Compute normals for given positions and indices
  88407. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88408. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88409. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88410. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88411. * * facetNormals : optional array of facet normals (vector3)
  88412. * * facetPositions : optional array of facet positions (vector3)
  88413. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88414. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88415. * * bInfo : optional bounding info, required for facetPartitioning computation
  88416. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88417. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88418. * * useRightHandedSystem: optional boolean to for right handed system computation
  88419. * * depthSort : optional boolean to enable the facet depth sort computation
  88420. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88421. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88422. */
  88423. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88424. facetNormals?: any;
  88425. facetPositions?: any;
  88426. facetPartitioning?: any;
  88427. ratio?: number;
  88428. bInfo?: any;
  88429. bbSize?: Vector3;
  88430. subDiv?: any;
  88431. useRightHandedSystem?: boolean;
  88432. depthSort?: boolean;
  88433. distanceTo?: Vector3;
  88434. depthSortedFacets?: any;
  88435. }): void;
  88436. /** @hidden */
  88437. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88438. /**
  88439. * Applies VertexData created from the imported parameters to the geometry
  88440. * @param parsedVertexData the parsed data from an imported file
  88441. * @param geometry the geometry to apply the VertexData to
  88442. */
  88443. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88444. }
  88445. }
  88446. declare module BABYLON {
  88447. /**
  88448. * Defines a target to use with MorphTargetManager
  88449. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88450. */
  88451. export class MorphTarget implements IAnimatable {
  88452. /** defines the name of the target */
  88453. name: string;
  88454. /**
  88455. * Gets or sets the list of animations
  88456. */
  88457. animations: Animation[];
  88458. private _scene;
  88459. private _positions;
  88460. private _normals;
  88461. private _tangents;
  88462. private _uvs;
  88463. private _influence;
  88464. /**
  88465. * Observable raised when the influence changes
  88466. */
  88467. onInfluenceChanged: Observable<boolean>;
  88468. /** @hidden */
  88469. _onDataLayoutChanged: Observable<void>;
  88470. /**
  88471. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88472. */
  88473. influence: number;
  88474. /**
  88475. * Gets or sets the id of the morph Target
  88476. */
  88477. id: string;
  88478. private _animationPropertiesOverride;
  88479. /**
  88480. * Gets or sets the animation properties override
  88481. */
  88482. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88483. /**
  88484. * Creates a new MorphTarget
  88485. * @param name defines the name of the target
  88486. * @param influence defines the influence to use
  88487. * @param scene defines the scene the morphtarget belongs to
  88488. */
  88489. constructor(
  88490. /** defines the name of the target */
  88491. name: string, influence?: number, scene?: Nullable<Scene>);
  88492. /**
  88493. * Gets a boolean defining if the target contains position data
  88494. */
  88495. readonly hasPositions: boolean;
  88496. /**
  88497. * Gets a boolean defining if the target contains normal data
  88498. */
  88499. readonly hasNormals: boolean;
  88500. /**
  88501. * Gets a boolean defining if the target contains tangent data
  88502. */
  88503. readonly hasTangents: boolean;
  88504. /**
  88505. * Gets a boolean defining if the target contains texture coordinates data
  88506. */
  88507. readonly hasUVs: boolean;
  88508. /**
  88509. * Affects position data to this target
  88510. * @param data defines the position data to use
  88511. */
  88512. setPositions(data: Nullable<FloatArray>): void;
  88513. /**
  88514. * Gets the position data stored in this target
  88515. * @returns a FloatArray containing the position data (or null if not present)
  88516. */
  88517. getPositions(): Nullable<FloatArray>;
  88518. /**
  88519. * Affects normal data to this target
  88520. * @param data defines the normal data to use
  88521. */
  88522. setNormals(data: Nullable<FloatArray>): void;
  88523. /**
  88524. * Gets the normal data stored in this target
  88525. * @returns a FloatArray containing the normal data (or null if not present)
  88526. */
  88527. getNormals(): Nullable<FloatArray>;
  88528. /**
  88529. * Affects tangent data to this target
  88530. * @param data defines the tangent data to use
  88531. */
  88532. setTangents(data: Nullable<FloatArray>): void;
  88533. /**
  88534. * Gets the tangent data stored in this target
  88535. * @returns a FloatArray containing the tangent data (or null if not present)
  88536. */
  88537. getTangents(): Nullable<FloatArray>;
  88538. /**
  88539. * Affects texture coordinates data to this target
  88540. * @param data defines the texture coordinates data to use
  88541. */
  88542. setUVs(data: Nullable<FloatArray>): void;
  88543. /**
  88544. * Gets the texture coordinates data stored in this target
  88545. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88546. */
  88547. getUVs(): Nullable<FloatArray>;
  88548. /**
  88549. * Serializes the current target into a Serialization object
  88550. * @returns the serialized object
  88551. */
  88552. serialize(): any;
  88553. /**
  88554. * Returns the string "MorphTarget"
  88555. * @returns "MorphTarget"
  88556. */
  88557. getClassName(): string;
  88558. /**
  88559. * Creates a new target from serialized data
  88560. * @param serializationObject defines the serialized data to use
  88561. * @returns a new MorphTarget
  88562. */
  88563. static Parse(serializationObject: any): MorphTarget;
  88564. /**
  88565. * Creates a MorphTarget from mesh data
  88566. * @param mesh defines the source mesh
  88567. * @param name defines the name to use for the new target
  88568. * @param influence defines the influence to attach to the target
  88569. * @returns a new MorphTarget
  88570. */
  88571. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88572. }
  88573. }
  88574. declare module BABYLON {
  88575. /**
  88576. * This class is used to deform meshes using morphing between different targets
  88577. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88578. */
  88579. export class MorphTargetManager {
  88580. private _targets;
  88581. private _targetInfluenceChangedObservers;
  88582. private _targetDataLayoutChangedObservers;
  88583. private _activeTargets;
  88584. private _scene;
  88585. private _influences;
  88586. private _supportsNormals;
  88587. private _supportsTangents;
  88588. private _supportsUVs;
  88589. private _vertexCount;
  88590. private _uniqueId;
  88591. private _tempInfluences;
  88592. /**
  88593. * Gets or sets a boolean indicating if normals must be morphed
  88594. */
  88595. enableNormalMorphing: boolean;
  88596. /**
  88597. * Gets or sets a boolean indicating if tangents must be morphed
  88598. */
  88599. enableTangentMorphing: boolean;
  88600. /**
  88601. * Gets or sets a boolean indicating if UV must be morphed
  88602. */
  88603. enableUVMorphing: boolean;
  88604. /**
  88605. * Creates a new MorphTargetManager
  88606. * @param scene defines the current scene
  88607. */
  88608. constructor(scene?: Nullable<Scene>);
  88609. /**
  88610. * Gets the unique ID of this manager
  88611. */
  88612. readonly uniqueId: number;
  88613. /**
  88614. * Gets the number of vertices handled by this manager
  88615. */
  88616. readonly vertexCount: number;
  88617. /**
  88618. * Gets a boolean indicating if this manager supports morphing of normals
  88619. */
  88620. readonly supportsNormals: boolean;
  88621. /**
  88622. * Gets a boolean indicating if this manager supports morphing of tangents
  88623. */
  88624. readonly supportsTangents: boolean;
  88625. /**
  88626. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88627. */
  88628. readonly supportsUVs: boolean;
  88629. /**
  88630. * Gets the number of targets stored in this manager
  88631. */
  88632. readonly numTargets: number;
  88633. /**
  88634. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88635. */
  88636. readonly numInfluencers: number;
  88637. /**
  88638. * Gets the list of influences (one per target)
  88639. */
  88640. readonly influences: Float32Array;
  88641. /**
  88642. * Gets the active target at specified index. An active target is a target with an influence > 0
  88643. * @param index defines the index to check
  88644. * @returns the requested target
  88645. */
  88646. getActiveTarget(index: number): MorphTarget;
  88647. /**
  88648. * Gets the target at specified index
  88649. * @param index defines the index to check
  88650. * @returns the requested target
  88651. */
  88652. getTarget(index: number): MorphTarget;
  88653. /**
  88654. * Add a new target to this manager
  88655. * @param target defines the target to add
  88656. */
  88657. addTarget(target: MorphTarget): void;
  88658. /**
  88659. * Removes a target from the manager
  88660. * @param target defines the target to remove
  88661. */
  88662. removeTarget(target: MorphTarget): void;
  88663. /**
  88664. * Serializes the current manager into a Serialization object
  88665. * @returns the serialized object
  88666. */
  88667. serialize(): any;
  88668. private _syncActiveTargets;
  88669. /**
  88670. * Syncrhonize the targets with all the meshes using this morph target manager
  88671. */
  88672. synchronize(): void;
  88673. /**
  88674. * Creates a new MorphTargetManager from serialized data
  88675. * @param serializationObject defines the serialized data
  88676. * @param scene defines the hosting scene
  88677. * @returns the new MorphTargetManager
  88678. */
  88679. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88680. }
  88681. }
  88682. declare module BABYLON {
  88683. /**
  88684. * Class used to represent a specific level of detail of a mesh
  88685. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88686. */
  88687. export class MeshLODLevel {
  88688. /** Defines the distance where this level should start being displayed */
  88689. distance: number;
  88690. /** Defines the mesh to use to render this level */
  88691. mesh: Nullable<Mesh>;
  88692. /**
  88693. * Creates a new LOD level
  88694. * @param distance defines the distance where this level should star being displayed
  88695. * @param mesh defines the mesh to use to render this level
  88696. */
  88697. constructor(
  88698. /** Defines the distance where this level should start being displayed */
  88699. distance: number,
  88700. /** Defines the mesh to use to render this level */
  88701. mesh: Nullable<Mesh>);
  88702. }
  88703. }
  88704. declare module BABYLON {
  88705. /**
  88706. * Mesh representing the gorund
  88707. */
  88708. export class GroundMesh extends Mesh {
  88709. /** If octree should be generated */
  88710. generateOctree: boolean;
  88711. private _heightQuads;
  88712. /** @hidden */
  88713. _subdivisionsX: number;
  88714. /** @hidden */
  88715. _subdivisionsY: number;
  88716. /** @hidden */
  88717. _width: number;
  88718. /** @hidden */
  88719. _height: number;
  88720. /** @hidden */
  88721. _minX: number;
  88722. /** @hidden */
  88723. _maxX: number;
  88724. /** @hidden */
  88725. _minZ: number;
  88726. /** @hidden */
  88727. _maxZ: number;
  88728. constructor(name: string, scene: Scene);
  88729. /**
  88730. * "GroundMesh"
  88731. * @returns "GroundMesh"
  88732. */
  88733. getClassName(): string;
  88734. /**
  88735. * The minimum of x and y subdivisions
  88736. */
  88737. readonly subdivisions: number;
  88738. /**
  88739. * X subdivisions
  88740. */
  88741. readonly subdivisionsX: number;
  88742. /**
  88743. * Y subdivisions
  88744. */
  88745. readonly subdivisionsY: number;
  88746. /**
  88747. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  88748. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  88749. * @param chunksCount the number of subdivisions for x and y
  88750. * @param octreeBlocksSize (Default: 32)
  88751. */
  88752. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  88753. /**
  88754. * Returns a height (y) value in the Worl system :
  88755. * the ground altitude at the coordinates (x, z) expressed in the World system.
  88756. * @param x x coordinate
  88757. * @param z z coordinate
  88758. * @returns the ground y position if (x, z) are outside the ground surface.
  88759. */
  88760. getHeightAtCoordinates(x: number, z: number): number;
  88761. /**
  88762. * Returns a normalized vector (Vector3) orthogonal to the ground
  88763. * at the ground coordinates (x, z) expressed in the World system.
  88764. * @param x x coordinate
  88765. * @param z z coordinate
  88766. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88767. */
  88768. getNormalAtCoordinates(x: number, z: number): Vector3;
  88769. /**
  88770. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88771. * at the ground coordinates (x, z) expressed in the World system.
  88772. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88773. * @param x x coordinate
  88774. * @param z z coordinate
  88775. * @param ref vector to store the result
  88776. * @returns the GroundMesh.
  88777. */
  88778. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88779. /**
  88780. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88781. * if the ground has been updated.
  88782. * This can be used in the render loop.
  88783. * @returns the GroundMesh.
  88784. */
  88785. updateCoordinateHeights(): GroundMesh;
  88786. private _getFacetAt;
  88787. private _initHeightQuads;
  88788. private _computeHeightQuads;
  88789. /**
  88790. * Serializes this ground mesh
  88791. * @param serializationObject object to write serialization to
  88792. */
  88793. serialize(serializationObject: any): void;
  88794. /**
  88795. * Parses a serialized ground mesh
  88796. * @param parsedMesh the serialized mesh
  88797. * @param scene the scene to create the ground mesh in
  88798. * @returns the created ground mesh
  88799. */
  88800. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88801. }
  88802. }
  88803. declare module BABYLON {
  88804. /**
  88805. * Interface for Physics-Joint data
  88806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88807. */
  88808. export interface PhysicsJointData {
  88809. /**
  88810. * The main pivot of the joint
  88811. */
  88812. mainPivot?: Vector3;
  88813. /**
  88814. * The connected pivot of the joint
  88815. */
  88816. connectedPivot?: Vector3;
  88817. /**
  88818. * The main axis of the joint
  88819. */
  88820. mainAxis?: Vector3;
  88821. /**
  88822. * The connected axis of the joint
  88823. */
  88824. connectedAxis?: Vector3;
  88825. /**
  88826. * The collision of the joint
  88827. */
  88828. collision?: boolean;
  88829. /**
  88830. * Native Oimo/Cannon/Energy data
  88831. */
  88832. nativeParams?: any;
  88833. }
  88834. /**
  88835. * This is a holder class for the physics joint created by the physics plugin
  88836. * It holds a set of functions to control the underlying joint
  88837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88838. */
  88839. export class PhysicsJoint {
  88840. /**
  88841. * The type of the physics joint
  88842. */
  88843. type: number;
  88844. /**
  88845. * The data for the physics joint
  88846. */
  88847. jointData: PhysicsJointData;
  88848. private _physicsJoint;
  88849. protected _physicsPlugin: IPhysicsEnginePlugin;
  88850. /**
  88851. * Initializes the physics joint
  88852. * @param type The type of the physics joint
  88853. * @param jointData The data for the physics joint
  88854. */
  88855. constructor(
  88856. /**
  88857. * The type of the physics joint
  88858. */
  88859. type: number,
  88860. /**
  88861. * The data for the physics joint
  88862. */
  88863. jointData: PhysicsJointData);
  88864. /**
  88865. * Gets the physics joint
  88866. */
  88867. /**
  88868. * Sets the physics joint
  88869. */
  88870. physicsJoint: any;
  88871. /**
  88872. * Sets the physics plugin
  88873. */
  88874. physicsPlugin: IPhysicsEnginePlugin;
  88875. /**
  88876. * Execute a function that is physics-plugin specific.
  88877. * @param {Function} func the function that will be executed.
  88878. * It accepts two parameters: the physics world and the physics joint
  88879. */
  88880. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88881. /**
  88882. * Distance-Joint type
  88883. */
  88884. static DistanceJoint: number;
  88885. /**
  88886. * Hinge-Joint type
  88887. */
  88888. static HingeJoint: number;
  88889. /**
  88890. * Ball-and-Socket joint type
  88891. */
  88892. static BallAndSocketJoint: number;
  88893. /**
  88894. * Wheel-Joint type
  88895. */
  88896. static WheelJoint: number;
  88897. /**
  88898. * Slider-Joint type
  88899. */
  88900. static SliderJoint: number;
  88901. /**
  88902. * Prismatic-Joint type
  88903. */
  88904. static PrismaticJoint: number;
  88905. /**
  88906. * Universal-Joint type
  88907. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88908. */
  88909. static UniversalJoint: number;
  88910. /**
  88911. * Hinge-Joint 2 type
  88912. */
  88913. static Hinge2Joint: number;
  88914. /**
  88915. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88916. */
  88917. static PointToPointJoint: number;
  88918. /**
  88919. * Spring-Joint type
  88920. */
  88921. static SpringJoint: number;
  88922. /**
  88923. * Lock-Joint type
  88924. */
  88925. static LockJoint: number;
  88926. }
  88927. /**
  88928. * A class representing a physics distance joint
  88929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88930. */
  88931. export class DistanceJoint extends PhysicsJoint {
  88932. /**
  88933. *
  88934. * @param jointData The data for the Distance-Joint
  88935. */
  88936. constructor(jointData: DistanceJointData);
  88937. /**
  88938. * Update the predefined distance.
  88939. * @param maxDistance The maximum preferred distance
  88940. * @param minDistance The minimum preferred distance
  88941. */
  88942. updateDistance(maxDistance: number, minDistance?: number): void;
  88943. }
  88944. /**
  88945. * Represents a Motor-Enabled Joint
  88946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88947. */
  88948. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88949. /**
  88950. * Initializes the Motor-Enabled Joint
  88951. * @param type The type of the joint
  88952. * @param jointData The physica joint data for the joint
  88953. */
  88954. constructor(type: number, jointData: PhysicsJointData);
  88955. /**
  88956. * Set the motor values.
  88957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88958. * @param force the force to apply
  88959. * @param maxForce max force for this motor.
  88960. */
  88961. setMotor(force?: number, maxForce?: number): void;
  88962. /**
  88963. * Set the motor's limits.
  88964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88965. * @param upperLimit The upper limit of the motor
  88966. * @param lowerLimit The lower limit of the motor
  88967. */
  88968. setLimit(upperLimit: number, lowerLimit?: number): void;
  88969. }
  88970. /**
  88971. * This class represents a single physics Hinge-Joint
  88972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88973. */
  88974. export class HingeJoint extends MotorEnabledJoint {
  88975. /**
  88976. * Initializes the Hinge-Joint
  88977. * @param jointData The joint data for the Hinge-Joint
  88978. */
  88979. constructor(jointData: PhysicsJointData);
  88980. /**
  88981. * Set the motor values.
  88982. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88983. * @param {number} force the force to apply
  88984. * @param {number} maxForce max force for this motor.
  88985. */
  88986. setMotor(force?: number, maxForce?: number): void;
  88987. /**
  88988. * Set the motor's limits.
  88989. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88990. * @param upperLimit The upper limit of the motor
  88991. * @param lowerLimit The lower limit of the motor
  88992. */
  88993. setLimit(upperLimit: number, lowerLimit?: number): void;
  88994. }
  88995. /**
  88996. * This class represents a dual hinge physics joint (same as wheel joint)
  88997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88998. */
  88999. export class Hinge2Joint extends MotorEnabledJoint {
  89000. /**
  89001. * Initializes the Hinge2-Joint
  89002. * @param jointData The joint data for the Hinge2-Joint
  89003. */
  89004. constructor(jointData: PhysicsJointData);
  89005. /**
  89006. * Set the motor values.
  89007. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89008. * @param {number} targetSpeed the speed the motor is to reach
  89009. * @param {number} maxForce max force for this motor.
  89010. * @param {motorIndex} the motor's index, 0 or 1.
  89011. */
  89012. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89013. /**
  89014. * Set the motor limits.
  89015. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89016. * @param {number} upperLimit the upper limit
  89017. * @param {number} lowerLimit lower limit
  89018. * @param {motorIndex} the motor's index, 0 or 1.
  89019. */
  89020. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89021. }
  89022. /**
  89023. * Interface for a motor enabled joint
  89024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89025. */
  89026. export interface IMotorEnabledJoint {
  89027. /**
  89028. * Physics joint
  89029. */
  89030. physicsJoint: any;
  89031. /**
  89032. * Sets the motor of the motor-enabled joint
  89033. * @param force The force of the motor
  89034. * @param maxForce The maximum force of the motor
  89035. * @param motorIndex The index of the motor
  89036. */
  89037. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89038. /**
  89039. * Sets the limit of the motor
  89040. * @param upperLimit The upper limit of the motor
  89041. * @param lowerLimit The lower limit of the motor
  89042. * @param motorIndex The index of the motor
  89043. */
  89044. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89045. }
  89046. /**
  89047. * Joint data for a Distance-Joint
  89048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89049. */
  89050. export interface DistanceJointData extends PhysicsJointData {
  89051. /**
  89052. * Max distance the 2 joint objects can be apart
  89053. */
  89054. maxDistance: number;
  89055. }
  89056. /**
  89057. * Joint data from a spring joint
  89058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89059. */
  89060. export interface SpringJointData extends PhysicsJointData {
  89061. /**
  89062. * Length of the spring
  89063. */
  89064. length: number;
  89065. /**
  89066. * Stiffness of the spring
  89067. */
  89068. stiffness: number;
  89069. /**
  89070. * Damping of the spring
  89071. */
  89072. damping: number;
  89073. /** this callback will be called when applying the force to the impostors. */
  89074. forceApplicationCallback: () => void;
  89075. }
  89076. }
  89077. declare module BABYLON {
  89078. /**
  89079. * Holds the data for the raycast result
  89080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89081. */
  89082. export class PhysicsRaycastResult {
  89083. private _hasHit;
  89084. private _hitDistance;
  89085. private _hitNormalWorld;
  89086. private _hitPointWorld;
  89087. private _rayFromWorld;
  89088. private _rayToWorld;
  89089. /**
  89090. * Gets if there was a hit
  89091. */
  89092. readonly hasHit: boolean;
  89093. /**
  89094. * Gets the distance from the hit
  89095. */
  89096. readonly hitDistance: number;
  89097. /**
  89098. * Gets the hit normal/direction in the world
  89099. */
  89100. readonly hitNormalWorld: Vector3;
  89101. /**
  89102. * Gets the hit point in the world
  89103. */
  89104. readonly hitPointWorld: Vector3;
  89105. /**
  89106. * Gets the ray "start point" of the ray in the world
  89107. */
  89108. readonly rayFromWorld: Vector3;
  89109. /**
  89110. * Gets the ray "end point" of the ray in the world
  89111. */
  89112. readonly rayToWorld: Vector3;
  89113. /**
  89114. * Sets the hit data (normal & point in world space)
  89115. * @param hitNormalWorld defines the normal in world space
  89116. * @param hitPointWorld defines the point in world space
  89117. */
  89118. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89119. /**
  89120. * Sets the distance from the start point to the hit point
  89121. * @param distance
  89122. */
  89123. setHitDistance(distance: number): void;
  89124. /**
  89125. * Calculates the distance manually
  89126. */
  89127. calculateHitDistance(): void;
  89128. /**
  89129. * Resets all the values to default
  89130. * @param from The from point on world space
  89131. * @param to The to point on world space
  89132. */
  89133. reset(from?: Vector3, to?: Vector3): void;
  89134. }
  89135. /**
  89136. * Interface for the size containing width and height
  89137. */
  89138. interface IXYZ {
  89139. /**
  89140. * X
  89141. */
  89142. x: number;
  89143. /**
  89144. * Y
  89145. */
  89146. y: number;
  89147. /**
  89148. * Z
  89149. */
  89150. z: number;
  89151. }
  89152. }
  89153. declare module BABYLON {
  89154. /**
  89155. * Interface used to describe a physics joint
  89156. */
  89157. export interface PhysicsImpostorJoint {
  89158. /** Defines the main impostor to which the joint is linked */
  89159. mainImpostor: PhysicsImpostor;
  89160. /** Defines the impostor that is connected to the main impostor using this joint */
  89161. connectedImpostor: PhysicsImpostor;
  89162. /** Defines the joint itself */
  89163. joint: PhysicsJoint;
  89164. }
  89165. /** @hidden */
  89166. export interface IPhysicsEnginePlugin {
  89167. world: any;
  89168. name: string;
  89169. setGravity(gravity: Vector3): void;
  89170. setTimeStep(timeStep: number): void;
  89171. getTimeStep(): number;
  89172. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89173. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89174. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89175. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89176. removePhysicsBody(impostor: PhysicsImpostor): void;
  89177. generateJoint(joint: PhysicsImpostorJoint): void;
  89178. removeJoint(joint: PhysicsImpostorJoint): void;
  89179. isSupported(): boolean;
  89180. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89181. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89182. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89183. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89184. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89185. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89186. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89187. getBodyMass(impostor: PhysicsImpostor): number;
  89188. getBodyFriction(impostor: PhysicsImpostor): number;
  89189. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89190. getBodyRestitution(impostor: PhysicsImpostor): number;
  89191. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89192. getBodyPressure?(impostor: PhysicsImpostor): number;
  89193. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89194. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89195. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89196. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89197. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89198. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89199. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89200. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89201. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89202. sleepBody(impostor: PhysicsImpostor): void;
  89203. wakeUpBody(impostor: PhysicsImpostor): void;
  89204. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89205. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89206. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89207. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89208. getRadius(impostor: PhysicsImpostor): number;
  89209. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89210. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89211. dispose(): void;
  89212. }
  89213. /**
  89214. * Interface used to define a physics engine
  89215. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89216. */
  89217. export interface IPhysicsEngine {
  89218. /**
  89219. * Gets the gravity vector used by the simulation
  89220. */
  89221. gravity: Vector3;
  89222. /**
  89223. * Sets the gravity vector used by the simulation
  89224. * @param gravity defines the gravity vector to use
  89225. */
  89226. setGravity(gravity: Vector3): void;
  89227. /**
  89228. * Set the time step of the physics engine.
  89229. * Default is 1/60.
  89230. * To slow it down, enter 1/600 for example.
  89231. * To speed it up, 1/30
  89232. * @param newTimeStep the new timestep to apply to this world.
  89233. */
  89234. setTimeStep(newTimeStep: number): void;
  89235. /**
  89236. * Get the time step of the physics engine.
  89237. * @returns the current time step
  89238. */
  89239. getTimeStep(): number;
  89240. /**
  89241. * Release all resources
  89242. */
  89243. dispose(): void;
  89244. /**
  89245. * Gets the name of the current physics plugin
  89246. * @returns the name of the plugin
  89247. */
  89248. getPhysicsPluginName(): string;
  89249. /**
  89250. * Adding a new impostor for the impostor tracking.
  89251. * This will be done by the impostor itself.
  89252. * @param impostor the impostor to add
  89253. */
  89254. addImpostor(impostor: PhysicsImpostor): void;
  89255. /**
  89256. * Remove an impostor from the engine.
  89257. * This impostor and its mesh will not longer be updated by the physics engine.
  89258. * @param impostor the impostor to remove
  89259. */
  89260. removeImpostor(impostor: PhysicsImpostor): void;
  89261. /**
  89262. * Add a joint to the physics engine
  89263. * @param mainImpostor defines the main impostor to which the joint is added.
  89264. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89265. * @param joint defines the joint that will connect both impostors.
  89266. */
  89267. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89268. /**
  89269. * Removes a joint from the simulation
  89270. * @param mainImpostor defines the impostor used with the joint
  89271. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89272. * @param joint defines the joint to remove
  89273. */
  89274. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89275. /**
  89276. * Gets the current plugin used to run the simulation
  89277. * @returns current plugin
  89278. */
  89279. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89280. /**
  89281. * Gets the list of physic impostors
  89282. * @returns an array of PhysicsImpostor
  89283. */
  89284. getImpostors(): Array<PhysicsImpostor>;
  89285. /**
  89286. * Gets the impostor for a physics enabled object
  89287. * @param object defines the object impersonated by the impostor
  89288. * @returns the PhysicsImpostor or null if not found
  89289. */
  89290. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89291. /**
  89292. * Gets the impostor for a physics body object
  89293. * @param body defines physics body used by the impostor
  89294. * @returns the PhysicsImpostor or null if not found
  89295. */
  89296. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89297. /**
  89298. * Does a raycast in the physics world
  89299. * @param from when should the ray start?
  89300. * @param to when should the ray end?
  89301. * @returns PhysicsRaycastResult
  89302. */
  89303. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89304. /**
  89305. * Called by the scene. No need to call it.
  89306. * @param delta defines the timespam between frames
  89307. */
  89308. _step(delta: number): void;
  89309. }
  89310. }
  89311. declare module BABYLON {
  89312. /**
  89313. * The interface for the physics imposter parameters
  89314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89315. */
  89316. export interface PhysicsImpostorParameters {
  89317. /**
  89318. * The mass of the physics imposter
  89319. */
  89320. mass: number;
  89321. /**
  89322. * The friction of the physics imposter
  89323. */
  89324. friction?: number;
  89325. /**
  89326. * The coefficient of restitution of the physics imposter
  89327. */
  89328. restitution?: number;
  89329. /**
  89330. * The native options of the physics imposter
  89331. */
  89332. nativeOptions?: any;
  89333. /**
  89334. * Specifies if the parent should be ignored
  89335. */
  89336. ignoreParent?: boolean;
  89337. /**
  89338. * Specifies if bi-directional transformations should be disabled
  89339. */
  89340. disableBidirectionalTransformation?: boolean;
  89341. /**
  89342. * The pressure inside the physics imposter, soft object only
  89343. */
  89344. pressure?: number;
  89345. /**
  89346. * The stiffness the physics imposter, soft object only
  89347. */
  89348. stiffness?: number;
  89349. /**
  89350. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89351. */
  89352. velocityIterations?: number;
  89353. /**
  89354. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89355. */
  89356. positionIterations?: number;
  89357. /**
  89358. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89359. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89360. * Add to fix multiple points
  89361. */
  89362. fixedPoints?: number;
  89363. /**
  89364. * The collision margin around a soft object
  89365. */
  89366. margin?: number;
  89367. /**
  89368. * The collision margin around a soft object
  89369. */
  89370. damping?: number;
  89371. /**
  89372. * The path for a rope based on an extrusion
  89373. */
  89374. path?: any;
  89375. /**
  89376. * The shape of an extrusion used for a rope based on an extrusion
  89377. */
  89378. shape?: any;
  89379. }
  89380. /**
  89381. * Interface for a physics-enabled object
  89382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89383. */
  89384. export interface IPhysicsEnabledObject {
  89385. /**
  89386. * The position of the physics-enabled object
  89387. */
  89388. position: Vector3;
  89389. /**
  89390. * The rotation of the physics-enabled object
  89391. */
  89392. rotationQuaternion: Nullable<Quaternion>;
  89393. /**
  89394. * The scale of the physics-enabled object
  89395. */
  89396. scaling: Vector3;
  89397. /**
  89398. * The rotation of the physics-enabled object
  89399. */
  89400. rotation?: Vector3;
  89401. /**
  89402. * The parent of the physics-enabled object
  89403. */
  89404. parent?: any;
  89405. /**
  89406. * The bounding info of the physics-enabled object
  89407. * @returns The bounding info of the physics-enabled object
  89408. */
  89409. getBoundingInfo(): BoundingInfo;
  89410. /**
  89411. * Computes the world matrix
  89412. * @param force Specifies if the world matrix should be computed by force
  89413. * @returns A world matrix
  89414. */
  89415. computeWorldMatrix(force: boolean): Matrix;
  89416. /**
  89417. * Gets the world matrix
  89418. * @returns A world matrix
  89419. */
  89420. getWorldMatrix?(): Matrix;
  89421. /**
  89422. * Gets the child meshes
  89423. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89424. * @returns An array of abstract meshes
  89425. */
  89426. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89427. /**
  89428. * Gets the vertex data
  89429. * @param kind The type of vertex data
  89430. * @returns A nullable array of numbers, or a float32 array
  89431. */
  89432. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89433. /**
  89434. * Gets the indices from the mesh
  89435. * @returns A nullable array of index arrays
  89436. */
  89437. getIndices?(): Nullable<IndicesArray>;
  89438. /**
  89439. * Gets the scene from the mesh
  89440. * @returns the indices array or null
  89441. */
  89442. getScene?(): Scene;
  89443. /**
  89444. * Gets the absolute position from the mesh
  89445. * @returns the absolute position
  89446. */
  89447. getAbsolutePosition(): Vector3;
  89448. /**
  89449. * Gets the absolute pivot point from the mesh
  89450. * @returns the absolute pivot point
  89451. */
  89452. getAbsolutePivotPoint(): Vector3;
  89453. /**
  89454. * Rotates the mesh
  89455. * @param axis The axis of rotation
  89456. * @param amount The amount of rotation
  89457. * @param space The space of the rotation
  89458. * @returns The rotation transform node
  89459. */
  89460. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89461. /**
  89462. * Translates the mesh
  89463. * @param axis The axis of translation
  89464. * @param distance The distance of translation
  89465. * @param space The space of the translation
  89466. * @returns The transform node
  89467. */
  89468. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89469. /**
  89470. * Sets the absolute position of the mesh
  89471. * @param absolutePosition The absolute position of the mesh
  89472. * @returns The transform node
  89473. */
  89474. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89475. /**
  89476. * Gets the class name of the mesh
  89477. * @returns The class name
  89478. */
  89479. getClassName(): string;
  89480. }
  89481. /**
  89482. * Represents a physics imposter
  89483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89484. */
  89485. export class PhysicsImpostor {
  89486. /**
  89487. * The physics-enabled object used as the physics imposter
  89488. */
  89489. object: IPhysicsEnabledObject;
  89490. /**
  89491. * The type of the physics imposter
  89492. */
  89493. type: number;
  89494. private _options;
  89495. private _scene?;
  89496. /**
  89497. * The default object size of the imposter
  89498. */
  89499. static DEFAULT_OBJECT_SIZE: Vector3;
  89500. /**
  89501. * The identity quaternion of the imposter
  89502. */
  89503. static IDENTITY_QUATERNION: Quaternion;
  89504. /** @hidden */
  89505. _pluginData: any;
  89506. private _physicsEngine;
  89507. private _physicsBody;
  89508. private _bodyUpdateRequired;
  89509. private _onBeforePhysicsStepCallbacks;
  89510. private _onAfterPhysicsStepCallbacks;
  89511. /** @hidden */
  89512. _onPhysicsCollideCallbacks: Array<{
  89513. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89514. otherImpostors: Array<PhysicsImpostor>;
  89515. }>;
  89516. private _deltaPosition;
  89517. private _deltaRotation;
  89518. private _deltaRotationConjugated;
  89519. /** @hidden */
  89520. _isFromLine: boolean;
  89521. private _parent;
  89522. private _isDisposed;
  89523. private static _tmpVecs;
  89524. private static _tmpQuat;
  89525. /**
  89526. * Specifies if the physics imposter is disposed
  89527. */
  89528. readonly isDisposed: boolean;
  89529. /**
  89530. * Gets the mass of the physics imposter
  89531. */
  89532. mass: number;
  89533. /**
  89534. * Gets the coefficient of friction
  89535. */
  89536. /**
  89537. * Sets the coefficient of friction
  89538. */
  89539. friction: number;
  89540. /**
  89541. * Gets the coefficient of restitution
  89542. */
  89543. /**
  89544. * Sets the coefficient of restitution
  89545. */
  89546. restitution: number;
  89547. /**
  89548. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89549. */
  89550. /**
  89551. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89552. */
  89553. pressure: number;
  89554. /**
  89555. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89556. */
  89557. /**
  89558. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89559. */
  89560. stiffness: number;
  89561. /**
  89562. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89563. */
  89564. /**
  89565. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89566. */
  89567. velocityIterations: number;
  89568. /**
  89569. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89570. */
  89571. /**
  89572. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89573. */
  89574. positionIterations: number;
  89575. /**
  89576. * The unique id of the physics imposter
  89577. * set by the physics engine when adding this impostor to the array
  89578. */
  89579. uniqueId: number;
  89580. /**
  89581. * @hidden
  89582. */
  89583. soft: boolean;
  89584. /**
  89585. * @hidden
  89586. */
  89587. segments: number;
  89588. private _joints;
  89589. /**
  89590. * Initializes the physics imposter
  89591. * @param object The physics-enabled object used as the physics imposter
  89592. * @param type The type of the physics imposter
  89593. * @param _options The options for the physics imposter
  89594. * @param _scene The Babylon scene
  89595. */
  89596. constructor(
  89597. /**
  89598. * The physics-enabled object used as the physics imposter
  89599. */
  89600. object: IPhysicsEnabledObject,
  89601. /**
  89602. * The type of the physics imposter
  89603. */
  89604. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89605. /**
  89606. * This function will completly initialize this impostor.
  89607. * It will create a new body - but only if this mesh has no parent.
  89608. * If it has, this impostor will not be used other than to define the impostor
  89609. * of the child mesh.
  89610. * @hidden
  89611. */
  89612. _init(): void;
  89613. private _getPhysicsParent;
  89614. /**
  89615. * Should a new body be generated.
  89616. * @returns boolean specifying if body initialization is required
  89617. */
  89618. isBodyInitRequired(): boolean;
  89619. /**
  89620. * Sets the updated scaling
  89621. * @param updated Specifies if the scaling is updated
  89622. */
  89623. setScalingUpdated(): void;
  89624. /**
  89625. * Force a regeneration of this or the parent's impostor's body.
  89626. * Use under cautious - This will remove all joints already implemented.
  89627. */
  89628. forceUpdate(): void;
  89629. /**
  89630. * Gets the body that holds this impostor. Either its own, or its parent.
  89631. */
  89632. /**
  89633. * Set the physics body. Used mainly by the physics engine/plugin
  89634. */
  89635. physicsBody: any;
  89636. /**
  89637. * Get the parent of the physics imposter
  89638. * @returns Physics imposter or null
  89639. */
  89640. /**
  89641. * Sets the parent of the physics imposter
  89642. */
  89643. parent: Nullable<PhysicsImpostor>;
  89644. /**
  89645. * Resets the update flags
  89646. */
  89647. resetUpdateFlags(): void;
  89648. /**
  89649. * Gets the object extend size
  89650. * @returns the object extend size
  89651. */
  89652. getObjectExtendSize(): Vector3;
  89653. /**
  89654. * Gets the object center
  89655. * @returns The object center
  89656. */
  89657. getObjectCenter(): Vector3;
  89658. /**
  89659. * Get a specific parametes from the options parameter
  89660. * @param paramName The object parameter name
  89661. * @returns The object parameter
  89662. */
  89663. getParam(paramName: string): any;
  89664. /**
  89665. * Sets a specific parameter in the options given to the physics plugin
  89666. * @param paramName The parameter name
  89667. * @param value The value of the parameter
  89668. */
  89669. setParam(paramName: string, value: number): void;
  89670. /**
  89671. * Specifically change the body's mass option. Won't recreate the physics body object
  89672. * @param mass The mass of the physics imposter
  89673. */
  89674. setMass(mass: number): void;
  89675. /**
  89676. * Gets the linear velocity
  89677. * @returns linear velocity or null
  89678. */
  89679. getLinearVelocity(): Nullable<Vector3>;
  89680. /**
  89681. * Sets the linear velocity
  89682. * @param velocity linear velocity or null
  89683. */
  89684. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89685. /**
  89686. * Gets the angular velocity
  89687. * @returns angular velocity or null
  89688. */
  89689. getAngularVelocity(): Nullable<Vector3>;
  89690. /**
  89691. * Sets the angular velocity
  89692. * @param velocity The velocity or null
  89693. */
  89694. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89695. /**
  89696. * Execute a function with the physics plugin native code
  89697. * Provide a function the will have two variables - the world object and the physics body object
  89698. * @param func The function to execute with the physics plugin native code
  89699. */
  89700. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  89701. /**
  89702. * Register a function that will be executed before the physics world is stepping forward
  89703. * @param func The function to execute before the physics world is stepped forward
  89704. */
  89705. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89706. /**
  89707. * Unregister a function that will be executed before the physics world is stepping forward
  89708. * @param func The function to execute before the physics world is stepped forward
  89709. */
  89710. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89711. /**
  89712. * Register a function that will be executed after the physics step
  89713. * @param func The function to execute after physics step
  89714. */
  89715. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89716. /**
  89717. * Unregisters a function that will be executed after the physics step
  89718. * @param func The function to execute after physics step
  89719. */
  89720. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89721. /**
  89722. * register a function that will be executed when this impostor collides against a different body
  89723. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  89724. * @param func Callback that is executed on collision
  89725. */
  89726. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  89727. /**
  89728. * Unregisters the physics imposter on contact
  89729. * @param collideAgainst The physics object to collide against
  89730. * @param func Callback to execute on collision
  89731. */
  89732. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  89733. private _tmpQuat;
  89734. private _tmpQuat2;
  89735. /**
  89736. * Get the parent rotation
  89737. * @returns The parent rotation
  89738. */
  89739. getParentsRotation(): Quaternion;
  89740. /**
  89741. * this function is executed by the physics engine.
  89742. */
  89743. beforeStep: () => void;
  89744. /**
  89745. * this function is executed by the physics engine
  89746. */
  89747. afterStep: () => void;
  89748. /**
  89749. * Legacy collision detection event support
  89750. */
  89751. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  89752. /**
  89753. * event and body object due to cannon's event-based architecture.
  89754. */
  89755. onCollide: (e: {
  89756. body: any;
  89757. }) => void;
  89758. /**
  89759. * Apply a force
  89760. * @param force The force to apply
  89761. * @param contactPoint The contact point for the force
  89762. * @returns The physics imposter
  89763. */
  89764. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89765. /**
  89766. * Apply an impulse
  89767. * @param force The impulse force
  89768. * @param contactPoint The contact point for the impulse force
  89769. * @returns The physics imposter
  89770. */
  89771. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89772. /**
  89773. * A help function to create a joint
  89774. * @param otherImpostor A physics imposter used to create a joint
  89775. * @param jointType The type of joint
  89776. * @param jointData The data for the joint
  89777. * @returns The physics imposter
  89778. */
  89779. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89780. /**
  89781. * Add a joint to this impostor with a different impostor
  89782. * @param otherImpostor A physics imposter used to add a joint
  89783. * @param joint The joint to add
  89784. * @returns The physics imposter
  89785. */
  89786. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89787. /**
  89788. * Add an anchor to a cloth impostor
  89789. * @param otherImpostor rigid impostor to anchor to
  89790. * @param width ratio across width from 0 to 1
  89791. * @param height ratio up height from 0 to 1
  89792. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89793. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89794. * @returns impostor the soft imposter
  89795. */
  89796. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89797. /**
  89798. * Add a hook to a rope impostor
  89799. * @param otherImpostor rigid impostor to anchor to
  89800. * @param length ratio across rope from 0 to 1
  89801. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89802. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89803. * @returns impostor the rope imposter
  89804. */
  89805. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89806. /**
  89807. * Will keep this body still, in a sleep mode.
  89808. * @returns the physics imposter
  89809. */
  89810. sleep(): PhysicsImpostor;
  89811. /**
  89812. * Wake the body up.
  89813. * @returns The physics imposter
  89814. */
  89815. wakeUp(): PhysicsImpostor;
  89816. /**
  89817. * Clones the physics imposter
  89818. * @param newObject The physics imposter clones to this physics-enabled object
  89819. * @returns A nullable physics imposter
  89820. */
  89821. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89822. /**
  89823. * Disposes the physics imposter
  89824. */
  89825. dispose(): void;
  89826. /**
  89827. * Sets the delta position
  89828. * @param position The delta position amount
  89829. */
  89830. setDeltaPosition(position: Vector3): void;
  89831. /**
  89832. * Sets the delta rotation
  89833. * @param rotation The delta rotation amount
  89834. */
  89835. setDeltaRotation(rotation: Quaternion): void;
  89836. /**
  89837. * Gets the box size of the physics imposter and stores the result in the input parameter
  89838. * @param result Stores the box size
  89839. * @returns The physics imposter
  89840. */
  89841. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89842. /**
  89843. * Gets the radius of the physics imposter
  89844. * @returns Radius of the physics imposter
  89845. */
  89846. getRadius(): number;
  89847. /**
  89848. * Sync a bone with this impostor
  89849. * @param bone The bone to sync to the impostor.
  89850. * @param boneMesh The mesh that the bone is influencing.
  89851. * @param jointPivot The pivot of the joint / bone in local space.
  89852. * @param distToJoint Optional distance from the impostor to the joint.
  89853. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89854. */
  89855. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89856. /**
  89857. * Sync impostor to a bone
  89858. * @param bone The bone that the impostor will be synced to.
  89859. * @param boneMesh The mesh that the bone is influencing.
  89860. * @param jointPivot The pivot of the joint / bone in local space.
  89861. * @param distToJoint Optional distance from the impostor to the joint.
  89862. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89863. * @param boneAxis Optional vector3 axis the bone is aligned with
  89864. */
  89865. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89866. /**
  89867. * No-Imposter type
  89868. */
  89869. static NoImpostor: number;
  89870. /**
  89871. * Sphere-Imposter type
  89872. */
  89873. static SphereImpostor: number;
  89874. /**
  89875. * Box-Imposter type
  89876. */
  89877. static BoxImpostor: number;
  89878. /**
  89879. * Plane-Imposter type
  89880. */
  89881. static PlaneImpostor: number;
  89882. /**
  89883. * Mesh-imposter type
  89884. */
  89885. static MeshImpostor: number;
  89886. /**
  89887. * Capsule-Impostor type (Ammo.js plugin only)
  89888. */
  89889. static CapsuleImpostor: number;
  89890. /**
  89891. * Cylinder-Imposter type
  89892. */
  89893. static CylinderImpostor: number;
  89894. /**
  89895. * Particle-Imposter type
  89896. */
  89897. static ParticleImpostor: number;
  89898. /**
  89899. * Heightmap-Imposter type
  89900. */
  89901. static HeightmapImpostor: number;
  89902. /**
  89903. * ConvexHull-Impostor type (Ammo.js plugin only)
  89904. */
  89905. static ConvexHullImpostor: number;
  89906. /**
  89907. * Rope-Imposter type
  89908. */
  89909. static RopeImpostor: number;
  89910. /**
  89911. * Cloth-Imposter type
  89912. */
  89913. static ClothImpostor: number;
  89914. /**
  89915. * Softbody-Imposter type
  89916. */
  89917. static SoftbodyImpostor: number;
  89918. }
  89919. }
  89920. declare module BABYLON {
  89921. /**
  89922. * @hidden
  89923. **/
  89924. export class _CreationDataStorage {
  89925. closePath?: boolean;
  89926. closeArray?: boolean;
  89927. idx: number[];
  89928. dashSize: number;
  89929. gapSize: number;
  89930. path3D: Path3D;
  89931. pathArray: Vector3[][];
  89932. arc: number;
  89933. radius: number;
  89934. cap: number;
  89935. tessellation: number;
  89936. }
  89937. /**
  89938. * @hidden
  89939. **/
  89940. class _InstanceDataStorage {
  89941. visibleInstances: any;
  89942. batchCache: _InstancesBatch;
  89943. instancesBufferSize: number;
  89944. instancesBuffer: Nullable<Buffer>;
  89945. instancesData: Float32Array;
  89946. overridenInstanceCount: number;
  89947. isFrozen: boolean;
  89948. previousBatch: Nullable<_InstancesBatch>;
  89949. hardwareInstancedRendering: boolean;
  89950. sideOrientation: number;
  89951. }
  89952. /**
  89953. * @hidden
  89954. **/
  89955. export class _InstancesBatch {
  89956. mustReturn: boolean;
  89957. visibleInstances: Nullable<InstancedMesh[]>[];
  89958. renderSelf: boolean[];
  89959. hardwareInstancedRendering: boolean[];
  89960. }
  89961. /**
  89962. * Class used to represent renderable models
  89963. */
  89964. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89965. /**
  89966. * Mesh side orientation : usually the external or front surface
  89967. */
  89968. static readonly FRONTSIDE: number;
  89969. /**
  89970. * Mesh side orientation : usually the internal or back surface
  89971. */
  89972. static readonly BACKSIDE: number;
  89973. /**
  89974. * Mesh side orientation : both internal and external or front and back surfaces
  89975. */
  89976. static readonly DOUBLESIDE: number;
  89977. /**
  89978. * Mesh side orientation : by default, `FRONTSIDE`
  89979. */
  89980. static readonly DEFAULTSIDE: number;
  89981. /**
  89982. * Mesh cap setting : no cap
  89983. */
  89984. static readonly NO_CAP: number;
  89985. /**
  89986. * Mesh cap setting : one cap at the beginning of the mesh
  89987. */
  89988. static readonly CAP_START: number;
  89989. /**
  89990. * Mesh cap setting : one cap at the end of the mesh
  89991. */
  89992. static readonly CAP_END: number;
  89993. /**
  89994. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89995. */
  89996. static readonly CAP_ALL: number;
  89997. /**
  89998. * Mesh pattern setting : no flip or rotate
  89999. */
  90000. static readonly NO_FLIP: number;
  90001. /**
  90002. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90003. */
  90004. static readonly FLIP_TILE: number;
  90005. /**
  90006. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90007. */
  90008. static readonly ROTATE_TILE: number;
  90009. /**
  90010. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90011. */
  90012. static readonly FLIP_ROW: number;
  90013. /**
  90014. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90015. */
  90016. static readonly ROTATE_ROW: number;
  90017. /**
  90018. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90019. */
  90020. static readonly FLIP_N_ROTATE_TILE: number;
  90021. /**
  90022. * Mesh pattern setting : rotate pattern and rotate
  90023. */
  90024. static readonly FLIP_N_ROTATE_ROW: number;
  90025. /**
  90026. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90027. */
  90028. static readonly CENTER: number;
  90029. /**
  90030. * Mesh tile positioning : part tiles on left
  90031. */
  90032. static readonly LEFT: number;
  90033. /**
  90034. * Mesh tile positioning : part tiles on right
  90035. */
  90036. static readonly RIGHT: number;
  90037. /**
  90038. * Mesh tile positioning : part tiles on top
  90039. */
  90040. static readonly TOP: number;
  90041. /**
  90042. * Mesh tile positioning : part tiles on bottom
  90043. */
  90044. static readonly BOTTOM: number;
  90045. /**
  90046. * Gets the default side orientation.
  90047. * @param orientation the orientation to value to attempt to get
  90048. * @returns the default orientation
  90049. * @hidden
  90050. */
  90051. static _GetDefaultSideOrientation(orientation?: number): number;
  90052. private _internalMeshDataInfo;
  90053. /**
  90054. * An event triggered before rendering the mesh
  90055. */
  90056. readonly onBeforeRenderObservable: Observable<Mesh>;
  90057. /**
  90058. * An event triggered before binding the mesh
  90059. */
  90060. readonly onBeforeBindObservable: Observable<Mesh>;
  90061. /**
  90062. * An event triggered after rendering the mesh
  90063. */
  90064. readonly onAfterRenderObservable: Observable<Mesh>;
  90065. /**
  90066. * An event triggered before drawing the mesh
  90067. */
  90068. readonly onBeforeDrawObservable: Observable<Mesh>;
  90069. private _onBeforeDrawObserver;
  90070. /**
  90071. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90072. */
  90073. onBeforeDraw: () => void;
  90074. readonly hasInstances: boolean;
  90075. /**
  90076. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90077. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90078. */
  90079. delayLoadState: number;
  90080. /**
  90081. * Gets the list of instances created from this mesh
  90082. * it is not supposed to be modified manually.
  90083. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90084. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90085. */
  90086. instances: InstancedMesh[];
  90087. /**
  90088. * Gets the file containing delay loading data for this mesh
  90089. */
  90090. delayLoadingFile: string;
  90091. /** @hidden */
  90092. _binaryInfo: any;
  90093. /**
  90094. * User defined function used to change how LOD level selection is done
  90095. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90096. */
  90097. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90098. /**
  90099. * Gets or sets the morph target manager
  90100. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90101. */
  90102. morphTargetManager: Nullable<MorphTargetManager>;
  90103. /** @hidden */
  90104. _creationDataStorage: Nullable<_CreationDataStorage>;
  90105. /** @hidden */
  90106. _geometry: Nullable<Geometry>;
  90107. /** @hidden */
  90108. _delayInfo: Array<string>;
  90109. /** @hidden */
  90110. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90111. /** @hidden */
  90112. _instanceDataStorage: _InstanceDataStorage;
  90113. private _effectiveMaterial;
  90114. /** @hidden */
  90115. _shouldGenerateFlatShading: boolean;
  90116. /** @hidden */
  90117. _originalBuilderSideOrientation: number;
  90118. /**
  90119. * Use this property to change the original side orientation defined at construction time
  90120. */
  90121. overrideMaterialSideOrientation: Nullable<number>;
  90122. /**
  90123. * Gets the source mesh (the one used to clone this one from)
  90124. */
  90125. readonly source: Nullable<Mesh>;
  90126. /**
  90127. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90128. */
  90129. isUnIndexed: boolean;
  90130. /**
  90131. * @constructor
  90132. * @param name The value used by scene.getMeshByName() to do a lookup.
  90133. * @param scene The scene to add this mesh to.
  90134. * @param parent The parent of this mesh, if it has one
  90135. * @param source An optional Mesh from which geometry is shared, cloned.
  90136. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90137. * When false, achieved by calling a clone(), also passing False.
  90138. * This will make creation of children, recursive.
  90139. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90140. */
  90141. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90142. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90143. /**
  90144. * Gets the class name
  90145. * @returns the string "Mesh".
  90146. */
  90147. getClassName(): string;
  90148. /** @hidden */
  90149. readonly _isMesh: boolean;
  90150. /**
  90151. * Returns a description of this mesh
  90152. * @param fullDetails define if full details about this mesh must be used
  90153. * @returns a descriptive string representing this mesh
  90154. */
  90155. toString(fullDetails?: boolean): string;
  90156. /** @hidden */
  90157. _unBindEffect(): void;
  90158. /**
  90159. * Gets a boolean indicating if this mesh has LOD
  90160. */
  90161. readonly hasLODLevels: boolean;
  90162. /**
  90163. * Gets the list of MeshLODLevel associated with the current mesh
  90164. * @returns an array of MeshLODLevel
  90165. */
  90166. getLODLevels(): MeshLODLevel[];
  90167. private _sortLODLevels;
  90168. /**
  90169. * Add a mesh as LOD level triggered at the given distance.
  90170. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90171. * @param distance The distance from the center of the object to show this level
  90172. * @param mesh The mesh to be added as LOD level (can be null)
  90173. * @return This mesh (for chaining)
  90174. */
  90175. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90176. /**
  90177. * Returns the LOD level mesh at the passed distance or null if not found.
  90178. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90179. * @param distance The distance from the center of the object to show this level
  90180. * @returns a Mesh or `null`
  90181. */
  90182. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90183. /**
  90184. * Remove a mesh from the LOD array
  90185. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90186. * @param mesh defines the mesh to be removed
  90187. * @return This mesh (for chaining)
  90188. */
  90189. removeLODLevel(mesh: Mesh): Mesh;
  90190. /**
  90191. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90192. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90193. * @param camera defines the camera to use to compute distance
  90194. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90195. * @return This mesh (for chaining)
  90196. */
  90197. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90198. /**
  90199. * Gets the mesh internal Geometry object
  90200. */
  90201. readonly geometry: Nullable<Geometry>;
  90202. /**
  90203. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90204. * @returns the total number of vertices
  90205. */
  90206. getTotalVertices(): number;
  90207. /**
  90208. * Returns the content of an associated vertex buffer
  90209. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90210. * - VertexBuffer.PositionKind
  90211. * - VertexBuffer.UVKind
  90212. * - VertexBuffer.UV2Kind
  90213. * - VertexBuffer.UV3Kind
  90214. * - VertexBuffer.UV4Kind
  90215. * - VertexBuffer.UV5Kind
  90216. * - VertexBuffer.UV6Kind
  90217. * - VertexBuffer.ColorKind
  90218. * - VertexBuffer.MatricesIndicesKind
  90219. * - VertexBuffer.MatricesIndicesExtraKind
  90220. * - VertexBuffer.MatricesWeightsKind
  90221. * - VertexBuffer.MatricesWeightsExtraKind
  90222. * @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
  90223. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90224. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90225. */
  90226. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90227. /**
  90228. * Returns the mesh VertexBuffer object from the requested `kind`
  90229. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90230. * - VertexBuffer.PositionKind
  90231. * - VertexBuffer.NormalKind
  90232. * - VertexBuffer.UVKind
  90233. * - VertexBuffer.UV2Kind
  90234. * - VertexBuffer.UV3Kind
  90235. * - VertexBuffer.UV4Kind
  90236. * - VertexBuffer.UV5Kind
  90237. * - VertexBuffer.UV6Kind
  90238. * - VertexBuffer.ColorKind
  90239. * - VertexBuffer.MatricesIndicesKind
  90240. * - VertexBuffer.MatricesIndicesExtraKind
  90241. * - VertexBuffer.MatricesWeightsKind
  90242. * - VertexBuffer.MatricesWeightsExtraKind
  90243. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90244. */
  90245. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90246. /**
  90247. * Tests if a specific vertex buffer is associated with this mesh
  90248. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90249. * - VertexBuffer.PositionKind
  90250. * - VertexBuffer.NormalKind
  90251. * - VertexBuffer.UVKind
  90252. * - VertexBuffer.UV2Kind
  90253. * - VertexBuffer.UV3Kind
  90254. * - VertexBuffer.UV4Kind
  90255. * - VertexBuffer.UV5Kind
  90256. * - VertexBuffer.UV6Kind
  90257. * - VertexBuffer.ColorKind
  90258. * - VertexBuffer.MatricesIndicesKind
  90259. * - VertexBuffer.MatricesIndicesExtraKind
  90260. * - VertexBuffer.MatricesWeightsKind
  90261. * - VertexBuffer.MatricesWeightsExtraKind
  90262. * @returns a boolean
  90263. */
  90264. isVerticesDataPresent(kind: string): boolean;
  90265. /**
  90266. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90267. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90268. * - VertexBuffer.PositionKind
  90269. * - VertexBuffer.UVKind
  90270. * - VertexBuffer.UV2Kind
  90271. * - VertexBuffer.UV3Kind
  90272. * - VertexBuffer.UV4Kind
  90273. * - VertexBuffer.UV5Kind
  90274. * - VertexBuffer.UV6Kind
  90275. * - VertexBuffer.ColorKind
  90276. * - VertexBuffer.MatricesIndicesKind
  90277. * - VertexBuffer.MatricesIndicesExtraKind
  90278. * - VertexBuffer.MatricesWeightsKind
  90279. * - VertexBuffer.MatricesWeightsExtraKind
  90280. * @returns a boolean
  90281. */
  90282. isVertexBufferUpdatable(kind: string): boolean;
  90283. /**
  90284. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90285. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90286. * - VertexBuffer.PositionKind
  90287. * - VertexBuffer.NormalKind
  90288. * - VertexBuffer.UVKind
  90289. * - VertexBuffer.UV2Kind
  90290. * - VertexBuffer.UV3Kind
  90291. * - VertexBuffer.UV4Kind
  90292. * - VertexBuffer.UV5Kind
  90293. * - VertexBuffer.UV6Kind
  90294. * - VertexBuffer.ColorKind
  90295. * - VertexBuffer.MatricesIndicesKind
  90296. * - VertexBuffer.MatricesIndicesExtraKind
  90297. * - VertexBuffer.MatricesWeightsKind
  90298. * - VertexBuffer.MatricesWeightsExtraKind
  90299. * @returns an array of strings
  90300. */
  90301. getVerticesDataKinds(): string[];
  90302. /**
  90303. * Returns a positive integer : the total number of indices in this mesh geometry.
  90304. * @returns the numner of indices or zero if the mesh has no geometry.
  90305. */
  90306. getTotalIndices(): number;
  90307. /**
  90308. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90309. * @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.
  90310. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90311. * @returns the indices array or an empty array if the mesh has no geometry
  90312. */
  90313. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90314. readonly isBlocked: boolean;
  90315. /**
  90316. * Determine if the current mesh is ready to be rendered
  90317. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90318. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90319. * @returns true if all associated assets are ready (material, textures, shaders)
  90320. */
  90321. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90322. /**
  90323. * 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.
  90324. */
  90325. readonly areNormalsFrozen: boolean;
  90326. /**
  90327. * 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.
  90328. * @returns the current mesh
  90329. */
  90330. freezeNormals(): Mesh;
  90331. /**
  90332. * 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
  90333. * @returns the current mesh
  90334. */
  90335. unfreezeNormals(): Mesh;
  90336. /**
  90337. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90338. */
  90339. overridenInstanceCount: number;
  90340. /** @hidden */
  90341. _preActivate(): Mesh;
  90342. /** @hidden */
  90343. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90344. /** @hidden */
  90345. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90346. /**
  90347. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90348. * This means the mesh underlying bounding box and sphere are recomputed.
  90349. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90350. * @returns the current mesh
  90351. */
  90352. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90353. /** @hidden */
  90354. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90355. /**
  90356. * This function will subdivide the mesh into multiple submeshes
  90357. * @param count defines the expected number of submeshes
  90358. */
  90359. subdivide(count: number): void;
  90360. /**
  90361. * Copy a FloatArray into a specific associated vertex buffer
  90362. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90363. * - VertexBuffer.PositionKind
  90364. * - VertexBuffer.UVKind
  90365. * - VertexBuffer.UV2Kind
  90366. * - VertexBuffer.UV3Kind
  90367. * - VertexBuffer.UV4Kind
  90368. * - VertexBuffer.UV5Kind
  90369. * - VertexBuffer.UV6Kind
  90370. * - VertexBuffer.ColorKind
  90371. * - VertexBuffer.MatricesIndicesKind
  90372. * - VertexBuffer.MatricesIndicesExtraKind
  90373. * - VertexBuffer.MatricesWeightsKind
  90374. * - VertexBuffer.MatricesWeightsExtraKind
  90375. * @param data defines the data source
  90376. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90377. * @param stride defines the data stride size (can be null)
  90378. * @returns the current mesh
  90379. */
  90380. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90381. /**
  90382. * Flags an associated vertex buffer as updatable
  90383. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90384. * - VertexBuffer.PositionKind
  90385. * - VertexBuffer.UVKind
  90386. * - VertexBuffer.UV2Kind
  90387. * - VertexBuffer.UV3Kind
  90388. * - VertexBuffer.UV4Kind
  90389. * - VertexBuffer.UV5Kind
  90390. * - VertexBuffer.UV6Kind
  90391. * - VertexBuffer.ColorKind
  90392. * - VertexBuffer.MatricesIndicesKind
  90393. * - VertexBuffer.MatricesIndicesExtraKind
  90394. * - VertexBuffer.MatricesWeightsKind
  90395. * - VertexBuffer.MatricesWeightsExtraKind
  90396. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90397. */
  90398. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90399. /**
  90400. * Sets the mesh global Vertex Buffer
  90401. * @param buffer defines the buffer to use
  90402. * @returns the current mesh
  90403. */
  90404. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90405. /**
  90406. * Update a specific associated vertex buffer
  90407. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90408. * - VertexBuffer.PositionKind
  90409. * - VertexBuffer.UVKind
  90410. * - VertexBuffer.UV2Kind
  90411. * - VertexBuffer.UV3Kind
  90412. * - VertexBuffer.UV4Kind
  90413. * - VertexBuffer.UV5Kind
  90414. * - VertexBuffer.UV6Kind
  90415. * - VertexBuffer.ColorKind
  90416. * - VertexBuffer.MatricesIndicesKind
  90417. * - VertexBuffer.MatricesIndicesExtraKind
  90418. * - VertexBuffer.MatricesWeightsKind
  90419. * - VertexBuffer.MatricesWeightsExtraKind
  90420. * @param data defines the data source
  90421. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90422. * @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)
  90423. * @returns the current mesh
  90424. */
  90425. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90426. /**
  90427. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90428. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90429. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90430. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90431. * @returns the current mesh
  90432. */
  90433. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90434. /**
  90435. * Creates a un-shared specific occurence of the geometry for the mesh.
  90436. * @returns the current mesh
  90437. */
  90438. makeGeometryUnique(): Mesh;
  90439. /**
  90440. * Set the index buffer of this mesh
  90441. * @param indices defines the source data
  90442. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90443. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90444. * @returns the current mesh
  90445. */
  90446. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90447. /**
  90448. * Update the current index buffer
  90449. * @param indices defines the source data
  90450. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90451. * @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)
  90452. * @returns the current mesh
  90453. */
  90454. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90455. /**
  90456. * Invert the geometry to move from a right handed system to a left handed one.
  90457. * @returns the current mesh
  90458. */
  90459. toLeftHanded(): Mesh;
  90460. /** @hidden */
  90461. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90462. /** @hidden */
  90463. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90464. /**
  90465. * Registers for this mesh a javascript function called just before the rendering process
  90466. * @param func defines the function to call before rendering this mesh
  90467. * @returns the current mesh
  90468. */
  90469. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90470. /**
  90471. * Disposes a previously registered javascript function called before the rendering
  90472. * @param func defines the function to remove
  90473. * @returns the current mesh
  90474. */
  90475. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90476. /**
  90477. * Registers for this mesh a javascript function called just after the rendering is complete
  90478. * @param func defines the function to call after rendering this mesh
  90479. * @returns the current mesh
  90480. */
  90481. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90482. /**
  90483. * Disposes a previously registered javascript function called after the rendering.
  90484. * @param func defines the function to remove
  90485. * @returns the current mesh
  90486. */
  90487. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90488. /** @hidden */
  90489. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90490. /** @hidden */
  90491. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90492. /** @hidden */
  90493. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90494. /** @hidden */
  90495. _rebuild(): void;
  90496. /** @hidden */
  90497. _freeze(): void;
  90498. /** @hidden */
  90499. _unFreeze(): void;
  90500. /**
  90501. * 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
  90502. * @param subMesh defines the subMesh to render
  90503. * @param enableAlphaMode defines if alpha mode can be changed
  90504. * @returns the current mesh
  90505. */
  90506. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90507. private _onBeforeDraw;
  90508. /**
  90509. * Renormalize the mesh and patch it up if there are no weights
  90510. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90511. * However in the case of zero weights then we set just a single influence to 1.
  90512. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90513. */
  90514. cleanMatrixWeights(): void;
  90515. private normalizeSkinFourWeights;
  90516. private normalizeSkinWeightsAndExtra;
  90517. /**
  90518. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90519. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90520. * the user know there was an issue with importing the mesh
  90521. * @returns a validation object with skinned, valid and report string
  90522. */
  90523. validateSkinning(): {
  90524. skinned: boolean;
  90525. valid: boolean;
  90526. report: string;
  90527. };
  90528. /** @hidden */
  90529. _checkDelayState(): Mesh;
  90530. private _queueLoad;
  90531. /**
  90532. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90533. * A mesh is in the frustum if its bounding box intersects the frustum
  90534. * @param frustumPlanes defines the frustum to test
  90535. * @returns true if the mesh is in the frustum planes
  90536. */
  90537. isInFrustum(frustumPlanes: Plane[]): boolean;
  90538. /**
  90539. * Sets the mesh material by the material or multiMaterial `id` property
  90540. * @param id is a string identifying the material or the multiMaterial
  90541. * @returns the current mesh
  90542. */
  90543. setMaterialByID(id: string): Mesh;
  90544. /**
  90545. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90546. * @returns an array of IAnimatable
  90547. */
  90548. getAnimatables(): IAnimatable[];
  90549. /**
  90550. * Modifies the mesh geometry according to the passed transformation matrix.
  90551. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90552. * The mesh normals are modified using the same transformation.
  90553. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90554. * @param transform defines the transform matrix to use
  90555. * @see http://doc.babylonjs.com/resources/baking_transformations
  90556. * @returns the current mesh
  90557. */
  90558. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90559. /**
  90560. * Modifies the mesh geometry according to its own current World Matrix.
  90561. * The mesh World Matrix is then reset.
  90562. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90563. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90564. * @see http://doc.babylonjs.com/resources/baking_transformations
  90565. * @returns the current mesh
  90566. */
  90567. bakeCurrentTransformIntoVertices(): Mesh;
  90568. /** @hidden */
  90569. readonly _positions: Nullable<Vector3[]>;
  90570. /** @hidden */
  90571. _resetPointsArrayCache(): Mesh;
  90572. /** @hidden */
  90573. _generatePointsArray(): boolean;
  90574. /**
  90575. * Returns a new Mesh object generated from the current mesh properties.
  90576. * This method must not get confused with createInstance()
  90577. * @param name is a string, the name given to the new mesh
  90578. * @param newParent can be any Node object (default `null`)
  90579. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90580. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90581. * @returns a new mesh
  90582. */
  90583. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90584. /**
  90585. * Releases resources associated with this mesh.
  90586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90588. */
  90589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90590. /**
  90591. * Modifies the mesh geometry according to a displacement map.
  90592. * 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.
  90593. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90594. * @param url is a string, the URL from the image file is to be downloaded.
  90595. * @param minHeight is the lower limit of the displacement.
  90596. * @param maxHeight is the upper limit of the displacement.
  90597. * @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.
  90598. * @param uvOffset is an optional vector2 used to offset UV.
  90599. * @param uvScale is an optional vector2 used to scale UV.
  90600. * @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.
  90601. * @returns the Mesh.
  90602. */
  90603. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90604. /**
  90605. * Modifies the mesh geometry according to a displacementMap buffer.
  90606. * 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.
  90607. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90608. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90609. * @param heightMapWidth is the width of the buffer image.
  90610. * @param heightMapHeight is the height of the buffer image.
  90611. * @param minHeight is the lower limit of the displacement.
  90612. * @param maxHeight is the upper limit of the displacement.
  90613. * @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.
  90614. * @param uvOffset is an optional vector2 used to offset UV.
  90615. * @param uvScale is an optional vector2 used to scale UV.
  90616. * @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.
  90617. * @returns the Mesh.
  90618. */
  90619. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90620. /**
  90621. * Modify the mesh to get a flat shading rendering.
  90622. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90623. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90624. * @returns current mesh
  90625. */
  90626. convertToFlatShadedMesh(): Mesh;
  90627. /**
  90628. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90629. * In other words, more vertices, no more indices and a single bigger VBO.
  90630. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90631. * @returns current mesh
  90632. */
  90633. convertToUnIndexedMesh(): Mesh;
  90634. /**
  90635. * Inverses facet orientations.
  90636. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90637. * @param flipNormals will also inverts the normals
  90638. * @returns current mesh
  90639. */
  90640. flipFaces(flipNormals?: boolean): Mesh;
  90641. /**
  90642. * Increase the number of facets and hence vertices in a mesh
  90643. * Vertex normals are interpolated from existing vertex normals
  90644. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90645. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90646. */
  90647. increaseVertices(numberPerEdge: number): void;
  90648. /**
  90649. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90650. * This will undo any application of covertToFlatShadedMesh
  90651. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90652. */
  90653. forceSharedVertices(): void;
  90654. /** @hidden */
  90655. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90656. /** @hidden */
  90657. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90658. /**
  90659. * Creates a new InstancedMesh object from the mesh model.
  90660. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90661. * @param name defines the name of the new instance
  90662. * @returns a new InstancedMesh
  90663. */
  90664. createInstance(name: string): InstancedMesh;
  90665. /**
  90666. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90667. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90668. * @returns the current mesh
  90669. */
  90670. synchronizeInstances(): Mesh;
  90671. /**
  90672. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90673. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90674. * This should be used together with the simplification to avoid disappearing triangles.
  90675. * @param successCallback an optional success callback to be called after the optimization finished.
  90676. * @returns the current mesh
  90677. */
  90678. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90679. /**
  90680. * Serialize current mesh
  90681. * @param serializationObject defines the object which will receive the serialization data
  90682. */
  90683. serialize(serializationObject: any): void;
  90684. /** @hidden */
  90685. _syncGeometryWithMorphTargetManager(): void;
  90686. /** @hidden */
  90687. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90688. /**
  90689. * Returns a new Mesh object parsed from the source provided.
  90690. * @param parsedMesh is the source
  90691. * @param scene defines the hosting scene
  90692. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90693. * @returns a new Mesh
  90694. */
  90695. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90696. /**
  90697. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90698. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90699. * @param name defines the name of the mesh to create
  90700. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90701. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90702. * @param closePath creates a seam between the first and the last points of each path of the path array
  90703. * @param offset is taken in account only if the `pathArray` is containing a single path
  90704. * @param scene defines the hosting scene
  90705. * @param updatable defines if the mesh must be flagged as updatable
  90706. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90707. * @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)
  90708. * @returns a new Mesh
  90709. */
  90710. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90711. /**
  90712. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90713. * @param name defines the name of the mesh to create
  90714. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90715. * @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
  90716. * @param scene defines the hosting scene
  90717. * @param updatable defines if the mesh must be flagged as updatable
  90718. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90719. * @returns a new Mesh
  90720. */
  90721. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90722. /**
  90723. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90724. * @param name defines the name of the mesh to create
  90725. * @param size sets the size (float) of each box side (default 1)
  90726. * @param scene defines the hosting scene
  90727. * @param updatable defines if the mesh must be flagged as updatable
  90728. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90729. * @returns a new Mesh
  90730. */
  90731. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90732. /**
  90733. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90734. * @param name defines the name of the mesh to create
  90735. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90736. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90737. * @param scene defines the hosting scene
  90738. * @param updatable defines if the mesh must be flagged as updatable
  90739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90740. * @returns a new Mesh
  90741. */
  90742. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90743. /**
  90744. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90745. * @param name defines the name of the mesh to create
  90746. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90747. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90748. * @param scene defines the hosting scene
  90749. * @returns a new Mesh
  90750. */
  90751. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  90752. /**
  90753. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90754. * @param name defines the name of the mesh to create
  90755. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90756. * @param diameterTop set the top cap diameter (floats, default 1)
  90757. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90758. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90759. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90760. * @param scene defines the hosting scene
  90761. * @param updatable defines if the mesh must be flagged as updatable
  90762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90763. * @returns a new Mesh
  90764. */
  90765. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90766. /**
  90767. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90768. * @param name defines the name of the mesh to create
  90769. * @param diameter sets the diameter size (float) of the torus (default 1)
  90770. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90771. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90772. * @param scene defines the hosting scene
  90773. * @param updatable defines if the mesh must be flagged as updatable
  90774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90775. * @returns a new Mesh
  90776. */
  90777. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90778. /**
  90779. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90780. * @param name defines the name of the mesh to create
  90781. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90782. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90783. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90784. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90785. * @param p the number of windings on X axis (positive integers, default 2)
  90786. * @param q the number of windings on Y axis (positive integers, default 3)
  90787. * @param scene defines the hosting scene
  90788. * @param updatable defines if the mesh must be flagged as updatable
  90789. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90790. * @returns a new Mesh
  90791. */
  90792. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90793. /**
  90794. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90795. * @param name defines the name of the mesh to create
  90796. * @param points is an array successive Vector3
  90797. * @param scene defines the hosting scene
  90798. * @param updatable defines if the mesh must be flagged as updatable
  90799. * @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).
  90800. * @returns a new Mesh
  90801. */
  90802. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90803. /**
  90804. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90805. * @param name defines the name of the mesh to create
  90806. * @param points is an array successive Vector3
  90807. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90808. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90809. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90810. * @param scene defines the hosting scene
  90811. * @param updatable defines if the mesh must be flagged as updatable
  90812. * @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)
  90813. * @returns a new Mesh
  90814. */
  90815. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90816. /**
  90817. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90818. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90819. * 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.
  90820. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90821. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90822. * Remember you can only change the shape positions, not their number when updating a polygon.
  90823. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90824. * @param name defines the name of the mesh to create
  90825. * @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
  90826. * @param scene defines the hosting scene
  90827. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90828. * @param updatable defines if the mesh must be flagged as updatable
  90829. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90830. * @param earcutInjection can be used to inject your own earcut reference
  90831. * @returns a new Mesh
  90832. */
  90833. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90834. /**
  90835. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90836. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90837. * @param name defines the name of the mesh to create
  90838. * @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
  90839. * @param depth defines the height of extrusion
  90840. * @param scene defines the hosting scene
  90841. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90842. * @param updatable defines if the mesh must be flagged as updatable
  90843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90844. * @param earcutInjection can be used to inject your own earcut reference
  90845. * @returns a new Mesh
  90846. */
  90847. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90848. /**
  90849. * Creates an extruded shape mesh.
  90850. * 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
  90851. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90852. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90853. * @param name defines the name of the mesh to create
  90854. * @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
  90855. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90856. * @param scale is the value to scale the shape
  90857. * @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
  90858. * @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
  90859. * @param scene defines the hosting scene
  90860. * @param updatable defines if the mesh must be flagged as updatable
  90861. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90862. * @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)
  90863. * @returns a new Mesh
  90864. */
  90865. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90866. /**
  90867. * Creates an custom extruded shape mesh.
  90868. * The custom extrusion is a parametric shape.
  90869. * It has no predefined shape. Its final shape will depend on the input parameters.
  90870. * Please consider using the same method from the MeshBuilder class instead
  90871. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90872. * @param name defines the name of the mesh to create
  90873. * @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
  90874. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90875. * @param scaleFunction is a custom Javascript function called on each path point
  90876. * @param rotationFunction is a custom Javascript function called on each path point
  90877. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90878. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90879. * @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
  90880. * @param scene defines the hosting scene
  90881. * @param updatable defines if the mesh must be flagged as updatable
  90882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90883. * @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)
  90884. * @returns a new Mesh
  90885. */
  90886. 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;
  90887. /**
  90888. * Creates lathe mesh.
  90889. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90890. * Please consider using the same method from the MeshBuilder class instead
  90891. * @param name defines the name of the mesh to create
  90892. * @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
  90893. * @param radius is the radius value of the lathe
  90894. * @param tessellation is the side number of the lathe.
  90895. * @param scene defines the hosting scene
  90896. * @param updatable defines if the mesh must be flagged as updatable
  90897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90898. * @returns a new Mesh
  90899. */
  90900. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90901. /**
  90902. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90903. * @param name defines the name of the mesh to create
  90904. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90905. * @param scene defines the hosting scene
  90906. * @param updatable defines if the mesh must be flagged as updatable
  90907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90908. * @returns a new Mesh
  90909. */
  90910. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90911. /**
  90912. * Creates a ground mesh.
  90913. * Please consider using the same method from the MeshBuilder class instead
  90914. * @param name defines the name of the mesh to create
  90915. * @param width set the width of the ground
  90916. * @param height set the height of the ground
  90917. * @param subdivisions sets the number of subdivisions per side
  90918. * @param scene defines the hosting scene
  90919. * @param updatable defines if the mesh must be flagged as updatable
  90920. * @returns a new Mesh
  90921. */
  90922. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90923. /**
  90924. * Creates a tiled ground mesh.
  90925. * Please consider using the same method from the MeshBuilder class instead
  90926. * @param name defines the name of the mesh to create
  90927. * @param xmin set the ground minimum X coordinate
  90928. * @param zmin set the ground minimum Y coordinate
  90929. * @param xmax set the ground maximum X coordinate
  90930. * @param zmax set the ground maximum Z coordinate
  90931. * @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
  90932. * @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
  90933. * @param scene defines the hosting scene
  90934. * @param updatable defines if the mesh must be flagged as updatable
  90935. * @returns a new Mesh
  90936. */
  90937. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90938. w: number;
  90939. h: number;
  90940. }, precision: {
  90941. w: number;
  90942. h: number;
  90943. }, scene: Scene, updatable?: boolean): Mesh;
  90944. /**
  90945. * Creates a ground mesh from a height map.
  90946. * Please consider using the same method from the MeshBuilder class instead
  90947. * @see http://doc.babylonjs.com/babylon101/height_map
  90948. * @param name defines the name of the mesh to create
  90949. * @param url sets the URL of the height map image resource
  90950. * @param width set the ground width size
  90951. * @param height set the ground height size
  90952. * @param subdivisions sets the number of subdivision per side
  90953. * @param minHeight is the minimum altitude on the ground
  90954. * @param maxHeight is the maximum altitude on the ground
  90955. * @param scene defines the hosting scene
  90956. * @param updatable defines if the mesh must be flagged as updatable
  90957. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90958. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90959. * @returns a new Mesh
  90960. */
  90961. 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;
  90962. /**
  90963. * Creates a tube mesh.
  90964. * The tube is a parametric shape.
  90965. * It has no predefined shape. Its final shape will depend on the input parameters.
  90966. * Please consider using the same method from the MeshBuilder class instead
  90967. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90968. * @param name defines the name of the mesh to create
  90969. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90970. * @param radius sets the tube radius size
  90971. * @param tessellation is the number of sides on the tubular surface
  90972. * @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
  90973. * @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
  90974. * @param scene defines the hosting scene
  90975. * @param updatable defines if the mesh must be flagged as updatable
  90976. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90977. * @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)
  90978. * @returns a new Mesh
  90979. */
  90980. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90981. (i: number, distance: number): number;
  90982. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90983. /**
  90984. * Creates a polyhedron mesh.
  90985. * Please consider using the same method from the MeshBuilder class instead.
  90986. * * 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
  90987. * * The parameter `size` (positive float, default 1) sets the polygon size
  90988. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90989. * * 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`
  90990. * * 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
  90991. * * 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)`)
  90992. * * 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
  90993. * * 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
  90994. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90995. * * If you create a double-sided mesh, you can choose what parts of 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
  90996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90997. * @param name defines the name of the mesh to create
  90998. * @param options defines the options used to create the mesh
  90999. * @param scene defines the hosting scene
  91000. * @returns a new Mesh
  91001. */
  91002. static CreatePolyhedron(name: string, options: {
  91003. type?: number;
  91004. size?: number;
  91005. sizeX?: number;
  91006. sizeY?: number;
  91007. sizeZ?: number;
  91008. custom?: any;
  91009. faceUV?: Vector4[];
  91010. faceColors?: Color4[];
  91011. updatable?: boolean;
  91012. sideOrientation?: number;
  91013. }, scene: Scene): Mesh;
  91014. /**
  91015. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91016. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91017. * * 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`)
  91018. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91019. * * 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
  91020. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91021. * * If you create a double-sided mesh, you can choose what parts of 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
  91022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91023. * @param name defines the name of the mesh
  91024. * @param options defines the options used to create the mesh
  91025. * @param scene defines the hosting scene
  91026. * @returns a new Mesh
  91027. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91028. */
  91029. static CreateIcoSphere(name: string, options: {
  91030. radius?: number;
  91031. flat?: boolean;
  91032. subdivisions?: number;
  91033. sideOrientation?: number;
  91034. updatable?: boolean;
  91035. }, scene: Scene): Mesh;
  91036. /**
  91037. * Creates a decal mesh.
  91038. * Please consider using the same method from the MeshBuilder class instead.
  91039. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91040. * @param name defines the name of the mesh
  91041. * @param sourceMesh defines the mesh receiving the decal
  91042. * @param position sets the position of the decal in world coordinates
  91043. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91044. * @param size sets the decal scaling
  91045. * @param angle sets the angle to rotate the decal
  91046. * @returns a new Mesh
  91047. */
  91048. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91049. /**
  91050. * Prepare internal position array for software CPU skinning
  91051. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91052. */
  91053. setPositionsForCPUSkinning(): Float32Array;
  91054. /**
  91055. * Prepare internal normal array for software CPU skinning
  91056. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91057. */
  91058. setNormalsForCPUSkinning(): Float32Array;
  91059. /**
  91060. * Updates the vertex buffer by applying transformation from the bones
  91061. * @param skeleton defines the skeleton to apply to current mesh
  91062. * @returns the current mesh
  91063. */
  91064. applySkeleton(skeleton: Skeleton): Mesh;
  91065. /**
  91066. * 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
  91067. * @param meshes defines the list of meshes to scan
  91068. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91069. */
  91070. static MinMax(meshes: AbstractMesh[]): {
  91071. min: Vector3;
  91072. max: Vector3;
  91073. };
  91074. /**
  91075. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91076. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91077. * @returns a vector3
  91078. */
  91079. static Center(meshesOrMinMaxVector: {
  91080. min: Vector3;
  91081. max: Vector3;
  91082. } | AbstractMesh[]): Vector3;
  91083. /**
  91084. * Merge the array of meshes into a single mesh for performance reasons.
  91085. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91086. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91087. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91088. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91089. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91090. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91091. * @returns a new mesh
  91092. */
  91093. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91094. /** @hidden */
  91095. addInstance(instance: InstancedMesh): void;
  91096. /** @hidden */
  91097. removeInstance(instance: InstancedMesh): void;
  91098. }
  91099. }
  91100. declare module BABYLON {
  91101. /**
  91102. * This is the base class of all the camera used in the application.
  91103. * @see http://doc.babylonjs.com/features/cameras
  91104. */
  91105. export class Camera extends Node {
  91106. /** @hidden */
  91107. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91108. /**
  91109. * This is the default projection mode used by the cameras.
  91110. * It helps recreating a feeling of perspective and better appreciate depth.
  91111. * This is the best way to simulate real life cameras.
  91112. */
  91113. static readonly PERSPECTIVE_CAMERA: number;
  91114. /**
  91115. * This helps creating camera with an orthographic mode.
  91116. * 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.
  91117. */
  91118. static readonly ORTHOGRAPHIC_CAMERA: number;
  91119. /**
  91120. * This is the default FOV mode for perspective cameras.
  91121. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91122. */
  91123. static readonly FOVMODE_VERTICAL_FIXED: number;
  91124. /**
  91125. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91126. */
  91127. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91128. /**
  91129. * This specifies ther is no need for a camera rig.
  91130. * Basically only one eye is rendered corresponding to the camera.
  91131. */
  91132. static readonly RIG_MODE_NONE: number;
  91133. /**
  91134. * Simulates a camera Rig with one blue eye and one red eye.
  91135. * This can be use with 3d blue and red glasses.
  91136. */
  91137. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91138. /**
  91139. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91140. */
  91141. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91142. /**
  91143. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91144. */
  91145. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91146. /**
  91147. * Defines that both eyes of the camera will be rendered over under each other.
  91148. */
  91149. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91150. /**
  91151. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91152. */
  91153. static readonly RIG_MODE_VR: number;
  91154. /**
  91155. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91156. */
  91157. static readonly RIG_MODE_WEBVR: number;
  91158. /**
  91159. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91160. */
  91161. static readonly RIG_MODE_CUSTOM: number;
  91162. /**
  91163. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91164. */
  91165. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91166. /**
  91167. * Define the input manager associated with the camera.
  91168. */
  91169. inputs: CameraInputsManager<Camera>;
  91170. /** @hidden */
  91171. _position: Vector3;
  91172. /**
  91173. * Define the current local position of the camera in the scene
  91174. */
  91175. position: Vector3;
  91176. /**
  91177. * The vector the camera should consider as up.
  91178. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91179. */
  91180. upVector: Vector3;
  91181. /**
  91182. * Define the current limit on the left side for an orthographic camera
  91183. * In scene unit
  91184. */
  91185. orthoLeft: Nullable<number>;
  91186. /**
  91187. * Define the current limit on the right side for an orthographic camera
  91188. * In scene unit
  91189. */
  91190. orthoRight: Nullable<number>;
  91191. /**
  91192. * Define the current limit on the bottom side for an orthographic camera
  91193. * In scene unit
  91194. */
  91195. orthoBottom: Nullable<number>;
  91196. /**
  91197. * Define the current limit on the top side for an orthographic camera
  91198. * In scene unit
  91199. */
  91200. orthoTop: Nullable<number>;
  91201. /**
  91202. * Field Of View is set in Radians. (default is 0.8)
  91203. */
  91204. fov: number;
  91205. /**
  91206. * Define the minimum distance the camera can see from.
  91207. * This is important to note that the depth buffer are not infinite and the closer it starts
  91208. * the more your scene might encounter depth fighting issue.
  91209. */
  91210. minZ: number;
  91211. /**
  91212. * Define the maximum distance the camera can see to.
  91213. * This is important to note that the depth buffer are not infinite and the further it end
  91214. * the more your scene might encounter depth fighting issue.
  91215. */
  91216. maxZ: number;
  91217. /**
  91218. * Define the default inertia of the camera.
  91219. * This helps giving a smooth feeling to the camera movement.
  91220. */
  91221. inertia: number;
  91222. /**
  91223. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91224. */
  91225. mode: number;
  91226. /**
  91227. * Define wether the camera is intermediate.
  91228. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91229. */
  91230. isIntermediate: boolean;
  91231. /**
  91232. * Define the viewport of the camera.
  91233. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91234. */
  91235. viewport: Viewport;
  91236. /**
  91237. * Restricts the camera to viewing objects with the same layerMask.
  91238. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91239. */
  91240. layerMask: number;
  91241. /**
  91242. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91243. */
  91244. fovMode: number;
  91245. /**
  91246. * Rig mode of the camera.
  91247. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91248. * This is normally controlled byt the camera themselves as internal use.
  91249. */
  91250. cameraRigMode: number;
  91251. /**
  91252. * Defines the distance between both "eyes" in case of a RIG
  91253. */
  91254. interaxialDistance: number;
  91255. /**
  91256. * Defines if stereoscopic rendering is done side by side or over under.
  91257. */
  91258. isStereoscopicSideBySide: boolean;
  91259. /**
  91260. * 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
  91261. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91262. * else in the scene. (Eg. security camera)
  91263. *
  91264. * 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)
  91265. */
  91266. customRenderTargets: RenderTargetTexture[];
  91267. /**
  91268. * When set, the camera will render to this render target instead of the default canvas
  91269. *
  91270. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91271. */
  91272. outputRenderTarget: Nullable<RenderTargetTexture>;
  91273. /**
  91274. * Observable triggered when the camera view matrix has changed.
  91275. */
  91276. onViewMatrixChangedObservable: Observable<Camera>;
  91277. /**
  91278. * Observable triggered when the camera Projection matrix has changed.
  91279. */
  91280. onProjectionMatrixChangedObservable: Observable<Camera>;
  91281. /**
  91282. * Observable triggered when the inputs have been processed.
  91283. */
  91284. onAfterCheckInputsObservable: Observable<Camera>;
  91285. /**
  91286. * Observable triggered when reset has been called and applied to the camera.
  91287. */
  91288. onRestoreStateObservable: Observable<Camera>;
  91289. /** @hidden */
  91290. _cameraRigParams: any;
  91291. /** @hidden */
  91292. _rigCameras: Camera[];
  91293. /** @hidden */
  91294. _rigPostProcess: Nullable<PostProcess>;
  91295. protected _webvrViewMatrix: Matrix;
  91296. /** @hidden */
  91297. _skipRendering: boolean;
  91298. /** @hidden */
  91299. _projectionMatrix: Matrix;
  91300. /** @hidden */
  91301. _postProcesses: Nullable<PostProcess>[];
  91302. /** @hidden */
  91303. _activeMeshes: SmartArray<AbstractMesh>;
  91304. protected _globalPosition: Vector3;
  91305. /** @hidden */
  91306. _computedViewMatrix: Matrix;
  91307. private _doNotComputeProjectionMatrix;
  91308. private _transformMatrix;
  91309. private _frustumPlanes;
  91310. private _refreshFrustumPlanes;
  91311. private _storedFov;
  91312. private _stateStored;
  91313. /**
  91314. * Instantiates a new camera object.
  91315. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91316. * @see http://doc.babylonjs.com/features/cameras
  91317. * @param name Defines the name of the camera in the scene
  91318. * @param position Defines the position of the camera
  91319. * @param scene Defines the scene the camera belongs too
  91320. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91321. */
  91322. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91323. /**
  91324. * Store current camera state (fov, position, etc..)
  91325. * @returns the camera
  91326. */
  91327. storeState(): Camera;
  91328. /**
  91329. * Restores the camera state values if it has been stored. You must call storeState() first
  91330. */
  91331. protected _restoreStateValues(): boolean;
  91332. /**
  91333. * Restored camera state. You must call storeState() first.
  91334. * @returns true if restored and false otherwise
  91335. */
  91336. restoreState(): boolean;
  91337. /**
  91338. * Gets the class name of the camera.
  91339. * @returns the class name
  91340. */
  91341. getClassName(): string;
  91342. /** @hidden */
  91343. readonly _isCamera: boolean;
  91344. /**
  91345. * Gets a string representation of the camera useful for debug purpose.
  91346. * @param fullDetails Defines that a more verboe level of logging is required
  91347. * @returns the string representation
  91348. */
  91349. toString(fullDetails?: boolean): string;
  91350. /**
  91351. * Gets the current world space position of the camera.
  91352. */
  91353. readonly globalPosition: Vector3;
  91354. /**
  91355. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91356. * @returns the active meshe list
  91357. */
  91358. getActiveMeshes(): SmartArray<AbstractMesh>;
  91359. /**
  91360. * Check wether a mesh is part of the current active mesh list of the camera
  91361. * @param mesh Defines the mesh to check
  91362. * @returns true if active, false otherwise
  91363. */
  91364. isActiveMesh(mesh: Mesh): boolean;
  91365. /**
  91366. * Is this camera ready to be used/rendered
  91367. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91368. * @return true if the camera is ready
  91369. */
  91370. isReady(completeCheck?: boolean): boolean;
  91371. /** @hidden */
  91372. _initCache(): void;
  91373. /** @hidden */
  91374. _updateCache(ignoreParentClass?: boolean): void;
  91375. /** @hidden */
  91376. _isSynchronized(): boolean;
  91377. /** @hidden */
  91378. _isSynchronizedViewMatrix(): boolean;
  91379. /** @hidden */
  91380. _isSynchronizedProjectionMatrix(): boolean;
  91381. /**
  91382. * Attach the input controls to a specific dom element to get the input from.
  91383. * @param element Defines the element the controls should be listened from
  91384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91385. */
  91386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91387. /**
  91388. * Detach the current controls from the specified dom element.
  91389. * @param element Defines the element to stop listening the inputs from
  91390. */
  91391. detachControl(element: HTMLElement): void;
  91392. /**
  91393. * Update the camera state according to the different inputs gathered during the frame.
  91394. */
  91395. update(): void;
  91396. /** @hidden */
  91397. _checkInputs(): void;
  91398. /** @hidden */
  91399. readonly rigCameras: Camera[];
  91400. /**
  91401. * Gets the post process used by the rig cameras
  91402. */
  91403. readonly rigPostProcess: Nullable<PostProcess>;
  91404. /**
  91405. * Internal, gets the first post proces.
  91406. * @returns the first post process to be run on this camera.
  91407. */
  91408. _getFirstPostProcess(): Nullable<PostProcess>;
  91409. private _cascadePostProcessesToRigCams;
  91410. /**
  91411. * Attach a post process to the camera.
  91412. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91413. * @param postProcess The post process to attach to the camera
  91414. * @param insertAt The position of the post process in case several of them are in use in the scene
  91415. * @returns the position the post process has been inserted at
  91416. */
  91417. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91418. /**
  91419. * Detach a post process to the camera.
  91420. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91421. * @param postProcess The post process to detach from the camera
  91422. */
  91423. detachPostProcess(postProcess: PostProcess): void;
  91424. /**
  91425. * Gets the current world matrix of the camera
  91426. */
  91427. getWorldMatrix(): Matrix;
  91428. /** @hidden */
  91429. _getViewMatrix(): Matrix;
  91430. /**
  91431. * Gets the current view matrix of the camera.
  91432. * @param force forces the camera to recompute the matrix without looking at the cached state
  91433. * @returns the view matrix
  91434. */
  91435. getViewMatrix(force?: boolean): Matrix;
  91436. /**
  91437. * Freeze the projection matrix.
  91438. * It will prevent the cache check of the camera projection compute and can speed up perf
  91439. * if no parameter of the camera are meant to change
  91440. * @param projection Defines manually a projection if necessary
  91441. */
  91442. freezeProjectionMatrix(projection?: Matrix): void;
  91443. /**
  91444. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91445. */
  91446. unfreezeProjectionMatrix(): void;
  91447. /**
  91448. * Gets the current projection matrix of the camera.
  91449. * @param force forces the camera to recompute the matrix without looking at the cached state
  91450. * @returns the projection matrix
  91451. */
  91452. getProjectionMatrix(force?: boolean): Matrix;
  91453. /**
  91454. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91455. * @returns a Matrix
  91456. */
  91457. getTransformationMatrix(): Matrix;
  91458. private _updateFrustumPlanes;
  91459. /**
  91460. * Checks if a cullable object (mesh...) is in the camera frustum
  91461. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91462. * @param target The object to check
  91463. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91464. * @returns true if the object is in frustum otherwise false
  91465. */
  91466. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91467. /**
  91468. * Checks if a cullable object (mesh...) is in the camera frustum
  91469. * Unlike isInFrustum this cheks the full bounding box
  91470. * @param target The object to check
  91471. * @returns true if the object is in frustum otherwise false
  91472. */
  91473. isCompletelyInFrustum(target: ICullable): boolean;
  91474. /**
  91475. * Gets a ray in the forward direction from the camera.
  91476. * @param length Defines the length of the ray to create
  91477. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91478. * @param origin Defines the start point of the ray which defaults to the camera position
  91479. * @returns the forward ray
  91480. */
  91481. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91482. /**
  91483. * Releases resources associated with this node.
  91484. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91485. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91486. */
  91487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91488. /** @hidden */
  91489. _isLeftCamera: boolean;
  91490. /**
  91491. * Gets the left camera of a rig setup in case of Rigged Camera
  91492. */
  91493. readonly isLeftCamera: boolean;
  91494. /** @hidden */
  91495. _isRightCamera: boolean;
  91496. /**
  91497. * Gets the right camera of a rig setup in case of Rigged Camera
  91498. */
  91499. readonly isRightCamera: boolean;
  91500. /**
  91501. * Gets the left camera of a rig setup in case of Rigged Camera
  91502. */
  91503. readonly leftCamera: Nullable<FreeCamera>;
  91504. /**
  91505. * Gets the right camera of a rig setup in case of Rigged Camera
  91506. */
  91507. readonly rightCamera: Nullable<FreeCamera>;
  91508. /**
  91509. * Gets the left camera target of a rig setup in case of Rigged Camera
  91510. * @returns the target position
  91511. */
  91512. getLeftTarget(): Nullable<Vector3>;
  91513. /**
  91514. * Gets the right camera target of a rig setup in case of Rigged Camera
  91515. * @returns the target position
  91516. */
  91517. getRightTarget(): Nullable<Vector3>;
  91518. /**
  91519. * @hidden
  91520. */
  91521. setCameraRigMode(mode: number, rigParams: any): void;
  91522. /** @hidden */
  91523. static _setStereoscopicRigMode(camera: Camera): void;
  91524. /** @hidden */
  91525. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91526. /** @hidden */
  91527. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91528. /** @hidden */
  91529. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91530. /** @hidden */
  91531. _getVRProjectionMatrix(): Matrix;
  91532. protected _updateCameraRotationMatrix(): void;
  91533. protected _updateWebVRCameraRotationMatrix(): void;
  91534. /**
  91535. * This function MUST be overwritten by the different WebVR cameras available.
  91536. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91537. * @hidden
  91538. */
  91539. _getWebVRProjectionMatrix(): Matrix;
  91540. /**
  91541. * This function MUST be overwritten by the different WebVR cameras available.
  91542. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91543. * @hidden
  91544. */
  91545. _getWebVRViewMatrix(): Matrix;
  91546. /** @hidden */
  91547. setCameraRigParameter(name: string, value: any): void;
  91548. /**
  91549. * needs to be overridden by children so sub has required properties to be copied
  91550. * @hidden
  91551. */
  91552. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91553. /**
  91554. * May need to be overridden by children
  91555. * @hidden
  91556. */
  91557. _updateRigCameras(): void;
  91558. /** @hidden */
  91559. _setupInputs(): void;
  91560. /**
  91561. * Serialiaze the camera setup to a json represention
  91562. * @returns the JSON representation
  91563. */
  91564. serialize(): any;
  91565. /**
  91566. * Clones the current camera.
  91567. * @param name The cloned camera name
  91568. * @returns the cloned camera
  91569. */
  91570. clone(name: string): Camera;
  91571. /**
  91572. * Gets the direction of the camera relative to a given local axis.
  91573. * @param localAxis Defines the reference axis to provide a relative direction.
  91574. * @return the direction
  91575. */
  91576. getDirection(localAxis: Vector3): Vector3;
  91577. /**
  91578. * Returns the current camera absolute rotation
  91579. */
  91580. readonly absoluteRotation: Quaternion;
  91581. /**
  91582. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91583. * @param localAxis Defines the reference axis to provide a relative direction.
  91584. * @param result Defines the vector to store the result in
  91585. */
  91586. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91587. /**
  91588. * Gets a camera constructor for a given camera type
  91589. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91590. * @param name The name of the camera the result will be able to instantiate
  91591. * @param scene The scene the result will construct the camera in
  91592. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91593. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91594. * @returns a factory method to construc the camera
  91595. */
  91596. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91597. /**
  91598. * Compute the world matrix of the camera.
  91599. * @returns the camera workd matrix
  91600. */
  91601. computeWorldMatrix(): Matrix;
  91602. /**
  91603. * Parse a JSON and creates the camera from the parsed information
  91604. * @param parsedCamera The JSON to parse
  91605. * @param scene The scene to instantiate the camera in
  91606. * @returns the newly constructed camera
  91607. */
  91608. static Parse(parsedCamera: any, scene: Scene): Camera;
  91609. }
  91610. }
  91611. declare module BABYLON {
  91612. /**
  91613. * Class containing static functions to help procedurally build meshes
  91614. */
  91615. export class DiscBuilder {
  91616. /**
  91617. * Creates a plane polygonal mesh. By default, this is a disc
  91618. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91619. * * 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
  91620. * * 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
  91621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91624. * @param name defines the name of the mesh
  91625. * @param options defines the options used to create the mesh
  91626. * @param scene defines the hosting scene
  91627. * @returns the plane polygonal mesh
  91628. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91629. */
  91630. static CreateDisc(name: string, options: {
  91631. radius?: number;
  91632. tessellation?: number;
  91633. arc?: number;
  91634. updatable?: boolean;
  91635. sideOrientation?: number;
  91636. frontUVs?: Vector4;
  91637. backUVs?: Vector4;
  91638. }, scene?: Nullable<Scene>): Mesh;
  91639. }
  91640. }
  91641. declare module BABYLON {
  91642. /**
  91643. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91644. *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.
  91645. * The SPS is also a particle system. It provides some methods to manage the particles.
  91646. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91647. *
  91648. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91649. */
  91650. export class SolidParticleSystem implements IDisposable {
  91651. /**
  91652. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91653. * Example : var p = SPS.particles[i];
  91654. */
  91655. particles: SolidParticle[];
  91656. /**
  91657. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91658. */
  91659. nbParticles: number;
  91660. /**
  91661. * If the particles must ever face the camera (default false). Useful for planar particles.
  91662. */
  91663. billboard: boolean;
  91664. /**
  91665. * Recompute normals when adding a shape
  91666. */
  91667. recomputeNormals: boolean;
  91668. /**
  91669. * This a counter ofr your own usage. It's not set by any SPS functions.
  91670. */
  91671. counter: number;
  91672. /**
  91673. * The SPS name. This name is also given to the underlying mesh.
  91674. */
  91675. name: string;
  91676. /**
  91677. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91678. */
  91679. mesh: Mesh;
  91680. /**
  91681. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91682. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91683. */
  91684. vars: any;
  91685. /**
  91686. * This array is populated when the SPS is set as 'pickable'.
  91687. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91688. * Each element of this array is an object `{idx: int, faceId: int}`.
  91689. * `idx` is the picked particle index in the `SPS.particles` array
  91690. * `faceId` is the picked face index counted within this particle.
  91691. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91692. */
  91693. pickedParticles: {
  91694. idx: number;
  91695. faceId: number;
  91696. }[];
  91697. /**
  91698. * This array is populated when `enableDepthSort` is set to true.
  91699. * Each element of this array is an instance of the class DepthSortedParticle.
  91700. */
  91701. depthSortedParticles: DepthSortedParticle[];
  91702. /**
  91703. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  91704. * @hidden
  91705. */
  91706. _bSphereOnly: boolean;
  91707. /**
  91708. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  91709. * @hidden
  91710. */
  91711. _bSphereRadiusFactor: number;
  91712. private _scene;
  91713. private _positions;
  91714. private _indices;
  91715. private _normals;
  91716. private _colors;
  91717. private _uvs;
  91718. private _indices32;
  91719. private _positions32;
  91720. private _normals32;
  91721. private _fixedNormal32;
  91722. private _colors32;
  91723. private _uvs32;
  91724. private _index;
  91725. private _updatable;
  91726. private _pickable;
  91727. private _isVisibilityBoxLocked;
  91728. private _alwaysVisible;
  91729. private _depthSort;
  91730. private _shapeCounter;
  91731. private _copy;
  91732. private _color;
  91733. private _computeParticleColor;
  91734. private _computeParticleTexture;
  91735. private _computeParticleRotation;
  91736. private _computeParticleVertex;
  91737. private _computeBoundingBox;
  91738. private _depthSortParticles;
  91739. private _camera;
  91740. private _mustUnrotateFixedNormals;
  91741. private _particlesIntersect;
  91742. private _needs32Bits;
  91743. /**
  91744. * Creates a SPS (Solid Particle System) object.
  91745. * @param name (String) is the SPS name, this will be the underlying mesh name.
  91746. * @param scene (Scene) is the scene in which the SPS is added.
  91747. * @param options defines the options of the sps e.g.
  91748. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  91749. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  91750. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  91751. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  91752. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  91753. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  91754. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  91755. */
  91756. constructor(name: string, scene: Scene, options?: {
  91757. updatable?: boolean;
  91758. isPickable?: boolean;
  91759. enableDepthSort?: boolean;
  91760. particleIntersection?: boolean;
  91761. boundingSphereOnly?: boolean;
  91762. bSphereRadiusFactor?: number;
  91763. });
  91764. /**
  91765. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91766. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91767. * @returns the created mesh
  91768. */
  91769. buildMesh(): Mesh;
  91770. /**
  91771. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91772. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91773. * Thus the particles generated from `digest()` have their property `position` set yet.
  91774. * @param mesh ( Mesh ) is the mesh to be digested
  91775. * @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
  91776. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91777. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91778. * @returns the current SPS
  91779. */
  91780. digest(mesh: Mesh, options?: {
  91781. facetNb?: number;
  91782. number?: number;
  91783. delta?: number;
  91784. }): SolidParticleSystem;
  91785. private _unrotateFixedNormals;
  91786. private _resetCopy;
  91787. private _meshBuilder;
  91788. private _posToShape;
  91789. private _uvsToShapeUV;
  91790. private _addParticle;
  91791. /**
  91792. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91793. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91794. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91795. * @param nb (positive integer) the number of particles to be created from this model
  91796. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91797. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91798. * @returns the number of shapes in the system
  91799. */
  91800. addShape(mesh: Mesh, nb: number, options?: {
  91801. positionFunction?: any;
  91802. vertexFunction?: any;
  91803. }): number;
  91804. private _rebuildParticle;
  91805. /**
  91806. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91807. * @returns the SPS.
  91808. */
  91809. rebuildMesh(): SolidParticleSystem;
  91810. /**
  91811. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91812. * This method calls `updateParticle()` for each particle of the SPS.
  91813. * For an animated SPS, it is usually called within the render loop.
  91814. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91815. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91816. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91817. * @returns the SPS.
  91818. */
  91819. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91820. /**
  91821. * Disposes the SPS.
  91822. */
  91823. dispose(): void;
  91824. /**
  91825. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91826. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91827. * @returns the SPS.
  91828. */
  91829. refreshVisibleSize(): SolidParticleSystem;
  91830. /**
  91831. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91832. * @param size the size (float) of the visibility box
  91833. * note : this doesn't lock the SPS mesh bounding box.
  91834. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91835. */
  91836. setVisibilityBox(size: number): void;
  91837. /**
  91838. * Gets whether the SPS as always visible or not
  91839. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91840. */
  91841. /**
  91842. * Sets the SPS as always visible or not
  91843. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91844. */
  91845. isAlwaysVisible: boolean;
  91846. /**
  91847. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91848. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91849. */
  91850. /**
  91851. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91852. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91853. */
  91854. isVisibilityBoxLocked: boolean;
  91855. /**
  91856. * Tells to `setParticles()` to compute the particle rotations or not.
  91857. * Default value : true. The SPS is faster when it's set to false.
  91858. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91859. */
  91860. /**
  91861. * Gets if `setParticles()` computes the particle rotations or not.
  91862. * Default value : true. The SPS is faster when it's set to false.
  91863. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91864. */
  91865. computeParticleRotation: boolean;
  91866. /**
  91867. * Tells to `setParticles()` to compute the particle colors or not.
  91868. * Default value : true. The SPS is faster when it's set to false.
  91869. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91870. */
  91871. /**
  91872. * Gets if `setParticles()` computes the particle colors or not.
  91873. * Default value : true. The SPS is faster when it's set to false.
  91874. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91875. */
  91876. computeParticleColor: boolean;
  91877. /**
  91878. * Gets if `setParticles()` computes the particle textures or not.
  91879. * Default value : true. The SPS is faster when it's set to false.
  91880. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91881. */
  91882. computeParticleTexture: boolean;
  91883. /**
  91884. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91885. * Default value : false. The SPS is faster when it's set to false.
  91886. * Note : the particle custom vertex positions aren't stored values.
  91887. */
  91888. /**
  91889. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91890. * Default value : false. The SPS is faster when it's set to false.
  91891. * Note : the particle custom vertex positions aren't stored values.
  91892. */
  91893. computeParticleVertex: boolean;
  91894. /**
  91895. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91896. */
  91897. /**
  91898. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91899. */
  91900. computeBoundingBox: boolean;
  91901. /**
  91902. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91903. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91904. * Default : `true`
  91905. */
  91906. /**
  91907. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91908. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91909. * Default : `true`
  91910. */
  91911. depthSortParticles: boolean;
  91912. /**
  91913. * This function does nothing. It may be overwritten to set all the particle first values.
  91914. * The SPS doesn't call this function, you may have to call it by your own.
  91915. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91916. */
  91917. initParticles(): void;
  91918. /**
  91919. * This function does nothing. It may be overwritten to recycle a particle.
  91920. * The SPS doesn't call this function, you may have to call it by your own.
  91921. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91922. * @param particle The particle to recycle
  91923. * @returns the recycled particle
  91924. */
  91925. recycleParticle(particle: SolidParticle): SolidParticle;
  91926. /**
  91927. * Updates a particle : this function should be overwritten by the user.
  91928. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91929. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91930. * @example : just set a particle position or velocity and recycle conditions
  91931. * @param particle The particle to update
  91932. * @returns the updated particle
  91933. */
  91934. updateParticle(particle: SolidParticle): SolidParticle;
  91935. /**
  91936. * Updates a vertex of a particle : it can be overwritten by the user.
  91937. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91938. * @param particle the current particle
  91939. * @param vertex the current index of the current particle
  91940. * @param pt the index of the current vertex in the particle shape
  91941. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91942. * @example : just set a vertex particle position
  91943. * @returns the updated vertex
  91944. */
  91945. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91946. /**
  91947. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91948. * This does nothing and may be overwritten by the user.
  91949. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91950. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91951. * @param update the boolean update value actually passed to setParticles()
  91952. */
  91953. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91954. /**
  91955. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91956. * This will be passed three parameters.
  91957. * This does nothing and may be overwritten by the user.
  91958. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91959. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91960. * @param update the boolean update value actually passed to setParticles()
  91961. */
  91962. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91963. }
  91964. }
  91965. declare module BABYLON {
  91966. /**
  91967. * Represents one particle of a solid particle system.
  91968. */
  91969. export class SolidParticle {
  91970. /**
  91971. * particle global index
  91972. */
  91973. idx: number;
  91974. /**
  91975. * The color of the particle
  91976. */
  91977. color: Nullable<Color4>;
  91978. /**
  91979. * The world space position of the particle.
  91980. */
  91981. position: Vector3;
  91982. /**
  91983. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91984. */
  91985. rotation: Vector3;
  91986. /**
  91987. * The world space rotation quaternion of the particle.
  91988. */
  91989. rotationQuaternion: Nullable<Quaternion>;
  91990. /**
  91991. * The scaling of the particle.
  91992. */
  91993. scaling: Vector3;
  91994. /**
  91995. * The uvs of the particle.
  91996. */
  91997. uvs: Vector4;
  91998. /**
  91999. * The current speed of the particle.
  92000. */
  92001. velocity: Vector3;
  92002. /**
  92003. * The pivot point in the particle local space.
  92004. */
  92005. pivot: Vector3;
  92006. /**
  92007. * Must the particle be translated from its pivot point in its local space ?
  92008. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92009. * Default : false
  92010. */
  92011. translateFromPivot: boolean;
  92012. /**
  92013. * Is the particle active or not ?
  92014. */
  92015. alive: boolean;
  92016. /**
  92017. * Is the particle visible or not ?
  92018. */
  92019. isVisible: boolean;
  92020. /**
  92021. * Index of this particle in the global "positions" array (Internal use)
  92022. * @hidden
  92023. */
  92024. _pos: number;
  92025. /**
  92026. * @hidden Index of this particle in the global "indices" array (Internal use)
  92027. */
  92028. _ind: number;
  92029. /**
  92030. * @hidden ModelShape of this particle (Internal use)
  92031. */
  92032. _model: ModelShape;
  92033. /**
  92034. * ModelShape id of this particle
  92035. */
  92036. shapeId: number;
  92037. /**
  92038. * Index of the particle in its shape id
  92039. */
  92040. idxInShape: number;
  92041. /**
  92042. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92043. */
  92044. _modelBoundingInfo: BoundingInfo;
  92045. /**
  92046. * @hidden Particle BoundingInfo object (Internal use)
  92047. */
  92048. _boundingInfo: BoundingInfo;
  92049. /**
  92050. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92051. */
  92052. _sps: SolidParticleSystem;
  92053. /**
  92054. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92055. */
  92056. _stillInvisible: boolean;
  92057. /**
  92058. * @hidden Last computed particle rotation matrix
  92059. */
  92060. _rotationMatrix: number[];
  92061. /**
  92062. * Parent particle Id, if any.
  92063. * Default null.
  92064. */
  92065. parentId: Nullable<number>;
  92066. /**
  92067. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92068. * The possible values are :
  92069. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92070. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92071. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92072. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92073. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92074. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92075. * */
  92076. cullingStrategy: number;
  92077. /**
  92078. * @hidden Internal global position in the SPS.
  92079. */
  92080. _globalPosition: Vector3;
  92081. /**
  92082. * Creates a Solid Particle object.
  92083. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92084. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92085. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92086. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92087. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92088. * @param shapeId (integer) is the model shape identifier in the SPS.
  92089. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92090. * @param sps defines the sps it is associated to
  92091. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92092. */
  92093. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92094. /**
  92095. * Legacy support, changed scale to scaling
  92096. */
  92097. /**
  92098. * Legacy support, changed scale to scaling
  92099. */
  92100. scale: Vector3;
  92101. /**
  92102. * Legacy support, changed quaternion to rotationQuaternion
  92103. */
  92104. /**
  92105. * Legacy support, changed quaternion to rotationQuaternion
  92106. */
  92107. quaternion: Nullable<Quaternion>;
  92108. /**
  92109. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92110. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92111. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92112. * @returns true if it intersects
  92113. */
  92114. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92115. /**
  92116. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92117. * A particle is in the frustum if its bounding box intersects the frustum
  92118. * @param frustumPlanes defines the frustum to test
  92119. * @returns true if the particle is in the frustum planes
  92120. */
  92121. isInFrustum(frustumPlanes: Plane[]): boolean;
  92122. /**
  92123. * get the rotation matrix of the particle
  92124. * @hidden
  92125. */
  92126. getRotationMatrix(m: Matrix): void;
  92127. }
  92128. /**
  92129. * Represents the shape of the model used by one particle of a solid particle system.
  92130. * SPS internal tool, don't use it manually.
  92131. */
  92132. export class ModelShape {
  92133. /**
  92134. * The shape id
  92135. * @hidden
  92136. */
  92137. shapeID: number;
  92138. /**
  92139. * flat array of model positions (internal use)
  92140. * @hidden
  92141. */
  92142. _shape: Vector3[];
  92143. /**
  92144. * flat array of model UVs (internal use)
  92145. * @hidden
  92146. */
  92147. _shapeUV: number[];
  92148. /**
  92149. * length of the shape in the model indices array (internal use)
  92150. * @hidden
  92151. */
  92152. _indicesLength: number;
  92153. /**
  92154. * Custom position function (internal use)
  92155. * @hidden
  92156. */
  92157. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92158. /**
  92159. * Custom vertex function (internal use)
  92160. * @hidden
  92161. */
  92162. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92163. /**
  92164. * 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.
  92165. * SPS internal tool, don't use it manually.
  92166. * @hidden
  92167. */
  92168. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  92169. }
  92170. /**
  92171. * Represents a Depth Sorted Particle in the solid particle system.
  92172. */
  92173. export class DepthSortedParticle {
  92174. /**
  92175. * Index of the particle in the "indices" array
  92176. */
  92177. ind: number;
  92178. /**
  92179. * Length of the particle shape in the "indices" array
  92180. */
  92181. indicesLength: number;
  92182. /**
  92183. * Squared distance from the particle to the camera
  92184. */
  92185. sqDistance: number;
  92186. }
  92187. }
  92188. declare module BABYLON {
  92189. /**
  92190. * @hidden
  92191. */
  92192. export class _MeshCollisionData {
  92193. _checkCollisions: boolean;
  92194. _collisionMask: number;
  92195. _collisionGroup: number;
  92196. _collider: Nullable<Collider>;
  92197. _oldPositionForCollisions: Vector3;
  92198. _diffPositionForCollisions: Vector3;
  92199. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92200. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92201. }
  92202. }
  92203. declare module BABYLON {
  92204. /** @hidden */
  92205. class _FacetDataStorage {
  92206. facetPositions: Vector3[];
  92207. facetNormals: Vector3[];
  92208. facetPartitioning: number[][];
  92209. facetNb: number;
  92210. partitioningSubdivisions: number;
  92211. partitioningBBoxRatio: number;
  92212. facetDataEnabled: boolean;
  92213. facetParameters: any;
  92214. bbSize: Vector3;
  92215. subDiv: {
  92216. max: number;
  92217. X: number;
  92218. Y: number;
  92219. Z: number;
  92220. };
  92221. facetDepthSort: boolean;
  92222. facetDepthSortEnabled: boolean;
  92223. depthSortedIndices: IndicesArray;
  92224. depthSortedFacets: {
  92225. ind: number;
  92226. sqDistance: number;
  92227. }[];
  92228. facetDepthSortFunction: (f1: {
  92229. ind: number;
  92230. sqDistance: number;
  92231. }, f2: {
  92232. ind: number;
  92233. sqDistance: number;
  92234. }) => number;
  92235. facetDepthSortFrom: Vector3;
  92236. facetDepthSortOrigin: Vector3;
  92237. invertedMatrix: Matrix;
  92238. }
  92239. /**
  92240. * @hidden
  92241. **/
  92242. class _InternalAbstractMeshDataInfo {
  92243. _hasVertexAlpha: boolean;
  92244. _useVertexColors: boolean;
  92245. _numBoneInfluencers: number;
  92246. _applyFog: boolean;
  92247. _receiveShadows: boolean;
  92248. _facetData: _FacetDataStorage;
  92249. _visibility: number;
  92250. _skeleton: Nullable<Skeleton>;
  92251. _layerMask: number;
  92252. _computeBonesUsingShaders: boolean;
  92253. _isActive: boolean;
  92254. _onlyForInstances: boolean;
  92255. _isActiveIntermediate: boolean;
  92256. _onlyForInstancesIntermediate: boolean;
  92257. }
  92258. /**
  92259. * Class used to store all common mesh properties
  92260. */
  92261. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92262. /** No occlusion */
  92263. static OCCLUSION_TYPE_NONE: number;
  92264. /** Occlusion set to optimisitic */
  92265. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92266. /** Occlusion set to strict */
  92267. static OCCLUSION_TYPE_STRICT: number;
  92268. /** Use an accurante occlusion algorithm */
  92269. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92270. /** Use a conservative occlusion algorithm */
  92271. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92272. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92273. * Test order :
  92274. * Is the bounding sphere outside the frustum ?
  92275. * If not, are the bounding box vertices outside the frustum ?
  92276. * It not, then the cullable object is in the frustum.
  92277. */
  92278. static readonly CULLINGSTRATEGY_STANDARD: number;
  92279. /** Culling strategy : Bounding Sphere Only.
  92280. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92281. * It's also less accurate than the standard because some not visible objects can still be selected.
  92282. * Test : is the bounding sphere outside the frustum ?
  92283. * If not, then the cullable object is in the frustum.
  92284. */
  92285. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92286. /** Culling strategy : Optimistic Inclusion.
  92287. * This in an inclusion test first, then the standard exclusion test.
  92288. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92289. * 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.
  92290. * Anyway, it's as accurate as the standard strategy.
  92291. * Test :
  92292. * Is the cullable object bounding sphere center in the frustum ?
  92293. * If not, apply the default culling strategy.
  92294. */
  92295. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92296. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92297. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92298. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92299. * 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.
  92300. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92301. * Test :
  92302. * Is the cullable object bounding sphere center in the frustum ?
  92303. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92304. */
  92305. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92306. /**
  92307. * No billboard
  92308. */
  92309. static readonly BILLBOARDMODE_NONE: number;
  92310. /** Billboard on X axis */
  92311. static readonly BILLBOARDMODE_X: number;
  92312. /** Billboard on Y axis */
  92313. static readonly BILLBOARDMODE_Y: number;
  92314. /** Billboard on Z axis */
  92315. static readonly BILLBOARDMODE_Z: number;
  92316. /** Billboard on all axes */
  92317. static readonly BILLBOARDMODE_ALL: number;
  92318. /** Billboard on using position instead of orientation */
  92319. static readonly BILLBOARDMODE_USE_POSITION: number;
  92320. /** @hidden */
  92321. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92322. /**
  92323. * The culling strategy to use to check whether the mesh must be rendered or not.
  92324. * This value can be changed at any time and will be used on the next render mesh selection.
  92325. * The possible values are :
  92326. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92327. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92328. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92329. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92330. * Please read each static variable documentation to get details about the culling process.
  92331. * */
  92332. cullingStrategy: number;
  92333. /**
  92334. * Gets the number of facets in the mesh
  92335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92336. */
  92337. readonly facetNb: number;
  92338. /**
  92339. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92341. */
  92342. partitioningSubdivisions: number;
  92343. /**
  92344. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92345. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92347. */
  92348. partitioningBBoxRatio: number;
  92349. /**
  92350. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92351. * Works only for updatable meshes.
  92352. * Doesn't work with multi-materials
  92353. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92354. */
  92355. mustDepthSortFacets: boolean;
  92356. /**
  92357. * The location (Vector3) where the facet depth sort must be computed from.
  92358. * By default, the active camera position.
  92359. * Used only when facet depth sort is enabled
  92360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92361. */
  92362. facetDepthSortFrom: Vector3;
  92363. /**
  92364. * gets a boolean indicating if facetData is enabled
  92365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92366. */
  92367. readonly isFacetDataEnabled: boolean;
  92368. /** @hidden */
  92369. _updateNonUniformScalingState(value: boolean): boolean;
  92370. /**
  92371. * An event triggered when this mesh collides with another one
  92372. */
  92373. onCollideObservable: Observable<AbstractMesh>;
  92374. /** Set a function to call when this mesh collides with another one */
  92375. onCollide: () => void;
  92376. /**
  92377. * An event triggered when the collision's position changes
  92378. */
  92379. onCollisionPositionChangeObservable: Observable<Vector3>;
  92380. /** Set a function to call when the collision's position changes */
  92381. onCollisionPositionChange: () => void;
  92382. /**
  92383. * An event triggered when material is changed
  92384. */
  92385. onMaterialChangedObservable: Observable<AbstractMesh>;
  92386. /**
  92387. * Gets or sets the orientation for POV movement & rotation
  92388. */
  92389. definedFacingForward: boolean;
  92390. /** @hidden */
  92391. _occlusionQuery: Nullable<WebGLQuery>;
  92392. /** @hidden */
  92393. _renderingGroup: Nullable<RenderingGroup>;
  92394. /**
  92395. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92396. */
  92397. /**
  92398. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92399. */
  92400. visibility: number;
  92401. /** Gets or sets the alpha index used to sort transparent meshes
  92402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92403. */
  92404. alphaIndex: number;
  92405. /**
  92406. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92407. */
  92408. isVisible: boolean;
  92409. /**
  92410. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92411. */
  92412. isPickable: boolean;
  92413. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92414. showSubMeshesBoundingBox: boolean;
  92415. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92416. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92417. */
  92418. isBlocker: boolean;
  92419. /**
  92420. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92421. */
  92422. enablePointerMoveEvents: boolean;
  92423. /**
  92424. * Specifies the rendering group id for this mesh (0 by default)
  92425. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92426. */
  92427. renderingGroupId: number;
  92428. private _material;
  92429. /** Gets or sets current material */
  92430. material: Nullable<Material>;
  92431. /**
  92432. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92433. * @see http://doc.babylonjs.com/babylon101/shadows
  92434. */
  92435. receiveShadows: boolean;
  92436. /** Defines color to use when rendering outline */
  92437. outlineColor: Color3;
  92438. /** Define width to use when rendering outline */
  92439. outlineWidth: number;
  92440. /** Defines color to use when rendering overlay */
  92441. overlayColor: Color3;
  92442. /** Defines alpha to use when rendering overlay */
  92443. overlayAlpha: number;
  92444. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92445. hasVertexAlpha: boolean;
  92446. /** 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) */
  92447. useVertexColors: boolean;
  92448. /**
  92449. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92450. */
  92451. computeBonesUsingShaders: boolean;
  92452. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92453. numBoneInfluencers: number;
  92454. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92455. applyFog: boolean;
  92456. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92457. useOctreeForRenderingSelection: boolean;
  92458. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92459. useOctreeForPicking: boolean;
  92460. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92461. useOctreeForCollisions: boolean;
  92462. /**
  92463. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92464. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92465. */
  92466. layerMask: number;
  92467. /**
  92468. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92469. */
  92470. alwaysSelectAsActiveMesh: boolean;
  92471. /**
  92472. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92473. */
  92474. doNotSyncBoundingInfo: boolean;
  92475. /**
  92476. * Gets or sets the current action manager
  92477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92478. */
  92479. actionManager: Nullable<AbstractActionManager>;
  92480. private _meshCollisionData;
  92481. /**
  92482. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92483. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92484. */
  92485. ellipsoid: Vector3;
  92486. /**
  92487. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92489. */
  92490. ellipsoidOffset: Vector3;
  92491. /**
  92492. * Gets or sets a collision mask used to mask collisions (default is -1).
  92493. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92494. */
  92495. collisionMask: number;
  92496. /**
  92497. * Gets or sets the current collision group mask (-1 by default).
  92498. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92499. */
  92500. collisionGroup: number;
  92501. /**
  92502. * Defines edge width used when edgesRenderer is enabled
  92503. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92504. */
  92505. edgesWidth: number;
  92506. /**
  92507. * Defines edge color used when edgesRenderer is enabled
  92508. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92509. */
  92510. edgesColor: Color4;
  92511. /** @hidden */
  92512. _edgesRenderer: Nullable<IEdgesRenderer>;
  92513. /** @hidden */
  92514. _masterMesh: Nullable<AbstractMesh>;
  92515. /** @hidden */
  92516. _boundingInfo: Nullable<BoundingInfo>;
  92517. /** @hidden */
  92518. _renderId: number;
  92519. /**
  92520. * Gets or sets the list of subMeshes
  92521. * @see http://doc.babylonjs.com/how_to/multi_materials
  92522. */
  92523. subMeshes: SubMesh[];
  92524. /** @hidden */
  92525. _intersectionsInProgress: AbstractMesh[];
  92526. /** @hidden */
  92527. _unIndexed: boolean;
  92528. /** @hidden */
  92529. _lightSources: Light[];
  92530. /** Gets the list of lights affecting that mesh */
  92531. readonly lightSources: Light[];
  92532. /** @hidden */
  92533. readonly _positions: Nullable<Vector3[]>;
  92534. /** @hidden */
  92535. _waitingData: {
  92536. lods: Nullable<any>;
  92537. actions: Nullable<any>;
  92538. freezeWorldMatrix: Nullable<boolean>;
  92539. };
  92540. /** @hidden */
  92541. _bonesTransformMatrices: Nullable<Float32Array>;
  92542. /** @hidden */
  92543. _transformMatrixTexture: Nullable<RawTexture>;
  92544. /**
  92545. * Gets or sets a skeleton to apply skining transformations
  92546. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92547. */
  92548. skeleton: Nullable<Skeleton>;
  92549. /**
  92550. * An event triggered when the mesh is rebuilt.
  92551. */
  92552. onRebuildObservable: Observable<AbstractMesh>;
  92553. /**
  92554. * Creates a new AbstractMesh
  92555. * @param name defines the name of the mesh
  92556. * @param scene defines the hosting scene
  92557. */
  92558. constructor(name: string, scene?: Nullable<Scene>);
  92559. /**
  92560. * Returns the string "AbstractMesh"
  92561. * @returns "AbstractMesh"
  92562. */
  92563. getClassName(): string;
  92564. /**
  92565. * Gets a string representation of the current mesh
  92566. * @param fullDetails defines a boolean indicating if full details must be included
  92567. * @returns a string representation of the current mesh
  92568. */
  92569. toString(fullDetails?: boolean): string;
  92570. /**
  92571. * @hidden
  92572. */
  92573. protected _getEffectiveParent(): Nullable<Node>;
  92574. /** @hidden */
  92575. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92576. /** @hidden */
  92577. _rebuild(): void;
  92578. /** @hidden */
  92579. _resyncLightSources(): void;
  92580. /** @hidden */
  92581. _resyncLighSource(light: Light): void;
  92582. /** @hidden */
  92583. _unBindEffect(): void;
  92584. /** @hidden */
  92585. _removeLightSource(light: Light, dispose: boolean): void;
  92586. private _markSubMeshesAsDirty;
  92587. /** @hidden */
  92588. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92589. /** @hidden */
  92590. _markSubMeshesAsAttributesDirty(): void;
  92591. /** @hidden */
  92592. _markSubMeshesAsMiscDirty(): void;
  92593. /**
  92594. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92595. */
  92596. scaling: Vector3;
  92597. /**
  92598. * Returns true if the mesh is blocked. Implemented by child classes
  92599. */
  92600. readonly isBlocked: boolean;
  92601. /**
  92602. * Returns the mesh itself by default. Implemented by child classes
  92603. * @param camera defines the camera to use to pick the right LOD level
  92604. * @returns the currentAbstractMesh
  92605. */
  92606. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92607. /**
  92608. * Returns 0 by default. Implemented by child classes
  92609. * @returns an integer
  92610. */
  92611. getTotalVertices(): number;
  92612. /**
  92613. * Returns a positive integer : the total number of indices in this mesh geometry.
  92614. * @returns the numner of indices or zero if the mesh has no geometry.
  92615. */
  92616. getTotalIndices(): number;
  92617. /**
  92618. * Returns null by default. Implemented by child classes
  92619. * @returns null
  92620. */
  92621. getIndices(): Nullable<IndicesArray>;
  92622. /**
  92623. * Returns the array of the requested vertex data kind. Implemented by child classes
  92624. * @param kind defines the vertex data kind to use
  92625. * @returns null
  92626. */
  92627. getVerticesData(kind: string): Nullable<FloatArray>;
  92628. /**
  92629. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92630. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92631. * Note that a new underlying VertexBuffer object is created each call.
  92632. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92633. * @param kind defines vertex data kind:
  92634. * * VertexBuffer.PositionKind
  92635. * * VertexBuffer.UVKind
  92636. * * VertexBuffer.UV2Kind
  92637. * * VertexBuffer.UV3Kind
  92638. * * VertexBuffer.UV4Kind
  92639. * * VertexBuffer.UV5Kind
  92640. * * VertexBuffer.UV6Kind
  92641. * * VertexBuffer.ColorKind
  92642. * * VertexBuffer.MatricesIndicesKind
  92643. * * VertexBuffer.MatricesIndicesExtraKind
  92644. * * VertexBuffer.MatricesWeightsKind
  92645. * * VertexBuffer.MatricesWeightsExtraKind
  92646. * @param data defines the data source
  92647. * @param updatable defines if the data must be flagged as updatable (or static)
  92648. * @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
  92649. * @returns the current mesh
  92650. */
  92651. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92652. /**
  92653. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92654. * If the mesh has no geometry, it is simply returned as it is.
  92655. * @param kind defines vertex data kind:
  92656. * * VertexBuffer.PositionKind
  92657. * * VertexBuffer.UVKind
  92658. * * VertexBuffer.UV2Kind
  92659. * * VertexBuffer.UV3Kind
  92660. * * VertexBuffer.UV4Kind
  92661. * * VertexBuffer.UV5Kind
  92662. * * VertexBuffer.UV6Kind
  92663. * * VertexBuffer.ColorKind
  92664. * * VertexBuffer.MatricesIndicesKind
  92665. * * VertexBuffer.MatricesIndicesExtraKind
  92666. * * VertexBuffer.MatricesWeightsKind
  92667. * * VertexBuffer.MatricesWeightsExtraKind
  92668. * @param data defines the data source
  92669. * @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
  92670. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92671. * @returns the current mesh
  92672. */
  92673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92674. /**
  92675. * Sets the mesh indices,
  92676. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92677. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92678. * @param totalVertices Defines the total number of vertices
  92679. * @returns the current mesh
  92680. */
  92681. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92682. /**
  92683. * Gets a boolean indicating if specific vertex data is present
  92684. * @param kind defines the vertex data kind to use
  92685. * @returns true is data kind is present
  92686. */
  92687. isVerticesDataPresent(kind: string): boolean;
  92688. /**
  92689. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  92690. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  92691. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  92692. * @returns a BoundingInfo
  92693. */
  92694. getBoundingInfo(): BoundingInfo;
  92695. /**
  92696. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92697. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92698. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92699. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92700. * @returns the current mesh
  92701. */
  92702. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  92703. /**
  92704. * Overwrite the current bounding info
  92705. * @param boundingInfo defines the new bounding info
  92706. * @returns the current mesh
  92707. */
  92708. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  92709. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  92710. readonly useBones: boolean;
  92711. /** @hidden */
  92712. _preActivate(): void;
  92713. /** @hidden */
  92714. _preActivateForIntermediateRendering(renderId: number): void;
  92715. /** @hidden */
  92716. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92717. /** @hidden */
  92718. _postActivate(): void;
  92719. /** @hidden */
  92720. _freeze(): void;
  92721. /** @hidden */
  92722. _unFreeze(): void;
  92723. /**
  92724. * Gets the current world matrix
  92725. * @returns a Matrix
  92726. */
  92727. getWorldMatrix(): Matrix;
  92728. /** @hidden */
  92729. _getWorldMatrixDeterminant(): number;
  92730. /**
  92731. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  92732. */
  92733. readonly isAnInstance: boolean;
  92734. /**
  92735. * Gets a boolean indicating if this mesh has instances
  92736. */
  92737. readonly hasInstances: boolean;
  92738. /**
  92739. * Perform relative position change from the point of view of behind the front of the mesh.
  92740. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92741. * Supports definition of mesh facing forward or backward
  92742. * @param amountRight defines the distance on the right axis
  92743. * @param amountUp defines the distance on the up axis
  92744. * @param amountForward defines the distance on the forward axis
  92745. * @returns the current mesh
  92746. */
  92747. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  92748. /**
  92749. * Calculate relative position change from the point of view of behind the front of the mesh.
  92750. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92751. * Supports definition of mesh facing forward or backward
  92752. * @param amountRight defines the distance on the right axis
  92753. * @param amountUp defines the distance on the up axis
  92754. * @param amountForward defines the distance on the forward axis
  92755. * @returns the new displacement vector
  92756. */
  92757. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  92758. /**
  92759. * Perform relative rotation change from the point of view of behind the front of the mesh.
  92760. * Supports definition of mesh facing forward or backward
  92761. * @param flipBack defines the flip
  92762. * @param twirlClockwise defines the twirl
  92763. * @param tiltRight defines the tilt
  92764. * @returns the current mesh
  92765. */
  92766. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92767. /**
  92768. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92769. * Supports definition of mesh facing forward or backward.
  92770. * @param flipBack defines the flip
  92771. * @param twirlClockwise defines the twirl
  92772. * @param tiltRight defines the tilt
  92773. * @returns the new rotation vector
  92774. */
  92775. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92776. /**
  92777. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92778. * This means the mesh underlying bounding box and sphere are recomputed.
  92779. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92780. * @returns the current mesh
  92781. */
  92782. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92783. /** @hidden */
  92784. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92785. /** @hidden */
  92786. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92787. /** @hidden */
  92788. _updateBoundingInfo(): AbstractMesh;
  92789. /** @hidden */
  92790. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92791. /** @hidden */
  92792. protected _afterComputeWorldMatrix(): void;
  92793. /** @hidden */
  92794. readonly _effectiveMesh: AbstractMesh;
  92795. /**
  92796. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92797. * A mesh is in the frustum if its bounding box intersects the frustum
  92798. * @param frustumPlanes defines the frustum to test
  92799. * @returns true if the mesh is in the frustum planes
  92800. */
  92801. isInFrustum(frustumPlanes: Plane[]): boolean;
  92802. /**
  92803. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92804. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92805. * @param frustumPlanes defines the frustum to test
  92806. * @returns true if the mesh is completely in the frustum planes
  92807. */
  92808. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92809. /**
  92810. * True if the mesh intersects another mesh or a SolidParticle object
  92811. * @param mesh defines a target mesh or SolidParticle to test
  92812. * @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)
  92813. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92814. * @returns true if there is an intersection
  92815. */
  92816. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92817. /**
  92818. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92819. * @param point defines the point to test
  92820. * @returns true if there is an intersection
  92821. */
  92822. intersectsPoint(point: Vector3): boolean;
  92823. /**
  92824. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92826. */
  92827. checkCollisions: boolean;
  92828. /**
  92829. * Gets Collider object used to compute collisions (not physics)
  92830. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92831. */
  92832. readonly collider: Nullable<Collider>;
  92833. /**
  92834. * Move the mesh using collision engine
  92835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92836. * @param displacement defines the requested displacement vector
  92837. * @returns the current mesh
  92838. */
  92839. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92840. private _onCollisionPositionChange;
  92841. /** @hidden */
  92842. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92843. /** @hidden */
  92844. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92845. /** @hidden */
  92846. _checkCollision(collider: Collider): AbstractMesh;
  92847. /** @hidden */
  92848. _generatePointsArray(): boolean;
  92849. /**
  92850. * Checks if the passed Ray intersects with the mesh
  92851. * @param ray defines the ray to use
  92852. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92854. * @returns the picking info
  92855. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92856. */
  92857. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92858. /**
  92859. * Clones the current mesh
  92860. * @param name defines the mesh name
  92861. * @param newParent defines the new mesh parent
  92862. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92863. * @returns the new mesh
  92864. */
  92865. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92866. /**
  92867. * Disposes all the submeshes of the current meshnp
  92868. * @returns the current mesh
  92869. */
  92870. releaseSubMeshes(): AbstractMesh;
  92871. /**
  92872. * Releases resources associated with this abstract mesh.
  92873. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92874. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92875. */
  92876. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92877. /**
  92878. * Adds the passed mesh as a child to the current mesh
  92879. * @param mesh defines the child mesh
  92880. * @returns the current mesh
  92881. */
  92882. addChild(mesh: AbstractMesh): AbstractMesh;
  92883. /**
  92884. * Removes the passed mesh from the current mesh children list
  92885. * @param mesh defines the child mesh
  92886. * @returns the current mesh
  92887. */
  92888. removeChild(mesh: AbstractMesh): AbstractMesh;
  92889. /** @hidden */
  92890. private _initFacetData;
  92891. /**
  92892. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92893. * This method can be called within the render loop.
  92894. * 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
  92895. * @returns the current mesh
  92896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92897. */
  92898. updateFacetData(): AbstractMesh;
  92899. /**
  92900. * Returns the facetLocalNormals array.
  92901. * The normals are expressed in the mesh local spac
  92902. * @returns an array of Vector3
  92903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92904. */
  92905. getFacetLocalNormals(): Vector3[];
  92906. /**
  92907. * Returns the facetLocalPositions array.
  92908. * The facet positions are expressed in the mesh local space
  92909. * @returns an array of Vector3
  92910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92911. */
  92912. getFacetLocalPositions(): Vector3[];
  92913. /**
  92914. * Returns the facetLocalPartioning array
  92915. * @returns an array of array of numbers
  92916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92917. */
  92918. getFacetLocalPartitioning(): number[][];
  92919. /**
  92920. * Returns the i-th facet position in the world system.
  92921. * This method allocates a new Vector3 per call
  92922. * @param i defines the facet index
  92923. * @returns a new Vector3
  92924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92925. */
  92926. getFacetPosition(i: number): Vector3;
  92927. /**
  92928. * Sets the reference Vector3 with the i-th facet position in the world system
  92929. * @param i defines the facet index
  92930. * @param ref defines the target vector
  92931. * @returns the current mesh
  92932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92933. */
  92934. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92935. /**
  92936. * Returns the i-th facet normal in the world system.
  92937. * This method allocates a new Vector3 per call
  92938. * @param i defines the facet index
  92939. * @returns a new Vector3
  92940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92941. */
  92942. getFacetNormal(i: number): Vector3;
  92943. /**
  92944. * Sets the reference Vector3 with the i-th facet normal in the world system
  92945. * @param i defines the facet index
  92946. * @param ref defines the target vector
  92947. * @returns the current mesh
  92948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92949. */
  92950. getFacetNormalToRef(i: number, ref: Vector3): this;
  92951. /**
  92952. * 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)
  92953. * @param x defines x coordinate
  92954. * @param y defines y coordinate
  92955. * @param z defines z coordinate
  92956. * @returns the array of facet indexes
  92957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92958. */
  92959. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92960. /**
  92961. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92962. * @param projected sets as the (x,y,z) world projection on the facet
  92963. * @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
  92964. * @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
  92965. * @param x defines x coordinate
  92966. * @param y defines y coordinate
  92967. * @param z defines z coordinate
  92968. * @returns the face index if found (or null instead)
  92969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92970. */
  92971. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92972. /**
  92973. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92974. * @param projected sets as the (x,y,z) local projection on the facet
  92975. * @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
  92976. * @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
  92977. * @param x defines x coordinate
  92978. * @param y defines y coordinate
  92979. * @param z defines z coordinate
  92980. * @returns the face index if found (or null instead)
  92981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92982. */
  92983. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92984. /**
  92985. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92986. * @returns the parameters
  92987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92988. */
  92989. getFacetDataParameters(): any;
  92990. /**
  92991. * Disables the feature FacetData and frees the related memory
  92992. * @returns the current mesh
  92993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92994. */
  92995. disableFacetData(): AbstractMesh;
  92996. /**
  92997. * Updates the AbstractMesh indices array
  92998. * @param indices defines the data source
  92999. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93000. * @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)
  93001. * @returns the current mesh
  93002. */
  93003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93004. /**
  93005. * Creates new normals data for the mesh
  93006. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93007. * @returns the current mesh
  93008. */
  93009. createNormals(updatable: boolean): AbstractMesh;
  93010. /**
  93011. * Align the mesh with a normal
  93012. * @param normal defines the normal to use
  93013. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93014. * @returns the current mesh
  93015. */
  93016. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93017. /** @hidden */
  93018. _checkOcclusionQuery(): boolean;
  93019. /**
  93020. * Disables the mesh edge rendering mode
  93021. * @returns the currentAbstractMesh
  93022. */
  93023. disableEdgesRendering(): AbstractMesh;
  93024. /**
  93025. * Enables the edge rendering mode on the mesh.
  93026. * This mode makes the mesh edges visible
  93027. * @param epsilon defines the maximal distance between two angles to detect a face
  93028. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93029. * @returns the currentAbstractMesh
  93030. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93031. */
  93032. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93033. }
  93034. }
  93035. declare module BABYLON {
  93036. /**
  93037. * Interface used to define ActionEvent
  93038. */
  93039. export interface IActionEvent {
  93040. /** The mesh or sprite that triggered the action */
  93041. source: any;
  93042. /** The X mouse cursor position at the time of the event */
  93043. pointerX: number;
  93044. /** The Y mouse cursor position at the time of the event */
  93045. pointerY: number;
  93046. /** The mesh that is currently pointed at (can be null) */
  93047. meshUnderPointer: Nullable<AbstractMesh>;
  93048. /** the original (browser) event that triggered the ActionEvent */
  93049. sourceEvent?: any;
  93050. /** additional data for the event */
  93051. additionalData?: any;
  93052. }
  93053. /**
  93054. * ActionEvent is the event being sent when an action is triggered.
  93055. */
  93056. export class ActionEvent implements IActionEvent {
  93057. /** The mesh or sprite that triggered the action */
  93058. source: any;
  93059. /** The X mouse cursor position at the time of the event */
  93060. pointerX: number;
  93061. /** The Y mouse cursor position at the time of the event */
  93062. pointerY: number;
  93063. /** The mesh that is currently pointed at (can be null) */
  93064. meshUnderPointer: Nullable<AbstractMesh>;
  93065. /** the original (browser) event that triggered the ActionEvent */
  93066. sourceEvent?: any;
  93067. /** additional data for the event */
  93068. additionalData?: any;
  93069. /**
  93070. * Creates a new ActionEvent
  93071. * @param source The mesh or sprite that triggered the action
  93072. * @param pointerX The X mouse cursor position at the time of the event
  93073. * @param pointerY The Y mouse cursor position at the time of the event
  93074. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93075. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93076. * @param additionalData additional data for the event
  93077. */
  93078. constructor(
  93079. /** The mesh or sprite that triggered the action */
  93080. source: any,
  93081. /** The X mouse cursor position at the time of the event */
  93082. pointerX: number,
  93083. /** The Y mouse cursor position at the time of the event */
  93084. pointerY: number,
  93085. /** The mesh that is currently pointed at (can be null) */
  93086. meshUnderPointer: Nullable<AbstractMesh>,
  93087. /** the original (browser) event that triggered the ActionEvent */
  93088. sourceEvent?: any,
  93089. /** additional data for the event */
  93090. additionalData?: any);
  93091. /**
  93092. * Helper function to auto-create an ActionEvent from a source mesh.
  93093. * @param source The source mesh that triggered the event
  93094. * @param evt The original (browser) event
  93095. * @param additionalData additional data for the event
  93096. * @returns the new ActionEvent
  93097. */
  93098. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93099. /**
  93100. * Helper function to auto-create an ActionEvent from a source sprite
  93101. * @param source The source sprite that triggered the event
  93102. * @param scene Scene associated with the sprite
  93103. * @param evt The original (browser) event
  93104. * @param additionalData additional data for the event
  93105. * @returns the new ActionEvent
  93106. */
  93107. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93108. /**
  93109. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93110. * @param scene the scene where the event occurred
  93111. * @param evt The original (browser) event
  93112. * @returns the new ActionEvent
  93113. */
  93114. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93115. /**
  93116. * Helper function to auto-create an ActionEvent from a primitive
  93117. * @param prim defines the target primitive
  93118. * @param pointerPos defines the pointer position
  93119. * @param evt The original (browser) event
  93120. * @param additionalData additional data for the event
  93121. * @returns the new ActionEvent
  93122. */
  93123. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93124. }
  93125. }
  93126. declare module BABYLON {
  93127. /**
  93128. * Abstract class used to decouple action Manager from scene and meshes.
  93129. * Do not instantiate.
  93130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93131. */
  93132. export abstract class AbstractActionManager implements IDisposable {
  93133. /** Gets the list of active triggers */
  93134. static Triggers: {
  93135. [key: string]: number;
  93136. };
  93137. /** Gets the cursor to use when hovering items */
  93138. hoverCursor: string;
  93139. /** Gets the list of actions */
  93140. actions: IAction[];
  93141. /**
  93142. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93143. */
  93144. isRecursive: boolean;
  93145. /**
  93146. * Releases all associated resources
  93147. */
  93148. abstract dispose(): void;
  93149. /**
  93150. * Does this action manager has pointer triggers
  93151. */
  93152. abstract readonly hasPointerTriggers: boolean;
  93153. /**
  93154. * Does this action manager has pick triggers
  93155. */
  93156. abstract readonly hasPickTriggers: boolean;
  93157. /**
  93158. * Process a specific trigger
  93159. * @param trigger defines the trigger to process
  93160. * @param evt defines the event details to be processed
  93161. */
  93162. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93163. /**
  93164. * Does this action manager handles actions of any of the given triggers
  93165. * @param triggers defines the triggers to be tested
  93166. * @return a boolean indicating whether one (or more) of the triggers is handled
  93167. */
  93168. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93169. /**
  93170. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93171. * speed.
  93172. * @param triggerA defines the trigger to be tested
  93173. * @param triggerB defines the trigger to be tested
  93174. * @return a boolean indicating whether one (or more) of the triggers is handled
  93175. */
  93176. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93177. /**
  93178. * Does this action manager handles actions of a given trigger
  93179. * @param trigger defines the trigger to be tested
  93180. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93181. * @return whether the trigger is handled
  93182. */
  93183. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93184. /**
  93185. * Serialize this manager to a JSON object
  93186. * @param name defines the property name to store this manager
  93187. * @returns a JSON representation of this manager
  93188. */
  93189. abstract serialize(name: string): any;
  93190. /**
  93191. * Registers an action to this action manager
  93192. * @param action defines the action to be registered
  93193. * @return the action amended (prepared) after registration
  93194. */
  93195. abstract registerAction(action: IAction): Nullable<IAction>;
  93196. /**
  93197. * Unregisters an action to this action manager
  93198. * @param action defines the action to be unregistered
  93199. * @return a boolean indicating whether the action has been unregistered
  93200. */
  93201. abstract unregisterAction(action: IAction): Boolean;
  93202. /**
  93203. * Does exist one action manager with at least one trigger
  93204. **/
  93205. static readonly HasTriggers: boolean;
  93206. /**
  93207. * Does exist one action manager with at least one pick trigger
  93208. **/
  93209. static readonly HasPickTriggers: boolean;
  93210. /**
  93211. * Does exist one action manager that handles actions of a given trigger
  93212. * @param trigger defines the trigger to be tested
  93213. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93214. **/
  93215. static HasSpecificTrigger(trigger: number): boolean;
  93216. }
  93217. }
  93218. declare module BABYLON {
  93219. /**
  93220. * Defines how a node can be built from a string name.
  93221. */
  93222. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93223. /**
  93224. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93225. */
  93226. export class Node implements IBehaviorAware<Node> {
  93227. /** @hidden */
  93228. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93229. private static _NodeConstructors;
  93230. /**
  93231. * Add a new node constructor
  93232. * @param type defines the type name of the node to construct
  93233. * @param constructorFunc defines the constructor function
  93234. */
  93235. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93236. /**
  93237. * Returns a node constructor based on type name
  93238. * @param type defines the type name
  93239. * @param name defines the new node name
  93240. * @param scene defines the hosting scene
  93241. * @param options defines optional options to transmit to constructors
  93242. * @returns the new constructor or null
  93243. */
  93244. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93245. /**
  93246. * Gets or sets the name of the node
  93247. */
  93248. name: string;
  93249. /**
  93250. * Gets or sets the id of the node
  93251. */
  93252. id: string;
  93253. /**
  93254. * Gets or sets the unique id of the node
  93255. */
  93256. uniqueId: number;
  93257. /**
  93258. * Gets or sets a string used to store user defined state for the node
  93259. */
  93260. state: string;
  93261. /**
  93262. * Gets or sets an object used to store user defined information for the node
  93263. */
  93264. metadata: any;
  93265. /**
  93266. * For internal use only. Please do not use.
  93267. */
  93268. reservedDataStore: any;
  93269. /**
  93270. * List of inspectable custom properties (used by the Inspector)
  93271. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93272. */
  93273. inspectableCustomProperties: IInspectable[];
  93274. /**
  93275. * Gets or sets a boolean used to define if the node must be serialized
  93276. */
  93277. doNotSerialize: boolean;
  93278. /** @hidden */
  93279. _isDisposed: boolean;
  93280. /**
  93281. * Gets a list of Animations associated with the node
  93282. */
  93283. animations: Animation[];
  93284. protected _ranges: {
  93285. [name: string]: Nullable<AnimationRange>;
  93286. };
  93287. /**
  93288. * Callback raised when the node is ready to be used
  93289. */
  93290. onReady: Nullable<(node: Node) => void>;
  93291. private _isEnabled;
  93292. private _isParentEnabled;
  93293. private _isReady;
  93294. /** @hidden */
  93295. _currentRenderId: number;
  93296. private _parentUpdateId;
  93297. /** @hidden */
  93298. _childUpdateId: number;
  93299. /** @hidden */
  93300. _waitingParentId: Nullable<string>;
  93301. /** @hidden */
  93302. _scene: Scene;
  93303. /** @hidden */
  93304. _cache: any;
  93305. private _parentNode;
  93306. private _children;
  93307. /** @hidden */
  93308. _worldMatrix: Matrix;
  93309. /** @hidden */
  93310. _worldMatrixDeterminant: number;
  93311. /** @hidden */
  93312. _worldMatrixDeterminantIsDirty: boolean;
  93313. /** @hidden */
  93314. private _sceneRootNodesIndex;
  93315. /**
  93316. * Gets a boolean indicating if the node has been disposed
  93317. * @returns true if the node was disposed
  93318. */
  93319. isDisposed(): boolean;
  93320. /**
  93321. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93322. * @see https://doc.babylonjs.com/how_to/parenting
  93323. */
  93324. parent: Nullable<Node>;
  93325. private addToSceneRootNodes;
  93326. private removeFromSceneRootNodes;
  93327. private _animationPropertiesOverride;
  93328. /**
  93329. * Gets or sets the animation properties override
  93330. */
  93331. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93332. /**
  93333. * Gets a string idenfifying the name of the class
  93334. * @returns "Node" string
  93335. */
  93336. getClassName(): string;
  93337. /** @hidden */
  93338. readonly _isNode: boolean;
  93339. /**
  93340. * An event triggered when the mesh is disposed
  93341. */
  93342. onDisposeObservable: Observable<Node>;
  93343. private _onDisposeObserver;
  93344. /**
  93345. * Sets a callback that will be raised when the node will be disposed
  93346. */
  93347. onDispose: () => void;
  93348. /**
  93349. * Creates a new Node
  93350. * @param name the name and id to be given to this node
  93351. * @param scene the scene this node will be added to
  93352. * @param addToRootNodes the node will be added to scene.rootNodes
  93353. */
  93354. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93355. /**
  93356. * Gets the scene of the node
  93357. * @returns a scene
  93358. */
  93359. getScene(): Scene;
  93360. /**
  93361. * Gets the engine of the node
  93362. * @returns a Engine
  93363. */
  93364. getEngine(): Engine;
  93365. private _behaviors;
  93366. /**
  93367. * Attach a behavior to the node
  93368. * @see http://doc.babylonjs.com/features/behaviour
  93369. * @param behavior defines the behavior to attach
  93370. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93371. * @returns the current Node
  93372. */
  93373. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93374. /**
  93375. * Remove an attached behavior
  93376. * @see http://doc.babylonjs.com/features/behaviour
  93377. * @param behavior defines the behavior to attach
  93378. * @returns the current Node
  93379. */
  93380. removeBehavior(behavior: Behavior<Node>): Node;
  93381. /**
  93382. * Gets the list of attached behaviors
  93383. * @see http://doc.babylonjs.com/features/behaviour
  93384. */
  93385. readonly behaviors: Behavior<Node>[];
  93386. /**
  93387. * Gets an attached behavior by name
  93388. * @param name defines the name of the behavior to look for
  93389. * @see http://doc.babylonjs.com/features/behaviour
  93390. * @returns null if behavior was not found else the requested behavior
  93391. */
  93392. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93393. /**
  93394. * Returns the latest update of the World matrix
  93395. * @returns a Matrix
  93396. */
  93397. getWorldMatrix(): Matrix;
  93398. /** @hidden */
  93399. _getWorldMatrixDeterminant(): number;
  93400. /**
  93401. * Returns directly the latest state of the mesh World matrix.
  93402. * A Matrix is returned.
  93403. */
  93404. readonly worldMatrixFromCache: Matrix;
  93405. /** @hidden */
  93406. _initCache(): void;
  93407. /** @hidden */
  93408. updateCache(force?: boolean): void;
  93409. /** @hidden */
  93410. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93411. /** @hidden */
  93412. _updateCache(ignoreParentClass?: boolean): void;
  93413. /** @hidden */
  93414. _isSynchronized(): boolean;
  93415. /** @hidden */
  93416. _markSyncedWithParent(): void;
  93417. /** @hidden */
  93418. isSynchronizedWithParent(): boolean;
  93419. /** @hidden */
  93420. isSynchronized(): boolean;
  93421. /**
  93422. * Is this node ready to be used/rendered
  93423. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93424. * @return true if the node is ready
  93425. */
  93426. isReady(completeCheck?: boolean): boolean;
  93427. /**
  93428. * Is this node enabled?
  93429. * 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
  93430. * @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
  93431. * @return whether this node (and its parent) is enabled
  93432. */
  93433. isEnabled(checkAncestors?: boolean): boolean;
  93434. /** @hidden */
  93435. protected _syncParentEnabledState(): void;
  93436. /**
  93437. * Set the enabled state of this node
  93438. * @param value defines the new enabled state
  93439. */
  93440. setEnabled(value: boolean): void;
  93441. /**
  93442. * Is this node a descendant of the given node?
  93443. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93444. * @param ancestor defines the parent node to inspect
  93445. * @returns a boolean indicating if this node is a descendant of the given node
  93446. */
  93447. isDescendantOf(ancestor: Node): boolean;
  93448. /** @hidden */
  93449. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93450. /**
  93451. * Will return all nodes that have this node as ascendant
  93452. * @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
  93453. * @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
  93454. * @return all children nodes of all types
  93455. */
  93456. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93457. /**
  93458. * Get all child-meshes of this node
  93459. * @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)
  93460. * @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
  93461. * @returns an array of AbstractMesh
  93462. */
  93463. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93464. /**
  93465. * Get all direct children of this node
  93466. * @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
  93467. * @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)
  93468. * @returns an array of Node
  93469. */
  93470. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93471. /** @hidden */
  93472. _setReady(state: boolean): void;
  93473. /**
  93474. * Get an animation by name
  93475. * @param name defines the name of the animation to look for
  93476. * @returns null if not found else the requested animation
  93477. */
  93478. getAnimationByName(name: string): Nullable<Animation>;
  93479. /**
  93480. * Creates an animation range for this node
  93481. * @param name defines the name of the range
  93482. * @param from defines the starting key
  93483. * @param to defines the end key
  93484. */
  93485. createAnimationRange(name: string, from: number, to: number): void;
  93486. /**
  93487. * Delete a specific animation range
  93488. * @param name defines the name of the range to delete
  93489. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93490. */
  93491. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93492. /**
  93493. * Get an animation range by name
  93494. * @param name defines the name of the animation range to look for
  93495. * @returns null if not found else the requested animation range
  93496. */
  93497. getAnimationRange(name: string): Nullable<AnimationRange>;
  93498. /**
  93499. * Gets the list of all animation ranges defined on this node
  93500. * @returns an array
  93501. */
  93502. getAnimationRanges(): Nullable<AnimationRange>[];
  93503. /**
  93504. * Will start the animation sequence
  93505. * @param name defines the range frames for animation sequence
  93506. * @param loop defines if the animation should loop (false by default)
  93507. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93508. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93509. * @returns the object created for this animation. If range does not exist, it will return null
  93510. */
  93511. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93512. /**
  93513. * Serialize animation ranges into a JSON compatible object
  93514. * @returns serialization object
  93515. */
  93516. serializeAnimationRanges(): any;
  93517. /**
  93518. * Computes the world matrix of the node
  93519. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93520. * @returns the world matrix
  93521. */
  93522. computeWorldMatrix(force?: boolean): Matrix;
  93523. /**
  93524. * Releases resources associated with this node.
  93525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93527. */
  93528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93529. /**
  93530. * Parse animation range data from a serialization object and store them into a given node
  93531. * @param node defines where to store the animation ranges
  93532. * @param parsedNode defines the serialization object to read data from
  93533. * @param scene defines the hosting scene
  93534. */
  93535. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93536. /**
  93537. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93538. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93539. * @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
  93540. * @returns the new bounding vectors
  93541. */
  93542. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93543. min: Vector3;
  93544. max: Vector3;
  93545. };
  93546. }
  93547. }
  93548. declare module BABYLON {
  93549. /**
  93550. * @hidden
  93551. */
  93552. export class _IAnimationState {
  93553. key: number;
  93554. repeatCount: number;
  93555. workValue?: any;
  93556. loopMode?: number;
  93557. offsetValue?: any;
  93558. highLimitValue?: any;
  93559. }
  93560. /**
  93561. * Class used to store any kind of animation
  93562. */
  93563. export class Animation {
  93564. /**Name of the animation */
  93565. name: string;
  93566. /**Property to animate */
  93567. targetProperty: string;
  93568. /**The frames per second of the animation */
  93569. framePerSecond: number;
  93570. /**The data type of the animation */
  93571. dataType: number;
  93572. /**The loop mode of the animation */
  93573. loopMode?: number | undefined;
  93574. /**Specifies if blending should be enabled */
  93575. enableBlending?: boolean | undefined;
  93576. /**
  93577. * Use matrix interpolation instead of using direct key value when animating matrices
  93578. */
  93579. static AllowMatricesInterpolation: boolean;
  93580. /**
  93581. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93582. */
  93583. static AllowMatrixDecomposeForInterpolation: boolean;
  93584. /**
  93585. * Stores the key frames of the animation
  93586. */
  93587. private _keys;
  93588. /**
  93589. * Stores the easing function of the animation
  93590. */
  93591. private _easingFunction;
  93592. /**
  93593. * @hidden Internal use only
  93594. */
  93595. _runtimeAnimations: RuntimeAnimation[];
  93596. /**
  93597. * The set of event that will be linked to this animation
  93598. */
  93599. private _events;
  93600. /**
  93601. * Stores an array of target property paths
  93602. */
  93603. targetPropertyPath: string[];
  93604. /**
  93605. * Stores the blending speed of the animation
  93606. */
  93607. blendingSpeed: number;
  93608. /**
  93609. * Stores the animation ranges for the animation
  93610. */
  93611. private _ranges;
  93612. /**
  93613. * @hidden Internal use
  93614. */
  93615. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93616. /**
  93617. * Sets up an animation
  93618. * @param property The property to animate
  93619. * @param animationType The animation type to apply
  93620. * @param framePerSecond The frames per second of the animation
  93621. * @param easingFunction The easing function used in the animation
  93622. * @returns The created animation
  93623. */
  93624. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93625. /**
  93626. * Create and start an animation on a node
  93627. * @param name defines the name of the global animation that will be run on all nodes
  93628. * @param node defines the root node where the animation will take place
  93629. * @param targetProperty defines property to animate
  93630. * @param framePerSecond defines the number of frame per second yo use
  93631. * @param totalFrame defines the number of frames in total
  93632. * @param from defines the initial value
  93633. * @param to defines the final value
  93634. * @param loopMode defines which loop mode you want to use (off by default)
  93635. * @param easingFunction defines the easing function to use (linear by default)
  93636. * @param onAnimationEnd defines the callback to call when animation end
  93637. * @returns the animatable created for this animation
  93638. */
  93639. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93640. /**
  93641. * Create and start an animation on a node and its descendants
  93642. * @param name defines the name of the global animation that will be run on all nodes
  93643. * @param node defines the root node where the animation will take place
  93644. * @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
  93645. * @param targetProperty defines property to animate
  93646. * @param framePerSecond defines the number of frame per second to use
  93647. * @param totalFrame defines the number of frames in total
  93648. * @param from defines the initial value
  93649. * @param to defines the final value
  93650. * @param loopMode defines which loop mode you want to use (off by default)
  93651. * @param easingFunction defines the easing function to use (linear by default)
  93652. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93653. * @returns the list of animatables created for all nodes
  93654. * @example https://www.babylonjs-playground.com/#MH0VLI
  93655. */
  93656. 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[]>;
  93657. /**
  93658. * Creates a new animation, merges it with the existing animations and starts it
  93659. * @param name Name of the animation
  93660. * @param node Node which contains the scene that begins the animations
  93661. * @param targetProperty Specifies which property to animate
  93662. * @param framePerSecond The frames per second of the animation
  93663. * @param totalFrame The total number of frames
  93664. * @param from The frame at the beginning of the animation
  93665. * @param to The frame at the end of the animation
  93666. * @param loopMode Specifies the loop mode of the animation
  93667. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93668. * @param onAnimationEnd Callback to run once the animation is complete
  93669. * @returns Nullable animation
  93670. */
  93671. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93672. /**
  93673. * Transition property of an host to the target Value
  93674. * @param property The property to transition
  93675. * @param targetValue The target Value of the property
  93676. * @param host The object where the property to animate belongs
  93677. * @param scene Scene used to run the animation
  93678. * @param frameRate Framerate (in frame/s) to use
  93679. * @param transition The transition type we want to use
  93680. * @param duration The duration of the animation, in milliseconds
  93681. * @param onAnimationEnd Callback trigger at the end of the animation
  93682. * @returns Nullable animation
  93683. */
  93684. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93685. /**
  93686. * Return the array of runtime animations currently using this animation
  93687. */
  93688. readonly runtimeAnimations: RuntimeAnimation[];
  93689. /**
  93690. * Specifies if any of the runtime animations are currently running
  93691. */
  93692. readonly hasRunningRuntimeAnimations: boolean;
  93693. /**
  93694. * Initializes the animation
  93695. * @param name Name of the animation
  93696. * @param targetProperty Property to animate
  93697. * @param framePerSecond The frames per second of the animation
  93698. * @param dataType The data type of the animation
  93699. * @param loopMode The loop mode of the animation
  93700. * @param enableBlending Specifies if blending should be enabled
  93701. */
  93702. constructor(
  93703. /**Name of the animation */
  93704. name: string,
  93705. /**Property to animate */
  93706. targetProperty: string,
  93707. /**The frames per second of the animation */
  93708. framePerSecond: number,
  93709. /**The data type of the animation */
  93710. dataType: number,
  93711. /**The loop mode of the animation */
  93712. loopMode?: number | undefined,
  93713. /**Specifies if blending should be enabled */
  93714. enableBlending?: boolean | undefined);
  93715. /**
  93716. * Converts the animation to a string
  93717. * @param fullDetails support for multiple levels of logging within scene loading
  93718. * @returns String form of the animation
  93719. */
  93720. toString(fullDetails?: boolean): string;
  93721. /**
  93722. * Add an event to this animation
  93723. * @param event Event to add
  93724. */
  93725. addEvent(event: AnimationEvent): void;
  93726. /**
  93727. * Remove all events found at the given frame
  93728. * @param frame The frame to remove events from
  93729. */
  93730. removeEvents(frame: number): void;
  93731. /**
  93732. * Retrieves all the events from the animation
  93733. * @returns Events from the animation
  93734. */
  93735. getEvents(): AnimationEvent[];
  93736. /**
  93737. * Creates an animation range
  93738. * @param name Name of the animation range
  93739. * @param from Starting frame of the animation range
  93740. * @param to Ending frame of the animation
  93741. */
  93742. createRange(name: string, from: number, to: number): void;
  93743. /**
  93744. * Deletes an animation range by name
  93745. * @param name Name of the animation range to delete
  93746. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  93747. */
  93748. deleteRange(name: string, deleteFrames?: boolean): void;
  93749. /**
  93750. * Gets the animation range by name, or null if not defined
  93751. * @param name Name of the animation range
  93752. * @returns Nullable animation range
  93753. */
  93754. getRange(name: string): Nullable<AnimationRange>;
  93755. /**
  93756. * Gets the key frames from the animation
  93757. * @returns The key frames of the animation
  93758. */
  93759. getKeys(): Array<IAnimationKey>;
  93760. /**
  93761. * Gets the highest frame rate of the animation
  93762. * @returns Highest frame rate of the animation
  93763. */
  93764. getHighestFrame(): number;
  93765. /**
  93766. * Gets the easing function of the animation
  93767. * @returns Easing function of the animation
  93768. */
  93769. getEasingFunction(): IEasingFunction;
  93770. /**
  93771. * Sets the easing function of the animation
  93772. * @param easingFunction A custom mathematical formula for animation
  93773. */
  93774. setEasingFunction(easingFunction: EasingFunction): void;
  93775. /**
  93776. * Interpolates a scalar linearly
  93777. * @param startValue Start value of the animation curve
  93778. * @param endValue End value of the animation curve
  93779. * @param gradient Scalar amount to interpolate
  93780. * @returns Interpolated scalar value
  93781. */
  93782. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93783. /**
  93784. * Interpolates a scalar cubically
  93785. * @param startValue Start value of the animation curve
  93786. * @param outTangent End tangent of the animation
  93787. * @param endValue End value of the animation curve
  93788. * @param inTangent Start tangent of the animation curve
  93789. * @param gradient Scalar amount to interpolate
  93790. * @returns Interpolated scalar value
  93791. */
  93792. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93793. /**
  93794. * Interpolates a quaternion using a spherical linear interpolation
  93795. * @param startValue Start value of the animation curve
  93796. * @param endValue End value of the animation curve
  93797. * @param gradient Scalar amount to interpolate
  93798. * @returns Interpolated quaternion value
  93799. */
  93800. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93801. /**
  93802. * Interpolates a quaternion cubically
  93803. * @param startValue Start value of the animation curve
  93804. * @param outTangent End tangent of the animation curve
  93805. * @param endValue End value of the animation curve
  93806. * @param inTangent Start tangent of the animation curve
  93807. * @param gradient Scalar amount to interpolate
  93808. * @returns Interpolated quaternion value
  93809. */
  93810. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93811. /**
  93812. * Interpolates a Vector3 linearl
  93813. * @param startValue Start value of the animation curve
  93814. * @param endValue End value of the animation curve
  93815. * @param gradient Scalar amount to interpolate
  93816. * @returns Interpolated scalar value
  93817. */
  93818. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93819. /**
  93820. * Interpolates a Vector3 cubically
  93821. * @param startValue Start value of the animation curve
  93822. * @param outTangent End tangent of the animation
  93823. * @param endValue End value of the animation curve
  93824. * @param inTangent Start tangent of the animation curve
  93825. * @param gradient Scalar amount to interpolate
  93826. * @returns InterpolatedVector3 value
  93827. */
  93828. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93829. /**
  93830. * Interpolates a Vector2 linearly
  93831. * @param startValue Start value of the animation curve
  93832. * @param endValue End value of the animation curve
  93833. * @param gradient Scalar amount to interpolate
  93834. * @returns Interpolated Vector2 value
  93835. */
  93836. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93837. /**
  93838. * Interpolates a Vector2 cubically
  93839. * @param startValue Start value of the animation curve
  93840. * @param outTangent End tangent of the animation
  93841. * @param endValue End value of the animation curve
  93842. * @param inTangent Start tangent of the animation curve
  93843. * @param gradient Scalar amount to interpolate
  93844. * @returns Interpolated Vector2 value
  93845. */
  93846. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93847. /**
  93848. * Interpolates a size linearly
  93849. * @param startValue Start value of the animation curve
  93850. * @param endValue End value of the animation curve
  93851. * @param gradient Scalar amount to interpolate
  93852. * @returns Interpolated Size value
  93853. */
  93854. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93855. /**
  93856. * Interpolates a Color3 linearly
  93857. * @param startValue Start value of the animation curve
  93858. * @param endValue End value of the animation curve
  93859. * @param gradient Scalar amount to interpolate
  93860. * @returns Interpolated Color3 value
  93861. */
  93862. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93863. /**
  93864. * @hidden Internal use only
  93865. */
  93866. _getKeyValue(value: any): any;
  93867. /**
  93868. * @hidden Internal use only
  93869. */
  93870. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93871. /**
  93872. * Defines the function to use to interpolate matrices
  93873. * @param startValue defines the start matrix
  93874. * @param endValue defines the end matrix
  93875. * @param gradient defines the gradient between both matrices
  93876. * @param result defines an optional target matrix where to store the interpolation
  93877. * @returns the interpolated matrix
  93878. */
  93879. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93880. /**
  93881. * Makes a copy of the animation
  93882. * @returns Cloned animation
  93883. */
  93884. clone(): Animation;
  93885. /**
  93886. * Sets the key frames of the animation
  93887. * @param values The animation key frames to set
  93888. */
  93889. setKeys(values: Array<IAnimationKey>): void;
  93890. /**
  93891. * Serializes the animation to an object
  93892. * @returns Serialized object
  93893. */
  93894. serialize(): any;
  93895. /**
  93896. * Float animation type
  93897. */
  93898. private static _ANIMATIONTYPE_FLOAT;
  93899. /**
  93900. * Vector3 animation type
  93901. */
  93902. private static _ANIMATIONTYPE_VECTOR3;
  93903. /**
  93904. * Quaternion animation type
  93905. */
  93906. private static _ANIMATIONTYPE_QUATERNION;
  93907. /**
  93908. * Matrix animation type
  93909. */
  93910. private static _ANIMATIONTYPE_MATRIX;
  93911. /**
  93912. * Color3 animation type
  93913. */
  93914. private static _ANIMATIONTYPE_COLOR3;
  93915. /**
  93916. * Vector2 animation type
  93917. */
  93918. private static _ANIMATIONTYPE_VECTOR2;
  93919. /**
  93920. * Size animation type
  93921. */
  93922. private static _ANIMATIONTYPE_SIZE;
  93923. /**
  93924. * Relative Loop Mode
  93925. */
  93926. private static _ANIMATIONLOOPMODE_RELATIVE;
  93927. /**
  93928. * Cycle Loop Mode
  93929. */
  93930. private static _ANIMATIONLOOPMODE_CYCLE;
  93931. /**
  93932. * Constant Loop Mode
  93933. */
  93934. private static _ANIMATIONLOOPMODE_CONSTANT;
  93935. /**
  93936. * Get the float animation type
  93937. */
  93938. static readonly ANIMATIONTYPE_FLOAT: number;
  93939. /**
  93940. * Get the Vector3 animation type
  93941. */
  93942. static readonly ANIMATIONTYPE_VECTOR3: number;
  93943. /**
  93944. * Get the Vector2 animation type
  93945. */
  93946. static readonly ANIMATIONTYPE_VECTOR2: number;
  93947. /**
  93948. * Get the Size animation type
  93949. */
  93950. static readonly ANIMATIONTYPE_SIZE: number;
  93951. /**
  93952. * Get the Quaternion animation type
  93953. */
  93954. static readonly ANIMATIONTYPE_QUATERNION: number;
  93955. /**
  93956. * Get the Matrix animation type
  93957. */
  93958. static readonly ANIMATIONTYPE_MATRIX: number;
  93959. /**
  93960. * Get the Color3 animation type
  93961. */
  93962. static readonly ANIMATIONTYPE_COLOR3: number;
  93963. /**
  93964. * Get the Relative Loop Mode
  93965. */
  93966. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93967. /**
  93968. * Get the Cycle Loop Mode
  93969. */
  93970. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93971. /**
  93972. * Get the Constant Loop Mode
  93973. */
  93974. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93975. /** @hidden */
  93976. static _UniversalLerp(left: any, right: any, amount: number): any;
  93977. /**
  93978. * Parses an animation object and creates an animation
  93979. * @param parsedAnimation Parsed animation object
  93980. * @returns Animation object
  93981. */
  93982. static Parse(parsedAnimation: any): Animation;
  93983. /**
  93984. * Appends the serialized animations from the source animations
  93985. * @param source Source containing the animations
  93986. * @param destination Target to store the animations
  93987. */
  93988. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93989. }
  93990. }
  93991. declare module BABYLON {
  93992. /**
  93993. * Interface containing an array of animations
  93994. */
  93995. export interface IAnimatable {
  93996. /**
  93997. * Array of animations
  93998. */
  93999. animations: Nullable<Array<Animation>>;
  94000. }
  94001. }
  94002. declare module BABYLON {
  94003. /**
  94004. * This represents all the required information to add a fresnel effect on a material:
  94005. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94006. */
  94007. export class FresnelParameters {
  94008. private _isEnabled;
  94009. /**
  94010. * Define if the fresnel effect is enable or not.
  94011. */
  94012. isEnabled: boolean;
  94013. /**
  94014. * Define the color used on edges (grazing angle)
  94015. */
  94016. leftColor: Color3;
  94017. /**
  94018. * Define the color used on center
  94019. */
  94020. rightColor: Color3;
  94021. /**
  94022. * Define bias applied to computed fresnel term
  94023. */
  94024. bias: number;
  94025. /**
  94026. * Defined the power exponent applied to fresnel term
  94027. */
  94028. power: number;
  94029. /**
  94030. * Clones the current fresnel and its valuues
  94031. * @returns a clone fresnel configuration
  94032. */
  94033. clone(): FresnelParameters;
  94034. /**
  94035. * Serializes the current fresnel parameters to a JSON representation.
  94036. * @return the JSON serialization
  94037. */
  94038. serialize(): any;
  94039. /**
  94040. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94041. * @param parsedFresnelParameters Define the JSON representation
  94042. * @returns the parsed parameters
  94043. */
  94044. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94045. }
  94046. }
  94047. declare module BABYLON {
  94048. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94049. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94050. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94051. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94052. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94053. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94054. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94055. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94056. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94057. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94058. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94059. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94060. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94061. /**
  94062. * Decorator used to define property that can be serialized as reference to a camera
  94063. * @param sourceName defines the name of the property to decorate
  94064. */
  94065. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94066. /**
  94067. * Class used to help serialization objects
  94068. */
  94069. export class SerializationHelper {
  94070. /** @hidden */
  94071. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94072. /** @hidden */
  94073. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94074. /** @hidden */
  94075. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94076. /** @hidden */
  94077. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94078. /**
  94079. * Appends the serialized animations from the source animations
  94080. * @param source Source containing the animations
  94081. * @param destination Target to store the animations
  94082. */
  94083. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94084. /**
  94085. * Static function used to serialized a specific entity
  94086. * @param entity defines the entity to serialize
  94087. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94088. * @returns a JSON compatible object representing the serialization of the entity
  94089. */
  94090. static Serialize<T>(entity: T, serializationObject?: any): any;
  94091. /**
  94092. * Creates a new entity from a serialization data object
  94093. * @param creationFunction defines a function used to instanciated the new entity
  94094. * @param source defines the source serialization data
  94095. * @param scene defines the hosting scene
  94096. * @param rootUrl defines the root url for resources
  94097. * @returns a new entity
  94098. */
  94099. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94100. /**
  94101. * Clones an object
  94102. * @param creationFunction defines the function used to instanciate the new object
  94103. * @param source defines the source object
  94104. * @returns the cloned object
  94105. */
  94106. static Clone<T>(creationFunction: () => T, source: T): T;
  94107. /**
  94108. * Instanciates a new object based on a source one (some data will be shared between both object)
  94109. * @param creationFunction defines the function used to instanciate the new object
  94110. * @param source defines the source object
  94111. * @returns the new object
  94112. */
  94113. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94114. }
  94115. }
  94116. declare module BABYLON {
  94117. /**
  94118. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  94119. */
  94120. export interface CubeMapInfo {
  94121. /**
  94122. * The pixel array for the front face.
  94123. * This is stored in format, left to right, up to down format.
  94124. */
  94125. front: Nullable<ArrayBufferView>;
  94126. /**
  94127. * The pixel array for the back face.
  94128. * This is stored in format, left to right, up to down format.
  94129. */
  94130. back: Nullable<ArrayBufferView>;
  94131. /**
  94132. * The pixel array for the left face.
  94133. * This is stored in format, left to right, up to down format.
  94134. */
  94135. left: Nullable<ArrayBufferView>;
  94136. /**
  94137. * The pixel array for the right face.
  94138. * This is stored in format, left to right, up to down format.
  94139. */
  94140. right: Nullable<ArrayBufferView>;
  94141. /**
  94142. * The pixel array for the up face.
  94143. * This is stored in format, left to right, up to down format.
  94144. */
  94145. up: Nullable<ArrayBufferView>;
  94146. /**
  94147. * The pixel array for the down face.
  94148. * This is stored in format, left to right, up to down format.
  94149. */
  94150. down: Nullable<ArrayBufferView>;
  94151. /**
  94152. * The size of the cubemap stored.
  94153. *
  94154. * Each faces will be size * size pixels.
  94155. */
  94156. size: number;
  94157. /**
  94158. * The format of the texture.
  94159. *
  94160. * RGBA, RGB.
  94161. */
  94162. format: number;
  94163. /**
  94164. * The type of the texture data.
  94165. *
  94166. * UNSIGNED_INT, FLOAT.
  94167. */
  94168. type: number;
  94169. /**
  94170. * Specifies whether the texture is in gamma space.
  94171. */
  94172. gammaSpace: boolean;
  94173. }
  94174. /**
  94175. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94176. */
  94177. export class PanoramaToCubeMapTools {
  94178. private static FACE_FRONT;
  94179. private static FACE_BACK;
  94180. private static FACE_RIGHT;
  94181. private static FACE_LEFT;
  94182. private static FACE_DOWN;
  94183. private static FACE_UP;
  94184. /**
  94185. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94186. *
  94187. * @param float32Array The source data.
  94188. * @param inputWidth The width of the input panorama.
  94189. * @param inputHeight The height of the input panorama.
  94190. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94191. * @return The cubemap data
  94192. */
  94193. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  94194. private static CreateCubemapTexture;
  94195. private static CalcProjectionSpherical;
  94196. }
  94197. }
  94198. declare module BABYLON {
  94199. /**
  94200. * Helper class dealing with the extraction of spherical polynomial dataArray
  94201. * from a cube map.
  94202. */
  94203. export class CubeMapToSphericalPolynomialTools {
  94204. private static FileFaces;
  94205. /**
  94206. * Converts a texture to the according Spherical Polynomial data.
  94207. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94208. *
  94209. * @param texture The texture to extract the information from.
  94210. * @return The Spherical Polynomial data.
  94211. */
  94212. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  94213. /**
  94214. * Converts a cubemap to the according Spherical Polynomial data.
  94215. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94216. *
  94217. * @param cubeInfo The Cube map to extract the information from.
  94218. * @return The Spherical Polynomial data.
  94219. */
  94220. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  94221. }
  94222. }
  94223. declare module BABYLON {
  94224. /**
  94225. * Class used to manipulate GUIDs
  94226. */
  94227. export class GUID {
  94228. /**
  94229. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94230. * Be aware Math.random() could cause collisions, but:
  94231. * "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"
  94232. * @returns a pseudo random id
  94233. */
  94234. static RandomId(): string;
  94235. }
  94236. }
  94237. declare module BABYLON {
  94238. /**
  94239. * Base class of all the textures in babylon.
  94240. * It groups all the common properties the materials, post process, lights... might need
  94241. * in order to make a correct use of the texture.
  94242. */
  94243. export class BaseTexture implements IAnimatable {
  94244. /**
  94245. * Default anisotropic filtering level for the application.
  94246. * It is set to 4 as a good tradeoff between perf and quality.
  94247. */
  94248. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94249. /**
  94250. * Gets or sets the unique id of the texture
  94251. */
  94252. uniqueId: number;
  94253. /**
  94254. * Define the name of the texture.
  94255. */
  94256. name: string;
  94257. /**
  94258. * Gets or sets an object used to store user defined information.
  94259. */
  94260. metadata: any;
  94261. /**
  94262. * For internal use only. Please do not use.
  94263. */
  94264. reservedDataStore: any;
  94265. private _hasAlpha;
  94266. /**
  94267. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94268. */
  94269. hasAlpha: boolean;
  94270. /**
  94271. * Defines if the alpha value should be determined via the rgb values.
  94272. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94273. */
  94274. getAlphaFromRGB: boolean;
  94275. /**
  94276. * Intensity or strength of the texture.
  94277. * It is commonly used by materials to fine tune the intensity of the texture
  94278. */
  94279. level: number;
  94280. /**
  94281. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94282. * This is part of the texture as textures usually maps to one uv set.
  94283. */
  94284. coordinatesIndex: number;
  94285. private _coordinatesMode;
  94286. /**
  94287. * How a texture is mapped.
  94288. *
  94289. * | Value | Type | Description |
  94290. * | ----- | ----------------------------------- | ----------- |
  94291. * | 0 | EXPLICIT_MODE | |
  94292. * | 1 | SPHERICAL_MODE | |
  94293. * | 2 | PLANAR_MODE | |
  94294. * | 3 | CUBIC_MODE | |
  94295. * | 4 | PROJECTION_MODE | |
  94296. * | 5 | SKYBOX_MODE | |
  94297. * | 6 | INVCUBIC_MODE | |
  94298. * | 7 | EQUIRECTANGULAR_MODE | |
  94299. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94300. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94301. */
  94302. coordinatesMode: number;
  94303. /**
  94304. * | Value | Type | Description |
  94305. * | ----- | ------------------ | ----------- |
  94306. * | 0 | CLAMP_ADDRESSMODE | |
  94307. * | 1 | WRAP_ADDRESSMODE | |
  94308. * | 2 | MIRROR_ADDRESSMODE | |
  94309. */
  94310. wrapU: number;
  94311. /**
  94312. * | Value | Type | Description |
  94313. * | ----- | ------------------ | ----------- |
  94314. * | 0 | CLAMP_ADDRESSMODE | |
  94315. * | 1 | WRAP_ADDRESSMODE | |
  94316. * | 2 | MIRROR_ADDRESSMODE | |
  94317. */
  94318. wrapV: number;
  94319. /**
  94320. * | Value | Type | Description |
  94321. * | ----- | ------------------ | ----------- |
  94322. * | 0 | CLAMP_ADDRESSMODE | |
  94323. * | 1 | WRAP_ADDRESSMODE | |
  94324. * | 2 | MIRROR_ADDRESSMODE | |
  94325. */
  94326. wrapR: number;
  94327. /**
  94328. * With compliant hardware and browser (supporting anisotropic filtering)
  94329. * this defines the level of anisotropic filtering in the texture.
  94330. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94331. */
  94332. anisotropicFilteringLevel: number;
  94333. /**
  94334. * Define if the texture is a cube texture or if false a 2d texture.
  94335. */
  94336. isCube: boolean;
  94337. /**
  94338. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94339. */
  94340. is3D: boolean;
  94341. /**
  94342. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94343. * HDR texture are usually stored in linear space.
  94344. * This only impacts the PBR and Background materials
  94345. */
  94346. gammaSpace: boolean;
  94347. /**
  94348. * Gets or sets whether or not the texture contains RGBD data.
  94349. */
  94350. isRGBD: boolean;
  94351. /**
  94352. * Is Z inverted in the texture (useful in a cube texture).
  94353. */
  94354. invertZ: boolean;
  94355. /**
  94356. * Are mip maps generated for this texture or not.
  94357. */
  94358. readonly noMipmap: boolean;
  94359. /**
  94360. * @hidden
  94361. */
  94362. lodLevelInAlpha: boolean;
  94363. /**
  94364. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94365. */
  94366. lodGenerationOffset: number;
  94367. /**
  94368. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94369. */
  94370. lodGenerationScale: number;
  94371. /**
  94372. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94373. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94374. * average roughness values.
  94375. */
  94376. linearSpecularLOD: boolean;
  94377. /**
  94378. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94379. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94380. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94381. */
  94382. irradianceTexture: Nullable<BaseTexture>;
  94383. /**
  94384. * Define if the texture is a render target.
  94385. */
  94386. isRenderTarget: boolean;
  94387. /**
  94388. * Define the unique id of the texture in the scene.
  94389. */
  94390. readonly uid: string;
  94391. /**
  94392. * Return a string representation of the texture.
  94393. * @returns the texture as a string
  94394. */
  94395. toString(): string;
  94396. /**
  94397. * Get the class name of the texture.
  94398. * @returns "BaseTexture"
  94399. */
  94400. getClassName(): string;
  94401. /**
  94402. * Define the list of animation attached to the texture.
  94403. */
  94404. animations: Animation[];
  94405. /**
  94406. * An event triggered when the texture is disposed.
  94407. */
  94408. onDisposeObservable: Observable<BaseTexture>;
  94409. private _onDisposeObserver;
  94410. /**
  94411. * Callback triggered when the texture has been disposed.
  94412. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94413. */
  94414. onDispose: () => void;
  94415. /**
  94416. * Define the current state of the loading sequence when in delayed load mode.
  94417. */
  94418. delayLoadState: number;
  94419. private _scene;
  94420. /** @hidden */
  94421. _texture: Nullable<InternalTexture>;
  94422. private _uid;
  94423. /**
  94424. * Define if the texture is preventinga material to render or not.
  94425. * If not and the texture is not ready, the engine will use a default black texture instead.
  94426. */
  94427. readonly isBlocking: boolean;
  94428. /**
  94429. * Instantiates a new BaseTexture.
  94430. * Base class of all the textures in babylon.
  94431. * It groups all the common properties the materials, post process, lights... might need
  94432. * in order to make a correct use of the texture.
  94433. * @param scene Define the scene the texture blongs to
  94434. */
  94435. constructor(scene: Nullable<Scene>);
  94436. /**
  94437. * Get the scene the texture belongs to.
  94438. * @returns the scene or null if undefined
  94439. */
  94440. getScene(): Nullable<Scene>;
  94441. /**
  94442. * Get the texture transform matrix used to offset tile the texture for istance.
  94443. * @returns the transformation matrix
  94444. */
  94445. getTextureMatrix(): Matrix;
  94446. /**
  94447. * Get the texture reflection matrix used to rotate/transform the reflection.
  94448. * @returns the reflection matrix
  94449. */
  94450. getReflectionTextureMatrix(): Matrix;
  94451. /**
  94452. * Get the underlying lower level texture from Babylon.
  94453. * @returns the insternal texture
  94454. */
  94455. getInternalTexture(): Nullable<InternalTexture>;
  94456. /**
  94457. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94458. * @returns true if ready or not blocking
  94459. */
  94460. isReadyOrNotBlocking(): boolean;
  94461. /**
  94462. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94463. * @returns true if fully ready
  94464. */
  94465. isReady(): boolean;
  94466. private _cachedSize;
  94467. /**
  94468. * Get the size of the texture.
  94469. * @returns the texture size.
  94470. */
  94471. getSize(): ISize;
  94472. /**
  94473. * Get the base size of the texture.
  94474. * It can be different from the size if the texture has been resized for POT for instance
  94475. * @returns the base size
  94476. */
  94477. getBaseSize(): ISize;
  94478. /**
  94479. * Update the sampling mode of the texture.
  94480. * Default is Trilinear mode.
  94481. *
  94482. * | Value | Type | Description |
  94483. * | ----- | ------------------ | ----------- |
  94484. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94485. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94486. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94487. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94488. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94489. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94490. * | 7 | NEAREST_LINEAR | |
  94491. * | 8 | NEAREST_NEAREST | |
  94492. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94493. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94494. * | 11 | LINEAR_LINEAR | |
  94495. * | 12 | LINEAR_NEAREST | |
  94496. *
  94497. * > _mag_: magnification filter (close to the viewer)
  94498. * > _min_: minification filter (far from the viewer)
  94499. * > _mip_: filter used between mip map levels
  94500. *@param samplingMode Define the new sampling mode of the texture
  94501. */
  94502. updateSamplingMode(samplingMode: number): void;
  94503. /**
  94504. * Scales the texture if is `canRescale()`
  94505. * @param ratio the resize factor we want to use to rescale
  94506. */
  94507. scale(ratio: number): void;
  94508. /**
  94509. * Get if the texture can rescale.
  94510. */
  94511. readonly canRescale: boolean;
  94512. /** @hidden */
  94513. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94514. /** @hidden */
  94515. _rebuild(): void;
  94516. /**
  94517. * Triggers the load sequence in delayed load mode.
  94518. */
  94519. delayLoad(): void;
  94520. /**
  94521. * Clones the texture.
  94522. * @returns the cloned texture
  94523. */
  94524. clone(): Nullable<BaseTexture>;
  94525. /**
  94526. * Get the texture underlying type (INT, FLOAT...)
  94527. */
  94528. readonly textureType: number;
  94529. /**
  94530. * Get the texture underlying format (RGB, RGBA...)
  94531. */
  94532. readonly textureFormat: number;
  94533. /**
  94534. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94535. * This will returns an RGBA array buffer containing either in values (0-255) or
  94536. * float values (0-1) depending of the underlying buffer type.
  94537. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94538. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94539. * @param buffer defines a user defined buffer to fill with data (can be null)
  94540. * @returns The Array buffer containing the pixels data.
  94541. */
  94542. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94543. /**
  94544. * Release and destroy the underlying lower level texture aka internalTexture.
  94545. */
  94546. releaseInternalTexture(): void;
  94547. /**
  94548. * Get the polynomial representation of the texture data.
  94549. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94550. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94551. */
  94552. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94553. /** @hidden */
  94554. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94555. /** @hidden */
  94556. readonly _lodTextureMid: Nullable<BaseTexture>;
  94557. /** @hidden */
  94558. readonly _lodTextureLow: Nullable<BaseTexture>;
  94559. /**
  94560. * Dispose the texture and release its associated resources.
  94561. */
  94562. dispose(): void;
  94563. /**
  94564. * Serialize the texture into a JSON representation that can be parsed later on.
  94565. * @returns the JSON representation of the texture
  94566. */
  94567. serialize(): any;
  94568. /**
  94569. * Helper function to be called back once a list of texture contains only ready textures.
  94570. * @param textures Define the list of textures to wait for
  94571. * @param callback Define the callback triggered once the entire list will be ready
  94572. */
  94573. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94574. }
  94575. }
  94576. declare module BABYLON {
  94577. /**
  94578. * Options to be used when creating an effect.
  94579. */
  94580. export class EffectCreationOptions {
  94581. /**
  94582. * Atrributes that will be used in the shader.
  94583. */
  94584. attributes: string[];
  94585. /**
  94586. * Uniform varible names that will be set in the shader.
  94587. */
  94588. uniformsNames: string[];
  94589. /**
  94590. * Uniform buffer varible names that will be set in the shader.
  94591. */
  94592. uniformBuffersNames: string[];
  94593. /**
  94594. * Sampler texture variable names that will be set in the shader.
  94595. */
  94596. samplers: string[];
  94597. /**
  94598. * Define statements that will be set in the shader.
  94599. */
  94600. defines: any;
  94601. /**
  94602. * Possible fallbacks for this effect to improve performance when needed.
  94603. */
  94604. fallbacks: Nullable<IEffectFallbacks>;
  94605. /**
  94606. * Callback that will be called when the shader is compiled.
  94607. */
  94608. onCompiled: Nullable<(effect: Effect) => void>;
  94609. /**
  94610. * Callback that will be called if an error occurs during shader compilation.
  94611. */
  94612. onError: Nullable<(effect: Effect, errors: string) => void>;
  94613. /**
  94614. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94615. */
  94616. indexParameters?: any;
  94617. /**
  94618. * Max number of lights that can be used in the shader.
  94619. */
  94620. maxSimultaneousLights?: number;
  94621. /**
  94622. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94623. */
  94624. transformFeedbackVaryings?: Nullable<string[]>;
  94625. }
  94626. /**
  94627. * Effect containing vertex and fragment shader that can be executed on an object.
  94628. */
  94629. export class Effect implements IDisposable {
  94630. /**
  94631. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94632. */
  94633. static ShadersRepository: string;
  94634. /**
  94635. * Name of the effect.
  94636. */
  94637. name: any;
  94638. /**
  94639. * String container all the define statements that should be set on the shader.
  94640. */
  94641. defines: string;
  94642. /**
  94643. * Callback that will be called when the shader is compiled.
  94644. */
  94645. onCompiled: Nullable<(effect: Effect) => void>;
  94646. /**
  94647. * Callback that will be called if an error occurs during shader compilation.
  94648. */
  94649. onError: Nullable<(effect: Effect, errors: string) => void>;
  94650. /**
  94651. * Callback that will be called when effect is bound.
  94652. */
  94653. onBind: Nullable<(effect: Effect) => void>;
  94654. /**
  94655. * Unique ID of the effect.
  94656. */
  94657. uniqueId: number;
  94658. /**
  94659. * Observable that will be called when the shader is compiled.
  94660. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94661. */
  94662. onCompileObservable: Observable<Effect>;
  94663. /**
  94664. * Observable that will be called if an error occurs during shader compilation.
  94665. */
  94666. onErrorObservable: Observable<Effect>;
  94667. /** @hidden */
  94668. _onBindObservable: Nullable<Observable<Effect>>;
  94669. /**
  94670. * Observable that will be called when effect is bound.
  94671. */
  94672. readonly onBindObservable: Observable<Effect>;
  94673. /** @hidden */
  94674. _bonesComputationForcedToCPU: boolean;
  94675. private static _uniqueIdSeed;
  94676. private _engine;
  94677. private _uniformBuffersNames;
  94678. private _uniformsNames;
  94679. private _samplerList;
  94680. private _samplers;
  94681. private _isReady;
  94682. private _compilationError;
  94683. private _attributesNames;
  94684. private _attributes;
  94685. private _uniforms;
  94686. /**
  94687. * Key for the effect.
  94688. * @hidden
  94689. */
  94690. _key: string;
  94691. private _indexParameters;
  94692. private _fallbacks;
  94693. private _vertexSourceCode;
  94694. private _fragmentSourceCode;
  94695. private _vertexSourceCodeOverride;
  94696. private _fragmentSourceCodeOverride;
  94697. private _transformFeedbackVaryings;
  94698. /**
  94699. * Compiled shader to webGL program.
  94700. * @hidden
  94701. */
  94702. _pipelineContext: Nullable<IPipelineContext>;
  94703. private _valueCache;
  94704. private static _baseCache;
  94705. /**
  94706. * Instantiates an effect.
  94707. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94708. * @param baseName Name of the effect.
  94709. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94710. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94711. * @param samplers List of sampler variables that will be passed to the shader.
  94712. * @param engine Engine to be used to render the effect
  94713. * @param defines Define statements to be added to the shader.
  94714. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94715. * @param onCompiled Callback that will be called when the shader is compiled.
  94716. * @param onError Callback that will be called if an error occurs during shader compilation.
  94717. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94718. */
  94719. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  94720. private _useFinalCode;
  94721. /**
  94722. * Unique key for this effect
  94723. */
  94724. readonly key: string;
  94725. /**
  94726. * If the effect has been compiled and prepared.
  94727. * @returns if the effect is compiled and prepared.
  94728. */
  94729. isReady(): boolean;
  94730. private _isReadyInternal;
  94731. /**
  94732. * The engine the effect was initialized with.
  94733. * @returns the engine.
  94734. */
  94735. getEngine(): Engine;
  94736. /**
  94737. * The pipeline context for this effect
  94738. * @returns the associated pipeline context
  94739. */
  94740. getPipelineContext(): Nullable<IPipelineContext>;
  94741. /**
  94742. * The set of names of attribute variables for the shader.
  94743. * @returns An array of attribute names.
  94744. */
  94745. getAttributesNames(): string[];
  94746. /**
  94747. * Returns the attribute at the given index.
  94748. * @param index The index of the attribute.
  94749. * @returns The location of the attribute.
  94750. */
  94751. getAttributeLocation(index: number): number;
  94752. /**
  94753. * Returns the attribute based on the name of the variable.
  94754. * @param name of the attribute to look up.
  94755. * @returns the attribute location.
  94756. */
  94757. getAttributeLocationByName(name: string): number;
  94758. /**
  94759. * The number of attributes.
  94760. * @returns the numnber of attributes.
  94761. */
  94762. getAttributesCount(): number;
  94763. /**
  94764. * Gets the index of a uniform variable.
  94765. * @param uniformName of the uniform to look up.
  94766. * @returns the index.
  94767. */
  94768. getUniformIndex(uniformName: string): number;
  94769. /**
  94770. * Returns the attribute based on the name of the variable.
  94771. * @param uniformName of the uniform to look up.
  94772. * @returns the location of the uniform.
  94773. */
  94774. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94775. /**
  94776. * Returns an array of sampler variable names
  94777. * @returns The array of sampler variable neames.
  94778. */
  94779. getSamplers(): string[];
  94780. /**
  94781. * The error from the last compilation.
  94782. * @returns the error string.
  94783. */
  94784. getCompilationError(): string;
  94785. /**
  94786. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94787. * @param func The callback to be used.
  94788. */
  94789. executeWhenCompiled(func: (effect: Effect) => void): void;
  94790. private _checkIsReady;
  94791. /** @hidden */
  94792. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94793. /** @hidden */
  94794. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94795. /** @hidden */
  94796. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94797. /**
  94798. * Recompiles the webGL program
  94799. * @param vertexSourceCode The source code for the vertex shader.
  94800. * @param fragmentSourceCode The source code for the fragment shader.
  94801. * @param onCompiled Callback called when completed.
  94802. * @param onError Callback called on error.
  94803. * @hidden
  94804. */
  94805. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94806. /**
  94807. * Prepares the effect
  94808. * @hidden
  94809. */
  94810. _prepareEffect(): void;
  94811. private _processCompilationErrors;
  94812. /**
  94813. * Checks if the effect is supported. (Must be called after compilation)
  94814. */
  94815. readonly isSupported: boolean;
  94816. /**
  94817. * Binds a texture to the engine to be used as output of the shader.
  94818. * @param channel Name of the output variable.
  94819. * @param texture Texture to bind.
  94820. * @hidden
  94821. */
  94822. _bindTexture(channel: string, texture: InternalTexture): void;
  94823. /**
  94824. * Sets a texture on the engine to be used in the shader.
  94825. * @param channel Name of the sampler variable.
  94826. * @param texture Texture to set.
  94827. */
  94828. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94829. /**
  94830. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94831. * @param channel Name of the sampler variable.
  94832. * @param texture Texture to set.
  94833. */
  94834. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94835. /**
  94836. * Sets an array of textures on the engine to be used in the shader.
  94837. * @param channel Name of the variable.
  94838. * @param textures Textures to set.
  94839. */
  94840. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94841. /**
  94842. * 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)
  94843. * @param channel Name of the sampler variable.
  94844. * @param postProcess Post process to get the input texture from.
  94845. */
  94846. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94847. /**
  94848. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94849. * 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)
  94850. * @param channel Name of the sampler variable.
  94851. * @param postProcess Post process to get the output texture from.
  94852. */
  94853. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94854. /** @hidden */
  94855. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94856. /** @hidden */
  94857. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94858. /** @hidden */
  94859. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94860. /** @hidden */
  94861. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94862. /**
  94863. * Binds a buffer to a uniform.
  94864. * @param buffer Buffer to bind.
  94865. * @param name Name of the uniform variable to bind to.
  94866. */
  94867. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94868. /**
  94869. * Binds block to a uniform.
  94870. * @param blockName Name of the block to bind.
  94871. * @param index Index to bind.
  94872. */
  94873. bindUniformBlock(blockName: string, index: number): void;
  94874. /**
  94875. * Sets an interger value on a uniform variable.
  94876. * @param uniformName Name of the variable.
  94877. * @param value Value to be set.
  94878. * @returns this effect.
  94879. */
  94880. setInt(uniformName: string, value: number): Effect;
  94881. /**
  94882. * Sets an int array on a uniform variable.
  94883. * @param uniformName Name of the variable.
  94884. * @param array array to be set.
  94885. * @returns this effect.
  94886. */
  94887. setIntArray(uniformName: string, array: Int32Array): Effect;
  94888. /**
  94889. * 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)
  94890. * @param uniformName Name of the variable.
  94891. * @param array array to be set.
  94892. * @returns this effect.
  94893. */
  94894. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94895. /**
  94896. * 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)
  94897. * @param uniformName Name of the variable.
  94898. * @param array array to be set.
  94899. * @returns this effect.
  94900. */
  94901. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94902. /**
  94903. * 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)
  94904. * @param uniformName Name of the variable.
  94905. * @param array array to be set.
  94906. * @returns this effect.
  94907. */
  94908. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94909. /**
  94910. * Sets an float array on a uniform variable.
  94911. * @param uniformName Name of the variable.
  94912. * @param array array to be set.
  94913. * @returns this effect.
  94914. */
  94915. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94916. /**
  94917. * 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)
  94918. * @param uniformName Name of the variable.
  94919. * @param array array to be set.
  94920. * @returns this effect.
  94921. */
  94922. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94923. /**
  94924. * 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)
  94925. * @param uniformName Name of the variable.
  94926. * @param array array to be set.
  94927. * @returns this effect.
  94928. */
  94929. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94930. /**
  94931. * 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)
  94932. * @param uniformName Name of the variable.
  94933. * @param array array to be set.
  94934. * @returns this effect.
  94935. */
  94936. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94937. /**
  94938. * Sets an array on a uniform variable.
  94939. * @param uniformName Name of the variable.
  94940. * @param array array to be set.
  94941. * @returns this effect.
  94942. */
  94943. setArray(uniformName: string, array: number[]): Effect;
  94944. /**
  94945. * 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)
  94946. * @param uniformName Name of the variable.
  94947. * @param array array to be set.
  94948. * @returns this effect.
  94949. */
  94950. setArray2(uniformName: string, array: number[]): Effect;
  94951. /**
  94952. * 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)
  94953. * @param uniformName Name of the variable.
  94954. * @param array array to be set.
  94955. * @returns this effect.
  94956. */
  94957. setArray3(uniformName: string, array: number[]): Effect;
  94958. /**
  94959. * 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)
  94960. * @param uniformName Name of the variable.
  94961. * @param array array to be set.
  94962. * @returns this effect.
  94963. */
  94964. setArray4(uniformName: string, array: number[]): Effect;
  94965. /**
  94966. * Sets matrices on a uniform variable.
  94967. * @param uniformName Name of the variable.
  94968. * @param matrices matrices to be set.
  94969. * @returns this effect.
  94970. */
  94971. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94972. /**
  94973. * Sets matrix on a uniform variable.
  94974. * @param uniformName Name of the variable.
  94975. * @param matrix matrix to be set.
  94976. * @returns this effect.
  94977. */
  94978. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94979. /**
  94980. * 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)
  94981. * @param uniformName Name of the variable.
  94982. * @param matrix matrix to be set.
  94983. * @returns this effect.
  94984. */
  94985. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94986. /**
  94987. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94988. * @param uniformName Name of the variable.
  94989. * @param matrix matrix to be set.
  94990. * @returns this effect.
  94991. */
  94992. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94993. /**
  94994. * Sets a float on a uniform variable.
  94995. * @param uniformName Name of the variable.
  94996. * @param value value to be set.
  94997. * @returns this effect.
  94998. */
  94999. setFloat(uniformName: string, value: number): Effect;
  95000. /**
  95001. * Sets a boolean on a uniform variable.
  95002. * @param uniformName Name of the variable.
  95003. * @param bool value to be set.
  95004. * @returns this effect.
  95005. */
  95006. setBool(uniformName: string, bool: boolean): Effect;
  95007. /**
  95008. * Sets a Vector2 on a uniform variable.
  95009. * @param uniformName Name of the variable.
  95010. * @param vector2 vector2 to be set.
  95011. * @returns this effect.
  95012. */
  95013. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95014. /**
  95015. * Sets a float2 on a uniform variable.
  95016. * @param uniformName Name of the variable.
  95017. * @param x First float in float2.
  95018. * @param y Second float in float2.
  95019. * @returns this effect.
  95020. */
  95021. setFloat2(uniformName: string, x: number, y: number): Effect;
  95022. /**
  95023. * Sets a Vector3 on a uniform variable.
  95024. * @param uniformName Name of the variable.
  95025. * @param vector3 Value to be set.
  95026. * @returns this effect.
  95027. */
  95028. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95029. /**
  95030. * Sets a float3 on a uniform variable.
  95031. * @param uniformName Name of the variable.
  95032. * @param x First float in float3.
  95033. * @param y Second float in float3.
  95034. * @param z Third float in float3.
  95035. * @returns this effect.
  95036. */
  95037. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95038. /**
  95039. * Sets a Vector4 on a uniform variable.
  95040. * @param uniformName Name of the variable.
  95041. * @param vector4 Value to be set.
  95042. * @returns this effect.
  95043. */
  95044. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95045. /**
  95046. * Sets a float4 on a uniform variable.
  95047. * @param uniformName Name of the variable.
  95048. * @param x First float in float4.
  95049. * @param y Second float in float4.
  95050. * @param z Third float in float4.
  95051. * @param w Fourth float in float4.
  95052. * @returns this effect.
  95053. */
  95054. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95055. /**
  95056. * Sets a Color3 on a uniform variable.
  95057. * @param uniformName Name of the variable.
  95058. * @param color3 Value to be set.
  95059. * @returns this effect.
  95060. */
  95061. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95062. /**
  95063. * Sets a Color4 on a uniform variable.
  95064. * @param uniformName Name of the variable.
  95065. * @param color3 Value to be set.
  95066. * @param alpha Alpha value to be set.
  95067. * @returns this effect.
  95068. */
  95069. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95070. /**
  95071. * Sets a Color4 on a uniform variable
  95072. * @param uniformName defines the name of the variable
  95073. * @param color4 defines the value to be set
  95074. * @returns this effect.
  95075. */
  95076. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95077. /** Release all associated resources */
  95078. dispose(): void;
  95079. /**
  95080. * This function will add a new shader to the shader store
  95081. * @param name the name of the shader
  95082. * @param pixelShader optional pixel shader content
  95083. * @param vertexShader optional vertex shader content
  95084. */
  95085. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95086. /**
  95087. * Store of each shader (The can be looked up using effect.key)
  95088. */
  95089. static ShadersStore: {
  95090. [key: string]: string;
  95091. };
  95092. /**
  95093. * Store of each included file for a shader (The can be looked up using effect.key)
  95094. */
  95095. static IncludesShadersStore: {
  95096. [key: string]: string;
  95097. };
  95098. /**
  95099. * Resets the cache of effects.
  95100. */
  95101. static ResetCache(): void;
  95102. }
  95103. }
  95104. declare module BABYLON {
  95105. /**
  95106. * Class used to describe the capabilities of the engine relatively to the current browser
  95107. */
  95108. export class EngineCapabilities {
  95109. /** Maximum textures units per fragment shader */
  95110. maxTexturesImageUnits: number;
  95111. /** Maximum texture units per vertex shader */
  95112. maxVertexTextureImageUnits: number;
  95113. /** Maximum textures units in the entire pipeline */
  95114. maxCombinedTexturesImageUnits: number;
  95115. /** Maximum texture size */
  95116. maxTextureSize: number;
  95117. /** Maximum cube texture size */
  95118. maxCubemapTextureSize: number;
  95119. /** Maximum render texture size */
  95120. maxRenderTextureSize: number;
  95121. /** Maximum number of vertex attributes */
  95122. maxVertexAttribs: number;
  95123. /** Maximum number of varyings */
  95124. maxVaryingVectors: number;
  95125. /** Maximum number of uniforms per vertex shader */
  95126. maxVertexUniformVectors: number;
  95127. /** Maximum number of uniforms per fragment shader */
  95128. maxFragmentUniformVectors: number;
  95129. /** Defines if standard derivates (dx/dy) are supported */
  95130. standardDerivatives: boolean;
  95131. /** Defines if s3tc texture compression is supported */
  95132. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95133. /** Defines if pvrtc texture compression is supported */
  95134. pvrtc: any;
  95135. /** Defines if etc1 texture compression is supported */
  95136. etc1: any;
  95137. /** Defines if etc2 texture compression is supported */
  95138. etc2: any;
  95139. /** Defines if astc texture compression is supported */
  95140. astc: any;
  95141. /** Defines if float textures are supported */
  95142. textureFloat: boolean;
  95143. /** Defines if vertex array objects are supported */
  95144. vertexArrayObject: boolean;
  95145. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95146. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95147. /** Gets the maximum level of anisotropy supported */
  95148. maxAnisotropy: number;
  95149. /** Defines if instancing is supported */
  95150. instancedArrays: boolean;
  95151. /** Defines if 32 bits indices are supported */
  95152. uintIndices: boolean;
  95153. /** Defines if high precision shaders are supported */
  95154. highPrecisionShaderSupported: boolean;
  95155. /** Defines if depth reading in the fragment shader is supported */
  95156. fragmentDepthSupported: boolean;
  95157. /** Defines if float texture linear filtering is supported*/
  95158. textureFloatLinearFiltering: boolean;
  95159. /** Defines if rendering to float textures is supported */
  95160. textureFloatRender: boolean;
  95161. /** Defines if half float textures are supported*/
  95162. textureHalfFloat: boolean;
  95163. /** Defines if half float texture linear filtering is supported*/
  95164. textureHalfFloatLinearFiltering: boolean;
  95165. /** Defines if rendering to half float textures is supported */
  95166. textureHalfFloatRender: boolean;
  95167. /** Defines if textureLOD shader command is supported */
  95168. textureLOD: boolean;
  95169. /** Defines if draw buffers extension is supported */
  95170. drawBuffersExtension: boolean;
  95171. /** Defines if depth textures are supported */
  95172. depthTextureExtension: boolean;
  95173. /** Defines if float color buffer are supported */
  95174. colorBufferFloat: boolean;
  95175. /** Gets disjoint timer query extension (null if not supported) */
  95176. timerQuery: EXT_disjoint_timer_query;
  95177. /** Defines if timestamp can be used with timer query */
  95178. canUseTimestampForTimerQuery: boolean;
  95179. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95180. multiview: any;
  95181. /** Function used to let the system compiles shaders in background */
  95182. parallelShaderCompile: {
  95183. COMPLETION_STATUS_KHR: number;
  95184. };
  95185. /** Max number of texture samples for MSAA */
  95186. maxMSAASamples: number;
  95187. /** Defines if the blend min max extension is supported */
  95188. blendMinMax: boolean;
  95189. }
  95190. }
  95191. declare module BABYLON {
  95192. /**
  95193. * This class is used to track a performance counter which is number based.
  95194. * The user has access to many properties which give statistics of different nature.
  95195. *
  95196. * The implementer can track two kinds of Performance Counter: time and count.
  95197. * 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.
  95198. * 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.
  95199. */
  95200. export class PerfCounter {
  95201. /**
  95202. * Gets or sets a global boolean to turn on and off all the counters
  95203. */
  95204. static Enabled: boolean;
  95205. /**
  95206. * Returns the smallest value ever
  95207. */
  95208. readonly min: number;
  95209. /**
  95210. * Returns the biggest value ever
  95211. */
  95212. readonly max: number;
  95213. /**
  95214. * Returns the average value since the performance counter is running
  95215. */
  95216. readonly average: number;
  95217. /**
  95218. * Returns the average value of the last second the counter was monitored
  95219. */
  95220. readonly lastSecAverage: number;
  95221. /**
  95222. * Returns the current value
  95223. */
  95224. readonly current: number;
  95225. /**
  95226. * Gets the accumulated total
  95227. */
  95228. readonly total: number;
  95229. /**
  95230. * Gets the total value count
  95231. */
  95232. readonly count: number;
  95233. /**
  95234. * Creates a new counter
  95235. */
  95236. constructor();
  95237. /**
  95238. * Call this method to start monitoring a new frame.
  95239. * 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.
  95240. */
  95241. fetchNewFrame(): void;
  95242. /**
  95243. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95244. * @param newCount the count value to add to the monitored count
  95245. * @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.
  95246. */
  95247. addCount(newCount: number, fetchResult: boolean): void;
  95248. /**
  95249. * Start monitoring this performance counter
  95250. */
  95251. beginMonitoring(): void;
  95252. /**
  95253. * Compute the time lapsed since the previous beginMonitoring() call.
  95254. * @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
  95255. */
  95256. endMonitoring(newFrame?: boolean): void;
  95257. private _fetchResult;
  95258. private _startMonitoringTime;
  95259. private _min;
  95260. private _max;
  95261. private _average;
  95262. private _current;
  95263. private _totalValueCount;
  95264. private _totalAccumulated;
  95265. private _lastSecAverage;
  95266. private _lastSecAccumulated;
  95267. private _lastSecTime;
  95268. private _lastSecValueCount;
  95269. }
  95270. }
  95271. declare module BABYLON {
  95272. /**
  95273. * @hidden
  95274. **/
  95275. export class DepthCullingState {
  95276. private _isDepthTestDirty;
  95277. private _isDepthMaskDirty;
  95278. private _isDepthFuncDirty;
  95279. private _isCullFaceDirty;
  95280. private _isCullDirty;
  95281. private _isZOffsetDirty;
  95282. private _isFrontFaceDirty;
  95283. private _depthTest;
  95284. private _depthMask;
  95285. private _depthFunc;
  95286. private _cull;
  95287. private _cullFace;
  95288. private _zOffset;
  95289. private _frontFace;
  95290. /**
  95291. * Initializes the state.
  95292. */
  95293. constructor();
  95294. readonly isDirty: boolean;
  95295. zOffset: number;
  95296. cullFace: Nullable<number>;
  95297. cull: Nullable<boolean>;
  95298. depthFunc: Nullable<number>;
  95299. depthMask: boolean;
  95300. depthTest: boolean;
  95301. frontFace: Nullable<number>;
  95302. reset(): void;
  95303. apply(gl: WebGLRenderingContext): void;
  95304. }
  95305. }
  95306. declare module BABYLON {
  95307. /**
  95308. * @hidden
  95309. **/
  95310. export class StencilState {
  95311. /** 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 */
  95312. static readonly ALWAYS: number;
  95313. /** Passed to stencilOperation to specify that stencil value must be kept */
  95314. static readonly KEEP: number;
  95315. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95316. static readonly REPLACE: number;
  95317. private _isStencilTestDirty;
  95318. private _isStencilMaskDirty;
  95319. private _isStencilFuncDirty;
  95320. private _isStencilOpDirty;
  95321. private _stencilTest;
  95322. private _stencilMask;
  95323. private _stencilFunc;
  95324. private _stencilFuncRef;
  95325. private _stencilFuncMask;
  95326. private _stencilOpStencilFail;
  95327. private _stencilOpDepthFail;
  95328. private _stencilOpStencilDepthPass;
  95329. readonly isDirty: boolean;
  95330. stencilFunc: number;
  95331. stencilFuncRef: number;
  95332. stencilFuncMask: number;
  95333. stencilOpStencilFail: number;
  95334. stencilOpDepthFail: number;
  95335. stencilOpStencilDepthPass: number;
  95336. stencilMask: number;
  95337. stencilTest: boolean;
  95338. constructor();
  95339. reset(): void;
  95340. apply(gl: WebGLRenderingContext): void;
  95341. }
  95342. }
  95343. declare module BABYLON {
  95344. /**
  95345. * @hidden
  95346. **/
  95347. export class AlphaState {
  95348. private _isAlphaBlendDirty;
  95349. private _isBlendFunctionParametersDirty;
  95350. private _isBlendEquationParametersDirty;
  95351. private _isBlendConstantsDirty;
  95352. private _alphaBlend;
  95353. private _blendFunctionParameters;
  95354. private _blendEquationParameters;
  95355. private _blendConstants;
  95356. /**
  95357. * Initializes the state.
  95358. */
  95359. constructor();
  95360. readonly isDirty: boolean;
  95361. alphaBlend: boolean;
  95362. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95363. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95364. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95365. reset(): void;
  95366. apply(gl: WebGLRenderingContext): void;
  95367. }
  95368. }
  95369. declare module BABYLON {
  95370. /** @hidden */
  95371. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95372. attributeProcessor(attribute: string): string;
  95373. varyingProcessor(varying: string, isFragment: boolean): string;
  95374. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95375. }
  95376. }
  95377. declare module BABYLON {
  95378. /**
  95379. * Interface for attribute information associated with buffer instanciation
  95380. */
  95381. export class InstancingAttributeInfo {
  95382. /**
  95383. * Index/offset of the attribute in the vertex shader
  95384. */
  95385. index: number;
  95386. /**
  95387. * size of the attribute, 1, 2, 3 or 4
  95388. */
  95389. attributeSize: number;
  95390. /**
  95391. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95392. * default is FLOAT
  95393. */
  95394. attribyteType: number;
  95395. /**
  95396. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95397. */
  95398. normalized: boolean;
  95399. /**
  95400. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95401. */
  95402. offset: number;
  95403. /**
  95404. * Name of the GLSL attribute, for debugging purpose only
  95405. */
  95406. attributeName: string;
  95407. }
  95408. }
  95409. declare module BABYLON {
  95410. interface ThinEngine {
  95411. /**
  95412. * Update a video texture
  95413. * @param texture defines the texture to update
  95414. * @param video defines the video element to use
  95415. * @param invertY defines if data must be stored with Y axis inverted
  95416. */
  95417. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95418. }
  95419. }
  95420. declare module BABYLON {
  95421. /**
  95422. * Settings for finer control over video usage
  95423. */
  95424. export interface VideoTextureSettings {
  95425. /**
  95426. * Applies `autoplay` to video, if specified
  95427. */
  95428. autoPlay?: boolean;
  95429. /**
  95430. * Applies `loop` to video, if specified
  95431. */
  95432. loop?: boolean;
  95433. /**
  95434. * Automatically updates internal texture from video at every frame in the render loop
  95435. */
  95436. autoUpdateTexture: boolean;
  95437. /**
  95438. * Image src displayed during the video loading or until the user interacts with the video.
  95439. */
  95440. poster?: string;
  95441. }
  95442. /**
  95443. * If you want to display a video in your scene, this is the special texture for that.
  95444. * This special texture works similar to other textures, with the exception of a few parameters.
  95445. * @see https://doc.babylonjs.com/how_to/video_texture
  95446. */
  95447. export class VideoTexture extends Texture {
  95448. /**
  95449. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95450. */
  95451. readonly autoUpdateTexture: boolean;
  95452. /**
  95453. * The video instance used by the texture internally
  95454. */
  95455. readonly video: HTMLVideoElement;
  95456. private _onUserActionRequestedObservable;
  95457. /**
  95458. * Event triggerd when a dom action is required by the user to play the video.
  95459. * This happens due to recent changes in browser policies preventing video to auto start.
  95460. */
  95461. readonly onUserActionRequestedObservable: Observable<Texture>;
  95462. private _generateMipMaps;
  95463. private _engine;
  95464. private _stillImageCaptured;
  95465. private _displayingPosterTexture;
  95466. private _settings;
  95467. private _createInternalTextureOnEvent;
  95468. private _frameId;
  95469. /**
  95470. * Creates a video texture.
  95471. * If you want to display a video in your scene, this is the special texture for that.
  95472. * This special texture works similar to other textures, with the exception of a few parameters.
  95473. * @see https://doc.babylonjs.com/how_to/video_texture
  95474. * @param name optional name, will detect from video source, if not defined
  95475. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95476. * @param scene is obviously the current scene.
  95477. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95478. * @param invertY is false by default but can be used to invert video on Y axis
  95479. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95480. * @param settings allows finer control over video usage
  95481. */
  95482. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95483. private _getName;
  95484. private _getVideo;
  95485. private _createInternalTexture;
  95486. private reset;
  95487. /**
  95488. * @hidden Internal method to initiate `update`.
  95489. */
  95490. _rebuild(): void;
  95491. /**
  95492. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95493. */
  95494. update(): void;
  95495. /**
  95496. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95497. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95498. */
  95499. updateTexture(isVisible: boolean): void;
  95500. protected _updateInternalTexture: () => void;
  95501. /**
  95502. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95503. * @param url New url.
  95504. */
  95505. updateURL(url: string): void;
  95506. /**
  95507. * Dispose the texture and release its associated resources.
  95508. */
  95509. dispose(): void;
  95510. /**
  95511. * Creates a video texture straight from a stream.
  95512. * @param scene Define the scene the texture should be created in
  95513. * @param stream Define the stream the texture should be created from
  95514. * @returns The created video texture as a promise
  95515. */
  95516. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95517. /**
  95518. * Creates a video texture straight from your WebCam video feed.
  95519. * @param scene Define the scene the texture should be created in
  95520. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95521. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95522. * @returns The created video texture as a promise
  95523. */
  95524. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95525. minWidth: number;
  95526. maxWidth: number;
  95527. minHeight: number;
  95528. maxHeight: number;
  95529. deviceId: string;
  95530. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95531. /**
  95532. * Creates a video texture straight from your WebCam video feed.
  95533. * @param scene Define the scene the texture should be created in
  95534. * @param onReady Define a callback to triggered once the texture will be ready
  95535. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95536. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95537. */
  95538. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95539. minWidth: number;
  95540. maxWidth: number;
  95541. minHeight: number;
  95542. maxHeight: number;
  95543. deviceId: string;
  95544. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95545. }
  95546. }
  95547. declare module BABYLON {
  95548. /**
  95549. * Defines the interface used by objects working like Scene
  95550. * @hidden
  95551. */
  95552. interface ISceneLike {
  95553. _addPendingData(data: any): void;
  95554. _removePendingData(data: any): void;
  95555. offlineProvider: IOfflineProvider;
  95556. }
  95557. /** Interface defining initialization parameters for Engine class */
  95558. export interface EngineOptions extends WebGLContextAttributes {
  95559. /**
  95560. * Defines if the engine should no exceed a specified device ratio
  95561. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95562. */
  95563. limitDeviceRatio?: number;
  95564. /**
  95565. * Defines if webvr should be enabled automatically
  95566. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95567. */
  95568. autoEnableWebVR?: boolean;
  95569. /**
  95570. * Defines if webgl2 should be turned off even if supported
  95571. * @see http://doc.babylonjs.com/features/webgl2
  95572. */
  95573. disableWebGL2Support?: boolean;
  95574. /**
  95575. * Defines if webaudio should be initialized as well
  95576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95577. */
  95578. audioEngine?: boolean;
  95579. /**
  95580. * Defines if animations should run using a deterministic lock step
  95581. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95582. */
  95583. deterministicLockstep?: boolean;
  95584. /** Defines the maximum steps to use with deterministic lock step mode */
  95585. lockstepMaxSteps?: number;
  95586. /**
  95587. * Defines that engine should ignore context lost events
  95588. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95589. */
  95590. doNotHandleContextLost?: boolean;
  95591. /**
  95592. * Defines that engine should ignore modifying touch action attribute and style
  95593. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95594. */
  95595. doNotHandleTouchAction?: boolean;
  95596. /**
  95597. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95598. */
  95599. useHighPrecisionFloats?: boolean;
  95600. }
  95601. /**
  95602. * The base engine class (root of all engines)
  95603. */
  95604. export class ThinEngine {
  95605. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95606. static ExceptionList: ({
  95607. key: string;
  95608. capture: string;
  95609. captureConstraint: number;
  95610. targets: string[];
  95611. } | {
  95612. key: string;
  95613. capture: null;
  95614. captureConstraint: null;
  95615. targets: string[];
  95616. })[];
  95617. /** @hidden */
  95618. static _TextureLoaders: IInternalTextureLoader[];
  95619. /**
  95620. * Returns the current npm package of the sdk
  95621. */
  95622. static readonly NpmPackage: string;
  95623. /**
  95624. * Returns the current version of the framework
  95625. */
  95626. static readonly Version: string;
  95627. /**
  95628. * Returns a string describing the current engine
  95629. */
  95630. readonly description: string;
  95631. /**
  95632. * Gets or sets the epsilon value used by collision engine
  95633. */
  95634. static CollisionsEpsilon: number;
  95635. /**
  95636. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95637. */
  95638. static ShadersRepository: string;
  95639. /** @hidden */
  95640. _shaderProcessor: IShaderProcessor;
  95641. /**
  95642. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95643. */
  95644. forcePOTTextures: boolean;
  95645. /**
  95646. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95647. */
  95648. isFullscreen: boolean;
  95649. /**
  95650. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95651. */
  95652. cullBackFaces: boolean;
  95653. /**
  95654. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95655. */
  95656. renderEvenInBackground: boolean;
  95657. /**
  95658. * Gets or sets a boolean indicating that cache can be kept between frames
  95659. */
  95660. preventCacheWipeBetweenFrames: boolean;
  95661. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95662. validateShaderPrograms: boolean;
  95663. /**
  95664. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95665. */
  95666. disableUniformBuffers: boolean;
  95667. /** @hidden */
  95668. _uniformBuffers: UniformBuffer[];
  95669. /**
  95670. * Gets a boolean indicating that the engine supports uniform buffers
  95671. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95672. */
  95673. readonly supportsUniformBuffers: boolean;
  95674. /** @hidden */
  95675. _gl: WebGLRenderingContext;
  95676. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95677. protected _windowIsBackground: boolean;
  95678. protected _webGLVersion: number;
  95679. protected _highPrecisionShadersAllowed: boolean;
  95680. /** @hidden */
  95681. readonly _shouldUseHighPrecisionShader: boolean;
  95682. /**
  95683. * Gets a boolean indicating that only power of 2 textures are supported
  95684. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95685. */
  95686. readonly needPOTTextures: boolean;
  95687. /** @hidden */
  95688. _badOS: boolean;
  95689. /** @hidden */
  95690. _badDesktopOS: boolean;
  95691. private _hardwareScalingLevel;
  95692. /** @hidden */
  95693. _caps: EngineCapabilities;
  95694. private _isStencilEnable;
  95695. protected _colorWrite: boolean;
  95696. /** @hidden */
  95697. _drawCalls: PerfCounter;
  95698. private _glVersion;
  95699. private _glRenderer;
  95700. private _glVendor;
  95701. /** @hidden */
  95702. _videoTextureSupported: boolean;
  95703. protected _renderingQueueLaunched: boolean;
  95704. protected _activeRenderLoops: (() => void)[];
  95705. /**
  95706. * Observable signaled when a context lost event is raised
  95707. */
  95708. onContextLostObservable: Observable<ThinEngine>;
  95709. /**
  95710. * Observable signaled when a context restored event is raised
  95711. */
  95712. onContextRestoredObservable: Observable<ThinEngine>;
  95713. private _onContextLost;
  95714. private _onContextRestored;
  95715. protected _contextWasLost: boolean;
  95716. /** @hidden */
  95717. _doNotHandleContextLost: boolean;
  95718. /**
  95719. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95721. */
  95722. doNotHandleContextLost: boolean;
  95723. /**
  95724. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95725. */
  95726. disableVertexArrayObjects: boolean;
  95727. /** @hidden */
  95728. protected _depthCullingState: DepthCullingState;
  95729. /** @hidden */
  95730. protected _stencilState: StencilState;
  95731. /** @hidden */
  95732. protected _alphaState: AlphaState;
  95733. /** @hidden */
  95734. _internalTexturesCache: InternalTexture[];
  95735. /** @hidden */
  95736. protected _activeChannel: number;
  95737. private _currentTextureChannel;
  95738. /** @hidden */
  95739. protected _boundTexturesCache: {
  95740. [key: string]: Nullable<InternalTexture>;
  95741. };
  95742. /** @hidden */
  95743. protected _currentEffect: Nullable<Effect>;
  95744. /** @hidden */
  95745. protected _currentProgram: Nullable<WebGLProgram>;
  95746. private _compiledEffects;
  95747. private _vertexAttribArraysEnabled;
  95748. /** @hidden */
  95749. protected _cachedViewport: Nullable<IViewportLike>;
  95750. private _cachedVertexArrayObject;
  95751. /** @hidden */
  95752. protected _cachedVertexBuffers: any;
  95753. /** @hidden */
  95754. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95755. /** @hidden */
  95756. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95757. /** @hidden */
  95758. _currentRenderTarget: Nullable<InternalTexture>;
  95759. private _uintIndicesCurrentlySet;
  95760. private _currentBoundBuffer;
  95761. /** @hidden */
  95762. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95763. private _currentBufferPointers;
  95764. private _currentInstanceLocations;
  95765. private _currentInstanceBuffers;
  95766. private _textureUnits;
  95767. /** @hidden */
  95768. _workingCanvas: Nullable<HTMLCanvasElement>;
  95769. /** @hidden */
  95770. _workingContext: Nullable<CanvasRenderingContext2D>;
  95771. /** @hidden */
  95772. _bindedRenderFunction: any;
  95773. private _vaoRecordInProgress;
  95774. private _mustWipeVertexAttributes;
  95775. private _emptyTexture;
  95776. private _emptyCubeTexture;
  95777. private _emptyTexture3D;
  95778. /** @hidden */
  95779. _frameHandler: number;
  95780. private _nextFreeTextureSlots;
  95781. private _maxSimultaneousTextures;
  95782. private _activeRequests;
  95783. protected _texturesSupported: string[];
  95784. /** @hidden */
  95785. _textureFormatInUse: Nullable<string>;
  95786. protected readonly _supportsHardwareTextureRescaling: boolean;
  95787. /**
  95788. * Gets the list of texture formats supported
  95789. */
  95790. readonly texturesSupported: Array<string>;
  95791. /**
  95792. * Gets the list of texture formats in use
  95793. */
  95794. readonly textureFormatInUse: Nullable<string>;
  95795. /**
  95796. * Gets the current viewport
  95797. */
  95798. readonly currentViewport: Nullable<IViewportLike>;
  95799. /**
  95800. * Gets the default empty texture
  95801. */
  95802. readonly emptyTexture: InternalTexture;
  95803. /**
  95804. * Gets the default empty 3D texture
  95805. */
  95806. readonly emptyTexture3D: InternalTexture;
  95807. /**
  95808. * Gets the default empty cube texture
  95809. */
  95810. readonly emptyCubeTexture: InternalTexture;
  95811. /**
  95812. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95813. */
  95814. readonly premultipliedAlpha: boolean;
  95815. /**
  95816. * Creates a new engine
  95817. * @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
  95818. * @param antialias defines enable antialiasing (default: false)
  95819. * @param options defines further options to be sent to the getContext() function
  95820. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95821. */
  95822. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95823. private _rebuildInternalTextures;
  95824. private _rebuildEffects;
  95825. /**
  95826. * Gets a boolean indicating if all created effects are ready
  95827. * @returns true if all effects are ready
  95828. */
  95829. areAllEffectsReady(): boolean;
  95830. protected _rebuildBuffers(): void;
  95831. private _initGLContext;
  95832. /**
  95833. * Gets version of the current webGL context
  95834. */
  95835. readonly webGLVersion: number;
  95836. /**
  95837. * Gets a string idenfifying the name of the class
  95838. * @returns "Engine" string
  95839. */
  95840. getClassName(): string;
  95841. /**
  95842. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95843. */
  95844. readonly isStencilEnable: boolean;
  95845. /** @hidden */
  95846. _prepareWorkingCanvas(): void;
  95847. /**
  95848. * Reset the texture cache to empty state
  95849. */
  95850. resetTextureCache(): void;
  95851. /**
  95852. * Gets an object containing information about the current webGL context
  95853. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95854. */
  95855. getGlInfo(): {
  95856. vendor: string;
  95857. renderer: string;
  95858. version: string;
  95859. };
  95860. /**
  95861. * Defines the hardware scaling level.
  95862. * By default the hardware scaling level is computed from the window device ratio.
  95863. * 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.
  95864. * @param level defines the level to use
  95865. */
  95866. setHardwareScalingLevel(level: number): void;
  95867. /**
  95868. * Gets the current hardware scaling level.
  95869. * By default the hardware scaling level is computed from the window device ratio.
  95870. * 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.
  95871. * @returns a number indicating the current hardware scaling level
  95872. */
  95873. getHardwareScalingLevel(): number;
  95874. /**
  95875. * Gets the list of loaded textures
  95876. * @returns an array containing all loaded textures
  95877. */
  95878. getLoadedTexturesCache(): InternalTexture[];
  95879. /**
  95880. * Gets the object containing all engine capabilities
  95881. * @returns the EngineCapabilities object
  95882. */
  95883. getCaps(): EngineCapabilities;
  95884. /**
  95885. * stop executing a render loop function and remove it from the execution array
  95886. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95887. */
  95888. stopRenderLoop(renderFunction?: () => void): void;
  95889. /** @hidden */
  95890. _renderLoop(): void;
  95891. /**
  95892. * Gets the HTML canvas attached with the current webGL context
  95893. * @returns a HTML canvas
  95894. */
  95895. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95896. /**
  95897. * Gets host window
  95898. * @returns the host window object
  95899. */
  95900. getHostWindow(): Window;
  95901. /**
  95902. * Gets the current render width
  95903. * @param useScreen defines if screen size must be used (or the current render target if any)
  95904. * @returns a number defining the current render width
  95905. */
  95906. getRenderWidth(useScreen?: boolean): number;
  95907. /**
  95908. * Gets the current render height
  95909. * @param useScreen defines if screen size must be used (or the current render target if any)
  95910. * @returns a number defining the current render height
  95911. */
  95912. getRenderHeight(useScreen?: boolean): number;
  95913. /**
  95914. * Can be used to override the current requestAnimationFrame requester.
  95915. * @hidden
  95916. */
  95917. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  95918. /**
  95919. * Register and execute a render loop. The engine can have more than one render function
  95920. * @param renderFunction defines the function to continuously execute
  95921. */
  95922. runRenderLoop(renderFunction: () => void): void;
  95923. /**
  95924. * Clear the current render buffer or the current render target (if any is set up)
  95925. * @param color defines the color to use
  95926. * @param backBuffer defines if the back buffer must be cleared
  95927. * @param depth defines if the depth buffer must be cleared
  95928. * @param stencil defines if the stencil buffer must be cleared
  95929. */
  95930. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95931. private _viewportCached;
  95932. /** @hidden */
  95933. _viewport(x: number, y: number, width: number, height: number): void;
  95934. /**
  95935. * Set the WebGL's viewport
  95936. * @param viewport defines the viewport element to be used
  95937. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95938. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95939. */
  95940. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95941. /**
  95942. * Begin a new frame
  95943. */
  95944. beginFrame(): void;
  95945. /**
  95946. * Enf the current frame
  95947. */
  95948. endFrame(): void;
  95949. /**
  95950. * Resize the view according to the canvas' size
  95951. */
  95952. resize(): void;
  95953. /**
  95954. * Force a specific size of the canvas
  95955. * @param width defines the new canvas' width
  95956. * @param height defines the new canvas' height
  95957. */
  95958. setSize(width: number, height: number): void;
  95959. /**
  95960. * Binds the frame buffer to the specified texture.
  95961. * @param texture The texture to render to or null for the default canvas
  95962. * @param faceIndex The face of the texture to render to in case of cube texture
  95963. * @param requiredWidth The width of the target to render to
  95964. * @param requiredHeight The height of the target to render to
  95965. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95966. * @param depthStencilTexture The depth stencil texture to use to render
  95967. * @param lodLevel defines le lod level to bind to the frame buffer
  95968. */
  95969. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95970. /** @hidden */
  95971. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95972. /**
  95973. * Unbind the current render target texture from the webGL context
  95974. * @param texture defines the render target texture to unbind
  95975. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95976. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95977. */
  95978. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95979. /**
  95980. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95981. */
  95982. flushFramebuffer(): void;
  95983. /**
  95984. * Unbind the current render target and bind the default framebuffer
  95985. */
  95986. restoreDefaultFramebuffer(): void;
  95987. private _resetVertexBufferBinding;
  95988. /**
  95989. * Creates a vertex buffer
  95990. * @param data the data for the vertex buffer
  95991. * @returns the new WebGL static buffer
  95992. */
  95993. createVertexBuffer(data: DataArray): DataBuffer;
  95994. private _createVertexBuffer;
  95995. /**
  95996. * Creates a dynamic vertex buffer
  95997. * @param data the data for the dynamic vertex buffer
  95998. * @returns the new WebGL dynamic buffer
  95999. */
  96000. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96001. /**
  96002. * Update a dynamic index buffer
  96003. * @param indexBuffer defines the target index buffer
  96004. * @param indices defines the data to update
  96005. * @param offset defines the offset in the target index buffer where update should start
  96006. */
  96007. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96008. /**
  96009. * Updates a dynamic vertex buffer.
  96010. * @param vertexBuffer the vertex buffer to update
  96011. * @param data the data used to update the vertex buffer
  96012. * @param byteOffset the byte offset of the data
  96013. * @param byteLength the byte length of the data
  96014. */
  96015. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96016. private _resetIndexBufferBinding;
  96017. /**
  96018. * Creates a new index buffer
  96019. * @param indices defines the content of the index buffer
  96020. * @param updatable defines if the index buffer must be updatable
  96021. * @returns a new webGL buffer
  96022. */
  96023. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96024. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96025. /**
  96026. * Bind a webGL buffer to the webGL context
  96027. * @param buffer defines the buffer to bind
  96028. */
  96029. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96030. private bindIndexBuffer;
  96031. private bindBuffer;
  96032. /**
  96033. * update the bound buffer with the given data
  96034. * @param data defines the data to update
  96035. */
  96036. updateArrayBuffer(data: Float32Array): void;
  96037. private _vertexAttribPointer;
  96038. private _bindIndexBufferWithCache;
  96039. private _bindVertexBuffersAttributes;
  96040. /**
  96041. * Records a vertex array object
  96042. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96043. * @param vertexBuffers defines the list of vertex buffers to store
  96044. * @param indexBuffer defines the index buffer to store
  96045. * @param effect defines the effect to store
  96046. * @returns the new vertex array object
  96047. */
  96048. recordVertexArrayObject(vertexBuffers: {
  96049. [key: string]: VertexBuffer;
  96050. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96051. /**
  96052. * Bind a specific vertex array object
  96053. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96054. * @param vertexArrayObject defines the vertex array object to bind
  96055. * @param indexBuffer defines the index buffer to bind
  96056. */
  96057. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96058. /**
  96059. * Bind webGl buffers directly to the webGL context
  96060. * @param vertexBuffer defines the vertex buffer to bind
  96061. * @param indexBuffer defines the index buffer to bind
  96062. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96063. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96064. * @param effect defines the effect associated with the vertex buffer
  96065. */
  96066. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96067. private _unbindVertexArrayObject;
  96068. /**
  96069. * Bind a list of vertex buffers to the webGL context
  96070. * @param vertexBuffers defines the list of vertex buffers to bind
  96071. * @param indexBuffer defines the index buffer to bind
  96072. * @param effect defines the effect associated with the vertex buffers
  96073. */
  96074. bindBuffers(vertexBuffers: {
  96075. [key: string]: Nullable<VertexBuffer>;
  96076. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96077. /**
  96078. * Unbind all instance attributes
  96079. */
  96080. unbindInstanceAttributes(): void;
  96081. /**
  96082. * Release and free the memory of a vertex array object
  96083. * @param vao defines the vertex array object to delete
  96084. */
  96085. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96086. /** @hidden */
  96087. _releaseBuffer(buffer: DataBuffer): boolean;
  96088. protected _deleteBuffer(buffer: DataBuffer): void;
  96089. /**
  96090. * Creates a webGL buffer to use with instanciation
  96091. * @param capacity defines the size of the buffer
  96092. * @returns the webGL buffer
  96093. */
  96094. createInstancesBuffer(capacity: number): DataBuffer;
  96095. /**
  96096. * Delete a webGL buffer used with instanciation
  96097. * @param buffer defines the webGL buffer to delete
  96098. */
  96099. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96100. /**
  96101. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96102. * @param instancesBuffer defines the webGL buffer to update and bind
  96103. * @param data defines the data to store in the buffer
  96104. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96105. */
  96106. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96107. /**
  96108. * Apply all cached states (depth, culling, stencil and alpha)
  96109. */
  96110. applyStates(): void;
  96111. /**
  96112. * Send a draw order
  96113. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96114. * @param indexStart defines the starting index
  96115. * @param indexCount defines the number of index to draw
  96116. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96117. */
  96118. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96119. /**
  96120. * Draw a list of points
  96121. * @param verticesStart defines the index of first vertex to draw
  96122. * @param verticesCount defines the count of vertices to draw
  96123. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96124. */
  96125. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96126. /**
  96127. * Draw a list of unindexed primitives
  96128. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96129. * @param verticesStart defines the index of first vertex to draw
  96130. * @param verticesCount defines the count of vertices to draw
  96131. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96132. */
  96133. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96134. /**
  96135. * Draw a list of indexed primitives
  96136. * @param fillMode defines the primitive to use
  96137. * @param indexStart defines the starting index
  96138. * @param indexCount defines the number of index to draw
  96139. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96140. */
  96141. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96142. /**
  96143. * Draw a list of unindexed primitives
  96144. * @param fillMode defines the primitive to use
  96145. * @param verticesStart defines the index of first vertex to draw
  96146. * @param verticesCount defines the count of vertices to draw
  96147. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96148. */
  96149. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96150. private _drawMode;
  96151. /** @hidden */
  96152. _releaseEffect(effect: Effect): void;
  96153. /** @hidden */
  96154. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96155. /**
  96156. * Create a new effect (used to store vertex/fragment shaders)
  96157. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96158. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96159. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96160. * @param samplers defines an array of string used to represent textures
  96161. * @param defines defines the string containing the defines to use to compile the shaders
  96162. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96163. * @param onCompiled defines a function to call when the effect creation is successful
  96164. * @param onError defines a function to call when the effect creation has failed
  96165. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96166. * @returns the new Effect
  96167. */
  96168. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96169. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96170. private _compileShader;
  96171. private _compileRawShader;
  96172. /**
  96173. * Directly creates a webGL program
  96174. * @param pipelineContext defines the pipeline context to attach to
  96175. * @param vertexCode defines the vertex shader code to use
  96176. * @param fragmentCode defines the fragment shader code to use
  96177. * @param context defines the webGL context to use (if not set, the current one will be used)
  96178. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96179. * @returns the new webGL program
  96180. */
  96181. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96182. /**
  96183. * Creates a webGL program
  96184. * @param pipelineContext defines the pipeline context to attach to
  96185. * @param vertexCode defines the vertex shader code to use
  96186. * @param fragmentCode defines the fragment shader code to use
  96187. * @param defines defines the string containing the defines to use to compile the shaders
  96188. * @param context defines the webGL context to use (if not set, the current one will be used)
  96189. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96190. * @returns the new webGL program
  96191. */
  96192. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96193. /**
  96194. * Creates a new pipeline context
  96195. * @returns the new pipeline
  96196. */
  96197. createPipelineContext(): IPipelineContext;
  96198. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96199. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96200. /** @hidden */
  96201. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96202. /** @hidden */
  96203. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96204. /** @hidden */
  96205. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96206. /**
  96207. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96208. * @param pipelineContext defines the pipeline context to use
  96209. * @param uniformsNames defines the list of uniform names
  96210. * @returns an array of webGL uniform locations
  96211. */
  96212. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96213. /**
  96214. * Gets the lsit of active attributes for a given webGL program
  96215. * @param pipelineContext defines the pipeline context to use
  96216. * @param attributesNames defines the list of attribute names to get
  96217. * @returns an array of indices indicating the offset of each attribute
  96218. */
  96219. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96220. /**
  96221. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96222. * @param effect defines the effect to activate
  96223. */
  96224. enableEffect(effect: Nullable<Effect>): void;
  96225. /**
  96226. * Set the value of an uniform to an array of int32
  96227. * @param uniform defines the webGL uniform location where to store the value
  96228. * @param array defines the array of int32 to store
  96229. */
  96230. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96231. /**
  96232. * Set the value of an uniform to an array of int32 (stored as vec2)
  96233. * @param uniform defines the webGL uniform location where to store the value
  96234. * @param array defines the array of int32 to store
  96235. */
  96236. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96237. /**
  96238. * Set the value of an uniform to an array of int32 (stored as vec3)
  96239. * @param uniform defines the webGL uniform location where to store the value
  96240. * @param array defines the array of int32 to store
  96241. */
  96242. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96243. /**
  96244. * Set the value of an uniform to an array of int32 (stored as vec4)
  96245. * @param uniform defines the webGL uniform location where to store the value
  96246. * @param array defines the array of int32 to store
  96247. */
  96248. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96249. /**
  96250. * Set the value of an uniform to an array of float32
  96251. * @param uniform defines the webGL uniform location where to store the value
  96252. * @param array defines the array of float32 to store
  96253. */
  96254. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96255. /**
  96256. * Set the value of an uniform to an array of float32 (stored as vec2)
  96257. * @param uniform defines the webGL uniform location where to store the value
  96258. * @param array defines the array of float32 to store
  96259. */
  96260. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96261. /**
  96262. * Set the value of an uniform to an array of float32 (stored as vec3)
  96263. * @param uniform defines the webGL uniform location where to store the value
  96264. * @param array defines the array of float32 to store
  96265. */
  96266. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96267. /**
  96268. * Set the value of an uniform to an array of float32 (stored as vec4)
  96269. * @param uniform defines the webGL uniform location where to store the value
  96270. * @param array defines the array of float32 to store
  96271. */
  96272. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96273. /**
  96274. * Set the value of an uniform to an array of number
  96275. * @param uniform defines the webGL uniform location where to store the value
  96276. * @param array defines the array of number to store
  96277. */
  96278. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96279. /**
  96280. * Set the value of an uniform to an array of number (stored as vec2)
  96281. * @param uniform defines the webGL uniform location where to store the value
  96282. * @param array defines the array of number to store
  96283. */
  96284. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96285. /**
  96286. * Set the value of an uniform to an array of number (stored as vec3)
  96287. * @param uniform defines the webGL uniform location where to store the value
  96288. * @param array defines the array of number to store
  96289. */
  96290. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96291. /**
  96292. * Set the value of an uniform to an array of number (stored as vec4)
  96293. * @param uniform defines the webGL uniform location where to store the value
  96294. * @param array defines the array of number to store
  96295. */
  96296. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96297. /**
  96298. * Set the value of an uniform to an array of float32 (stored as matrices)
  96299. * @param uniform defines the webGL uniform location where to store the value
  96300. * @param matrices defines the array of float32 to store
  96301. */
  96302. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96303. /**
  96304. * Set the value of an uniform to a matrix (3x3)
  96305. * @param uniform defines the webGL uniform location where to store the value
  96306. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96307. */
  96308. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96309. /**
  96310. * Set the value of an uniform to a matrix (2x2)
  96311. * @param uniform defines the webGL uniform location where to store the value
  96312. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96313. */
  96314. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96315. /**
  96316. * Set the value of an uniform to a number (int)
  96317. * @param uniform defines the webGL uniform location where to store the value
  96318. * @param value defines the int number to store
  96319. */
  96320. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96321. /**
  96322. * Set the value of an uniform to a number (float)
  96323. * @param uniform defines the webGL uniform location where to store the value
  96324. * @param value defines the float number to store
  96325. */
  96326. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96327. /**
  96328. * Set the value of an uniform to a vec2
  96329. * @param uniform defines the webGL uniform location where to store the value
  96330. * @param x defines the 1st component of the value
  96331. * @param y defines the 2nd component of the value
  96332. */
  96333. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96334. /**
  96335. * Set the value of an uniform to a vec3
  96336. * @param uniform defines the webGL uniform location where to store the value
  96337. * @param x defines the 1st component of the value
  96338. * @param y defines the 2nd component of the value
  96339. * @param z defines the 3rd component of the value
  96340. */
  96341. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96342. /**
  96343. * Set the value of an uniform to a boolean
  96344. * @param uniform defines the webGL uniform location where to store the value
  96345. * @param bool defines the boolean to store
  96346. */
  96347. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96348. /**
  96349. * Set the value of an uniform to a vec4
  96350. * @param uniform defines the webGL uniform location where to store the value
  96351. * @param x defines the 1st component of the value
  96352. * @param y defines the 2nd component of the value
  96353. * @param z defines the 3rd component of the value
  96354. * @param w defines the 4th component of the value
  96355. */
  96356. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96357. /**
  96358. * Sets a Color4 on a uniform variable
  96359. * @param uniform defines the uniform location
  96360. * @param color4 defines the value to be set
  96361. */
  96362. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96363. /**
  96364. * Gets the depth culling state manager
  96365. */
  96366. readonly depthCullingState: DepthCullingState;
  96367. /**
  96368. * Gets the alpha state manager
  96369. */
  96370. readonly alphaState: AlphaState;
  96371. /**
  96372. * Gets the stencil state manager
  96373. */
  96374. readonly stencilState: StencilState;
  96375. /**
  96376. * Clears the list of texture accessible through engine.
  96377. * This can help preventing texture load conflict due to name collision.
  96378. */
  96379. clearInternalTexturesCache(): void;
  96380. /**
  96381. * Force the entire cache to be cleared
  96382. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96383. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96384. */
  96385. wipeCaches(bruteForce?: boolean): void;
  96386. /** @hidden */
  96387. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96388. min: number;
  96389. mag: number;
  96390. };
  96391. /** @hidden */
  96392. _createTexture(): WebGLTexture;
  96393. /**
  96394. * Usually called from Texture.ts.
  96395. * Passed information to create a WebGLTexture
  96396. * @param urlArg defines a value which contains one of the following:
  96397. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96398. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96399. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96401. * @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)
  96402. * @param scene needed for loading to the correct scene
  96403. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96404. * @param onLoad optional callback to be called upon successful completion
  96405. * @param onError optional callback to be called upon failure
  96406. * @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
  96407. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96408. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96409. * @param forcedExtension defines the extension to use to pick the right loader
  96410. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96411. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96412. */
  96413. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96414. /**
  96415. * @hidden
  96416. */
  96417. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96418. /**
  96419. * Creates a raw texture
  96420. * @param data defines the data to store in the texture
  96421. * @param width defines the width of the texture
  96422. * @param height defines the height of the texture
  96423. * @param format defines the format of the data
  96424. * @param generateMipMaps defines if the engine should generate the mip levels
  96425. * @param invertY defines if data must be stored with Y axis inverted
  96426. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96427. * @param compression defines the compression used (null by default)
  96428. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96429. * @returns the raw texture inside an InternalTexture
  96430. */
  96431. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96432. /**
  96433. * Creates a new raw cube texture
  96434. * @param data defines the array of data to use to create each face
  96435. * @param size defines the size of the textures
  96436. * @param format defines the format of the data
  96437. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96438. * @param generateMipMaps defines if the engine should generate the mip levels
  96439. * @param invertY defines if data must be stored with Y axis inverted
  96440. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96441. * @param compression defines the compression used (null by default)
  96442. * @returns the cube texture as an InternalTexture
  96443. */
  96444. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96445. /**
  96446. * Creates a new raw 3D texture
  96447. * @param data defines the data used to create the texture
  96448. * @param width defines the width of the texture
  96449. * @param height defines the height of the texture
  96450. * @param depth defines the depth of the texture
  96451. * @param format defines the format of the texture
  96452. * @param generateMipMaps defines if the engine must generate mip levels
  96453. * @param invertY defines if data must be stored with Y axis inverted
  96454. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96455. * @param compression defines the compressed used (can be null)
  96456. * @param textureType defines the compressed used (can be null)
  96457. * @returns a new raw 3D texture (stored in an InternalTexture)
  96458. */
  96459. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96460. private _unpackFlipYCached;
  96461. /**
  96462. * In case you are sharing the context with other applications, it might
  96463. * be interested to not cache the unpack flip y state to ensure a consistent
  96464. * value would be set.
  96465. */
  96466. enableUnpackFlipYCached: boolean;
  96467. /** @hidden */
  96468. _unpackFlipY(value: boolean): void;
  96469. /** @hidden */
  96470. _getUnpackAlignement(): number;
  96471. /**
  96472. * Update the sampling mode of a given texture
  96473. * @param samplingMode defines the required sampling mode
  96474. * @param texture defines the texture to update
  96475. */
  96476. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96477. /**
  96478. * Updates a depth texture Comparison Mode and Function.
  96479. * If the comparison Function is equal to 0, the mode will be set to none.
  96480. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96481. * @param texture The texture to set the comparison function for
  96482. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96483. */
  96484. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96485. /** @hidden */
  96486. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96487. width: number;
  96488. height: number;
  96489. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96490. /**
  96491. * Creates a depth stencil texture.
  96492. * This is only available in WebGL 2 or with the depth texture extension available.
  96493. * @param size The size of face edge in the texture.
  96494. * @param options The options defining the texture.
  96495. * @returns The texture
  96496. */
  96497. createDepthStencilTexture(size: number | {
  96498. width: number;
  96499. height: number;
  96500. }, options: DepthTextureCreationOptions): InternalTexture;
  96501. /**
  96502. * Creates a depth stencil texture.
  96503. * This is only available in WebGL 2 or with the depth texture extension available.
  96504. * @param size The size of face edge in the texture.
  96505. * @param options The options defining the texture.
  96506. * @returns The texture
  96507. */
  96508. private _createDepthStencilTexture;
  96509. /**
  96510. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96511. * @param renderTarget The render target to set the frame buffer for
  96512. */
  96513. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96514. /** @hidden */
  96515. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96516. /** @hidden */
  96517. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96518. /** @hidden */
  96519. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96520. /** @hidden */
  96521. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96522. /** @hidden */
  96523. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96524. /**
  96525. * @hidden
  96526. */
  96527. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96528. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96529. private _prepareWebGLTexture;
  96530. /** @hidden */
  96531. _releaseFramebufferObjects(texture: InternalTexture): void;
  96532. /** @hidden */
  96533. _releaseTexture(texture: InternalTexture): void;
  96534. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96535. protected _setProgram(program: WebGLProgram): void;
  96536. protected _boundUniforms: {
  96537. [key: number]: WebGLUniformLocation;
  96538. };
  96539. /**
  96540. * Binds an effect to the webGL context
  96541. * @param effect defines the effect to bind
  96542. */
  96543. bindSamplers(effect: Effect): void;
  96544. private _activateCurrentTexture;
  96545. /** @hidden */
  96546. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96547. /** @hidden */
  96548. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96549. /**
  96550. * Unbind all textures from the webGL context
  96551. */
  96552. unbindAllTextures(): void;
  96553. /**
  96554. * Sets a texture to the according uniform.
  96555. * @param channel The texture channel
  96556. * @param uniform The uniform to set
  96557. * @param texture The texture to apply
  96558. */
  96559. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96560. private _bindSamplerUniformToChannel;
  96561. private _getTextureWrapMode;
  96562. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96563. /**
  96564. * Sets an array of texture to the webGL context
  96565. * @param channel defines the channel where the texture array must be set
  96566. * @param uniform defines the associated uniform location
  96567. * @param textures defines the array of textures to bind
  96568. */
  96569. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96570. /** @hidden */
  96571. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96572. private _setTextureParameterFloat;
  96573. private _setTextureParameterInteger;
  96574. /**
  96575. * Unbind all vertex attributes from the webGL context
  96576. */
  96577. unbindAllAttributes(): void;
  96578. /**
  96579. * 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
  96580. */
  96581. releaseEffects(): void;
  96582. /**
  96583. * Dispose and release all associated resources
  96584. */
  96585. dispose(): void;
  96586. /**
  96587. * Attach a new callback raised when context lost event is fired
  96588. * @param callback defines the callback to call
  96589. */
  96590. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96591. /**
  96592. * Attach a new callback raised when context restored event is fired
  96593. * @param callback defines the callback to call
  96594. */
  96595. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96596. /**
  96597. * Get the current error code of the webGL context
  96598. * @returns the error code
  96599. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96600. */
  96601. getError(): number;
  96602. private _canRenderToFloatFramebuffer;
  96603. private _canRenderToHalfFloatFramebuffer;
  96604. private _canRenderToFramebuffer;
  96605. /** @hidden */
  96606. _getWebGLTextureType(type: number): number;
  96607. /** @hidden */
  96608. _getInternalFormat(format: number): number;
  96609. /** @hidden */
  96610. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96611. /** @hidden */
  96612. _getRGBAMultiSampleBufferFormat(type: number): number;
  96613. /** @hidden */
  96614. _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;
  96615. /**
  96616. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96617. * @returns true if the engine can be created
  96618. * @ignorenaming
  96619. */
  96620. static isSupported(): boolean;
  96621. /**
  96622. * Find the next highest power of two.
  96623. * @param x Number to start search from.
  96624. * @return Next highest power of two.
  96625. */
  96626. static CeilingPOT(x: number): number;
  96627. /**
  96628. * Find the next lowest power of two.
  96629. * @param x Number to start search from.
  96630. * @return Next lowest power of two.
  96631. */
  96632. static FloorPOT(x: number): number;
  96633. /**
  96634. * Find the nearest power of two.
  96635. * @param x Number to start search from.
  96636. * @return Next nearest power of two.
  96637. */
  96638. static NearestPOT(x: number): number;
  96639. /**
  96640. * Get the closest exponent of two
  96641. * @param value defines the value to approximate
  96642. * @param max defines the maximum value to return
  96643. * @param mode defines how to define the closest value
  96644. * @returns closest exponent of two of the given value
  96645. */
  96646. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96647. /**
  96648. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96649. * @param func - the function to be called
  96650. * @param requester - the object that will request the next frame. Falls back to window.
  96651. * @returns frame number
  96652. */
  96653. static QueueNewFrame(func: () => void, requester?: any): number;
  96654. }
  96655. }
  96656. declare module BABYLON {
  96657. /**
  96658. * Class used to store data associated with WebGL texture data for the engine
  96659. * This class should not be used directly
  96660. */
  96661. export class InternalTexture {
  96662. /** @hidden */
  96663. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  96664. /**
  96665. * The source of the texture data is unknown
  96666. */
  96667. static DATASOURCE_UNKNOWN: number;
  96668. /**
  96669. * Texture data comes from an URL
  96670. */
  96671. static DATASOURCE_URL: number;
  96672. /**
  96673. * Texture data is only used for temporary storage
  96674. */
  96675. static DATASOURCE_TEMP: number;
  96676. /**
  96677. * Texture data comes from raw data (ArrayBuffer)
  96678. */
  96679. static DATASOURCE_RAW: number;
  96680. /**
  96681. * Texture content is dynamic (video or dynamic texture)
  96682. */
  96683. static DATASOURCE_DYNAMIC: number;
  96684. /**
  96685. * Texture content is generated by rendering to it
  96686. */
  96687. static DATASOURCE_RENDERTARGET: number;
  96688. /**
  96689. * Texture content is part of a multi render target process
  96690. */
  96691. static DATASOURCE_MULTIRENDERTARGET: number;
  96692. /**
  96693. * Texture data comes from a cube data file
  96694. */
  96695. static DATASOURCE_CUBE: number;
  96696. /**
  96697. * Texture data comes from a raw cube data
  96698. */
  96699. static DATASOURCE_CUBERAW: number;
  96700. /**
  96701. * Texture data come from a prefiltered cube data file
  96702. */
  96703. static DATASOURCE_CUBEPREFILTERED: number;
  96704. /**
  96705. * Texture content is raw 3D data
  96706. */
  96707. static DATASOURCE_RAW3D: number;
  96708. /**
  96709. * Texture content is a depth texture
  96710. */
  96711. static DATASOURCE_DEPTHTEXTURE: number;
  96712. /**
  96713. * Texture data comes from a raw cube data encoded with RGBD
  96714. */
  96715. static DATASOURCE_CUBERAW_RGBD: number;
  96716. /**
  96717. * Defines if the texture is ready
  96718. */
  96719. isReady: boolean;
  96720. /**
  96721. * Defines if the texture is a cube texture
  96722. */
  96723. isCube: boolean;
  96724. /**
  96725. * Defines if the texture contains 3D data
  96726. */
  96727. is3D: boolean;
  96728. /**
  96729. * Defines if the texture contains multiview data
  96730. */
  96731. isMultiview: boolean;
  96732. /**
  96733. * Gets the URL used to load this texture
  96734. */
  96735. url: string;
  96736. /**
  96737. * Gets the sampling mode of the texture
  96738. */
  96739. samplingMode: number;
  96740. /**
  96741. * Gets a boolean indicating if the texture needs mipmaps generation
  96742. */
  96743. generateMipMaps: boolean;
  96744. /**
  96745. * Gets the number of samples used by the texture (WebGL2+ only)
  96746. */
  96747. samples: number;
  96748. /**
  96749. * Gets the type of the texture (int, float...)
  96750. */
  96751. type: number;
  96752. /**
  96753. * Gets the format of the texture (RGB, RGBA...)
  96754. */
  96755. format: number;
  96756. /**
  96757. * Observable called when the texture is loaded
  96758. */
  96759. onLoadedObservable: Observable<InternalTexture>;
  96760. /**
  96761. * Gets the width of the texture
  96762. */
  96763. width: number;
  96764. /**
  96765. * Gets the height of the texture
  96766. */
  96767. height: number;
  96768. /**
  96769. * Gets the depth of the texture
  96770. */
  96771. depth: number;
  96772. /**
  96773. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  96774. */
  96775. baseWidth: number;
  96776. /**
  96777. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  96778. */
  96779. baseHeight: number;
  96780. /**
  96781. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  96782. */
  96783. baseDepth: number;
  96784. /**
  96785. * Gets a boolean indicating if the texture is inverted on Y axis
  96786. */
  96787. invertY: boolean;
  96788. /** @hidden */
  96789. _invertVScale: boolean;
  96790. /** @hidden */
  96791. _associatedChannel: number;
  96792. /** @hidden */
  96793. _dataSource: number;
  96794. /** @hidden */
  96795. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  96796. /** @hidden */
  96797. _bufferView: Nullable<ArrayBufferView>;
  96798. /** @hidden */
  96799. _bufferViewArray: Nullable<ArrayBufferView[]>;
  96800. /** @hidden */
  96801. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  96802. /** @hidden */
  96803. _size: number;
  96804. /** @hidden */
  96805. _extension: string;
  96806. /** @hidden */
  96807. _files: Nullable<string[]>;
  96808. /** @hidden */
  96809. _workingCanvas: Nullable<HTMLCanvasElement>;
  96810. /** @hidden */
  96811. _workingContext: Nullable<CanvasRenderingContext2D>;
  96812. /** @hidden */
  96813. _framebuffer: Nullable<WebGLFramebuffer>;
  96814. /** @hidden */
  96815. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  96816. /** @hidden */
  96817. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  96818. /** @hidden */
  96819. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  96820. /** @hidden */
  96821. _attachments: Nullable<number[]>;
  96822. /** @hidden */
  96823. _cachedCoordinatesMode: Nullable<number>;
  96824. /** @hidden */
  96825. _cachedWrapU: Nullable<number>;
  96826. /** @hidden */
  96827. _cachedWrapV: Nullable<number>;
  96828. /** @hidden */
  96829. _cachedWrapR: Nullable<number>;
  96830. /** @hidden */
  96831. _cachedAnisotropicFilteringLevel: Nullable<number>;
  96832. /** @hidden */
  96833. _isDisabled: boolean;
  96834. /** @hidden */
  96835. _compression: Nullable<string>;
  96836. /** @hidden */
  96837. _generateStencilBuffer: boolean;
  96838. /** @hidden */
  96839. _generateDepthBuffer: boolean;
  96840. /** @hidden */
  96841. _comparisonFunction: number;
  96842. /** @hidden */
  96843. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  96844. /** @hidden */
  96845. _lodGenerationScale: number;
  96846. /** @hidden */
  96847. _lodGenerationOffset: number;
  96848. /** @hidden */
  96849. _colorTextureArray: Nullable<WebGLTexture>;
  96850. /** @hidden */
  96851. _depthStencilTextureArray: Nullable<WebGLTexture>;
  96852. /** @hidden */
  96853. _lodTextureHigh: Nullable<BaseTexture>;
  96854. /** @hidden */
  96855. _lodTextureMid: Nullable<BaseTexture>;
  96856. /** @hidden */
  96857. _lodTextureLow: Nullable<BaseTexture>;
  96858. /** @hidden */
  96859. _isRGBD: boolean;
  96860. /** @hidden */
  96861. _linearSpecularLOD: boolean;
  96862. /** @hidden */
  96863. _irradianceTexture: Nullable<BaseTexture>;
  96864. /** @hidden */
  96865. _webGLTexture: Nullable<WebGLTexture>;
  96866. /** @hidden */
  96867. _references: number;
  96868. private _engine;
  96869. /**
  96870. * Gets the Engine the texture belongs to.
  96871. * @returns The babylon engine
  96872. */
  96873. getEngine(): ThinEngine;
  96874. /**
  96875. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  96876. */
  96877. readonly dataSource: number;
  96878. /**
  96879. * Creates a new InternalTexture
  96880. * @param engine defines the engine to use
  96881. * @param dataSource defines the type of data that will be used
  96882. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96883. */
  96884. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  96885. /**
  96886. * Increments the number of references (ie. the number of Texture that point to it)
  96887. */
  96888. incrementReferences(): void;
  96889. /**
  96890. * Change the size of the texture (not the size of the content)
  96891. * @param width defines the new width
  96892. * @param height defines the new height
  96893. * @param depth defines the new depth (1 by default)
  96894. */
  96895. updateSize(width: int, height: int, depth?: int): void;
  96896. /** @hidden */
  96897. _rebuild(): void;
  96898. /** @hidden */
  96899. _swapAndDie(target: InternalTexture): void;
  96900. /**
  96901. * Dispose the current allocated resources
  96902. */
  96903. dispose(): void;
  96904. }
  96905. }
  96906. declare module BABYLON {
  96907. /**
  96908. * Class used to work with sound analyzer using fast fourier transform (FFT)
  96909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96910. */
  96911. export class Analyser {
  96912. /**
  96913. * Gets or sets the smoothing
  96914. * @ignorenaming
  96915. */
  96916. SMOOTHING: number;
  96917. /**
  96918. * Gets or sets the FFT table size
  96919. * @ignorenaming
  96920. */
  96921. FFT_SIZE: number;
  96922. /**
  96923. * Gets or sets the bar graph amplitude
  96924. * @ignorenaming
  96925. */
  96926. BARGRAPHAMPLITUDE: number;
  96927. /**
  96928. * Gets or sets the position of the debug canvas
  96929. * @ignorenaming
  96930. */
  96931. DEBUGCANVASPOS: {
  96932. x: number;
  96933. y: number;
  96934. };
  96935. /**
  96936. * Gets or sets the debug canvas size
  96937. * @ignorenaming
  96938. */
  96939. DEBUGCANVASSIZE: {
  96940. width: number;
  96941. height: number;
  96942. };
  96943. private _byteFreqs;
  96944. private _byteTime;
  96945. private _floatFreqs;
  96946. private _webAudioAnalyser;
  96947. private _debugCanvas;
  96948. private _debugCanvasContext;
  96949. private _scene;
  96950. private _registerFunc;
  96951. private _audioEngine;
  96952. /**
  96953. * Creates a new analyser
  96954. * @param scene defines hosting scene
  96955. */
  96956. constructor(scene: Scene);
  96957. /**
  96958. * Get the number of data values you will have to play with for the visualization
  96959. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  96960. * @returns a number
  96961. */
  96962. getFrequencyBinCount(): number;
  96963. /**
  96964. * Gets the current frequency data as a byte array
  96965. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  96966. * @returns a Uint8Array
  96967. */
  96968. getByteFrequencyData(): Uint8Array;
  96969. /**
  96970. * Gets the current waveform as a byte array
  96971. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  96972. * @returns a Uint8Array
  96973. */
  96974. getByteTimeDomainData(): Uint8Array;
  96975. /**
  96976. * Gets the current frequency data as a float array
  96977. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  96978. * @returns a Float32Array
  96979. */
  96980. getFloatFrequencyData(): Float32Array;
  96981. /**
  96982. * Renders the debug canvas
  96983. */
  96984. drawDebugCanvas(): void;
  96985. /**
  96986. * Stops rendering the debug canvas and removes it
  96987. */
  96988. stopDebugCanvas(): void;
  96989. /**
  96990. * Connects two audio nodes
  96991. * @param inputAudioNode defines first node to connect
  96992. * @param outputAudioNode defines second node to connect
  96993. */
  96994. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  96995. /**
  96996. * Releases all associated resources
  96997. */
  96998. dispose(): void;
  96999. }
  97000. }
  97001. declare module BABYLON {
  97002. /**
  97003. * This represents an audio engine and it is responsible
  97004. * to play, synchronize and analyse sounds throughout the application.
  97005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97006. */
  97007. export interface IAudioEngine extends IDisposable {
  97008. /**
  97009. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97010. */
  97011. readonly canUseWebAudio: boolean;
  97012. /**
  97013. * Gets the current AudioContext if available.
  97014. */
  97015. readonly audioContext: Nullable<AudioContext>;
  97016. /**
  97017. * The master gain node defines the global audio volume of your audio engine.
  97018. */
  97019. readonly masterGain: GainNode;
  97020. /**
  97021. * Gets whether or not mp3 are supported by your browser.
  97022. */
  97023. readonly isMP3supported: boolean;
  97024. /**
  97025. * Gets whether or not ogg are supported by your browser.
  97026. */
  97027. readonly isOGGsupported: boolean;
  97028. /**
  97029. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97030. * @ignoreNaming
  97031. */
  97032. WarnedWebAudioUnsupported: boolean;
  97033. /**
  97034. * Defines if the audio engine relies on a custom unlocked button.
  97035. * In this case, the embedded button will not be displayed.
  97036. */
  97037. useCustomUnlockedButton: boolean;
  97038. /**
  97039. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97040. */
  97041. readonly unlocked: boolean;
  97042. /**
  97043. * Event raised when audio has been unlocked on the browser.
  97044. */
  97045. onAudioUnlockedObservable: Observable<AudioEngine>;
  97046. /**
  97047. * Event raised when audio has been locked on the browser.
  97048. */
  97049. onAudioLockedObservable: Observable<AudioEngine>;
  97050. /**
  97051. * Flags the audio engine in Locked state.
  97052. * This happens due to new browser policies preventing audio to autoplay.
  97053. */
  97054. lock(): void;
  97055. /**
  97056. * Unlocks the audio engine once a user action has been done on the dom.
  97057. * This is helpful to resume play once browser policies have been satisfied.
  97058. */
  97059. unlock(): void;
  97060. }
  97061. /**
  97062. * This represents the default audio engine used in babylon.
  97063. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97065. */
  97066. export class AudioEngine implements IAudioEngine {
  97067. private _audioContext;
  97068. private _audioContextInitialized;
  97069. private _muteButton;
  97070. private _hostElement;
  97071. /**
  97072. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97073. */
  97074. canUseWebAudio: boolean;
  97075. /**
  97076. * The master gain node defines the global audio volume of your audio engine.
  97077. */
  97078. masterGain: GainNode;
  97079. /**
  97080. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97081. * @ignoreNaming
  97082. */
  97083. WarnedWebAudioUnsupported: boolean;
  97084. /**
  97085. * Gets whether or not mp3 are supported by your browser.
  97086. */
  97087. isMP3supported: boolean;
  97088. /**
  97089. * Gets whether or not ogg are supported by your browser.
  97090. */
  97091. isOGGsupported: boolean;
  97092. /**
  97093. * Gets whether audio has been unlocked on the device.
  97094. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97095. * a user interaction has happened.
  97096. */
  97097. unlocked: boolean;
  97098. /**
  97099. * Defines if the audio engine relies on a custom unlocked button.
  97100. * In this case, the embedded button will not be displayed.
  97101. */
  97102. useCustomUnlockedButton: boolean;
  97103. /**
  97104. * Event raised when audio has been unlocked on the browser.
  97105. */
  97106. onAudioUnlockedObservable: Observable<AudioEngine>;
  97107. /**
  97108. * Event raised when audio has been locked on the browser.
  97109. */
  97110. onAudioLockedObservable: Observable<AudioEngine>;
  97111. /**
  97112. * Gets the current AudioContext if available.
  97113. */
  97114. readonly audioContext: Nullable<AudioContext>;
  97115. private _connectedAnalyser;
  97116. /**
  97117. * Instantiates a new audio engine.
  97118. *
  97119. * There should be only one per page as some browsers restrict the number
  97120. * of audio contexts you can create.
  97121. * @param hostElement defines the host element where to display the mute icon if necessary
  97122. */
  97123. constructor(hostElement?: Nullable<HTMLElement>);
  97124. /**
  97125. * Flags the audio engine in Locked state.
  97126. * This happens due to new browser policies preventing audio to autoplay.
  97127. */
  97128. lock(): void;
  97129. /**
  97130. * Unlocks the audio engine once a user action has been done on the dom.
  97131. * This is helpful to resume play once browser policies have been satisfied.
  97132. */
  97133. unlock(): void;
  97134. private _resumeAudioContext;
  97135. private _initializeAudioContext;
  97136. private _tryToRun;
  97137. private _triggerRunningState;
  97138. private _triggerSuspendedState;
  97139. private _displayMuteButton;
  97140. private _moveButtonToTopLeft;
  97141. private _onResize;
  97142. private _hideMuteButton;
  97143. /**
  97144. * Destroy and release the resources associated with the audio ccontext.
  97145. */
  97146. dispose(): void;
  97147. /**
  97148. * Gets the global volume sets on the master gain.
  97149. * @returns the global volume if set or -1 otherwise
  97150. */
  97151. getGlobalVolume(): number;
  97152. /**
  97153. * Sets the global volume of your experience (sets on the master gain).
  97154. * @param newVolume Defines the new global volume of the application
  97155. */
  97156. setGlobalVolume(newVolume: number): void;
  97157. /**
  97158. * Connect the audio engine to an audio analyser allowing some amazing
  97159. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97161. * @param analyser The analyser to connect to the engine
  97162. */
  97163. connectToAnalyser(analyser: Analyser): void;
  97164. }
  97165. }
  97166. declare module BABYLON {
  97167. /**
  97168. * Interface used to present a loading screen while loading a scene
  97169. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97170. */
  97171. export interface ILoadingScreen {
  97172. /**
  97173. * Function called to display the loading screen
  97174. */
  97175. displayLoadingUI: () => void;
  97176. /**
  97177. * Function called to hide the loading screen
  97178. */
  97179. hideLoadingUI: () => void;
  97180. /**
  97181. * Gets or sets the color to use for the background
  97182. */
  97183. loadingUIBackgroundColor: string;
  97184. /**
  97185. * Gets or sets the text to display while loading
  97186. */
  97187. loadingUIText: string;
  97188. }
  97189. /**
  97190. * Class used for the default loading screen
  97191. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97192. */
  97193. export class DefaultLoadingScreen implements ILoadingScreen {
  97194. private _renderingCanvas;
  97195. private _loadingText;
  97196. private _loadingDivBackgroundColor;
  97197. private _loadingDiv;
  97198. private _loadingTextDiv;
  97199. /** Gets or sets the logo url to use for the default loading screen */
  97200. static DefaultLogoUrl: string;
  97201. /** Gets or sets the spinner url to use for the default loading screen */
  97202. static DefaultSpinnerUrl: string;
  97203. /**
  97204. * Creates a new default loading screen
  97205. * @param _renderingCanvas defines the canvas used to render the scene
  97206. * @param _loadingText defines the default text to display
  97207. * @param _loadingDivBackgroundColor defines the default background color
  97208. */
  97209. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97210. /**
  97211. * Function called to display the loading screen
  97212. */
  97213. displayLoadingUI(): void;
  97214. /**
  97215. * Function called to hide the loading screen
  97216. */
  97217. hideLoadingUI(): void;
  97218. /**
  97219. * Gets or sets the text to display while loading
  97220. */
  97221. loadingUIText: string;
  97222. /**
  97223. * Gets or sets the color to use for the background
  97224. */
  97225. loadingUIBackgroundColor: string;
  97226. private _resizeLoadingUI;
  97227. }
  97228. }
  97229. declare module BABYLON {
  97230. /**
  97231. * Interface for any object that can request an animation frame
  97232. */
  97233. export interface ICustomAnimationFrameRequester {
  97234. /**
  97235. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97236. */
  97237. renderFunction?: Function;
  97238. /**
  97239. * Called to request the next frame to render to
  97240. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97241. */
  97242. requestAnimationFrame: Function;
  97243. /**
  97244. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97245. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97246. */
  97247. requestID?: number;
  97248. }
  97249. }
  97250. declare module BABYLON {
  97251. /**
  97252. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97253. */
  97254. export class PerformanceMonitor {
  97255. private _enabled;
  97256. private _rollingFrameTime;
  97257. private _lastFrameTimeMs;
  97258. /**
  97259. * constructor
  97260. * @param frameSampleSize The number of samples required to saturate the sliding window
  97261. */
  97262. constructor(frameSampleSize?: number);
  97263. /**
  97264. * Samples current frame
  97265. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97266. */
  97267. sampleFrame(timeMs?: number): void;
  97268. /**
  97269. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97270. */
  97271. readonly averageFrameTime: number;
  97272. /**
  97273. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97274. */
  97275. readonly averageFrameTimeVariance: number;
  97276. /**
  97277. * Returns the frame time of the most recent frame
  97278. */
  97279. readonly instantaneousFrameTime: number;
  97280. /**
  97281. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97282. */
  97283. readonly averageFPS: number;
  97284. /**
  97285. * Returns the average framerate in frames per second using the most recent frame time
  97286. */
  97287. readonly instantaneousFPS: number;
  97288. /**
  97289. * Returns true if enough samples have been taken to completely fill the sliding window
  97290. */
  97291. readonly isSaturated: boolean;
  97292. /**
  97293. * Enables contributions to the sliding window sample set
  97294. */
  97295. enable(): void;
  97296. /**
  97297. * Disables contributions to the sliding window sample set
  97298. * Samples will not be interpolated over the disabled period
  97299. */
  97300. disable(): void;
  97301. /**
  97302. * Returns true if sampling is enabled
  97303. */
  97304. readonly isEnabled: boolean;
  97305. /**
  97306. * Resets performance monitor
  97307. */
  97308. reset(): void;
  97309. }
  97310. /**
  97311. * RollingAverage
  97312. *
  97313. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97314. */
  97315. export class RollingAverage {
  97316. /**
  97317. * Current average
  97318. */
  97319. average: number;
  97320. /**
  97321. * Current variance
  97322. */
  97323. variance: number;
  97324. protected _samples: Array<number>;
  97325. protected _sampleCount: number;
  97326. protected _pos: number;
  97327. protected _m2: number;
  97328. /**
  97329. * constructor
  97330. * @param length The number of samples required to saturate the sliding window
  97331. */
  97332. constructor(length: number);
  97333. /**
  97334. * Adds a sample to the sample set
  97335. * @param v The sample value
  97336. */
  97337. add(v: number): void;
  97338. /**
  97339. * Returns previously added values or null if outside of history or outside the sliding window domain
  97340. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97341. * @return Value previously recorded with add() or null if outside of range
  97342. */
  97343. history(i: number): number;
  97344. /**
  97345. * Returns true if enough samples have been taken to completely fill the sliding window
  97346. * @return true if sample-set saturated
  97347. */
  97348. isSaturated(): boolean;
  97349. /**
  97350. * Resets the rolling average (equivalent to 0 samples taken so far)
  97351. */
  97352. reset(): void;
  97353. /**
  97354. * Wraps a value around the sample range boundaries
  97355. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97356. * @return Wrapped position in sample range
  97357. */
  97358. protected _wrapPosition(i: number): number;
  97359. }
  97360. }
  97361. declare module BABYLON {
  97362. /**
  97363. * Defines the interface used by display changed events
  97364. */
  97365. export interface IDisplayChangedEventArgs {
  97366. /** Gets the vrDisplay object (if any) */
  97367. vrDisplay: Nullable<any>;
  97368. /** Gets a boolean indicating if webVR is supported */
  97369. vrSupported: boolean;
  97370. }
  97371. /**
  97372. * Defines the interface used by objects containing a viewport (like a camera)
  97373. */
  97374. interface IViewportOwnerLike {
  97375. /**
  97376. * Gets or sets the viewport
  97377. */
  97378. viewport: IViewportLike;
  97379. }
  97380. /**
  97381. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97382. */
  97383. export class Engine extends ThinEngine {
  97384. /** Defines that alpha blending is disabled */
  97385. static readonly ALPHA_DISABLE: number;
  97386. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97387. static readonly ALPHA_ADD: number;
  97388. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97389. static readonly ALPHA_COMBINE: number;
  97390. /** Defines that alpha blending to DEST - SRC * DEST */
  97391. static readonly ALPHA_SUBTRACT: number;
  97392. /** Defines that alpha blending to SRC * DEST */
  97393. static readonly ALPHA_MULTIPLY: number;
  97394. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97395. static readonly ALPHA_MAXIMIZED: number;
  97396. /** Defines that alpha blending to SRC + DEST */
  97397. static readonly ALPHA_ONEONE: number;
  97398. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97399. static readonly ALPHA_PREMULTIPLIED: number;
  97400. /**
  97401. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97402. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97403. */
  97404. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97405. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97406. static readonly ALPHA_INTERPOLATE: number;
  97407. /**
  97408. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97409. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97410. */
  97411. static readonly ALPHA_SCREENMODE: number;
  97412. /** Defines that the ressource is not delayed*/
  97413. static readonly DELAYLOADSTATE_NONE: number;
  97414. /** Defines that the ressource was successfully delay loaded */
  97415. static readonly DELAYLOADSTATE_LOADED: number;
  97416. /** Defines that the ressource is currently delay loading */
  97417. static readonly DELAYLOADSTATE_LOADING: number;
  97418. /** Defines that the ressource is delayed and has not started loading */
  97419. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97420. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97421. static readonly NEVER: number;
  97422. /** 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 */
  97423. static readonly ALWAYS: number;
  97424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97425. static readonly LESS: number;
  97426. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97427. static readonly EQUAL: number;
  97428. /** 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 */
  97429. static readonly LEQUAL: number;
  97430. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97431. static readonly GREATER: number;
  97432. /** 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 */
  97433. static readonly GEQUAL: number;
  97434. /** 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 */
  97435. static readonly NOTEQUAL: number;
  97436. /** Passed to stencilOperation to specify that stencil value must be kept */
  97437. static readonly KEEP: number;
  97438. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97439. static readonly REPLACE: number;
  97440. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97441. static readonly INCR: number;
  97442. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97443. static readonly DECR: number;
  97444. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97445. static readonly INVERT: number;
  97446. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97447. static readonly INCR_WRAP: number;
  97448. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97449. static readonly DECR_WRAP: number;
  97450. /** Texture is not repeating outside of 0..1 UVs */
  97451. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97452. /** Texture is repeating outside of 0..1 UVs */
  97453. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97454. /** Texture is repeating and mirrored */
  97455. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97456. /** ALPHA */
  97457. static readonly TEXTUREFORMAT_ALPHA: number;
  97458. /** LUMINANCE */
  97459. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97460. /** LUMINANCE_ALPHA */
  97461. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97462. /** RGB */
  97463. static readonly TEXTUREFORMAT_RGB: number;
  97464. /** RGBA */
  97465. static readonly TEXTUREFORMAT_RGBA: number;
  97466. /** RED */
  97467. static readonly TEXTUREFORMAT_RED: number;
  97468. /** RED (2nd reference) */
  97469. static readonly TEXTUREFORMAT_R: number;
  97470. /** RG */
  97471. static readonly TEXTUREFORMAT_RG: number;
  97472. /** RED_INTEGER */
  97473. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97474. /** RED_INTEGER (2nd reference) */
  97475. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97476. /** RG_INTEGER */
  97477. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97478. /** RGB_INTEGER */
  97479. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97480. /** RGBA_INTEGER */
  97481. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97482. /** UNSIGNED_BYTE */
  97483. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97484. /** UNSIGNED_BYTE (2nd reference) */
  97485. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97486. /** FLOAT */
  97487. static readonly TEXTURETYPE_FLOAT: number;
  97488. /** HALF_FLOAT */
  97489. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97490. /** BYTE */
  97491. static readonly TEXTURETYPE_BYTE: number;
  97492. /** SHORT */
  97493. static readonly TEXTURETYPE_SHORT: number;
  97494. /** UNSIGNED_SHORT */
  97495. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97496. /** INT */
  97497. static readonly TEXTURETYPE_INT: number;
  97498. /** UNSIGNED_INT */
  97499. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97500. /** UNSIGNED_SHORT_4_4_4_4 */
  97501. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97502. /** UNSIGNED_SHORT_5_5_5_1 */
  97503. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97504. /** UNSIGNED_SHORT_5_6_5 */
  97505. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97506. /** UNSIGNED_INT_2_10_10_10_REV */
  97507. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97508. /** UNSIGNED_INT_24_8 */
  97509. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97510. /** UNSIGNED_INT_10F_11F_11F_REV */
  97511. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97512. /** UNSIGNED_INT_5_9_9_9_REV */
  97513. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97514. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97515. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97516. /** nearest is mag = nearest and min = nearest and mip = linear */
  97517. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97518. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97519. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97520. /** Trilinear is mag = linear and min = linear and mip = linear */
  97521. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97522. /** nearest is mag = nearest and min = nearest and mip = linear */
  97523. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97524. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97525. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97526. /** Trilinear is mag = linear and min = linear and mip = linear */
  97527. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97528. /** mag = nearest and min = nearest and mip = nearest */
  97529. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97530. /** mag = nearest and min = linear and mip = nearest */
  97531. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97532. /** mag = nearest and min = linear and mip = linear */
  97533. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97534. /** mag = nearest and min = linear and mip = none */
  97535. static readonly TEXTURE_NEAREST_LINEAR: number;
  97536. /** mag = nearest and min = nearest and mip = none */
  97537. static readonly TEXTURE_NEAREST_NEAREST: number;
  97538. /** mag = linear and min = nearest and mip = nearest */
  97539. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97540. /** mag = linear and min = nearest and mip = linear */
  97541. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97542. /** mag = linear and min = linear and mip = none */
  97543. static readonly TEXTURE_LINEAR_LINEAR: number;
  97544. /** mag = linear and min = nearest and mip = none */
  97545. static readonly TEXTURE_LINEAR_NEAREST: number;
  97546. /** Explicit coordinates mode */
  97547. static readonly TEXTURE_EXPLICIT_MODE: number;
  97548. /** Spherical coordinates mode */
  97549. static readonly TEXTURE_SPHERICAL_MODE: number;
  97550. /** Planar coordinates mode */
  97551. static readonly TEXTURE_PLANAR_MODE: number;
  97552. /** Cubic coordinates mode */
  97553. static readonly TEXTURE_CUBIC_MODE: number;
  97554. /** Projection coordinates mode */
  97555. static readonly TEXTURE_PROJECTION_MODE: number;
  97556. /** Skybox coordinates mode */
  97557. static readonly TEXTURE_SKYBOX_MODE: number;
  97558. /** Inverse Cubic coordinates mode */
  97559. static readonly TEXTURE_INVCUBIC_MODE: number;
  97560. /** Equirectangular coordinates mode */
  97561. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97562. /** Equirectangular Fixed coordinates mode */
  97563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97564. /** Equirectangular Fixed Mirrored coordinates mode */
  97565. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97566. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97567. static readonly SCALEMODE_FLOOR: number;
  97568. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97569. static readonly SCALEMODE_NEAREST: number;
  97570. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97571. static readonly SCALEMODE_CEILING: number;
  97572. /**
  97573. * Returns the current npm package of the sdk
  97574. */
  97575. static readonly NpmPackage: string;
  97576. /**
  97577. * Returns the current version of the framework
  97578. */
  97579. static readonly Version: string;
  97580. /** Gets the list of created engines */
  97581. static readonly Instances: Engine[];
  97582. /**
  97583. * Gets the latest created engine
  97584. */
  97585. static readonly LastCreatedEngine: Nullable<Engine>;
  97586. /**
  97587. * Gets the latest created scene
  97588. */
  97589. static readonly LastCreatedScene: Nullable<Scene>;
  97590. /**
  97591. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97592. * @param flag defines which part of the materials must be marked as dirty
  97593. * @param predicate defines a predicate used to filter which materials should be affected
  97594. */
  97595. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97596. /**
  97597. * Method called to create the default loading screen.
  97598. * This can be overriden in your own app.
  97599. * @param canvas The rendering canvas element
  97600. * @returns The loading screen
  97601. */
  97602. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97603. /**
  97604. * Method called to create the default rescale post process on each engine.
  97605. */
  97606. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97607. /**
  97608. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97609. **/
  97610. enableOfflineSupport: boolean;
  97611. /**
  97612. * 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)
  97613. **/
  97614. disableManifestCheck: boolean;
  97615. /**
  97616. * Gets the list of created scenes
  97617. */
  97618. scenes: Scene[];
  97619. /**
  97620. * Event raised when a new scene is created
  97621. */
  97622. onNewSceneAddedObservable: Observable<Scene>;
  97623. /**
  97624. * Gets the list of created postprocesses
  97625. */
  97626. postProcesses: PostProcess[];
  97627. /**
  97628. * Gets a boolean indicating if the pointer is currently locked
  97629. */
  97630. isPointerLock: boolean;
  97631. /**
  97632. * Observable event triggered each time the rendering canvas is resized
  97633. */
  97634. onResizeObservable: Observable<Engine>;
  97635. /**
  97636. * Observable event triggered each time the canvas loses focus
  97637. */
  97638. onCanvasBlurObservable: Observable<Engine>;
  97639. /**
  97640. * Observable event triggered each time the canvas gains focus
  97641. */
  97642. onCanvasFocusObservable: Observable<Engine>;
  97643. /**
  97644. * Observable event triggered each time the canvas receives pointerout event
  97645. */
  97646. onCanvasPointerOutObservable: Observable<PointerEvent>;
  97647. /**
  97648. * Observable event triggered before each texture is initialized
  97649. */
  97650. onBeforeTextureInitObservable: Observable<Texture>;
  97651. /**
  97652. * Observable raised when the engine begins a new frame
  97653. */
  97654. onBeginFrameObservable: Observable<Engine>;
  97655. /**
  97656. * If set, will be used to request the next animation frame for the render loop
  97657. */
  97658. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  97659. /**
  97660. * Observable raised when the engine ends the current frame
  97661. */
  97662. onEndFrameObservable: Observable<Engine>;
  97663. /**
  97664. * Observable raised when the engine is about to compile a shader
  97665. */
  97666. onBeforeShaderCompilationObservable: Observable<Engine>;
  97667. /**
  97668. * Observable raised when the engine has jsut compiled a shader
  97669. */
  97670. onAfterShaderCompilationObservable: Observable<Engine>;
  97671. /**
  97672. * Gets the audio engine
  97673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97674. * @ignorenaming
  97675. */
  97676. static audioEngine: IAudioEngine;
  97677. /**
  97678. * Default AudioEngine factory responsible of creating the Audio Engine.
  97679. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  97680. */
  97681. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  97682. /**
  97683. * Default offline support factory responsible of creating a tool used to store data locally.
  97684. * By default, this will create a Database object if the workload has been embedded.
  97685. */
  97686. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  97687. private _loadingScreen;
  97688. private _pointerLockRequested;
  97689. private _dummyFramebuffer;
  97690. private _rescalePostProcess;
  97691. /** @hidden */
  97692. protected _alphaMode: number;
  97693. /** @hidden */
  97694. protected _alphaEquation: number;
  97695. private _deterministicLockstep;
  97696. private _lockstepMaxSteps;
  97697. protected readonly _supportsHardwareTextureRescaling: boolean;
  97698. private _fps;
  97699. private _deltaTime;
  97700. /**
  97701. * Turn this value on if you want to pause FPS computation when in background
  97702. */
  97703. disablePerformanceMonitorInBackground: boolean;
  97704. private _performanceMonitor;
  97705. /**
  97706. * Gets the performance monitor attached to this engine
  97707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  97708. */
  97709. readonly performanceMonitor: PerformanceMonitor;
  97710. private _onFocus;
  97711. private _onBlur;
  97712. private _onCanvasPointerOut;
  97713. private _onCanvasBlur;
  97714. private _onCanvasFocus;
  97715. private _onFullscreenChange;
  97716. private _onPointerLockChange;
  97717. /**
  97718. * Creates a new engine
  97719. * @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
  97720. * @param antialias defines enable antialiasing (default: false)
  97721. * @param options defines further options to be sent to the getContext() function
  97722. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97723. */
  97724. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97725. /**
  97726. * Gets current aspect ratio
  97727. * @param viewportOwner defines the camera to use to get the aspect ratio
  97728. * @param useScreen defines if screen size must be used (or the current render target if any)
  97729. * @returns a number defining the aspect ratio
  97730. */
  97731. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  97732. /**
  97733. * Gets current screen aspect ratio
  97734. * @returns a number defining the aspect ratio
  97735. */
  97736. getScreenAspectRatio(): number;
  97737. /**
  97738. * Gets host document
  97739. * @returns the host document object
  97740. */
  97741. getHostDocument(): Document;
  97742. /**
  97743. * Gets the client rect of the HTML canvas attached with the current webGL context
  97744. * @returns a client rectanglee
  97745. */
  97746. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  97747. /**
  97748. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  97749. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97750. * @returns true if engine is in deterministic lock step mode
  97751. */
  97752. isDeterministicLockStep(): boolean;
  97753. /**
  97754. * Gets the max steps when engine is running in deterministic lock step
  97755. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97756. * @returns the max steps
  97757. */
  97758. getLockstepMaxSteps(): number;
  97759. /**
  97760. * Force the mipmap generation for the given render target texture
  97761. * @param texture defines the render target texture to use
  97762. */
  97763. generateMipMapsForCubemap(texture: InternalTexture): void;
  97764. /** States */
  97765. /**
  97766. * Set various states to the webGL context
  97767. * @param culling defines backface culling state
  97768. * @param zOffset defines the value to apply to zOffset (0 by default)
  97769. * @param force defines if states must be applied even if cache is up to date
  97770. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97771. */
  97772. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97773. /**
  97774. * Set the z offset to apply to current rendering
  97775. * @param value defines the offset to apply
  97776. */
  97777. setZOffset(value: number): void;
  97778. /**
  97779. * Gets the current value of the zOffset
  97780. * @returns the current zOffset state
  97781. */
  97782. getZOffset(): number;
  97783. /**
  97784. * Enable or disable depth buffering
  97785. * @param enable defines the state to set
  97786. */
  97787. setDepthBuffer(enable: boolean): void;
  97788. /**
  97789. * Gets a boolean indicating if depth writing is enabled
  97790. * @returns the current depth writing state
  97791. */
  97792. getDepthWrite(): boolean;
  97793. /**
  97794. * Enable or disable depth writing
  97795. * @param enable defines the state to set
  97796. */
  97797. setDepthWrite(enable: boolean): void;
  97798. /**
  97799. * Enable or disable color writing
  97800. * @param enable defines the state to set
  97801. */
  97802. setColorWrite(enable: boolean): void;
  97803. /**
  97804. * Gets a boolean indicating if color writing is enabled
  97805. * @returns the current color writing state
  97806. */
  97807. getColorWrite(): boolean;
  97808. /**
  97809. * Sets alpha constants used by some alpha blending modes
  97810. * @param r defines the red component
  97811. * @param g defines the green component
  97812. * @param b defines the blue component
  97813. * @param a defines the alpha component
  97814. */
  97815. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97816. /**
  97817. * Sets the current alpha mode
  97818. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97819. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97820. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97821. */
  97822. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97823. /**
  97824. * Gets the current alpha mode
  97825. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97826. * @returns the current alpha mode
  97827. */
  97828. getAlphaMode(): number;
  97829. /**
  97830. * Sets the current alpha equation
  97831. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  97832. */
  97833. setAlphaEquation(equation: number): void;
  97834. /**
  97835. * Gets the current alpha equation.
  97836. * @returns the current alpha equation
  97837. */
  97838. getAlphaEquation(): number;
  97839. /**
  97840. * Gets a boolean indicating if stencil buffer is enabled
  97841. * @returns the current stencil buffer state
  97842. */
  97843. getStencilBuffer(): boolean;
  97844. /**
  97845. * Enable or disable the stencil buffer
  97846. * @param enable defines if the stencil buffer must be enabled or disabled
  97847. */
  97848. setStencilBuffer(enable: boolean): void;
  97849. /**
  97850. * Gets the current stencil mask
  97851. * @returns a number defining the new stencil mask to use
  97852. */
  97853. getStencilMask(): number;
  97854. /**
  97855. * Sets the current stencil mask
  97856. * @param mask defines the new stencil mask to use
  97857. */
  97858. setStencilMask(mask: number): void;
  97859. /**
  97860. * Gets the current stencil function
  97861. * @returns a number defining the stencil function to use
  97862. */
  97863. getStencilFunction(): number;
  97864. /**
  97865. * Gets the current stencil reference value
  97866. * @returns a number defining the stencil reference value to use
  97867. */
  97868. getStencilFunctionReference(): number;
  97869. /**
  97870. * Gets the current stencil mask
  97871. * @returns a number defining the stencil mask to use
  97872. */
  97873. getStencilFunctionMask(): number;
  97874. /**
  97875. * Sets the current stencil function
  97876. * @param stencilFunc defines the new stencil function to use
  97877. */
  97878. setStencilFunction(stencilFunc: number): void;
  97879. /**
  97880. * Sets the current stencil reference
  97881. * @param reference defines the new stencil reference to use
  97882. */
  97883. setStencilFunctionReference(reference: number): void;
  97884. /**
  97885. * Sets the current stencil mask
  97886. * @param mask defines the new stencil mask to use
  97887. */
  97888. setStencilFunctionMask(mask: number): void;
  97889. /**
  97890. * Gets the current stencil operation when stencil fails
  97891. * @returns a number defining stencil operation to use when stencil fails
  97892. */
  97893. getStencilOperationFail(): number;
  97894. /**
  97895. * Gets the current stencil operation when depth fails
  97896. * @returns a number defining stencil operation to use when depth fails
  97897. */
  97898. getStencilOperationDepthFail(): number;
  97899. /**
  97900. * Gets the current stencil operation when stencil passes
  97901. * @returns a number defining stencil operation to use when stencil passes
  97902. */
  97903. getStencilOperationPass(): number;
  97904. /**
  97905. * Sets the stencil operation to use when stencil fails
  97906. * @param operation defines the stencil operation to use when stencil fails
  97907. */
  97908. setStencilOperationFail(operation: number): void;
  97909. /**
  97910. * Sets the stencil operation to use when depth fails
  97911. * @param operation defines the stencil operation to use when depth fails
  97912. */
  97913. setStencilOperationDepthFail(operation: number): void;
  97914. /**
  97915. * Sets the stencil operation to use when stencil passes
  97916. * @param operation defines the stencil operation to use when stencil passes
  97917. */
  97918. setStencilOperationPass(operation: number): void;
  97919. /**
  97920. * Sets a boolean indicating if the dithering state is enabled or disabled
  97921. * @param value defines the dithering state
  97922. */
  97923. setDitheringState(value: boolean): void;
  97924. /**
  97925. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  97926. * @param value defines the rasterizer state
  97927. */
  97928. setRasterizerState(value: boolean): void;
  97929. /**
  97930. * Gets the current depth function
  97931. * @returns a number defining the depth function
  97932. */
  97933. getDepthFunction(): Nullable<number>;
  97934. /**
  97935. * Sets the current depth function
  97936. * @param depthFunc defines the function to use
  97937. */
  97938. setDepthFunction(depthFunc: number): void;
  97939. /**
  97940. * Sets the current depth function to GREATER
  97941. */
  97942. setDepthFunctionToGreater(): void;
  97943. /**
  97944. * Sets the current depth function to GEQUAL
  97945. */
  97946. setDepthFunctionToGreaterOrEqual(): void;
  97947. /**
  97948. * Sets the current depth function to LESS
  97949. */
  97950. setDepthFunctionToLess(): void;
  97951. /**
  97952. * Sets the current depth function to LEQUAL
  97953. */
  97954. setDepthFunctionToLessOrEqual(): void;
  97955. private _cachedStencilBuffer;
  97956. private _cachedStencilFunction;
  97957. private _cachedStencilMask;
  97958. private _cachedStencilOperationPass;
  97959. private _cachedStencilOperationFail;
  97960. private _cachedStencilOperationDepthFail;
  97961. private _cachedStencilReference;
  97962. /**
  97963. * Caches the the state of the stencil buffer
  97964. */
  97965. cacheStencilState(): void;
  97966. /**
  97967. * Restores the state of the stencil buffer
  97968. */
  97969. restoreStencilState(): void;
  97970. /**
  97971. * Directly set the WebGL Viewport
  97972. * @param x defines the x coordinate of the viewport (in screen space)
  97973. * @param y defines the y coordinate of the viewport (in screen space)
  97974. * @param width defines the width of the viewport (in screen space)
  97975. * @param height defines the height of the viewport (in screen space)
  97976. * @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
  97977. */
  97978. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  97979. /**
  97980. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  97981. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  97982. * @param y defines the y-coordinate of the corner of the clear rectangle
  97983. * @param width defines the width of the clear rectangle
  97984. * @param height defines the height of the clear rectangle
  97985. * @param clearColor defines the clear color
  97986. */
  97987. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  97988. /**
  97989. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  97990. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  97991. * @param y defines the y-coordinate of the corner of the clear rectangle
  97992. * @param width defines the width of the clear rectangle
  97993. * @param height defines the height of the clear rectangle
  97994. */
  97995. enableScissor(x: number, y: number, width: number, height: number): void;
  97996. /**
  97997. * Disable previously set scissor test rectangle
  97998. */
  97999. disableScissor(): void;
  98000. /**
  98001. * Initializes a webVR display and starts listening to display change events
  98002. * The onVRDisplayChangedObservable will be notified upon these changes
  98003. * @returns The onVRDisplayChangedObservable
  98004. */
  98005. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98006. /** @hidden */
  98007. _prepareVRComponent(): void;
  98008. /** @hidden */
  98009. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98010. /** @hidden */
  98011. _submitVRFrame(): void;
  98012. /**
  98013. * Call this function to leave webVR mode
  98014. * Will do nothing if webVR is not supported or if there is no webVR device
  98015. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98016. */
  98017. disableVR(): void;
  98018. /**
  98019. * Gets a boolean indicating that the system is in VR mode and is presenting
  98020. * @returns true if VR mode is engaged
  98021. */
  98022. isVRPresenting(): boolean;
  98023. /** @hidden */
  98024. _requestVRFrame(): void;
  98025. /** @hidden */
  98026. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98027. /**
  98028. * Gets the source code of the vertex shader associated with a specific webGL program
  98029. * @param program defines the program to use
  98030. * @returns a string containing the source code of the vertex shader associated with the program
  98031. */
  98032. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98033. /**
  98034. * Gets the source code of the fragment shader associated with a specific webGL program
  98035. * @param program defines the program to use
  98036. * @returns a string containing the source code of the fragment shader associated with the program
  98037. */
  98038. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98039. /**
  98040. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98041. * @param x defines the x coordinate of the rectangle where pixels must be read
  98042. * @param y defines the y coordinate of the rectangle where pixels must be read
  98043. * @param width defines the width of the rectangle where pixels must be read
  98044. * @param height defines the height of the rectangle where pixels must be read
  98045. * @returns a Uint8Array containing RGBA colors
  98046. */
  98047. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98048. /**
  98049. * Sets a depth stencil texture from a render target to the according uniform.
  98050. * @param channel The texture channel
  98051. * @param uniform The uniform to set
  98052. * @param texture The render target texture containing the depth stencil texture to apply
  98053. */
  98054. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98055. /**
  98056. * Sets a texture to the webGL context from a postprocess
  98057. * @param channel defines the channel to use
  98058. * @param postProcess defines the source postprocess
  98059. */
  98060. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98061. /**
  98062. * Binds the output of the passed in post process to the texture channel specified
  98063. * @param channel The channel the texture should be bound to
  98064. * @param postProcess The post process which's output should be bound
  98065. */
  98066. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98067. /** @hidden */
  98068. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98069. protected _rebuildBuffers(): void;
  98070. _renderLoop(): void;
  98071. /**
  98072. * Toggle full screen mode
  98073. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98074. */
  98075. switchFullscreen(requestPointerLock: boolean): void;
  98076. /**
  98077. * Enters full screen mode
  98078. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98079. */
  98080. enterFullscreen(requestPointerLock: boolean): void;
  98081. /**
  98082. * Exits full screen mode
  98083. */
  98084. exitFullscreen(): void;
  98085. /**
  98086. * Enters Pointerlock mode
  98087. */
  98088. enterPointerlock(): void;
  98089. /**
  98090. * Exits Pointerlock mode
  98091. */
  98092. exitPointerlock(): void;
  98093. /**
  98094. * Begin a new frame
  98095. */
  98096. beginFrame(): void;
  98097. /**
  98098. * Enf the current frame
  98099. */
  98100. endFrame(): void;
  98101. resize(): void;
  98102. /**
  98103. * Set the compressed texture format to use, based on the formats you have, and the formats
  98104. * supported by the hardware / browser.
  98105. *
  98106. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98107. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98108. * to API arguments needed to compressed textures. This puts the burden on the container
  98109. * generator to house the arcane code for determining these for current & future formats.
  98110. *
  98111. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98112. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98113. *
  98114. * Note: The result of this call is not taken into account when a texture is base64.
  98115. *
  98116. * @param formatsAvailable defines the list of those format families you have created
  98117. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98118. *
  98119. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98120. * @returns The extension selected.
  98121. */
  98122. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98123. /**
  98124. * Force a specific size of the canvas
  98125. * @param width defines the new canvas' width
  98126. * @param height defines the new canvas' height
  98127. */
  98128. setSize(width: number, height: number): void;
  98129. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98130. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98131. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98132. _releaseTexture(texture: InternalTexture): void;
  98133. /**
  98134. * @hidden
  98135. * Rescales a texture
  98136. * @param source input texutre
  98137. * @param destination destination texture
  98138. * @param scene scene to use to render the resize
  98139. * @param internalFormat format to use when resizing
  98140. * @param onComplete callback to be called when resize has completed
  98141. */
  98142. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98143. /**
  98144. * Gets the current framerate
  98145. * @returns a number representing the framerate
  98146. */
  98147. getFps(): number;
  98148. /**
  98149. * Gets the time spent between current and previous frame
  98150. * @returns a number representing the delta time in ms
  98151. */
  98152. getDeltaTime(): number;
  98153. private _measureFps;
  98154. /**
  98155. * Creates a new render target texture
  98156. * @param size defines the size of the texture
  98157. * @param options defines the options used to create the texture
  98158. * @returns a new render target texture stored in an InternalTexture
  98159. */
  98160. createRenderTargetTexture(size: number | {
  98161. width: number;
  98162. height: number;
  98163. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98164. /**
  98165. * Updates the sample count of a render target texture
  98166. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98167. * @param texture defines the texture to update
  98168. * @param samples defines the sample count to set
  98169. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98170. */
  98171. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98172. /** @hidden */
  98173. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98174. dispose(): void;
  98175. private _disableTouchAction;
  98176. /**
  98177. * Display the loading screen
  98178. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98179. */
  98180. displayLoadingUI(): void;
  98181. /**
  98182. * Hide the loading screen
  98183. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98184. */
  98185. hideLoadingUI(): void;
  98186. /**
  98187. * Gets the current loading screen object
  98188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98189. */
  98190. /**
  98191. * Sets the current loading screen object
  98192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98193. */
  98194. loadingScreen: ILoadingScreen;
  98195. /**
  98196. * Sets the current loading screen text
  98197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98198. */
  98199. loadingUIText: string;
  98200. /**
  98201. * Sets the current loading screen background color
  98202. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98203. */
  98204. loadingUIBackgroundColor: string;
  98205. /** Pointerlock and fullscreen */
  98206. /**
  98207. * Ask the browser to promote the current element to pointerlock mode
  98208. * @param element defines the DOM element to promote
  98209. */
  98210. static _RequestPointerlock(element: HTMLElement): void;
  98211. /**
  98212. * Asks the browser to exit pointerlock mode
  98213. */
  98214. static _ExitPointerlock(): void;
  98215. /**
  98216. * Ask the browser to promote the current element to fullscreen rendering mode
  98217. * @param element defines the DOM element to promote
  98218. */
  98219. static _RequestFullscreen(element: HTMLElement): void;
  98220. /**
  98221. * Asks the browser to exit fullscreen mode
  98222. */
  98223. static _ExitFullscreen(): void;
  98224. }
  98225. }
  98226. declare module BABYLON {
  98227. /**
  98228. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98229. * during the life time of the application.
  98230. */
  98231. export class EngineStore {
  98232. /** Gets the list of created engines */
  98233. static Instances: Engine[];
  98234. /** @hidden */
  98235. static _LastCreatedScene: Nullable<Scene>;
  98236. /**
  98237. * Gets the latest created engine
  98238. */
  98239. static readonly LastCreatedEngine: Nullable<Engine>;
  98240. /**
  98241. * Gets the latest created scene
  98242. */
  98243. static readonly LastCreatedScene: Nullable<Scene>;
  98244. /**
  98245. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98246. * @ignorenaming
  98247. */
  98248. static UseFallbackTexture: boolean;
  98249. /**
  98250. * Texture content used if a texture cannot loaded
  98251. * @ignorenaming
  98252. */
  98253. static FallbackTexture: string;
  98254. }
  98255. }
  98256. declare module BABYLON {
  98257. /**
  98258. * Helper class that provides a small promise polyfill
  98259. */
  98260. export class PromisePolyfill {
  98261. /**
  98262. * Static function used to check if the polyfill is required
  98263. * If this is the case then the function will inject the polyfill to window.Promise
  98264. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98265. */
  98266. static Apply(force?: boolean): void;
  98267. }
  98268. }
  98269. declare module BABYLON {
  98270. /**
  98271. * Interface for screenshot methods with describe argument called `size` as object with options
  98272. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98273. */
  98274. export interface IScreenshotSize {
  98275. /**
  98276. * number in pixels for canvas height
  98277. */
  98278. height?: number;
  98279. /**
  98280. * multiplier allowing render at a higher or lower resolution
  98281. * If value is defined then height and width will be ignored and taken from camera
  98282. */
  98283. precision?: number;
  98284. /**
  98285. * number in pixels for canvas width
  98286. */
  98287. width?: number;
  98288. }
  98289. }
  98290. declare module BABYLON {
  98291. interface IColor4Like {
  98292. r: float;
  98293. g: float;
  98294. b: float;
  98295. a: float;
  98296. }
  98297. /**
  98298. * Class containing a set of static utilities functions
  98299. */
  98300. export class Tools {
  98301. /**
  98302. * Gets or sets the base URL to use to load assets
  98303. */
  98304. static BaseUrl: string;
  98305. /**
  98306. * Enable/Disable Custom HTTP Request Headers globally.
  98307. * default = false
  98308. * @see CustomRequestHeaders
  98309. */
  98310. static UseCustomRequestHeaders: boolean;
  98311. /**
  98312. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98313. * i.e. when loading files, where the server/service expects an Authorization header
  98314. */
  98315. static CustomRequestHeaders: {
  98316. [key: string]: string;
  98317. };
  98318. /**
  98319. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98320. */
  98321. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98322. /**
  98323. * Default behaviour for cors in the application.
  98324. * It can be a string if the expected behavior is identical in the entire app.
  98325. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98326. */
  98327. static CorsBehavior: string | ((url: string | string[]) => string);
  98328. /**
  98329. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98330. * @ignorenaming
  98331. */
  98332. static UseFallbackTexture: boolean;
  98333. /**
  98334. * Use this object to register external classes like custom textures or material
  98335. * to allow the laoders to instantiate them
  98336. */
  98337. static RegisteredExternalClasses: {
  98338. [key: string]: Object;
  98339. };
  98340. /**
  98341. * Texture content used if a texture cannot loaded
  98342. * @ignorenaming
  98343. */
  98344. static fallbackTexture: string;
  98345. /**
  98346. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98347. * @param u defines the coordinate on X axis
  98348. * @param v defines the coordinate on Y axis
  98349. * @param width defines the width of the source data
  98350. * @param height defines the height of the source data
  98351. * @param pixels defines the source byte array
  98352. * @param color defines the output color
  98353. */
  98354. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98355. /**
  98356. * Interpolates between a and b via alpha
  98357. * @param a The lower value (returned when alpha = 0)
  98358. * @param b The upper value (returned when alpha = 1)
  98359. * @param alpha The interpolation-factor
  98360. * @return The mixed value
  98361. */
  98362. static Mix(a: number, b: number, alpha: number): number;
  98363. /**
  98364. * Tries to instantiate a new object from a given class name
  98365. * @param className defines the class name to instantiate
  98366. * @returns the new object or null if the system was not able to do the instantiation
  98367. */
  98368. static Instantiate(className: string): any;
  98369. /**
  98370. * Provides a slice function that will work even on IE
  98371. * @param data defines the array to slice
  98372. * @param start defines the start of the data (optional)
  98373. * @param end defines the end of the data (optional)
  98374. * @returns the new sliced array
  98375. */
  98376. static Slice<T>(data: T, start?: number, end?: number): T;
  98377. /**
  98378. * Polyfill for setImmediate
  98379. * @param action defines the action to execute after the current execution block
  98380. */
  98381. static SetImmediate(action: () => void): void;
  98382. /**
  98383. * Function indicating if a number is an exponent of 2
  98384. * @param value defines the value to test
  98385. * @returns true if the value is an exponent of 2
  98386. */
  98387. static IsExponentOfTwo(value: number): boolean;
  98388. private static _tmpFloatArray;
  98389. /**
  98390. * Returns the nearest 32-bit single precision float representation of a Number
  98391. * @param value A Number. If the parameter is of a different type, it will get converted
  98392. * to a number or to NaN if it cannot be converted
  98393. * @returns number
  98394. */
  98395. static FloatRound(value: number): number;
  98396. /**
  98397. * Extracts the filename from a path
  98398. * @param path defines the path to use
  98399. * @returns the filename
  98400. */
  98401. static GetFilename(path: string): string;
  98402. /**
  98403. * Extracts the "folder" part of a path (everything before the filename).
  98404. * @param uri The URI to extract the info from
  98405. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98406. * @returns The "folder" part of the path
  98407. */
  98408. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98409. /**
  98410. * Extracts text content from a DOM element hierarchy
  98411. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98412. */
  98413. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98414. /**
  98415. * Convert an angle in radians to degrees
  98416. * @param angle defines the angle to convert
  98417. * @returns the angle in degrees
  98418. */
  98419. static ToDegrees(angle: number): number;
  98420. /**
  98421. * Convert an angle in degrees to radians
  98422. * @param angle defines the angle to convert
  98423. * @returns the angle in radians
  98424. */
  98425. static ToRadians(angle: number): number;
  98426. /**
  98427. * Encode a buffer to a base64 string
  98428. * @param buffer defines the buffer to encode
  98429. * @returns the encoded string
  98430. */
  98431. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98432. /**
  98433. * Returns an array if obj is not an array
  98434. * @param obj defines the object to evaluate as an array
  98435. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98436. * @returns either obj directly if obj is an array or a new array containing obj
  98437. */
  98438. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98439. /**
  98440. * Gets the pointer prefix to use
  98441. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98442. */
  98443. static GetPointerPrefix(): string;
  98444. /**
  98445. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98446. * @param url define the url we are trying
  98447. * @param element define the dom element where to configure the cors policy
  98448. */
  98449. static SetCorsBehavior(url: string | string[], element: {
  98450. crossOrigin: string | null;
  98451. }): void;
  98452. /**
  98453. * Removes unwanted characters from an url
  98454. * @param url defines the url to clean
  98455. * @returns the cleaned url
  98456. */
  98457. static CleanUrl(url: string): string;
  98458. /**
  98459. * Gets or sets a function used to pre-process url before using them to load assets
  98460. */
  98461. static PreprocessUrl: (url: string) => string;
  98462. /**
  98463. * Loads an image as an HTMLImageElement.
  98464. * @param input url string, ArrayBuffer, or Blob to load
  98465. * @param onLoad callback called when the image successfully loads
  98466. * @param onError callback called when the image fails to load
  98467. * @param offlineProvider offline provider for caching
  98468. * @returns the HTMLImageElement of the loaded image
  98469. */
  98470. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98471. /**
  98472. * Loads a file
  98473. * @param url url string, ArrayBuffer, or Blob to load
  98474. * @param onSuccess callback called when the file successfully loads
  98475. * @param onProgress callback called while file is loading (if the server supports this mode)
  98476. * @param offlineProvider defines the offline provider for caching
  98477. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98478. * @param onError callback called when the file fails to load
  98479. * @returns a file request object
  98480. */
  98481. 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;
  98482. /**
  98483. * Loads a file from a url
  98484. * @param url the file url to load
  98485. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98486. */
  98487. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98488. /**
  98489. * Load a script (identified by an url). When the url returns, the
  98490. * content of this file is added into a new script element, attached to the DOM (body element)
  98491. * @param scriptUrl defines the url of the script to laod
  98492. * @param onSuccess defines the callback called when the script is loaded
  98493. * @param onError defines the callback to call if an error occurs
  98494. * @param scriptId defines the id of the script element
  98495. */
  98496. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98497. /**
  98498. * Load an asynchronous script (identified by an url). When the url returns, the
  98499. * content of this file is added into a new script element, attached to the DOM (body element)
  98500. * @param scriptUrl defines the url of the script to laod
  98501. * @param scriptId defines the id of the script element
  98502. * @returns a promise request object
  98503. */
  98504. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98505. /**
  98506. * Loads a file from a blob
  98507. * @param fileToLoad defines the blob to use
  98508. * @param callback defines the callback to call when data is loaded
  98509. * @param progressCallback defines the callback to call during loading process
  98510. * @returns a file request object
  98511. */
  98512. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98513. /**
  98514. * Loads a file
  98515. * @param fileToLoad defines the file to load
  98516. * @param callback defines the callback to call when data is loaded
  98517. * @param progressCallBack defines the callback to call during loading process
  98518. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98519. * @returns a file request object
  98520. */
  98521. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98522. /**
  98523. * Creates a data url from a given string content
  98524. * @param content defines the content to convert
  98525. * @returns the new data url link
  98526. */
  98527. static FileAsURL(content: string): string;
  98528. /**
  98529. * Format the given number to a specific decimal format
  98530. * @param value defines the number to format
  98531. * @param decimals defines the number of decimals to use
  98532. * @returns the formatted string
  98533. */
  98534. static Format(value: number, decimals?: number): string;
  98535. /**
  98536. * Tries to copy an object by duplicating every property
  98537. * @param source defines the source object
  98538. * @param destination defines the target object
  98539. * @param doNotCopyList defines a list of properties to avoid
  98540. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98541. */
  98542. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98543. /**
  98544. * Gets a boolean indicating if the given object has no own property
  98545. * @param obj defines the object to test
  98546. * @returns true if object has no own property
  98547. */
  98548. static IsEmpty(obj: any): boolean;
  98549. /**
  98550. * Function used to register events at window level
  98551. * @param windowElement defines the Window object to use
  98552. * @param events defines the events to register
  98553. */
  98554. static RegisterTopRootEvents(windowElement: Window, events: {
  98555. name: string;
  98556. handler: Nullable<(e: FocusEvent) => any>;
  98557. }[]): void;
  98558. /**
  98559. * Function used to unregister events from window level
  98560. * @param windowElement defines the Window object to use
  98561. * @param events defines the events to unregister
  98562. */
  98563. static UnregisterTopRootEvents(windowElement: Window, events: {
  98564. name: string;
  98565. handler: Nullable<(e: FocusEvent) => any>;
  98566. }[]): void;
  98567. /**
  98568. * @ignore
  98569. */
  98570. static _ScreenshotCanvas: HTMLCanvasElement;
  98571. /**
  98572. * Dumps the current bound framebuffer
  98573. * @param width defines the rendering width
  98574. * @param height defines the rendering height
  98575. * @param engine defines the hosting engine
  98576. * @param successCallback defines the callback triggered once the data are available
  98577. * @param mimeType defines the mime type of the result
  98578. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98579. */
  98580. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98581. /**
  98582. * Converts the canvas data to blob.
  98583. * This acts as a polyfill for browsers not supporting the to blob function.
  98584. * @param canvas Defines the canvas to extract the data from
  98585. * @param successCallback Defines the callback triggered once the data are available
  98586. * @param mimeType Defines the mime type of the result
  98587. */
  98588. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98589. /**
  98590. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98591. * @param successCallback defines the callback triggered once the data are available
  98592. * @param mimeType defines the mime type of the result
  98593. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98594. */
  98595. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98596. /**
  98597. * Downloads a blob in the browser
  98598. * @param blob defines the blob to download
  98599. * @param fileName defines the name of the downloaded file
  98600. */
  98601. static Download(blob: Blob, fileName: string): void;
  98602. /**
  98603. * Captures a screenshot of the current rendering
  98604. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98605. * @param engine defines the rendering engine
  98606. * @param camera defines the source camera
  98607. * @param size This parameter can be set to a single number or to an object with the
  98608. * following (optional) properties: precision, width, height. If a single number is passed,
  98609. * it will be used for both width and height. If an object is passed, the screenshot size
  98610. * will be derived from the parameters. The precision property is a multiplier allowing
  98611. * rendering at a higher or lower resolution
  98612. * @param successCallback defines the callback receives a single parameter which contains the
  98613. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98614. * src parameter of an <img> to display it
  98615. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98616. * Check your browser for supported MIME types
  98617. */
  98618. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98619. /**
  98620. * Captures a screenshot of the current rendering
  98621. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98622. * @param engine defines the rendering engine
  98623. * @param camera defines the source camera
  98624. * @param size This parameter can be set to a single number or to an object with the
  98625. * following (optional) properties: precision, width, height. If a single number is passed,
  98626. * it will be used for both width and height. If an object is passed, the screenshot size
  98627. * will be derived from the parameters. The precision property is a multiplier allowing
  98628. * rendering at a higher or lower resolution
  98629. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98630. * Check your browser for supported MIME types
  98631. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98632. * to the src parameter of an <img> to display it
  98633. */
  98634. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98635. /**
  98636. * Generates an image screenshot from the specified camera.
  98637. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98638. * @param engine The engine to use for rendering
  98639. * @param camera The camera to use for rendering
  98640. * @param size This parameter can be set to a single number or to an object with the
  98641. * following (optional) properties: precision, width, height. If a single number is passed,
  98642. * it will be used for both width and height. If an object is passed, the screenshot size
  98643. * will be derived from the parameters. The precision property is a multiplier allowing
  98644. * rendering at a higher or lower resolution
  98645. * @param successCallback The callback receives a single parameter which contains the
  98646. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98647. * src parameter of an <img> to display it
  98648. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98649. * Check your browser for supported MIME types
  98650. * @param samples Texture samples (default: 1)
  98651. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98652. * @param fileName A name for for the downloaded file.
  98653. */
  98654. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98655. /**
  98656. * Generates an image screenshot from the specified camera.
  98657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98658. * @param engine The engine to use for rendering
  98659. * @param camera The camera to use for rendering
  98660. * @param size This parameter can be set to a single number or to an object with the
  98661. * following (optional) properties: precision, width, height. If a single number is passed,
  98662. * it will be used for both width and height. If an object is passed, the screenshot size
  98663. * will be derived from the parameters. The precision property is a multiplier allowing
  98664. * rendering at a higher or lower resolution
  98665. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98666. * Check your browser for supported MIME types
  98667. * @param samples Texture samples (default: 1)
  98668. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98669. * @param fileName A name for for the downloaded file.
  98670. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98671. * to the src parameter of an <img> to display it
  98672. */
  98673. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  98674. /**
  98675. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98676. * Be aware Math.random() could cause collisions, but:
  98677. * "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"
  98678. * @returns a pseudo random id
  98679. */
  98680. static RandomId(): string;
  98681. /**
  98682. * Test if the given uri is a base64 string
  98683. * @param uri The uri to test
  98684. * @return True if the uri is a base64 string or false otherwise
  98685. */
  98686. static IsBase64(uri: string): boolean;
  98687. /**
  98688. * Decode the given base64 uri.
  98689. * @param uri The uri to decode
  98690. * @return The decoded base64 data.
  98691. */
  98692. static DecodeBase64(uri: string): ArrayBuffer;
  98693. /**
  98694. * Gets the absolute url.
  98695. * @param url the input url
  98696. * @return the absolute url
  98697. */
  98698. static GetAbsoluteUrl(url: string): string;
  98699. /**
  98700. * No log
  98701. */
  98702. static readonly NoneLogLevel: number;
  98703. /**
  98704. * Only message logs
  98705. */
  98706. static readonly MessageLogLevel: number;
  98707. /**
  98708. * Only warning logs
  98709. */
  98710. static readonly WarningLogLevel: number;
  98711. /**
  98712. * Only error logs
  98713. */
  98714. static readonly ErrorLogLevel: number;
  98715. /**
  98716. * All logs
  98717. */
  98718. static readonly AllLogLevel: number;
  98719. /**
  98720. * Gets a value indicating the number of loading errors
  98721. * @ignorenaming
  98722. */
  98723. static readonly errorsCount: number;
  98724. /**
  98725. * Callback called when a new log is added
  98726. */
  98727. static OnNewCacheEntry: (entry: string) => void;
  98728. /**
  98729. * Log a message to the console
  98730. * @param message defines the message to log
  98731. */
  98732. static Log(message: string): void;
  98733. /**
  98734. * Write a warning message to the console
  98735. * @param message defines the message to log
  98736. */
  98737. static Warn(message: string): void;
  98738. /**
  98739. * Write an error message to the console
  98740. * @param message defines the message to log
  98741. */
  98742. static Error(message: string): void;
  98743. /**
  98744. * Gets current log cache (list of logs)
  98745. */
  98746. static readonly LogCache: string;
  98747. /**
  98748. * Clears the log cache
  98749. */
  98750. static ClearLogCache(): void;
  98751. /**
  98752. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98753. */
  98754. static LogLevels: number;
  98755. /**
  98756. * Checks if the window object exists
  98757. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98758. */
  98759. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98760. /**
  98761. * No performance log
  98762. */
  98763. static readonly PerformanceNoneLogLevel: number;
  98764. /**
  98765. * Use user marks to log performance
  98766. */
  98767. static readonly PerformanceUserMarkLogLevel: number;
  98768. /**
  98769. * Log performance to the console
  98770. */
  98771. static readonly PerformanceConsoleLogLevel: number;
  98772. private static _performance;
  98773. /**
  98774. * Sets the current performance log level
  98775. */
  98776. static PerformanceLogLevel: number;
  98777. private static _StartPerformanceCounterDisabled;
  98778. private static _EndPerformanceCounterDisabled;
  98779. private static _StartUserMark;
  98780. private static _EndUserMark;
  98781. private static _StartPerformanceConsole;
  98782. private static _EndPerformanceConsole;
  98783. /**
  98784. * Starts a performance counter
  98785. */
  98786. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98787. /**
  98788. * Ends a specific performance coutner
  98789. */
  98790. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98791. /**
  98792. * Gets either window.performance.now() if supported or Date.now() else
  98793. */
  98794. static readonly Now: number;
  98795. /**
  98796. * This method will return the name of the class used to create the instance of the given object.
  98797. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98798. * @param object the object to get the class name from
  98799. * @param isType defines if the object is actually a type
  98800. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98801. */
  98802. static GetClassName(object: any, isType?: boolean): string;
  98803. /**
  98804. * Gets the first element of an array satisfying a given predicate
  98805. * @param array defines the array to browse
  98806. * @param predicate defines the predicate to use
  98807. * @returns null if not found or the element
  98808. */
  98809. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98810. /**
  98811. * This method will return the name of the full name of the class, including its owning module (if any).
  98812. * 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).
  98813. * @param object the object to get the class name from
  98814. * @param isType defines if the object is actually a type
  98815. * @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.
  98816. * @ignorenaming
  98817. */
  98818. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98819. /**
  98820. * Returns a promise that resolves after the given amount of time.
  98821. * @param delay Number of milliseconds to delay
  98822. * @returns Promise that resolves after the given amount of time
  98823. */
  98824. static DelayAsync(delay: number): Promise<void>;
  98825. }
  98826. /**
  98827. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98828. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98829. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98830. * @param name The name of the class, case should be preserved
  98831. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98832. */
  98833. export function className(name: string, module?: string): (target: Object) => void;
  98834. /**
  98835. * An implementation of a loop for asynchronous functions.
  98836. */
  98837. export class AsyncLoop {
  98838. /**
  98839. * Defines the number of iterations for the loop
  98840. */
  98841. iterations: number;
  98842. /**
  98843. * Defines the current index of the loop.
  98844. */
  98845. index: number;
  98846. private _done;
  98847. private _fn;
  98848. private _successCallback;
  98849. /**
  98850. * Constructor.
  98851. * @param iterations the number of iterations.
  98852. * @param func the function to run each iteration
  98853. * @param successCallback the callback that will be called upon succesful execution
  98854. * @param offset starting offset.
  98855. */
  98856. constructor(
  98857. /**
  98858. * Defines the number of iterations for the loop
  98859. */
  98860. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98861. /**
  98862. * Execute the next iteration. Must be called after the last iteration was finished.
  98863. */
  98864. executeNext(): void;
  98865. /**
  98866. * Break the loop and run the success callback.
  98867. */
  98868. breakLoop(): void;
  98869. /**
  98870. * Create and run an async loop.
  98871. * @param iterations the number of iterations.
  98872. * @param fn the function to run each iteration
  98873. * @param successCallback the callback that will be called upon succesful execution
  98874. * @param offset starting offset.
  98875. * @returns the created async loop object
  98876. */
  98877. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98878. /**
  98879. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98880. * @param iterations total number of iterations
  98881. * @param syncedIterations number of synchronous iterations in each async iteration.
  98882. * @param fn the function to call each iteration.
  98883. * @param callback a success call back that will be called when iterating stops.
  98884. * @param breakFunction a break condition (optional)
  98885. * @param timeout timeout settings for the setTimeout function. default - 0.
  98886. * @returns the created async loop object
  98887. */
  98888. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98889. }
  98890. }
  98891. declare module BABYLON {
  98892. /**
  98893. * This class implement a typical dictionary using a string as key and the generic type T as value.
  98894. * The underlying implementation relies on an associative array to ensure the best performances.
  98895. * The value can be anything including 'null' but except 'undefined'
  98896. */
  98897. export class StringDictionary<T> {
  98898. /**
  98899. * This will clear this dictionary and copy the content from the 'source' one.
  98900. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  98901. * @param source the dictionary to take the content from and copy to this dictionary
  98902. */
  98903. copyFrom(source: StringDictionary<T>): void;
  98904. /**
  98905. * Get a value based from its key
  98906. * @param key the given key to get the matching value from
  98907. * @return the value if found, otherwise undefined is returned
  98908. */
  98909. get(key: string): T | undefined;
  98910. /**
  98911. * Get a value from its key or add it if it doesn't exist.
  98912. * This method will ensure you that a given key/data will be present in the dictionary.
  98913. * @param key the given key to get the matching value from
  98914. * @param factory the factory that will create the value if the key is not present in the dictionary.
  98915. * The factory will only be invoked if there's no data for the given key.
  98916. * @return the value corresponding to the key.
  98917. */
  98918. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  98919. /**
  98920. * Get a value from its key if present in the dictionary otherwise add it
  98921. * @param key the key to get the value from
  98922. * @param val if there's no such key/value pair in the dictionary add it with this value
  98923. * @return the value corresponding to the key
  98924. */
  98925. getOrAdd(key: string, val: T): T;
  98926. /**
  98927. * Check if there's a given key in the dictionary
  98928. * @param key the key to check for
  98929. * @return true if the key is present, false otherwise
  98930. */
  98931. contains(key: string): boolean;
  98932. /**
  98933. * Add a new key and its corresponding value
  98934. * @param key the key to add
  98935. * @param value the value corresponding to the key
  98936. * @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
  98937. */
  98938. add(key: string, value: T): boolean;
  98939. /**
  98940. * Update a specific value associated to a key
  98941. * @param key defines the key to use
  98942. * @param value defines the value to store
  98943. * @returns true if the value was updated (or false if the key was not found)
  98944. */
  98945. set(key: string, value: T): boolean;
  98946. /**
  98947. * Get the element of the given key and remove it from the dictionary
  98948. * @param key defines the key to search
  98949. * @returns the value associated with the key or null if not found
  98950. */
  98951. getAndRemove(key: string): Nullable<T>;
  98952. /**
  98953. * Remove a key/value from the dictionary.
  98954. * @param key the key to remove
  98955. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  98956. */
  98957. remove(key: string): boolean;
  98958. /**
  98959. * Clear the whole content of the dictionary
  98960. */
  98961. clear(): void;
  98962. /**
  98963. * Gets the current count
  98964. */
  98965. readonly count: number;
  98966. /**
  98967. * Execute a callback on each key/val of the dictionary.
  98968. * Note that you can remove any element in this dictionary in the callback implementation
  98969. * @param callback the callback to execute on a given key/value pair
  98970. */
  98971. forEach(callback: (key: string, val: T) => void): void;
  98972. /**
  98973. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  98974. * If the callback returns null or undefined the method will iterate to the next key/value pair
  98975. * Note that you can remove any element in this dictionary in the callback implementation
  98976. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  98977. * @returns the first item
  98978. */
  98979. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  98980. private _count;
  98981. private _data;
  98982. }
  98983. }
  98984. declare module BABYLON {
  98985. /** @hidden */
  98986. export interface ICollisionCoordinator {
  98987. createCollider(): Collider;
  98988. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98989. init(scene: Scene): void;
  98990. }
  98991. /** @hidden */
  98992. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98993. private _scene;
  98994. private _scaledPosition;
  98995. private _scaledVelocity;
  98996. private _finalPosition;
  98997. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98998. createCollider(): Collider;
  98999. init(scene: Scene): void;
  99000. private _collideWithWorld;
  99001. }
  99002. }
  99003. declare module BABYLON {
  99004. /**
  99005. * Class used to manage all inputs for the scene.
  99006. */
  99007. export class InputManager {
  99008. /** The distance in pixel that you have to move to prevent some events */
  99009. static DragMovementThreshold: number;
  99010. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99011. static LongPressDelay: number;
  99012. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99013. static DoubleClickDelay: number;
  99014. /** If you need to check double click without raising a single click at first click, enable this flag */
  99015. static ExclusiveDoubleClickMode: boolean;
  99016. private _wheelEventName;
  99017. private _onPointerMove;
  99018. private _onPointerDown;
  99019. private _onPointerUp;
  99020. private _initClickEvent;
  99021. private _initActionManager;
  99022. private _delayedSimpleClick;
  99023. private _delayedSimpleClickTimeout;
  99024. private _previousDelayedSimpleClickTimeout;
  99025. private _meshPickProceed;
  99026. private _previousButtonPressed;
  99027. private _currentPickResult;
  99028. private _previousPickResult;
  99029. private _totalPointersPressed;
  99030. private _doubleClickOccured;
  99031. private _pointerOverMesh;
  99032. private _pickedDownMesh;
  99033. private _pickedUpMesh;
  99034. private _pointerX;
  99035. private _pointerY;
  99036. private _unTranslatedPointerX;
  99037. private _unTranslatedPointerY;
  99038. private _startingPointerPosition;
  99039. private _previousStartingPointerPosition;
  99040. private _startingPointerTime;
  99041. private _previousStartingPointerTime;
  99042. private _pointerCaptures;
  99043. private _onKeyDown;
  99044. private _onKeyUp;
  99045. private _onCanvasFocusObserver;
  99046. private _onCanvasBlurObserver;
  99047. private _scene;
  99048. /**
  99049. * Creates a new InputManager
  99050. * @param scene defines the hosting scene
  99051. */
  99052. constructor(scene: Scene);
  99053. /**
  99054. * Gets the mesh that is currently under the pointer
  99055. */
  99056. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99057. /**
  99058. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99059. */
  99060. readonly unTranslatedPointer: Vector2;
  99061. /**
  99062. * Gets or sets the current on-screen X position of the pointer
  99063. */
  99064. pointerX: number;
  99065. /**
  99066. * Gets or sets the current on-screen Y position of the pointer
  99067. */
  99068. pointerY: number;
  99069. private _updatePointerPosition;
  99070. private _processPointerMove;
  99071. private _setRayOnPointerInfo;
  99072. private _checkPrePointerObservable;
  99073. /**
  99074. * Use this method to simulate a pointer move on a mesh
  99075. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99076. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99077. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99078. */
  99079. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99080. /**
  99081. * Use this method to simulate a pointer down on a mesh
  99082. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99083. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99084. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99085. */
  99086. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99087. private _processPointerDown;
  99088. /** @hidden */
  99089. _isPointerSwiping(): boolean;
  99090. /**
  99091. * Use this method to simulate a pointer up on a mesh
  99092. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99093. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99094. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99095. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99096. */
  99097. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99098. private _processPointerUp;
  99099. /**
  99100. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99101. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99102. * @returns true if the pointer was captured
  99103. */
  99104. isPointerCaptured(pointerId?: number): boolean;
  99105. /**
  99106. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99107. * @param attachUp defines if you want to attach events to pointerup
  99108. * @param attachDown defines if you want to attach events to pointerdown
  99109. * @param attachMove defines if you want to attach events to pointermove
  99110. */
  99111. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99112. /**
  99113. * Detaches all event handlers
  99114. */
  99115. detachControl(): void;
  99116. /**
  99117. * Force the value of meshUnderPointer
  99118. * @param mesh defines the mesh to use
  99119. */
  99120. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99121. /**
  99122. * Gets the mesh under the pointer
  99123. * @returns a Mesh or null if no mesh is under the pointer
  99124. */
  99125. getPointerOverMesh(): Nullable<AbstractMesh>;
  99126. }
  99127. }
  99128. declare module BABYLON {
  99129. /**
  99130. * Helper class used to generate session unique ID
  99131. */
  99132. export class UniqueIdGenerator {
  99133. private static _UniqueIdCounter;
  99134. /**
  99135. * Gets an unique (relatively to the current scene) Id
  99136. */
  99137. static readonly UniqueId: number;
  99138. }
  99139. }
  99140. declare module BABYLON {
  99141. /**
  99142. * This class defines the direct association between an animation and a target
  99143. */
  99144. export class TargetedAnimation {
  99145. /**
  99146. * Animation to perform
  99147. */
  99148. animation: Animation;
  99149. /**
  99150. * Target to animate
  99151. */
  99152. target: any;
  99153. /**
  99154. * Serialize the object
  99155. * @returns the JSON object representing the current entity
  99156. */
  99157. serialize(): any;
  99158. }
  99159. /**
  99160. * Use this class to create coordinated animations on multiple targets
  99161. */
  99162. export class AnimationGroup implements IDisposable {
  99163. /** The name of the animation group */
  99164. name: string;
  99165. private _scene;
  99166. private _targetedAnimations;
  99167. private _animatables;
  99168. private _from;
  99169. private _to;
  99170. private _isStarted;
  99171. private _isPaused;
  99172. private _speedRatio;
  99173. private _loopAnimation;
  99174. /**
  99175. * Gets or sets the unique id of the node
  99176. */
  99177. uniqueId: number;
  99178. /**
  99179. * This observable will notify when one animation have ended
  99180. */
  99181. onAnimationEndObservable: Observable<TargetedAnimation>;
  99182. /**
  99183. * Observer raised when one animation loops
  99184. */
  99185. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99186. /**
  99187. * This observable will notify when all animations have ended.
  99188. */
  99189. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99190. /**
  99191. * This observable will notify when all animations have paused.
  99192. */
  99193. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99194. /**
  99195. * This observable will notify when all animations are playing.
  99196. */
  99197. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99198. /**
  99199. * Gets the first frame
  99200. */
  99201. readonly from: number;
  99202. /**
  99203. * Gets the last frame
  99204. */
  99205. readonly to: number;
  99206. /**
  99207. * Define if the animations are started
  99208. */
  99209. readonly isStarted: boolean;
  99210. /**
  99211. * Gets a value indicating that the current group is playing
  99212. */
  99213. readonly isPlaying: boolean;
  99214. /**
  99215. * Gets or sets the speed ratio to use for all animations
  99216. */
  99217. /**
  99218. * Gets or sets the speed ratio to use for all animations
  99219. */
  99220. speedRatio: number;
  99221. /**
  99222. * Gets or sets if all animations should loop or not
  99223. */
  99224. loopAnimation: boolean;
  99225. /**
  99226. * Gets the targeted animations for this animation group
  99227. */
  99228. readonly targetedAnimations: Array<TargetedAnimation>;
  99229. /**
  99230. * returning the list of animatables controlled by this animation group.
  99231. */
  99232. readonly animatables: Array<Animatable>;
  99233. /**
  99234. * Instantiates a new Animation Group.
  99235. * This helps managing several animations at once.
  99236. * @see http://doc.babylonjs.com/how_to/group
  99237. * @param name Defines the name of the group
  99238. * @param scene Defines the scene the group belongs to
  99239. */
  99240. constructor(
  99241. /** The name of the animation group */
  99242. name: string, scene?: Nullable<Scene>);
  99243. /**
  99244. * Add an animation (with its target) in the group
  99245. * @param animation defines the animation we want to add
  99246. * @param target defines the target of the animation
  99247. * @returns the TargetedAnimation object
  99248. */
  99249. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99250. /**
  99251. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99252. * It can add constant keys at begin or end
  99253. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99254. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99255. * @returns the animation group
  99256. */
  99257. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99258. /**
  99259. * Start all animations on given targets
  99260. * @param loop defines if animations must loop
  99261. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99262. * @param from defines the from key (optional)
  99263. * @param to defines the to key (optional)
  99264. * @returns the current animation group
  99265. */
  99266. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99267. /**
  99268. * Pause all animations
  99269. * @returns the animation group
  99270. */
  99271. pause(): AnimationGroup;
  99272. /**
  99273. * Play all animations to initial state
  99274. * This function will start() the animations if they were not started or will restart() them if they were paused
  99275. * @param loop defines if animations must loop
  99276. * @returns the animation group
  99277. */
  99278. play(loop?: boolean): AnimationGroup;
  99279. /**
  99280. * Reset all animations to initial state
  99281. * @returns the animation group
  99282. */
  99283. reset(): AnimationGroup;
  99284. /**
  99285. * Restart animations from key 0
  99286. * @returns the animation group
  99287. */
  99288. restart(): AnimationGroup;
  99289. /**
  99290. * Stop all animations
  99291. * @returns the animation group
  99292. */
  99293. stop(): AnimationGroup;
  99294. /**
  99295. * Set animation weight for all animatables
  99296. * @param weight defines the weight to use
  99297. * @return the animationGroup
  99298. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99299. */
  99300. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99301. /**
  99302. * Synchronize and normalize all animatables with a source animatable
  99303. * @param root defines the root animatable to synchronize with
  99304. * @return the animationGroup
  99305. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99306. */
  99307. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99308. /**
  99309. * Goes to a specific frame in this animation group
  99310. * @param frame the frame number to go to
  99311. * @return the animationGroup
  99312. */
  99313. goToFrame(frame: number): AnimationGroup;
  99314. /**
  99315. * Dispose all associated resources
  99316. */
  99317. dispose(): void;
  99318. private _checkAnimationGroupEnded;
  99319. /**
  99320. * Clone the current animation group and returns a copy
  99321. * @param newName defines the name of the new group
  99322. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99323. * @returns the new aniamtion group
  99324. */
  99325. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99326. /**
  99327. * Serializes the animationGroup to an object
  99328. * @returns Serialized object
  99329. */
  99330. serialize(): any;
  99331. /**
  99332. * Returns a new AnimationGroup object parsed from the source provided.
  99333. * @param parsedAnimationGroup defines the source
  99334. * @param scene defines the scene that will receive the animationGroup
  99335. * @returns a new AnimationGroup
  99336. */
  99337. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99338. /**
  99339. * Returns the string "AnimationGroup"
  99340. * @returns "AnimationGroup"
  99341. */
  99342. getClassName(): string;
  99343. /**
  99344. * Creates a detailled string about the object
  99345. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99346. * @returns a string representing the object
  99347. */
  99348. toString(fullDetails?: boolean): string;
  99349. }
  99350. }
  99351. declare module BABYLON {
  99352. /**
  99353. * Define an interface for all classes that will hold resources
  99354. */
  99355. export interface IDisposable {
  99356. /**
  99357. * Releases all held resources
  99358. */
  99359. dispose(): void;
  99360. }
  99361. /** Interface defining initialization parameters for Scene class */
  99362. export interface SceneOptions {
  99363. /**
  99364. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99365. * It will improve performance when the number of geometries becomes important.
  99366. */
  99367. useGeometryUniqueIdsMap?: boolean;
  99368. /**
  99369. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99370. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99371. */
  99372. useMaterialMeshMap?: boolean;
  99373. /**
  99374. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99375. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99376. */
  99377. useClonedMeshhMap?: boolean;
  99378. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99379. virtual?: boolean;
  99380. }
  99381. /**
  99382. * Represents a scene to be rendered by the engine.
  99383. * @see http://doc.babylonjs.com/features/scene
  99384. */
  99385. export class Scene extends AbstractScene implements IAnimatable {
  99386. /** The fog is deactivated */
  99387. static readonly FOGMODE_NONE: number;
  99388. /** The fog density is following an exponential function */
  99389. static readonly FOGMODE_EXP: number;
  99390. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99391. static readonly FOGMODE_EXP2: number;
  99392. /** The fog density is following a linear function. */
  99393. static readonly FOGMODE_LINEAR: number;
  99394. /**
  99395. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99396. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99397. */
  99398. static MinDeltaTime: number;
  99399. /**
  99400. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99401. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99402. */
  99403. static MaxDeltaTime: number;
  99404. /**
  99405. * Factory used to create the default material.
  99406. * @param name The name of the material to create
  99407. * @param scene The scene to create the material for
  99408. * @returns The default material
  99409. */
  99410. static DefaultMaterialFactory(scene: Scene): Material;
  99411. /**
  99412. * Factory used to create the a collision coordinator.
  99413. * @returns The collision coordinator
  99414. */
  99415. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99416. /** @hidden */
  99417. _inputManager: InputManager;
  99418. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99419. cameraToUseForPointers: Nullable<Camera>;
  99420. /** @hidden */
  99421. readonly _isScene: boolean;
  99422. /**
  99423. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99424. */
  99425. autoClear: boolean;
  99426. /**
  99427. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99428. */
  99429. autoClearDepthAndStencil: boolean;
  99430. /**
  99431. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99432. */
  99433. clearColor: Color4;
  99434. /**
  99435. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99436. */
  99437. ambientColor: Color3;
  99438. /**
  99439. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99440. * It should only be one of the following (if not the default embedded one):
  99441. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99442. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99443. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99444. * The material properties need to be setup according to the type of texture in use.
  99445. */
  99446. environmentBRDFTexture: BaseTexture;
  99447. /** @hidden */
  99448. protected _environmentTexture: Nullable<BaseTexture>;
  99449. /**
  99450. * Texture used in all pbr material as the reflection texture.
  99451. * As in the majority of the scene they are the same (exception for multi room and so on),
  99452. * this is easier to reference from here than from all the materials.
  99453. */
  99454. /**
  99455. * Texture used in all pbr material as the reflection texture.
  99456. * As in the majority of the scene they are the same (exception for multi room and so on),
  99457. * this is easier to set here than in all the materials.
  99458. */
  99459. environmentTexture: Nullable<BaseTexture>;
  99460. /** @hidden */
  99461. protected _environmentIntensity: number;
  99462. /**
  99463. * Intensity of the environment in all pbr material.
  99464. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99465. * As in the majority of the scene they are the same (exception for multi room and so on),
  99466. * this is easier to reference from here than from all the materials.
  99467. */
  99468. /**
  99469. * Intensity of the environment in all pbr material.
  99470. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99471. * As in the majority of the scene they are the same (exception for multi room and so on),
  99472. * this is easier to set here than in all the materials.
  99473. */
  99474. environmentIntensity: number;
  99475. /** @hidden */
  99476. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99477. /**
  99478. * Default image processing configuration used either in the rendering
  99479. * Forward main pass or through the imageProcessingPostProcess if present.
  99480. * As in the majority of the scene they are the same (exception for multi camera),
  99481. * this is easier to reference from here than from all the materials and post process.
  99482. *
  99483. * No setter as we it is a shared configuration, you can set the values instead.
  99484. */
  99485. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99486. private _forceWireframe;
  99487. /**
  99488. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99489. */
  99490. forceWireframe: boolean;
  99491. private _forcePointsCloud;
  99492. /**
  99493. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99494. */
  99495. forcePointsCloud: boolean;
  99496. /**
  99497. * Gets or sets the active clipplane 1
  99498. */
  99499. clipPlane: Nullable<Plane>;
  99500. /**
  99501. * Gets or sets the active clipplane 2
  99502. */
  99503. clipPlane2: Nullable<Plane>;
  99504. /**
  99505. * Gets or sets the active clipplane 3
  99506. */
  99507. clipPlane3: Nullable<Plane>;
  99508. /**
  99509. * Gets or sets the active clipplane 4
  99510. */
  99511. clipPlane4: Nullable<Plane>;
  99512. /**
  99513. * Gets or sets a boolean indicating if animations are enabled
  99514. */
  99515. animationsEnabled: boolean;
  99516. private _animationPropertiesOverride;
  99517. /**
  99518. * Gets or sets the animation properties override
  99519. */
  99520. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99521. /**
  99522. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99523. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99524. */
  99525. useConstantAnimationDeltaTime: boolean;
  99526. /**
  99527. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99528. * Please note that it requires to run a ray cast through the scene on every frame
  99529. */
  99530. constantlyUpdateMeshUnderPointer: boolean;
  99531. /**
  99532. * Defines the HTML cursor to use when hovering over interactive elements
  99533. */
  99534. hoverCursor: string;
  99535. /**
  99536. * Defines the HTML default cursor to use (empty by default)
  99537. */
  99538. defaultCursor: string;
  99539. /**
  99540. * This is used to call preventDefault() on pointer down
  99541. * in order to block unwanted artifacts like system double clicks
  99542. */
  99543. preventDefaultOnPointerDown: boolean;
  99544. /**
  99545. * This is used to call preventDefault() on pointer up
  99546. * in order to block unwanted artifacts like system double clicks
  99547. */
  99548. preventDefaultOnPointerUp: boolean;
  99549. /**
  99550. * Gets or sets user defined metadata
  99551. */
  99552. metadata: any;
  99553. /**
  99554. * For internal use only. Please do not use.
  99555. */
  99556. reservedDataStore: any;
  99557. /**
  99558. * Gets the name of the plugin used to load this scene (null by default)
  99559. */
  99560. loadingPluginName: string;
  99561. /**
  99562. * Use this array to add regular expressions used to disable offline support for specific urls
  99563. */
  99564. disableOfflineSupportExceptionRules: RegExp[];
  99565. /**
  99566. * An event triggered when the scene is disposed.
  99567. */
  99568. onDisposeObservable: Observable<Scene>;
  99569. private _onDisposeObserver;
  99570. /** Sets a function to be executed when this scene is disposed. */
  99571. onDispose: () => void;
  99572. /**
  99573. * An event triggered before rendering the scene (right after animations and physics)
  99574. */
  99575. onBeforeRenderObservable: Observable<Scene>;
  99576. private _onBeforeRenderObserver;
  99577. /** Sets a function to be executed before rendering this scene */
  99578. beforeRender: Nullable<() => void>;
  99579. /**
  99580. * An event triggered after rendering the scene
  99581. */
  99582. onAfterRenderObservable: Observable<Scene>;
  99583. /**
  99584. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99585. */
  99586. onAfterRenderCameraObservable: Observable<Camera>;
  99587. private _onAfterRenderObserver;
  99588. /** Sets a function to be executed after rendering this scene */
  99589. afterRender: Nullable<() => void>;
  99590. /**
  99591. * An event triggered before animating the scene
  99592. */
  99593. onBeforeAnimationsObservable: Observable<Scene>;
  99594. /**
  99595. * An event triggered after animations processing
  99596. */
  99597. onAfterAnimationsObservable: Observable<Scene>;
  99598. /**
  99599. * An event triggered before draw calls are ready to be sent
  99600. */
  99601. onBeforeDrawPhaseObservable: Observable<Scene>;
  99602. /**
  99603. * An event triggered after draw calls have been sent
  99604. */
  99605. onAfterDrawPhaseObservable: Observable<Scene>;
  99606. /**
  99607. * An event triggered when the scene is ready
  99608. */
  99609. onReadyObservable: Observable<Scene>;
  99610. /**
  99611. * An event triggered before rendering a camera
  99612. */
  99613. onBeforeCameraRenderObservable: Observable<Camera>;
  99614. private _onBeforeCameraRenderObserver;
  99615. /** Sets a function to be executed before rendering a camera*/
  99616. beforeCameraRender: () => void;
  99617. /**
  99618. * An event triggered after rendering a camera
  99619. */
  99620. onAfterCameraRenderObservable: Observable<Camera>;
  99621. private _onAfterCameraRenderObserver;
  99622. /** Sets a function to be executed after rendering a camera*/
  99623. afterCameraRender: () => void;
  99624. /**
  99625. * An event triggered when active meshes evaluation is about to start
  99626. */
  99627. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  99628. /**
  99629. * An event triggered when active meshes evaluation is done
  99630. */
  99631. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  99632. /**
  99633. * An event triggered when particles rendering is about to start
  99634. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99635. */
  99636. onBeforeParticlesRenderingObservable: Observable<Scene>;
  99637. /**
  99638. * An event triggered when particles rendering is done
  99639. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99640. */
  99641. onAfterParticlesRenderingObservable: Observable<Scene>;
  99642. /**
  99643. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99644. */
  99645. onDataLoadedObservable: Observable<Scene>;
  99646. /**
  99647. * An event triggered when a camera is created
  99648. */
  99649. onNewCameraAddedObservable: Observable<Camera>;
  99650. /**
  99651. * An event triggered when a camera is removed
  99652. */
  99653. onCameraRemovedObservable: Observable<Camera>;
  99654. /**
  99655. * An event triggered when a light is created
  99656. */
  99657. onNewLightAddedObservable: Observable<Light>;
  99658. /**
  99659. * An event triggered when a light is removed
  99660. */
  99661. onLightRemovedObservable: Observable<Light>;
  99662. /**
  99663. * An event triggered when a geometry is created
  99664. */
  99665. onNewGeometryAddedObservable: Observable<Geometry>;
  99666. /**
  99667. * An event triggered when a geometry is removed
  99668. */
  99669. onGeometryRemovedObservable: Observable<Geometry>;
  99670. /**
  99671. * An event triggered when a transform node is created
  99672. */
  99673. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  99674. /**
  99675. * An event triggered when a transform node is removed
  99676. */
  99677. onTransformNodeRemovedObservable: Observable<TransformNode>;
  99678. /**
  99679. * An event triggered when a mesh is created
  99680. */
  99681. onNewMeshAddedObservable: Observable<AbstractMesh>;
  99682. /**
  99683. * An event triggered when a mesh is removed
  99684. */
  99685. onMeshRemovedObservable: Observable<AbstractMesh>;
  99686. /**
  99687. * An event triggered when a skeleton is created
  99688. */
  99689. onNewSkeletonAddedObservable: Observable<Skeleton>;
  99690. /**
  99691. * An event triggered when a skeleton is removed
  99692. */
  99693. onSkeletonRemovedObservable: Observable<Skeleton>;
  99694. /**
  99695. * An event triggered when a material is created
  99696. */
  99697. onNewMaterialAddedObservable: Observable<Material>;
  99698. /**
  99699. * An event triggered when a material is removed
  99700. */
  99701. onMaterialRemovedObservable: Observable<Material>;
  99702. /**
  99703. * An event triggered when a texture is created
  99704. */
  99705. onNewTextureAddedObservable: Observable<BaseTexture>;
  99706. /**
  99707. * An event triggered when a texture is removed
  99708. */
  99709. onTextureRemovedObservable: Observable<BaseTexture>;
  99710. /**
  99711. * An event triggered when render targets are about to be rendered
  99712. * Can happen multiple times per frame.
  99713. */
  99714. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  99715. /**
  99716. * An event triggered when render targets were rendered.
  99717. * Can happen multiple times per frame.
  99718. */
  99719. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  99720. /**
  99721. * An event triggered before calculating deterministic simulation step
  99722. */
  99723. onBeforeStepObservable: Observable<Scene>;
  99724. /**
  99725. * An event triggered after calculating deterministic simulation step
  99726. */
  99727. onAfterStepObservable: Observable<Scene>;
  99728. /**
  99729. * An event triggered when the activeCamera property is updated
  99730. */
  99731. onActiveCameraChanged: Observable<Scene>;
  99732. /**
  99733. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  99734. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99735. * 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)
  99736. */
  99737. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99738. /**
  99739. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  99740. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99741. * 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)
  99742. */
  99743. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99744. /**
  99745. * This Observable will when a mesh has been imported into the scene.
  99746. */
  99747. onMeshImportedObservable: Observable<AbstractMesh>;
  99748. /**
  99749. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  99750. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  99751. */
  99752. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  99753. /** @hidden */
  99754. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  99755. /**
  99756. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  99757. */
  99758. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  99759. /**
  99760. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  99761. */
  99762. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  99763. /**
  99764. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  99765. */
  99766. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  99767. /** Callback called when a pointer move is detected */
  99768. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99769. /** Callback called when a pointer down is detected */
  99770. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99771. /** Callback called when a pointer up is detected */
  99772. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  99773. /** Callback called when a pointer pick is detected */
  99774. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99775. /**
  99776. * 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).
  99777. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99778. */
  99779. onPrePointerObservable: Observable<PointerInfoPre>;
  99780. /**
  99781. * Observable event triggered each time an input event is received from the rendering canvas
  99782. */
  99783. onPointerObservable: Observable<PointerInfo>;
  99784. /**
  99785. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99786. */
  99787. readonly unTranslatedPointer: Vector2;
  99788. /**
  99789. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99790. */
  99791. static DragMovementThreshold: number;
  99792. /**
  99793. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99794. */
  99795. static LongPressDelay: number;
  99796. /**
  99797. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99798. */
  99799. static DoubleClickDelay: number;
  99800. /** If you need to check double click without raising a single click at first click, enable this flag */
  99801. static ExclusiveDoubleClickMode: boolean;
  99802. /** @hidden */
  99803. _mirroredCameraPosition: Nullable<Vector3>;
  99804. /**
  99805. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99806. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99807. */
  99808. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99809. /**
  99810. * Observable event triggered each time an keyboard event is received from the hosting window
  99811. */
  99812. onKeyboardObservable: Observable<KeyboardInfo>;
  99813. private _useRightHandedSystem;
  99814. /**
  99815. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99816. */
  99817. useRightHandedSystem: boolean;
  99818. private _timeAccumulator;
  99819. private _currentStepId;
  99820. private _currentInternalStep;
  99821. /**
  99822. * Sets the step Id used by deterministic lock step
  99823. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99824. * @param newStepId defines the step Id
  99825. */
  99826. setStepId(newStepId: number): void;
  99827. /**
  99828. * Gets the step Id used by deterministic lock step
  99829. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99830. * @returns the step Id
  99831. */
  99832. getStepId(): number;
  99833. /**
  99834. * Gets the internal step used by deterministic lock step
  99835. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99836. * @returns the internal step
  99837. */
  99838. getInternalStep(): number;
  99839. private _fogEnabled;
  99840. /**
  99841. * Gets or sets a boolean indicating if fog is enabled on this scene
  99842. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99843. * (Default is true)
  99844. */
  99845. fogEnabled: boolean;
  99846. private _fogMode;
  99847. /**
  99848. * Gets or sets the fog mode to use
  99849. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99850. * | mode | value |
  99851. * | --- | --- |
  99852. * | FOGMODE_NONE | 0 |
  99853. * | FOGMODE_EXP | 1 |
  99854. * | FOGMODE_EXP2 | 2 |
  99855. * | FOGMODE_LINEAR | 3 |
  99856. */
  99857. fogMode: number;
  99858. /**
  99859. * Gets or sets the fog color to use
  99860. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99861. * (Default is Color3(0.2, 0.2, 0.3))
  99862. */
  99863. fogColor: Color3;
  99864. /**
  99865. * Gets or sets the fog density to use
  99866. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99867. * (Default is 0.1)
  99868. */
  99869. fogDensity: number;
  99870. /**
  99871. * Gets or sets the fog start distance to use
  99872. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99873. * (Default is 0)
  99874. */
  99875. fogStart: number;
  99876. /**
  99877. * Gets or sets the fog end distance to use
  99878. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99879. * (Default is 1000)
  99880. */
  99881. fogEnd: number;
  99882. private _shadowsEnabled;
  99883. /**
  99884. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99885. */
  99886. shadowsEnabled: boolean;
  99887. private _lightsEnabled;
  99888. /**
  99889. * Gets or sets a boolean indicating if lights are enabled on this scene
  99890. */
  99891. lightsEnabled: boolean;
  99892. /** All of the active cameras added to this scene. */
  99893. activeCameras: Camera[];
  99894. /** @hidden */
  99895. _activeCamera: Nullable<Camera>;
  99896. /** Gets or sets the current active camera */
  99897. activeCamera: Nullable<Camera>;
  99898. private _defaultMaterial;
  99899. /** The default material used on meshes when no material is affected */
  99900. /** The default material used on meshes when no material is affected */
  99901. defaultMaterial: Material;
  99902. private _texturesEnabled;
  99903. /**
  99904. * Gets or sets a boolean indicating if textures are enabled on this scene
  99905. */
  99906. texturesEnabled: boolean;
  99907. /**
  99908. * Gets or sets a boolean indicating if particles are enabled on this scene
  99909. */
  99910. particlesEnabled: boolean;
  99911. /**
  99912. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99913. */
  99914. spritesEnabled: boolean;
  99915. private _skeletonsEnabled;
  99916. /**
  99917. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99918. */
  99919. skeletonsEnabled: boolean;
  99920. /**
  99921. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99922. */
  99923. lensFlaresEnabled: boolean;
  99924. /**
  99925. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99926. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99927. */
  99928. collisionsEnabled: boolean;
  99929. private _collisionCoordinator;
  99930. /** @hidden */
  99931. readonly collisionCoordinator: ICollisionCoordinator;
  99932. /**
  99933. * Defines the gravity applied to this scene (used only for collisions)
  99934. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99935. */
  99936. gravity: Vector3;
  99937. /**
  99938. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99939. */
  99940. postProcessesEnabled: boolean;
  99941. /**
  99942. * The list of postprocesses added to the scene
  99943. */
  99944. postProcesses: PostProcess[];
  99945. /**
  99946. * Gets the current postprocess manager
  99947. */
  99948. postProcessManager: PostProcessManager;
  99949. /**
  99950. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99951. */
  99952. renderTargetsEnabled: boolean;
  99953. /**
  99954. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99955. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99956. */
  99957. dumpNextRenderTargets: boolean;
  99958. /**
  99959. * The list of user defined render targets added to the scene
  99960. */
  99961. customRenderTargets: RenderTargetTexture[];
  99962. /**
  99963. * Defines if texture loading must be delayed
  99964. * If true, textures will only be loaded when they need to be rendered
  99965. */
  99966. useDelayedTextureLoading: boolean;
  99967. /**
  99968. * Gets the list of meshes imported to the scene through SceneLoader
  99969. */
  99970. importedMeshesFiles: String[];
  99971. /**
  99972. * Gets or sets a boolean indicating if probes are enabled on this scene
  99973. */
  99974. probesEnabled: boolean;
  99975. /**
  99976. * Gets or sets the current offline provider to use to store scene data
  99977. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99978. */
  99979. offlineProvider: IOfflineProvider;
  99980. /**
  99981. * Gets or sets the action manager associated with the scene
  99982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99983. */
  99984. actionManager: AbstractActionManager;
  99985. private _meshesForIntersections;
  99986. /**
  99987. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99988. */
  99989. proceduralTexturesEnabled: boolean;
  99990. private _engine;
  99991. private _totalVertices;
  99992. /** @hidden */
  99993. _activeIndices: PerfCounter;
  99994. /** @hidden */
  99995. _activeParticles: PerfCounter;
  99996. /** @hidden */
  99997. _activeBones: PerfCounter;
  99998. private _animationRatio;
  99999. /** @hidden */
  100000. _animationTimeLast: number;
  100001. /** @hidden */
  100002. _animationTime: number;
  100003. /**
  100004. * Gets or sets a general scale for animation speed
  100005. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100006. */
  100007. animationTimeScale: number;
  100008. /** @hidden */
  100009. _cachedMaterial: Nullable<Material>;
  100010. /** @hidden */
  100011. _cachedEffect: Nullable<Effect>;
  100012. /** @hidden */
  100013. _cachedVisibility: Nullable<number>;
  100014. private _renderId;
  100015. private _frameId;
  100016. private _executeWhenReadyTimeoutId;
  100017. private _intermediateRendering;
  100018. private _viewUpdateFlag;
  100019. private _projectionUpdateFlag;
  100020. /** @hidden */
  100021. _toBeDisposed: Nullable<IDisposable>[];
  100022. private _activeRequests;
  100023. /** @hidden */
  100024. _pendingData: any[];
  100025. private _isDisposed;
  100026. /**
  100027. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100028. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100029. */
  100030. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100031. private _activeMeshes;
  100032. private _processedMaterials;
  100033. private _renderTargets;
  100034. /** @hidden */
  100035. _activeParticleSystems: SmartArray<IParticleSystem>;
  100036. private _activeSkeletons;
  100037. private _softwareSkinnedMeshes;
  100038. private _renderingManager;
  100039. /** @hidden */
  100040. _activeAnimatables: Animatable[];
  100041. private _transformMatrix;
  100042. private _sceneUbo;
  100043. /** @hidden */
  100044. _viewMatrix: Matrix;
  100045. private _projectionMatrix;
  100046. /** @hidden */
  100047. _forcedViewPosition: Nullable<Vector3>;
  100048. /** @hidden */
  100049. _frustumPlanes: Plane[];
  100050. /**
  100051. * Gets the list of frustum planes (built from the active camera)
  100052. */
  100053. readonly frustumPlanes: Plane[];
  100054. /**
  100055. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100056. * This is useful if there are more lights that the maximum simulteanous authorized
  100057. */
  100058. requireLightSorting: boolean;
  100059. /** @hidden */
  100060. readonly useMaterialMeshMap: boolean;
  100061. /** @hidden */
  100062. readonly useClonedMeshhMap: boolean;
  100063. private _externalData;
  100064. private _uid;
  100065. /**
  100066. * @hidden
  100067. * Backing store of defined scene components.
  100068. */
  100069. _components: ISceneComponent[];
  100070. /**
  100071. * @hidden
  100072. * Backing store of defined scene components.
  100073. */
  100074. _serializableComponents: ISceneSerializableComponent[];
  100075. /**
  100076. * List of components to register on the next registration step.
  100077. */
  100078. private _transientComponents;
  100079. /**
  100080. * Registers the transient components if needed.
  100081. */
  100082. private _registerTransientComponents;
  100083. /**
  100084. * @hidden
  100085. * Add a component to the scene.
  100086. * Note that the ccomponent could be registered on th next frame if this is called after
  100087. * the register component stage.
  100088. * @param component Defines the component to add to the scene
  100089. */
  100090. _addComponent(component: ISceneComponent): void;
  100091. /**
  100092. * @hidden
  100093. * Gets a component from the scene.
  100094. * @param name defines the name of the component to retrieve
  100095. * @returns the component or null if not present
  100096. */
  100097. _getComponent(name: string): Nullable<ISceneComponent>;
  100098. /**
  100099. * @hidden
  100100. * Defines the actions happening before camera updates.
  100101. */
  100102. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100103. /**
  100104. * @hidden
  100105. * Defines the actions happening before clear the canvas.
  100106. */
  100107. _beforeClearStage: Stage<SimpleStageAction>;
  100108. /**
  100109. * @hidden
  100110. * Defines the actions when collecting render targets for the frame.
  100111. */
  100112. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100113. /**
  100114. * @hidden
  100115. * Defines the actions happening for one camera in the frame.
  100116. */
  100117. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100118. /**
  100119. * @hidden
  100120. * Defines the actions happening during the per mesh ready checks.
  100121. */
  100122. _isReadyForMeshStage: Stage<MeshStageAction>;
  100123. /**
  100124. * @hidden
  100125. * Defines the actions happening before evaluate active mesh checks.
  100126. */
  100127. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100128. /**
  100129. * @hidden
  100130. * Defines the actions happening during the evaluate sub mesh checks.
  100131. */
  100132. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100133. /**
  100134. * @hidden
  100135. * Defines the actions happening during the active mesh stage.
  100136. */
  100137. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100138. /**
  100139. * @hidden
  100140. * Defines the actions happening during the per camera render target step.
  100141. */
  100142. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100143. /**
  100144. * @hidden
  100145. * Defines the actions happening just before the active camera is drawing.
  100146. */
  100147. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100148. /**
  100149. * @hidden
  100150. * Defines the actions happening just before a render target is drawing.
  100151. */
  100152. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100153. /**
  100154. * @hidden
  100155. * Defines the actions happening just before a rendering group is drawing.
  100156. */
  100157. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100158. /**
  100159. * @hidden
  100160. * Defines the actions happening just before a mesh is drawing.
  100161. */
  100162. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100163. /**
  100164. * @hidden
  100165. * Defines the actions happening just after a mesh has been drawn.
  100166. */
  100167. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100168. /**
  100169. * @hidden
  100170. * Defines the actions happening just after a rendering group has been drawn.
  100171. */
  100172. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100173. /**
  100174. * @hidden
  100175. * Defines the actions happening just after the active camera has been drawn.
  100176. */
  100177. _afterCameraDrawStage: Stage<CameraStageAction>;
  100178. /**
  100179. * @hidden
  100180. * Defines the actions happening just after a render target has been drawn.
  100181. */
  100182. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100183. /**
  100184. * @hidden
  100185. * Defines the actions happening just after rendering all cameras and computing intersections.
  100186. */
  100187. _afterRenderStage: Stage<SimpleStageAction>;
  100188. /**
  100189. * @hidden
  100190. * Defines the actions happening when a pointer move event happens.
  100191. */
  100192. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100193. /**
  100194. * @hidden
  100195. * Defines the actions happening when a pointer down event happens.
  100196. */
  100197. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100198. /**
  100199. * @hidden
  100200. * Defines the actions happening when a pointer up event happens.
  100201. */
  100202. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100203. /**
  100204. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100205. */
  100206. private geometriesByUniqueId;
  100207. /**
  100208. * Creates a new Scene
  100209. * @param engine defines the engine to use to render this scene
  100210. * @param options defines the scene options
  100211. */
  100212. constructor(engine: Engine, options?: SceneOptions);
  100213. /**
  100214. * Gets a string idenfifying the name of the class
  100215. * @returns "Scene" string
  100216. */
  100217. getClassName(): string;
  100218. private _defaultMeshCandidates;
  100219. /**
  100220. * @hidden
  100221. */
  100222. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100223. private _defaultSubMeshCandidates;
  100224. /**
  100225. * @hidden
  100226. */
  100227. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100228. /**
  100229. * Sets the default candidate providers for the scene.
  100230. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100231. * and getCollidingSubMeshCandidates to their default function
  100232. */
  100233. setDefaultCandidateProviders(): void;
  100234. /**
  100235. * Gets the mesh that is currently under the pointer
  100236. */
  100237. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100238. /**
  100239. * Gets or sets the current on-screen X position of the pointer
  100240. */
  100241. pointerX: number;
  100242. /**
  100243. * Gets or sets the current on-screen Y position of the pointer
  100244. */
  100245. pointerY: number;
  100246. /**
  100247. * Gets the cached material (ie. the latest rendered one)
  100248. * @returns the cached material
  100249. */
  100250. getCachedMaterial(): Nullable<Material>;
  100251. /**
  100252. * Gets the cached effect (ie. the latest rendered one)
  100253. * @returns the cached effect
  100254. */
  100255. getCachedEffect(): Nullable<Effect>;
  100256. /**
  100257. * Gets the cached visibility state (ie. the latest rendered one)
  100258. * @returns the cached visibility state
  100259. */
  100260. getCachedVisibility(): Nullable<number>;
  100261. /**
  100262. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100263. * @param material defines the current material
  100264. * @param effect defines the current effect
  100265. * @param visibility defines the current visibility state
  100266. * @returns true if one parameter is not cached
  100267. */
  100268. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100269. /**
  100270. * Gets the engine associated with the scene
  100271. * @returns an Engine
  100272. */
  100273. getEngine(): Engine;
  100274. /**
  100275. * Gets the total number of vertices rendered per frame
  100276. * @returns the total number of vertices rendered per frame
  100277. */
  100278. getTotalVertices(): number;
  100279. /**
  100280. * Gets the performance counter for total vertices
  100281. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100282. */
  100283. readonly totalVerticesPerfCounter: PerfCounter;
  100284. /**
  100285. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100286. * @returns the total number of active indices rendered per frame
  100287. */
  100288. getActiveIndices(): number;
  100289. /**
  100290. * Gets the performance counter for active indices
  100291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100292. */
  100293. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100294. /**
  100295. * Gets the total number of active particles rendered per frame
  100296. * @returns the total number of active particles rendered per frame
  100297. */
  100298. getActiveParticles(): number;
  100299. /**
  100300. * Gets the performance counter for active particles
  100301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100302. */
  100303. readonly activeParticlesPerfCounter: PerfCounter;
  100304. /**
  100305. * Gets the total number of active bones rendered per frame
  100306. * @returns the total number of active bones rendered per frame
  100307. */
  100308. getActiveBones(): number;
  100309. /**
  100310. * Gets the performance counter for active bones
  100311. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100312. */
  100313. readonly activeBonesPerfCounter: PerfCounter;
  100314. /**
  100315. * Gets the array of active meshes
  100316. * @returns an array of AbstractMesh
  100317. */
  100318. getActiveMeshes(): SmartArray<AbstractMesh>;
  100319. /**
  100320. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100321. * @returns a number
  100322. */
  100323. getAnimationRatio(): number;
  100324. /**
  100325. * Gets an unique Id for the current render phase
  100326. * @returns a number
  100327. */
  100328. getRenderId(): number;
  100329. /**
  100330. * Gets an unique Id for the current frame
  100331. * @returns a number
  100332. */
  100333. getFrameId(): number;
  100334. /** Call this function if you want to manually increment the render Id*/
  100335. incrementRenderId(): void;
  100336. private _createUbo;
  100337. /**
  100338. * Use this method to simulate a pointer move on a mesh
  100339. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100340. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100341. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100342. * @returns the current scene
  100343. */
  100344. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100345. /**
  100346. * Use this method to simulate a pointer down on a mesh
  100347. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100348. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100349. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100350. * @returns the current scene
  100351. */
  100352. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100353. /**
  100354. * Use this method to simulate a pointer up on a mesh
  100355. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100356. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100357. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100358. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100359. * @returns the current scene
  100360. */
  100361. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100362. /**
  100363. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100364. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100365. * @returns true if the pointer was captured
  100366. */
  100367. isPointerCaptured(pointerId?: number): boolean;
  100368. /**
  100369. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100370. * @param attachUp defines if you want to attach events to pointerup
  100371. * @param attachDown defines if you want to attach events to pointerdown
  100372. * @param attachMove defines if you want to attach events to pointermove
  100373. */
  100374. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100375. /** Detaches all event handlers*/
  100376. detachControl(): void;
  100377. /**
  100378. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100379. * Delay loaded resources are not taking in account
  100380. * @return true if all required resources are ready
  100381. */
  100382. isReady(): boolean;
  100383. /** Resets all cached information relative to material (including effect and visibility) */
  100384. resetCachedMaterial(): void;
  100385. /**
  100386. * Registers a function to be called before every frame render
  100387. * @param func defines the function to register
  100388. */
  100389. registerBeforeRender(func: () => void): void;
  100390. /**
  100391. * Unregisters a function called before every frame render
  100392. * @param func defines the function to unregister
  100393. */
  100394. unregisterBeforeRender(func: () => void): void;
  100395. /**
  100396. * Registers a function to be called after every frame render
  100397. * @param func defines the function to register
  100398. */
  100399. registerAfterRender(func: () => void): void;
  100400. /**
  100401. * Unregisters a function called after every frame render
  100402. * @param func defines the function to unregister
  100403. */
  100404. unregisterAfterRender(func: () => void): void;
  100405. private _executeOnceBeforeRender;
  100406. /**
  100407. * The provided function will run before render once and will be disposed afterwards.
  100408. * A timeout delay can be provided so that the function will be executed in N ms.
  100409. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100410. * @param func The function to be executed.
  100411. * @param timeout optional delay in ms
  100412. */
  100413. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100414. /** @hidden */
  100415. _addPendingData(data: any): void;
  100416. /** @hidden */
  100417. _removePendingData(data: any): void;
  100418. /**
  100419. * Returns the number of items waiting to be loaded
  100420. * @returns the number of items waiting to be loaded
  100421. */
  100422. getWaitingItemsCount(): number;
  100423. /**
  100424. * Returns a boolean indicating if the scene is still loading data
  100425. */
  100426. readonly isLoading: boolean;
  100427. /**
  100428. * Registers a function to be executed when the scene is ready
  100429. * @param {Function} func - the function to be executed
  100430. */
  100431. executeWhenReady(func: () => void): void;
  100432. /**
  100433. * Returns a promise that resolves when the scene is ready
  100434. * @returns A promise that resolves when the scene is ready
  100435. */
  100436. whenReadyAsync(): Promise<void>;
  100437. /** @hidden */
  100438. _checkIsReady(): void;
  100439. /**
  100440. * Gets all animatable attached to the scene
  100441. */
  100442. readonly animatables: Animatable[];
  100443. /**
  100444. * Resets the last animation time frame.
  100445. * Useful to override when animations start running when loading a scene for the first time.
  100446. */
  100447. resetLastAnimationTimeFrame(): void;
  100448. /**
  100449. * Gets the current view matrix
  100450. * @returns a Matrix
  100451. */
  100452. getViewMatrix(): Matrix;
  100453. /**
  100454. * Gets the current projection matrix
  100455. * @returns a Matrix
  100456. */
  100457. getProjectionMatrix(): Matrix;
  100458. /**
  100459. * Gets the current transform matrix
  100460. * @returns a Matrix made of View * Projection
  100461. */
  100462. getTransformMatrix(): Matrix;
  100463. /**
  100464. * Sets the current transform matrix
  100465. * @param viewL defines the View matrix to use
  100466. * @param projectionL defines the Projection matrix to use
  100467. * @param viewR defines the right View matrix to use (if provided)
  100468. * @param projectionR defines the right Projection matrix to use (if provided)
  100469. */
  100470. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100471. /**
  100472. * Gets the uniform buffer used to store scene data
  100473. * @returns a UniformBuffer
  100474. */
  100475. getSceneUniformBuffer(): UniformBuffer;
  100476. /**
  100477. * Gets an unique (relatively to the current scene) Id
  100478. * @returns an unique number for the scene
  100479. */
  100480. getUniqueId(): number;
  100481. /**
  100482. * Add a mesh to the list of scene's meshes
  100483. * @param newMesh defines the mesh to add
  100484. * @param recursive if all child meshes should also be added to the scene
  100485. */
  100486. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100487. /**
  100488. * Remove a mesh for the list of scene's meshes
  100489. * @param toRemove defines the mesh to remove
  100490. * @param recursive if all child meshes should also be removed from the scene
  100491. * @returns the index where the mesh was in the mesh list
  100492. */
  100493. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100494. /**
  100495. * Add a transform node to the list of scene's transform nodes
  100496. * @param newTransformNode defines the transform node to add
  100497. */
  100498. addTransformNode(newTransformNode: TransformNode): void;
  100499. /**
  100500. * Remove a transform node for the list of scene's transform nodes
  100501. * @param toRemove defines the transform node to remove
  100502. * @returns the index where the transform node was in the transform node list
  100503. */
  100504. removeTransformNode(toRemove: TransformNode): number;
  100505. /**
  100506. * Remove a skeleton for the list of scene's skeletons
  100507. * @param toRemove defines the skeleton to remove
  100508. * @returns the index where the skeleton was in the skeleton list
  100509. */
  100510. removeSkeleton(toRemove: Skeleton): number;
  100511. /**
  100512. * Remove a morph target for the list of scene's morph targets
  100513. * @param toRemove defines the morph target to remove
  100514. * @returns the index where the morph target was in the morph target list
  100515. */
  100516. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100517. /**
  100518. * Remove a light for the list of scene's lights
  100519. * @param toRemove defines the light to remove
  100520. * @returns the index where the light was in the light list
  100521. */
  100522. removeLight(toRemove: Light): number;
  100523. /**
  100524. * Remove a camera for the list of scene's cameras
  100525. * @param toRemove defines the camera to remove
  100526. * @returns the index where the camera was in the camera list
  100527. */
  100528. removeCamera(toRemove: Camera): number;
  100529. /**
  100530. * Remove a particle system for the list of scene's particle systems
  100531. * @param toRemove defines the particle system to remove
  100532. * @returns the index where the particle system was in the particle system list
  100533. */
  100534. removeParticleSystem(toRemove: IParticleSystem): number;
  100535. /**
  100536. * Remove a animation for the list of scene's animations
  100537. * @param toRemove defines the animation to remove
  100538. * @returns the index where the animation was in the animation list
  100539. */
  100540. removeAnimation(toRemove: Animation): number;
  100541. /**
  100542. * Will stop the animation of the given target
  100543. * @param target - the target
  100544. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100545. * @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)
  100546. */
  100547. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100548. /**
  100549. * Removes the given animation group from this scene.
  100550. * @param toRemove The animation group to remove
  100551. * @returns The index of the removed animation group
  100552. */
  100553. removeAnimationGroup(toRemove: AnimationGroup): number;
  100554. /**
  100555. * Removes the given multi-material from this scene.
  100556. * @param toRemove The multi-material to remove
  100557. * @returns The index of the removed multi-material
  100558. */
  100559. removeMultiMaterial(toRemove: MultiMaterial): number;
  100560. /**
  100561. * Removes the given material from this scene.
  100562. * @param toRemove The material to remove
  100563. * @returns The index of the removed material
  100564. */
  100565. removeMaterial(toRemove: Material): number;
  100566. /**
  100567. * Removes the given action manager from this scene.
  100568. * @param toRemove The action manager to remove
  100569. * @returns The index of the removed action manager
  100570. */
  100571. removeActionManager(toRemove: AbstractActionManager): number;
  100572. /**
  100573. * Removes the given texture from this scene.
  100574. * @param toRemove The texture to remove
  100575. * @returns The index of the removed texture
  100576. */
  100577. removeTexture(toRemove: BaseTexture): number;
  100578. /**
  100579. * Adds the given light to this scene
  100580. * @param newLight The light to add
  100581. */
  100582. addLight(newLight: Light): void;
  100583. /**
  100584. * Sorts the list list based on light priorities
  100585. */
  100586. sortLightsByPriority(): void;
  100587. /**
  100588. * Adds the given camera to this scene
  100589. * @param newCamera The camera to add
  100590. */
  100591. addCamera(newCamera: Camera): void;
  100592. /**
  100593. * Adds the given skeleton to this scene
  100594. * @param newSkeleton The skeleton to add
  100595. */
  100596. addSkeleton(newSkeleton: Skeleton): void;
  100597. /**
  100598. * Adds the given particle system to this scene
  100599. * @param newParticleSystem The particle system to add
  100600. */
  100601. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100602. /**
  100603. * Adds the given animation to this scene
  100604. * @param newAnimation The animation to add
  100605. */
  100606. addAnimation(newAnimation: Animation): void;
  100607. /**
  100608. * Adds the given animation group to this scene.
  100609. * @param newAnimationGroup The animation group to add
  100610. */
  100611. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100612. /**
  100613. * Adds the given multi-material to this scene
  100614. * @param newMultiMaterial The multi-material to add
  100615. */
  100616. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100617. /**
  100618. * Adds the given material to this scene
  100619. * @param newMaterial The material to add
  100620. */
  100621. addMaterial(newMaterial: Material): void;
  100622. /**
  100623. * Adds the given morph target to this scene
  100624. * @param newMorphTargetManager The morph target to add
  100625. */
  100626. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  100627. /**
  100628. * Adds the given geometry to this scene
  100629. * @param newGeometry The geometry to add
  100630. */
  100631. addGeometry(newGeometry: Geometry): void;
  100632. /**
  100633. * Adds the given action manager to this scene
  100634. * @param newActionManager The action manager to add
  100635. */
  100636. addActionManager(newActionManager: AbstractActionManager): void;
  100637. /**
  100638. * Adds the given texture to this scene.
  100639. * @param newTexture The texture to add
  100640. */
  100641. addTexture(newTexture: BaseTexture): void;
  100642. /**
  100643. * Switch active camera
  100644. * @param newCamera defines the new active camera
  100645. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  100646. */
  100647. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  100648. /**
  100649. * sets the active camera of the scene using its ID
  100650. * @param id defines the camera's ID
  100651. * @return the new active camera or null if none found.
  100652. */
  100653. setActiveCameraByID(id: string): Nullable<Camera>;
  100654. /**
  100655. * sets the active camera of the scene using its name
  100656. * @param name defines the camera's name
  100657. * @returns the new active camera or null if none found.
  100658. */
  100659. setActiveCameraByName(name: string): Nullable<Camera>;
  100660. /**
  100661. * get an animation group using its name
  100662. * @param name defines the material's name
  100663. * @return the animation group or null if none found.
  100664. */
  100665. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100666. /**
  100667. * Get a material using its unique id
  100668. * @param uniqueId defines the material's unique id
  100669. * @return the material or null if none found.
  100670. */
  100671. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100672. /**
  100673. * get a material using its id
  100674. * @param id defines the material's ID
  100675. * @return the material or null if none found.
  100676. */
  100677. getMaterialByID(id: string): Nullable<Material>;
  100678. /**
  100679. * Gets a the last added material using a given id
  100680. * @param id defines the material's ID
  100681. * @return the last material with the given id or null if none found.
  100682. */
  100683. getLastMaterialByID(id: string): Nullable<Material>;
  100684. /**
  100685. * Gets a material using its name
  100686. * @param name defines the material's name
  100687. * @return the material or null if none found.
  100688. */
  100689. getMaterialByName(name: string): Nullable<Material>;
  100690. /**
  100691. * Get a texture using its unique id
  100692. * @param uniqueId defines the texture's unique id
  100693. * @return the texture or null if none found.
  100694. */
  100695. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  100696. /**
  100697. * Gets a camera using its id
  100698. * @param id defines the id to look for
  100699. * @returns the camera or null if not found
  100700. */
  100701. getCameraByID(id: string): Nullable<Camera>;
  100702. /**
  100703. * Gets a camera using its unique id
  100704. * @param uniqueId defines the unique id to look for
  100705. * @returns the camera or null if not found
  100706. */
  100707. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  100708. /**
  100709. * Gets a camera using its name
  100710. * @param name defines the camera's name
  100711. * @return the camera or null if none found.
  100712. */
  100713. getCameraByName(name: string): Nullable<Camera>;
  100714. /**
  100715. * Gets a bone using its id
  100716. * @param id defines the bone's id
  100717. * @return the bone or null if not found
  100718. */
  100719. getBoneByID(id: string): Nullable<Bone>;
  100720. /**
  100721. * Gets a bone using its id
  100722. * @param name defines the bone's name
  100723. * @return the bone or null if not found
  100724. */
  100725. getBoneByName(name: string): Nullable<Bone>;
  100726. /**
  100727. * Gets a light node using its name
  100728. * @param name defines the the light's name
  100729. * @return the light or null if none found.
  100730. */
  100731. getLightByName(name: string): Nullable<Light>;
  100732. /**
  100733. * Gets a light node using its id
  100734. * @param id defines the light's id
  100735. * @return the light or null if none found.
  100736. */
  100737. getLightByID(id: string): Nullable<Light>;
  100738. /**
  100739. * Gets a light node using its scene-generated unique ID
  100740. * @param uniqueId defines the light's unique id
  100741. * @return the light or null if none found.
  100742. */
  100743. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  100744. /**
  100745. * Gets a particle system by id
  100746. * @param id defines the particle system id
  100747. * @return the corresponding system or null if none found
  100748. */
  100749. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  100750. /**
  100751. * Gets a geometry using its ID
  100752. * @param id defines the geometry's id
  100753. * @return the geometry or null if none found.
  100754. */
  100755. getGeometryByID(id: string): Nullable<Geometry>;
  100756. private _getGeometryByUniqueID;
  100757. /**
  100758. * Add a new geometry to this scene
  100759. * @param geometry defines the geometry to be added to the scene.
  100760. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  100761. * @return a boolean defining if the geometry was added or not
  100762. */
  100763. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  100764. /**
  100765. * Removes an existing geometry
  100766. * @param geometry defines the geometry to be removed from the scene
  100767. * @return a boolean defining if the geometry was removed or not
  100768. */
  100769. removeGeometry(geometry: Geometry): boolean;
  100770. /**
  100771. * Gets the list of geometries attached to the scene
  100772. * @returns an array of Geometry
  100773. */
  100774. getGeometries(): Geometry[];
  100775. /**
  100776. * Gets the first added mesh found of a given ID
  100777. * @param id defines the id to search for
  100778. * @return the mesh found or null if not found at all
  100779. */
  100780. getMeshByID(id: string): Nullable<AbstractMesh>;
  100781. /**
  100782. * Gets a list of meshes using their id
  100783. * @param id defines the id to search for
  100784. * @returns a list of meshes
  100785. */
  100786. getMeshesByID(id: string): Array<AbstractMesh>;
  100787. /**
  100788. * Gets the first added transform node found of a given ID
  100789. * @param id defines the id to search for
  100790. * @return the found transform node or null if not found at all.
  100791. */
  100792. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100793. /**
  100794. * Gets a transform node with its auto-generated unique id
  100795. * @param uniqueId efines the unique id to search for
  100796. * @return the found transform node or null if not found at all.
  100797. */
  100798. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100799. /**
  100800. * Gets a list of transform nodes using their id
  100801. * @param id defines the id to search for
  100802. * @returns a list of transform nodes
  100803. */
  100804. getTransformNodesByID(id: string): Array<TransformNode>;
  100805. /**
  100806. * Gets a mesh with its auto-generated unique id
  100807. * @param uniqueId defines the unique id to search for
  100808. * @return the found mesh or null if not found at all.
  100809. */
  100810. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100811. /**
  100812. * Gets a the last added mesh using a given id
  100813. * @param id defines the id to search for
  100814. * @return the found mesh or null if not found at all.
  100815. */
  100816. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100817. /**
  100818. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100819. * @param id defines the id to search for
  100820. * @return the found node or null if not found at all
  100821. */
  100822. getLastEntryByID(id: string): Nullable<Node>;
  100823. /**
  100824. * Gets a node (Mesh, Camera, Light) using a given id
  100825. * @param id defines the id to search for
  100826. * @return the found node or null if not found at all
  100827. */
  100828. getNodeByID(id: string): Nullable<Node>;
  100829. /**
  100830. * Gets a node (Mesh, Camera, Light) using a given name
  100831. * @param name defines the name to search for
  100832. * @return the found node or null if not found at all.
  100833. */
  100834. getNodeByName(name: string): Nullable<Node>;
  100835. /**
  100836. * Gets a mesh using a given name
  100837. * @param name defines the name to search for
  100838. * @return the found mesh or null if not found at all.
  100839. */
  100840. getMeshByName(name: string): Nullable<AbstractMesh>;
  100841. /**
  100842. * Gets a transform node using a given name
  100843. * @param name defines the name to search for
  100844. * @return the found transform node or null if not found at all.
  100845. */
  100846. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100847. /**
  100848. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100849. * @param id defines the id to search for
  100850. * @return the found skeleton or null if not found at all.
  100851. */
  100852. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100853. /**
  100854. * Gets a skeleton using a given auto generated unique id
  100855. * @param uniqueId defines the unique id to search for
  100856. * @return the found skeleton or null if not found at all.
  100857. */
  100858. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100859. /**
  100860. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100861. * @param id defines the id to search for
  100862. * @return the found skeleton or null if not found at all.
  100863. */
  100864. getSkeletonById(id: string): Nullable<Skeleton>;
  100865. /**
  100866. * Gets a skeleton using a given name
  100867. * @param name defines the name to search for
  100868. * @return the found skeleton or null if not found at all.
  100869. */
  100870. getSkeletonByName(name: string): Nullable<Skeleton>;
  100871. /**
  100872. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100873. * @param id defines the id to search for
  100874. * @return the found morph target manager or null if not found at all.
  100875. */
  100876. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100877. /**
  100878. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100879. * @param id defines the id to search for
  100880. * @return the found morph target or null if not found at all.
  100881. */
  100882. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100883. /**
  100884. * Gets a boolean indicating if the given mesh is active
  100885. * @param mesh defines the mesh to look for
  100886. * @returns true if the mesh is in the active list
  100887. */
  100888. isActiveMesh(mesh: AbstractMesh): boolean;
  100889. /**
  100890. * Return a unique id as a string which can serve as an identifier for the scene
  100891. */
  100892. readonly uid: string;
  100893. /**
  100894. * Add an externaly attached data from its key.
  100895. * This method call will fail and return false, if such key already exists.
  100896. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100897. * @param key the unique key that identifies the data
  100898. * @param data the data object to associate to the key for this Engine instance
  100899. * @return true if no such key were already present and the data was added successfully, false otherwise
  100900. */
  100901. addExternalData<T>(key: string, data: T): boolean;
  100902. /**
  100903. * Get an externaly attached data from its key
  100904. * @param key the unique key that identifies the data
  100905. * @return the associated data, if present (can be null), or undefined if not present
  100906. */
  100907. getExternalData<T>(key: string): Nullable<T>;
  100908. /**
  100909. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100910. * @param key the unique key that identifies the data
  100911. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100912. * @return the associated data, can be null if the factory returned null.
  100913. */
  100914. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100915. /**
  100916. * Remove an externaly attached data from the Engine instance
  100917. * @param key the unique key that identifies the data
  100918. * @return true if the data was successfully removed, false if it doesn't exist
  100919. */
  100920. removeExternalData(key: string): boolean;
  100921. private _evaluateSubMesh;
  100922. /**
  100923. * Clear the processed materials smart array preventing retention point in material dispose.
  100924. */
  100925. freeProcessedMaterials(): void;
  100926. private _preventFreeActiveMeshesAndRenderingGroups;
  100927. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100928. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100929. * when disposing several meshes in a row or a hierarchy of meshes.
  100930. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100931. */
  100932. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100933. /**
  100934. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100935. */
  100936. freeActiveMeshes(): void;
  100937. /**
  100938. * Clear the info related to rendering groups preventing retention points during dispose.
  100939. */
  100940. freeRenderingGroups(): void;
  100941. /** @hidden */
  100942. _isInIntermediateRendering(): boolean;
  100943. /**
  100944. * Lambda returning the list of potentially active meshes.
  100945. */
  100946. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100947. /**
  100948. * Lambda returning the list of potentially active sub meshes.
  100949. */
  100950. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100951. /**
  100952. * Lambda returning the list of potentially intersecting sub meshes.
  100953. */
  100954. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100955. /**
  100956. * Lambda returning the list of potentially colliding sub meshes.
  100957. */
  100958. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100959. private _activeMeshesFrozen;
  100960. /**
  100961. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100962. * @returns the current scene
  100963. */
  100964. freezeActiveMeshes(): Scene;
  100965. /**
  100966. * Use this function to restart evaluating active meshes on every frame
  100967. * @returns the current scene
  100968. */
  100969. unfreezeActiveMeshes(): Scene;
  100970. private _evaluateActiveMeshes;
  100971. private _activeMesh;
  100972. /**
  100973. * Update the transform matrix to update from the current active camera
  100974. * @param force defines a boolean used to force the update even if cache is up to date
  100975. */
  100976. updateTransformMatrix(force?: boolean): void;
  100977. private _bindFrameBuffer;
  100978. /** @hidden */
  100979. _allowPostProcessClearColor: boolean;
  100980. /** @hidden */
  100981. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100982. private _processSubCameras;
  100983. private _checkIntersections;
  100984. /** @hidden */
  100985. _advancePhysicsEngineStep(step: number): void;
  100986. /**
  100987. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100988. */
  100989. getDeterministicFrameTime: () => number;
  100990. /** @hidden */
  100991. _animate(): void;
  100992. /** Execute all animations (for a frame) */
  100993. animate(): void;
  100994. /**
  100995. * Render the scene
  100996. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100997. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100998. */
  100999. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101000. /**
  101001. * Freeze all materials
  101002. * A frozen material will not be updatable but should be faster to render
  101003. */
  101004. freezeMaterials(): void;
  101005. /**
  101006. * Unfreeze all materials
  101007. * A frozen material will not be updatable but should be faster to render
  101008. */
  101009. unfreezeMaterials(): void;
  101010. /**
  101011. * Releases all held ressources
  101012. */
  101013. dispose(): void;
  101014. /**
  101015. * Gets if the scene is already disposed
  101016. */
  101017. readonly isDisposed: boolean;
  101018. /**
  101019. * Call this function to reduce memory footprint of the scene.
  101020. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101021. */
  101022. clearCachedVertexData(): void;
  101023. /**
  101024. * This function will remove the local cached buffer data from texture.
  101025. * It will save memory but will prevent the texture from being rebuilt
  101026. */
  101027. cleanCachedTextureBuffer(): void;
  101028. /**
  101029. * Get the world extend vectors with an optional filter
  101030. *
  101031. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101032. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101033. */
  101034. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101035. min: Vector3;
  101036. max: Vector3;
  101037. };
  101038. /**
  101039. * Creates a ray that can be used to pick in the scene
  101040. * @param x defines the x coordinate of the origin (on-screen)
  101041. * @param y defines the y coordinate of the origin (on-screen)
  101042. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101043. * @param camera defines the camera to use for the picking
  101044. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101045. * @returns a Ray
  101046. */
  101047. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101048. /**
  101049. * Creates a ray that can be used to pick in the scene
  101050. * @param x defines the x coordinate of the origin (on-screen)
  101051. * @param y defines the y coordinate of the origin (on-screen)
  101052. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101053. * @param result defines the ray where to store the picking ray
  101054. * @param camera defines the camera to use for the picking
  101055. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101056. * @returns the current scene
  101057. */
  101058. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101059. /**
  101060. * Creates a ray that can be used to pick in the scene
  101061. * @param x defines the x coordinate of the origin (on-screen)
  101062. * @param y defines the y coordinate of the origin (on-screen)
  101063. * @param camera defines the camera to use for the picking
  101064. * @returns a Ray
  101065. */
  101066. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101067. /**
  101068. * Creates a ray that can be used to pick in the scene
  101069. * @param x defines the x coordinate of the origin (on-screen)
  101070. * @param y defines the y coordinate of the origin (on-screen)
  101071. * @param result defines the ray where to store the picking ray
  101072. * @param camera defines the camera to use for the picking
  101073. * @returns the current scene
  101074. */
  101075. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101076. /** Launch a ray to try to pick a mesh in the scene
  101077. * @param x position on screen
  101078. * @param y position on screen
  101079. * @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
  101080. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101081. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101082. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101083. * @returns a PickingInfo
  101084. */
  101085. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101086. /** Use the given ray to pick a mesh in the scene
  101087. * @param ray The ray to use to pick meshes
  101088. * @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
  101089. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101090. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101091. * @returns a PickingInfo
  101092. */
  101093. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101094. /**
  101095. * Launch a ray to try to pick a mesh in the scene
  101096. * @param x X position on screen
  101097. * @param y Y position on screen
  101098. * @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
  101099. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101100. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101101. * @returns an array of PickingInfo
  101102. */
  101103. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101104. /**
  101105. * Launch a ray to try to pick a mesh in the scene
  101106. * @param ray Ray to use
  101107. * @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
  101108. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101109. * @returns an array of PickingInfo
  101110. */
  101111. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101112. /**
  101113. * Force the value of meshUnderPointer
  101114. * @param mesh defines the mesh to use
  101115. */
  101116. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101117. /**
  101118. * Gets the mesh under the pointer
  101119. * @returns a Mesh or null if no mesh is under the pointer
  101120. */
  101121. getPointerOverMesh(): Nullable<AbstractMesh>;
  101122. /** @hidden */
  101123. _rebuildGeometries(): void;
  101124. /** @hidden */
  101125. _rebuildTextures(): void;
  101126. private _getByTags;
  101127. /**
  101128. * Get a list of meshes by tags
  101129. * @param tagsQuery defines the tags query to use
  101130. * @param forEach defines a predicate used to filter results
  101131. * @returns an array of Mesh
  101132. */
  101133. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101134. /**
  101135. * Get a list of cameras by tags
  101136. * @param tagsQuery defines the tags query to use
  101137. * @param forEach defines a predicate used to filter results
  101138. * @returns an array of Camera
  101139. */
  101140. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101141. /**
  101142. * Get a list of lights by tags
  101143. * @param tagsQuery defines the tags query to use
  101144. * @param forEach defines a predicate used to filter results
  101145. * @returns an array of Light
  101146. */
  101147. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101148. /**
  101149. * Get a list of materials by tags
  101150. * @param tagsQuery defines the tags query to use
  101151. * @param forEach defines a predicate used to filter results
  101152. * @returns an array of Material
  101153. */
  101154. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101155. /**
  101156. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101157. * This allowed control for front to back rendering or reversly depending of the special needs.
  101158. *
  101159. * @param renderingGroupId The rendering group id corresponding to its index
  101160. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101161. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101162. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101163. */
  101164. 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;
  101165. /**
  101166. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101167. *
  101168. * @param renderingGroupId The rendering group id corresponding to its index
  101169. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101170. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101171. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101172. */
  101173. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101174. /**
  101175. * Gets the current auto clear configuration for one rendering group of the rendering
  101176. * manager.
  101177. * @param index the rendering group index to get the information for
  101178. * @returns The auto clear setup for the requested rendering group
  101179. */
  101180. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101181. private _blockMaterialDirtyMechanism;
  101182. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101183. blockMaterialDirtyMechanism: boolean;
  101184. /**
  101185. * Will flag all materials as dirty to trigger new shader compilation
  101186. * @param flag defines the flag used to specify which material part must be marked as dirty
  101187. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101188. */
  101189. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101190. /** @hidden */
  101191. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  101192. /** @hidden */
  101193. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101194. }
  101195. }
  101196. declare module BABYLON {
  101197. /**
  101198. * Set of assets to keep when moving a scene into an asset container.
  101199. */
  101200. export class KeepAssets extends AbstractScene {
  101201. }
  101202. /**
  101203. * Container with a set of assets that can be added or removed from a scene.
  101204. */
  101205. export class AssetContainer extends AbstractScene {
  101206. /**
  101207. * The scene the AssetContainer belongs to.
  101208. */
  101209. scene: Scene;
  101210. /**
  101211. * Instantiates an AssetContainer.
  101212. * @param scene The scene the AssetContainer belongs to.
  101213. */
  101214. constructor(scene: Scene);
  101215. /**
  101216. * Adds all the assets from the container to the scene.
  101217. */
  101218. addAllToScene(): void;
  101219. /**
  101220. * Removes all the assets in the container from the scene
  101221. */
  101222. removeAllFromScene(): void;
  101223. /**
  101224. * Disposes all the assets in the container
  101225. */
  101226. dispose(): void;
  101227. private _moveAssets;
  101228. /**
  101229. * Removes all the assets contained in the scene and adds them to the container.
  101230. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101231. */
  101232. moveAllFromScene(keepAssets?: KeepAssets): void;
  101233. /**
  101234. * 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.
  101235. * @returns the root mesh
  101236. */
  101237. createRootMesh(): Mesh;
  101238. }
  101239. }
  101240. declare module BABYLON {
  101241. /**
  101242. * Defines how the parser contract is defined.
  101243. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101244. */
  101245. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101246. /**
  101247. * Defines how the individual parser contract is defined.
  101248. * These parser can parse an individual asset
  101249. */
  101250. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101251. /**
  101252. * Base class of the scene acting as a container for the different elements composing a scene.
  101253. * This class is dynamically extended by the different components of the scene increasing
  101254. * flexibility and reducing coupling
  101255. */
  101256. export abstract class AbstractScene {
  101257. /**
  101258. * Stores the list of available parsers in the application.
  101259. */
  101260. private static _BabylonFileParsers;
  101261. /**
  101262. * Stores the list of available individual parsers in the application.
  101263. */
  101264. private static _IndividualBabylonFileParsers;
  101265. /**
  101266. * Adds a parser in the list of available ones
  101267. * @param name Defines the name of the parser
  101268. * @param parser Defines the parser to add
  101269. */
  101270. static AddParser(name: string, parser: BabylonFileParser): void;
  101271. /**
  101272. * Gets a general parser from the list of avaialble ones
  101273. * @param name Defines the name of the parser
  101274. * @returns the requested parser or null
  101275. */
  101276. static GetParser(name: string): Nullable<BabylonFileParser>;
  101277. /**
  101278. * Adds n individual parser in the list of available ones
  101279. * @param name Defines the name of the parser
  101280. * @param parser Defines the parser to add
  101281. */
  101282. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101283. /**
  101284. * Gets an individual parser from the list of avaialble ones
  101285. * @param name Defines the name of the parser
  101286. * @returns the requested parser or null
  101287. */
  101288. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101289. /**
  101290. * Parser json data and populate both a scene and its associated container object
  101291. * @param jsonData Defines the data to parse
  101292. * @param scene Defines the scene to parse the data for
  101293. * @param container Defines the container attached to the parsing sequence
  101294. * @param rootUrl Defines the root url of the data
  101295. */
  101296. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101297. /**
  101298. * Gets the list of root nodes (ie. nodes with no parent)
  101299. */
  101300. rootNodes: Node[];
  101301. /** All of the cameras added to this scene
  101302. * @see http://doc.babylonjs.com/babylon101/cameras
  101303. */
  101304. cameras: Camera[];
  101305. /**
  101306. * All of the lights added to this scene
  101307. * @see http://doc.babylonjs.com/babylon101/lights
  101308. */
  101309. lights: Light[];
  101310. /**
  101311. * All of the (abstract) meshes added to this scene
  101312. */
  101313. meshes: AbstractMesh[];
  101314. /**
  101315. * The list of skeletons added to the scene
  101316. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101317. */
  101318. skeletons: Skeleton[];
  101319. /**
  101320. * All of the particle systems added to this scene
  101321. * @see http://doc.babylonjs.com/babylon101/particles
  101322. */
  101323. particleSystems: IParticleSystem[];
  101324. /**
  101325. * Gets a list of Animations associated with the scene
  101326. */
  101327. animations: Animation[];
  101328. /**
  101329. * All of the animation groups added to this scene
  101330. * @see http://doc.babylonjs.com/how_to/group
  101331. */
  101332. animationGroups: AnimationGroup[];
  101333. /**
  101334. * All of the multi-materials added to this scene
  101335. * @see http://doc.babylonjs.com/how_to/multi_materials
  101336. */
  101337. multiMaterials: MultiMaterial[];
  101338. /**
  101339. * All of the materials added to this scene
  101340. * In the context of a Scene, it is not supposed to be modified manually.
  101341. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101342. * Note also that the order of the Material wihin the array is not significant and might change.
  101343. * @see http://doc.babylonjs.com/babylon101/materials
  101344. */
  101345. materials: Material[];
  101346. /**
  101347. * The list of morph target managers added to the scene
  101348. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101349. */
  101350. morphTargetManagers: MorphTargetManager[];
  101351. /**
  101352. * The list of geometries used in the scene.
  101353. */
  101354. geometries: Geometry[];
  101355. /**
  101356. * All of the tranform nodes added to this scene
  101357. * In the context of a Scene, it is not supposed to be modified manually.
  101358. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101359. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101360. * @see http://doc.babylonjs.com/how_to/transformnode
  101361. */
  101362. transformNodes: TransformNode[];
  101363. /**
  101364. * ActionManagers available on the scene.
  101365. */
  101366. actionManagers: AbstractActionManager[];
  101367. /**
  101368. * Textures to keep.
  101369. */
  101370. textures: BaseTexture[];
  101371. /**
  101372. * Environment texture for the scene
  101373. */
  101374. environmentTexture: Nullable<BaseTexture>;
  101375. }
  101376. }
  101377. declare module BABYLON {
  101378. /**
  101379. * Interface used to define options for Sound class
  101380. */
  101381. export interface ISoundOptions {
  101382. /**
  101383. * Does the sound autoplay once loaded.
  101384. */
  101385. autoplay?: boolean;
  101386. /**
  101387. * Does the sound loop after it finishes playing once.
  101388. */
  101389. loop?: boolean;
  101390. /**
  101391. * Sound's volume
  101392. */
  101393. volume?: number;
  101394. /**
  101395. * Is it a spatial sound?
  101396. */
  101397. spatialSound?: boolean;
  101398. /**
  101399. * Maximum distance to hear that sound
  101400. */
  101401. maxDistance?: number;
  101402. /**
  101403. * Uses user defined attenuation function
  101404. */
  101405. useCustomAttenuation?: boolean;
  101406. /**
  101407. * Define the roll off factor of spatial sounds.
  101408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101409. */
  101410. rolloffFactor?: number;
  101411. /**
  101412. * Define the reference distance the sound should be heard perfectly.
  101413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101414. */
  101415. refDistance?: number;
  101416. /**
  101417. * Define the distance attenuation model the sound will follow.
  101418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101419. */
  101420. distanceModel?: string;
  101421. /**
  101422. * Defines the playback speed (1 by default)
  101423. */
  101424. playbackRate?: number;
  101425. /**
  101426. * Defines if the sound is from a streaming source
  101427. */
  101428. streaming?: boolean;
  101429. /**
  101430. * Defines an optional length (in seconds) inside the sound file
  101431. */
  101432. length?: number;
  101433. /**
  101434. * Defines an optional offset (in seconds) inside the sound file
  101435. */
  101436. offset?: number;
  101437. /**
  101438. * If true, URLs will not be required to state the audio file codec to use.
  101439. */
  101440. skipCodecCheck?: boolean;
  101441. }
  101442. /**
  101443. * Defines a sound that can be played in the application.
  101444. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101446. */
  101447. export class Sound {
  101448. /**
  101449. * The name of the sound in the scene.
  101450. */
  101451. name: string;
  101452. /**
  101453. * Does the sound autoplay once loaded.
  101454. */
  101455. autoplay: boolean;
  101456. /**
  101457. * Does the sound loop after it finishes playing once.
  101458. */
  101459. loop: boolean;
  101460. /**
  101461. * Does the sound use a custom attenuation curve to simulate the falloff
  101462. * happening when the source gets further away from the camera.
  101463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101464. */
  101465. useCustomAttenuation: boolean;
  101466. /**
  101467. * The sound track id this sound belongs to.
  101468. */
  101469. soundTrackId: number;
  101470. /**
  101471. * Is this sound currently played.
  101472. */
  101473. isPlaying: boolean;
  101474. /**
  101475. * Is this sound currently paused.
  101476. */
  101477. isPaused: boolean;
  101478. /**
  101479. * Does this sound enables spatial sound.
  101480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101481. */
  101482. spatialSound: boolean;
  101483. /**
  101484. * Define the reference distance the sound should be heard perfectly.
  101485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101486. */
  101487. refDistance: number;
  101488. /**
  101489. * Define the roll off factor of spatial sounds.
  101490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101491. */
  101492. rolloffFactor: number;
  101493. /**
  101494. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101496. */
  101497. maxDistance: number;
  101498. /**
  101499. * Define the distance attenuation model the sound will follow.
  101500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101501. */
  101502. distanceModel: string;
  101503. /**
  101504. * @hidden
  101505. * Back Compat
  101506. **/
  101507. onended: () => any;
  101508. /**
  101509. * Observable event when the current playing sound finishes.
  101510. */
  101511. onEndedObservable: Observable<Sound>;
  101512. private _panningModel;
  101513. private _playbackRate;
  101514. private _streaming;
  101515. private _startTime;
  101516. private _startOffset;
  101517. private _position;
  101518. /** @hidden */
  101519. _positionInEmitterSpace: boolean;
  101520. private _localDirection;
  101521. private _volume;
  101522. private _isReadyToPlay;
  101523. private _isDirectional;
  101524. private _readyToPlayCallback;
  101525. private _audioBuffer;
  101526. private _soundSource;
  101527. private _streamingSource;
  101528. private _soundPanner;
  101529. private _soundGain;
  101530. private _inputAudioNode;
  101531. private _outputAudioNode;
  101532. private _coneInnerAngle;
  101533. private _coneOuterAngle;
  101534. private _coneOuterGain;
  101535. private _scene;
  101536. private _connectedTransformNode;
  101537. private _customAttenuationFunction;
  101538. private _registerFunc;
  101539. private _isOutputConnected;
  101540. private _htmlAudioElement;
  101541. private _urlType;
  101542. private _length?;
  101543. private _offset?;
  101544. /** @hidden */
  101545. static _SceneComponentInitialization: (scene: Scene) => void;
  101546. /**
  101547. * Create a sound and attach it to a scene
  101548. * @param name Name of your sound
  101549. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101550. * @param scene defines the scene the sound belongs to
  101551. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101552. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101553. */
  101554. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101555. /**
  101556. * Release the sound and its associated resources
  101557. */
  101558. dispose(): void;
  101559. /**
  101560. * Gets if the sounds is ready to be played or not.
  101561. * @returns true if ready, otherwise false
  101562. */
  101563. isReady(): boolean;
  101564. private _soundLoaded;
  101565. /**
  101566. * Sets the data of the sound from an audiobuffer
  101567. * @param audioBuffer The audioBuffer containing the data
  101568. */
  101569. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101570. /**
  101571. * Updates the current sounds options such as maxdistance, loop...
  101572. * @param options A JSON object containing values named as the object properties
  101573. */
  101574. updateOptions(options: ISoundOptions): void;
  101575. private _createSpatialParameters;
  101576. private _updateSpatialParameters;
  101577. /**
  101578. * Switch the panning model to HRTF:
  101579. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101581. */
  101582. switchPanningModelToHRTF(): void;
  101583. /**
  101584. * Switch the panning model to Equal Power:
  101585. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101587. */
  101588. switchPanningModelToEqualPower(): void;
  101589. private _switchPanningModel;
  101590. /**
  101591. * Connect this sound to a sound track audio node like gain...
  101592. * @param soundTrackAudioNode the sound track audio node to connect to
  101593. */
  101594. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101595. /**
  101596. * Transform this sound into a directional source
  101597. * @param coneInnerAngle Size of the inner cone in degree
  101598. * @param coneOuterAngle Size of the outer cone in degree
  101599. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101600. */
  101601. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101602. /**
  101603. * Gets or sets the inner angle for the directional cone.
  101604. */
  101605. /**
  101606. * Gets or sets the inner angle for the directional cone.
  101607. */
  101608. directionalConeInnerAngle: number;
  101609. /**
  101610. * Gets or sets the outer angle for the directional cone.
  101611. */
  101612. /**
  101613. * Gets or sets the outer angle for the directional cone.
  101614. */
  101615. directionalConeOuterAngle: number;
  101616. /**
  101617. * Sets the position of the emitter if spatial sound is enabled
  101618. * @param newPosition Defines the new posisiton
  101619. */
  101620. setPosition(newPosition: Vector3): void;
  101621. /**
  101622. * Sets the local direction of the emitter if spatial sound is enabled
  101623. * @param newLocalDirection Defines the new local direction
  101624. */
  101625. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  101626. private _updateDirection;
  101627. /** @hidden */
  101628. updateDistanceFromListener(): void;
  101629. /**
  101630. * Sets a new custom attenuation function for the sound.
  101631. * @param callback Defines the function used for the attenuation
  101632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101633. */
  101634. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  101635. /**
  101636. * Play the sound
  101637. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101638. * @param offset (optional) Start the sound at a specific time in seconds
  101639. * @param length (optional) Sound duration (in seconds)
  101640. */
  101641. play(time?: number, offset?: number, length?: number): void;
  101642. private _onended;
  101643. /**
  101644. * Stop the sound
  101645. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  101646. */
  101647. stop(time?: number): void;
  101648. /**
  101649. * Put the sound in pause
  101650. */
  101651. pause(): void;
  101652. /**
  101653. * Sets a dedicated volume for this sounds
  101654. * @param newVolume Define the new volume of the sound
  101655. * @param time Define time for gradual change to new volume
  101656. */
  101657. setVolume(newVolume: number, time?: number): void;
  101658. /**
  101659. * Set the sound play back rate
  101660. * @param newPlaybackRate Define the playback rate the sound should be played at
  101661. */
  101662. setPlaybackRate(newPlaybackRate: number): void;
  101663. /**
  101664. * Gets the volume of the sound.
  101665. * @returns the volume of the sound
  101666. */
  101667. getVolume(): number;
  101668. /**
  101669. * Attach the sound to a dedicated mesh
  101670. * @param transformNode The transform node to connect the sound with
  101671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101672. */
  101673. attachToMesh(transformNode: TransformNode): void;
  101674. /**
  101675. * Detach the sound from the previously attached mesh
  101676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101677. */
  101678. detachFromMesh(): void;
  101679. private _onRegisterAfterWorldMatrixUpdate;
  101680. /**
  101681. * Clone the current sound in the scene.
  101682. * @returns the new sound clone
  101683. */
  101684. clone(): Nullable<Sound>;
  101685. /**
  101686. * Gets the current underlying audio buffer containing the data
  101687. * @returns the audio buffer
  101688. */
  101689. getAudioBuffer(): Nullable<AudioBuffer>;
  101690. /**
  101691. * Serializes the Sound in a JSON representation
  101692. * @returns the JSON representation of the sound
  101693. */
  101694. serialize(): any;
  101695. /**
  101696. * Parse a JSON representation of a sound to innstantiate in a given scene
  101697. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  101698. * @param scene Define the scene the new parsed sound should be created in
  101699. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  101700. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  101701. * @returns the newly parsed sound
  101702. */
  101703. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  101704. }
  101705. }
  101706. declare module BABYLON {
  101707. /**
  101708. * This defines an action helpful to play a defined sound on a triggered action.
  101709. */
  101710. export class PlaySoundAction extends Action {
  101711. private _sound;
  101712. /**
  101713. * Instantiate the action
  101714. * @param triggerOptions defines the trigger options
  101715. * @param sound defines the sound to play
  101716. * @param condition defines the trigger related conditions
  101717. */
  101718. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101719. /** @hidden */
  101720. _prepare(): void;
  101721. /**
  101722. * Execute the action and play the sound.
  101723. */
  101724. execute(): void;
  101725. /**
  101726. * Serializes the actions and its related information.
  101727. * @param parent defines the object to serialize in
  101728. * @returns the serialized object
  101729. */
  101730. serialize(parent: any): any;
  101731. }
  101732. /**
  101733. * This defines an action helpful to stop a defined sound on a triggered action.
  101734. */
  101735. export class StopSoundAction extends Action {
  101736. private _sound;
  101737. /**
  101738. * Instantiate the action
  101739. * @param triggerOptions defines the trigger options
  101740. * @param sound defines the sound to stop
  101741. * @param condition defines the trigger related conditions
  101742. */
  101743. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101744. /** @hidden */
  101745. _prepare(): void;
  101746. /**
  101747. * Execute the action and stop the sound.
  101748. */
  101749. execute(): void;
  101750. /**
  101751. * Serializes the actions and its related information.
  101752. * @param parent defines the object to serialize in
  101753. * @returns the serialized object
  101754. */
  101755. serialize(parent: any): any;
  101756. }
  101757. }
  101758. declare module BABYLON {
  101759. /**
  101760. * This defines an action responsible to change the value of a property
  101761. * by interpolating between its current value and the newly set one once triggered.
  101762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101763. */
  101764. export class InterpolateValueAction extends Action {
  101765. /**
  101766. * Defines the path of the property where the value should be interpolated
  101767. */
  101768. propertyPath: string;
  101769. /**
  101770. * Defines the target value at the end of the interpolation.
  101771. */
  101772. value: any;
  101773. /**
  101774. * Defines the time it will take for the property to interpolate to the value.
  101775. */
  101776. duration: number;
  101777. /**
  101778. * Defines if the other scene animations should be stopped when the action has been triggered
  101779. */
  101780. stopOtherAnimations?: boolean;
  101781. /**
  101782. * Defines a callback raised once the interpolation animation has been done.
  101783. */
  101784. onInterpolationDone?: () => void;
  101785. /**
  101786. * Observable triggered once the interpolation animation has been done.
  101787. */
  101788. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101789. private _target;
  101790. private _effectiveTarget;
  101791. private _property;
  101792. /**
  101793. * Instantiate the action
  101794. * @param triggerOptions defines the trigger options
  101795. * @param target defines the object containing the value to interpolate
  101796. * @param propertyPath defines the path to the property in the target object
  101797. * @param value defines the target value at the end of the interpolation
  101798. * @param duration deines the time it will take for the property to interpolate to the value.
  101799. * @param condition defines the trigger related conditions
  101800. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101801. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101802. */
  101803. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101804. /** @hidden */
  101805. _prepare(): void;
  101806. /**
  101807. * Execute the action starts the value interpolation.
  101808. */
  101809. execute(): void;
  101810. /**
  101811. * Serializes the actions and its related information.
  101812. * @param parent defines the object to serialize in
  101813. * @returns the serialized object
  101814. */
  101815. serialize(parent: any): any;
  101816. }
  101817. }
  101818. declare module BABYLON {
  101819. /**
  101820. * Options allowed during the creation of a sound track.
  101821. */
  101822. export interface ISoundTrackOptions {
  101823. /**
  101824. * The volume the sound track should take during creation
  101825. */
  101826. volume?: number;
  101827. /**
  101828. * Define if the sound track is the main sound track of the scene
  101829. */
  101830. mainTrack?: boolean;
  101831. }
  101832. /**
  101833. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101834. * It will be also used in a future release to apply effects on a specific track.
  101835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101836. */
  101837. export class SoundTrack {
  101838. /**
  101839. * The unique identifier of the sound track in the scene.
  101840. */
  101841. id: number;
  101842. /**
  101843. * The list of sounds included in the sound track.
  101844. */
  101845. soundCollection: Array<Sound>;
  101846. private _outputAudioNode;
  101847. private _scene;
  101848. private _isMainTrack;
  101849. private _connectedAnalyser;
  101850. private _options;
  101851. private _isInitialized;
  101852. /**
  101853. * Creates a new sound track.
  101854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101855. * @param scene Define the scene the sound track belongs to
  101856. * @param options
  101857. */
  101858. constructor(scene: Scene, options?: ISoundTrackOptions);
  101859. private _initializeSoundTrackAudioGraph;
  101860. /**
  101861. * Release the sound track and its associated resources
  101862. */
  101863. dispose(): void;
  101864. /**
  101865. * Adds a sound to this sound track
  101866. * @param sound define the cound to add
  101867. * @ignoreNaming
  101868. */
  101869. AddSound(sound: Sound): void;
  101870. /**
  101871. * Removes a sound to this sound track
  101872. * @param sound define the cound to remove
  101873. * @ignoreNaming
  101874. */
  101875. RemoveSound(sound: Sound): void;
  101876. /**
  101877. * Set a global volume for the full sound track.
  101878. * @param newVolume Define the new volume of the sound track
  101879. */
  101880. setVolume(newVolume: number): void;
  101881. /**
  101882. * Switch the panning model to HRTF:
  101883. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101885. */
  101886. switchPanningModelToHRTF(): void;
  101887. /**
  101888. * Switch the panning model to Equal Power:
  101889. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101891. */
  101892. switchPanningModelToEqualPower(): void;
  101893. /**
  101894. * Connect the sound track to an audio analyser allowing some amazing
  101895. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101897. * @param analyser The analyser to connect to the engine
  101898. */
  101899. connectToAnalyser(analyser: Analyser): void;
  101900. }
  101901. }
  101902. declare module BABYLON {
  101903. interface AbstractScene {
  101904. /**
  101905. * The list of sounds used in the scene.
  101906. */
  101907. sounds: Nullable<Array<Sound>>;
  101908. }
  101909. interface Scene {
  101910. /**
  101911. * @hidden
  101912. * Backing field
  101913. */
  101914. _mainSoundTrack: SoundTrack;
  101915. /**
  101916. * The main sound track played by the scene.
  101917. * It cotains your primary collection of sounds.
  101918. */
  101919. mainSoundTrack: SoundTrack;
  101920. /**
  101921. * The list of sound tracks added to the scene
  101922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101923. */
  101924. soundTracks: Nullable<Array<SoundTrack>>;
  101925. /**
  101926. * Gets a sound using a given name
  101927. * @param name defines the name to search for
  101928. * @return the found sound or null if not found at all.
  101929. */
  101930. getSoundByName(name: string): Nullable<Sound>;
  101931. /**
  101932. * Gets or sets if audio support is enabled
  101933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101934. */
  101935. audioEnabled: boolean;
  101936. /**
  101937. * Gets or sets if audio will be output to headphones
  101938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101939. */
  101940. headphone: boolean;
  101941. /**
  101942. * Gets or sets custom audio listener position provider
  101943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101944. */
  101945. audioListenerPositionProvider: Nullable<() => Vector3>;
  101946. }
  101947. /**
  101948. * Defines the sound scene component responsible to manage any sounds
  101949. * in a given scene.
  101950. */
  101951. export class AudioSceneComponent implements ISceneSerializableComponent {
  101952. /**
  101953. * The component name helpfull to identify the component in the list of scene components.
  101954. */
  101955. readonly name: string;
  101956. /**
  101957. * The scene the component belongs to.
  101958. */
  101959. scene: Scene;
  101960. private _audioEnabled;
  101961. /**
  101962. * Gets whether audio is enabled or not.
  101963. * Please use related enable/disable method to switch state.
  101964. */
  101965. readonly audioEnabled: boolean;
  101966. private _headphone;
  101967. /**
  101968. * Gets whether audio is outputing to headphone or not.
  101969. * Please use the according Switch methods to change output.
  101970. */
  101971. readonly headphone: boolean;
  101972. private _audioListenerPositionProvider;
  101973. /**
  101974. * Gets the current audio listener position provider
  101975. */
  101976. /**
  101977. * Sets a custom listener position for all sounds in the scene
  101978. * By default, this is the position of the first active camera
  101979. */
  101980. audioListenerPositionProvider: Nullable<() => Vector3>;
  101981. /**
  101982. * Creates a new instance of the component for the given scene
  101983. * @param scene Defines the scene to register the component in
  101984. */
  101985. constructor(scene: Scene);
  101986. /**
  101987. * Registers the component in a given scene
  101988. */
  101989. register(): void;
  101990. /**
  101991. * Rebuilds the elements related to this component in case of
  101992. * context lost for instance.
  101993. */
  101994. rebuild(): void;
  101995. /**
  101996. * Serializes the component data to the specified json object
  101997. * @param serializationObject The object to serialize to
  101998. */
  101999. serialize(serializationObject: any): void;
  102000. /**
  102001. * Adds all the elements from the container to the scene
  102002. * @param container the container holding the elements
  102003. */
  102004. addFromContainer(container: AbstractScene): void;
  102005. /**
  102006. * Removes all the elements in the container from the scene
  102007. * @param container contains the elements to remove
  102008. * @param dispose if the removed element should be disposed (default: false)
  102009. */
  102010. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102011. /**
  102012. * Disposes the component and the associated ressources.
  102013. */
  102014. dispose(): void;
  102015. /**
  102016. * Disables audio in the associated scene.
  102017. */
  102018. disableAudio(): void;
  102019. /**
  102020. * Enables audio in the associated scene.
  102021. */
  102022. enableAudio(): void;
  102023. /**
  102024. * Switch audio to headphone output.
  102025. */
  102026. switchAudioModeForHeadphones(): void;
  102027. /**
  102028. * Switch audio to normal speakers.
  102029. */
  102030. switchAudioModeForNormalSpeakers(): void;
  102031. private _afterRender;
  102032. }
  102033. }
  102034. declare module BABYLON {
  102035. /**
  102036. * Wraps one or more Sound objects and selects one with random weight for playback.
  102037. */
  102038. export class WeightedSound {
  102039. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102040. loop: boolean;
  102041. private _coneInnerAngle;
  102042. private _coneOuterAngle;
  102043. private _volume;
  102044. /** A Sound is currently playing. */
  102045. isPlaying: boolean;
  102046. /** A Sound is currently paused. */
  102047. isPaused: boolean;
  102048. private _sounds;
  102049. private _weights;
  102050. private _currentIndex?;
  102051. /**
  102052. * Creates a new WeightedSound from the list of sounds given.
  102053. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102054. * @param sounds Array of Sounds that will be selected from.
  102055. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102056. */
  102057. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102058. /**
  102059. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102060. */
  102061. /**
  102062. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102063. */
  102064. directionalConeInnerAngle: number;
  102065. /**
  102066. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102067. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102068. */
  102069. /**
  102070. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102071. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102072. */
  102073. directionalConeOuterAngle: number;
  102074. /**
  102075. * Playback volume.
  102076. */
  102077. /**
  102078. * Playback volume.
  102079. */
  102080. volume: number;
  102081. private _onended;
  102082. /**
  102083. * Suspend playback
  102084. */
  102085. pause(): void;
  102086. /**
  102087. * Stop playback
  102088. */
  102089. stop(): void;
  102090. /**
  102091. * Start playback.
  102092. * @param startOffset Position the clip head at a specific time in seconds.
  102093. */
  102094. play(startOffset?: number): void;
  102095. }
  102096. }
  102097. declare module BABYLON {
  102098. /**
  102099. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102101. */
  102102. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102103. /**
  102104. * Gets the name of the behavior.
  102105. */
  102106. readonly name: string;
  102107. /**
  102108. * The easing function used by animations
  102109. */
  102110. static EasingFunction: BackEase;
  102111. /**
  102112. * The easing mode used by animations
  102113. */
  102114. static EasingMode: number;
  102115. /**
  102116. * The duration of the animation, in milliseconds
  102117. */
  102118. transitionDuration: number;
  102119. /**
  102120. * Length of the distance animated by the transition when lower radius is reached
  102121. */
  102122. lowerRadiusTransitionRange: number;
  102123. /**
  102124. * Length of the distance animated by the transition when upper radius is reached
  102125. */
  102126. upperRadiusTransitionRange: number;
  102127. private _autoTransitionRange;
  102128. /**
  102129. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102130. */
  102131. /**
  102132. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102133. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102134. */
  102135. autoTransitionRange: boolean;
  102136. private _attachedCamera;
  102137. private _onAfterCheckInputsObserver;
  102138. private _onMeshTargetChangedObserver;
  102139. /**
  102140. * Initializes the behavior.
  102141. */
  102142. init(): void;
  102143. /**
  102144. * Attaches the behavior to its arc rotate camera.
  102145. * @param camera Defines the camera to attach the behavior to
  102146. */
  102147. attach(camera: ArcRotateCamera): void;
  102148. /**
  102149. * Detaches the behavior from its current arc rotate camera.
  102150. */
  102151. detach(): void;
  102152. private _radiusIsAnimating;
  102153. private _radiusBounceTransition;
  102154. private _animatables;
  102155. private _cachedWheelPrecision;
  102156. /**
  102157. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102158. * @param radiusLimit The limit to check against.
  102159. * @return Bool to indicate if at limit.
  102160. */
  102161. private _isRadiusAtLimit;
  102162. /**
  102163. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102164. * @param radiusDelta The delta by which to animate to. Can be negative.
  102165. */
  102166. private _applyBoundRadiusAnimation;
  102167. /**
  102168. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102169. */
  102170. protected _clearAnimationLocks(): void;
  102171. /**
  102172. * Stops and removes all animations that have been applied to the camera
  102173. */
  102174. stopAllAnimations(): void;
  102175. }
  102176. }
  102177. declare module BABYLON {
  102178. /**
  102179. * 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.
  102180. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102181. */
  102182. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102183. /**
  102184. * Gets the name of the behavior.
  102185. */
  102186. readonly name: string;
  102187. private _mode;
  102188. private _radiusScale;
  102189. private _positionScale;
  102190. private _defaultElevation;
  102191. private _elevationReturnTime;
  102192. private _elevationReturnWaitTime;
  102193. private _zoomStopsAnimation;
  102194. private _framingTime;
  102195. /**
  102196. * The easing function used by animations
  102197. */
  102198. static EasingFunction: ExponentialEase;
  102199. /**
  102200. * The easing mode used by animations
  102201. */
  102202. static EasingMode: number;
  102203. /**
  102204. * Sets the current mode used by the behavior
  102205. */
  102206. /**
  102207. * Gets current mode used by the behavior.
  102208. */
  102209. mode: number;
  102210. /**
  102211. * Sets the scale applied to the radius (1 by default)
  102212. */
  102213. /**
  102214. * Gets the scale applied to the radius
  102215. */
  102216. radiusScale: number;
  102217. /**
  102218. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102219. */
  102220. /**
  102221. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102222. */
  102223. positionScale: number;
  102224. /**
  102225. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102226. * behaviour is triggered, in radians.
  102227. */
  102228. /**
  102229. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102230. * behaviour is triggered, in radians.
  102231. */
  102232. defaultElevation: number;
  102233. /**
  102234. * Sets the time (in milliseconds) taken to return to the default beta position.
  102235. * Negative value indicates camera should not return to default.
  102236. */
  102237. /**
  102238. * Gets the time (in milliseconds) taken to return to the default beta position.
  102239. * Negative value indicates camera should not return to default.
  102240. */
  102241. elevationReturnTime: number;
  102242. /**
  102243. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102244. */
  102245. /**
  102246. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102247. */
  102248. elevationReturnWaitTime: number;
  102249. /**
  102250. * Sets the flag that indicates if user zooming should stop animation.
  102251. */
  102252. /**
  102253. * Gets the flag that indicates if user zooming should stop animation.
  102254. */
  102255. zoomStopsAnimation: boolean;
  102256. /**
  102257. * Sets the transition time when framing the mesh, in milliseconds
  102258. */
  102259. /**
  102260. * Gets the transition time when framing the mesh, in milliseconds
  102261. */
  102262. framingTime: number;
  102263. /**
  102264. * Define if the behavior should automatically change the configured
  102265. * camera limits and sensibilities.
  102266. */
  102267. autoCorrectCameraLimitsAndSensibility: boolean;
  102268. private _onPrePointerObservableObserver;
  102269. private _onAfterCheckInputsObserver;
  102270. private _onMeshTargetChangedObserver;
  102271. private _attachedCamera;
  102272. private _isPointerDown;
  102273. private _lastInteractionTime;
  102274. /**
  102275. * Initializes the behavior.
  102276. */
  102277. init(): void;
  102278. /**
  102279. * Attaches the behavior to its arc rotate camera.
  102280. * @param camera Defines the camera to attach the behavior to
  102281. */
  102282. attach(camera: ArcRotateCamera): void;
  102283. /**
  102284. * Detaches the behavior from its current arc rotate camera.
  102285. */
  102286. detach(): void;
  102287. private _animatables;
  102288. private _betaIsAnimating;
  102289. private _betaTransition;
  102290. private _radiusTransition;
  102291. private _vectorTransition;
  102292. /**
  102293. * Targets the given mesh and updates zoom level accordingly.
  102294. * @param mesh The mesh to target.
  102295. * @param radius Optional. If a cached radius position already exists, overrides default.
  102296. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102297. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102298. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102299. */
  102300. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102301. /**
  102302. * Targets the given mesh with its children and updates zoom level accordingly.
  102303. * @param mesh The mesh to target.
  102304. * @param radius Optional. If a cached radius position already exists, overrides default.
  102305. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102306. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102307. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102308. */
  102309. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102310. /**
  102311. * Targets the given meshes with their children and updates zoom level accordingly.
  102312. * @param meshes The mesh to target.
  102313. * @param radius Optional. If a cached radius position already exists, overrides default.
  102314. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102315. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102316. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102317. */
  102318. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102319. /**
  102320. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102321. * @param minimumWorld Determines the smaller position of the bounding box extend
  102322. * @param maximumWorld Determines the bigger position of the bounding box extend
  102323. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102324. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102325. */
  102326. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102327. /**
  102328. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102329. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102330. * frustum width.
  102331. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102332. * to fully enclose the mesh in the viewing frustum.
  102333. */
  102334. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102335. /**
  102336. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102337. * is automatically returned to its default position (expected to be above ground plane).
  102338. */
  102339. private _maintainCameraAboveGround;
  102340. /**
  102341. * Returns the frustum slope based on the canvas ratio and camera FOV
  102342. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102343. */
  102344. private _getFrustumSlope;
  102345. /**
  102346. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102347. */
  102348. private _clearAnimationLocks;
  102349. /**
  102350. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102351. */
  102352. private _applyUserInteraction;
  102353. /**
  102354. * Stops and removes all animations that have been applied to the camera
  102355. */
  102356. stopAllAnimations(): void;
  102357. /**
  102358. * Gets a value indicating if the user is moving the camera
  102359. */
  102360. readonly isUserIsMoving: boolean;
  102361. /**
  102362. * The camera can move all the way towards the mesh.
  102363. */
  102364. static IgnoreBoundsSizeMode: number;
  102365. /**
  102366. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102367. */
  102368. static FitFrustumSidesMode: number;
  102369. }
  102370. }
  102371. declare module BABYLON {
  102372. /**
  102373. * Base class for Camera Pointer Inputs.
  102374. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102375. * for example usage.
  102376. */
  102377. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102378. /**
  102379. * Defines the camera the input is attached to.
  102380. */
  102381. abstract camera: Camera;
  102382. /**
  102383. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102384. */
  102385. protected _altKey: boolean;
  102386. protected _ctrlKey: boolean;
  102387. protected _metaKey: boolean;
  102388. protected _shiftKey: boolean;
  102389. /**
  102390. * Which mouse buttons were pressed at time of last mouse event.
  102391. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102392. */
  102393. protected _buttonsPressed: number;
  102394. /**
  102395. * Defines the buttons associated with the input to handle camera move.
  102396. */
  102397. buttons: number[];
  102398. /**
  102399. * Attach the input controls to a specific dom element to get the input from.
  102400. * @param element Defines the element the controls should be listened from
  102401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102402. */
  102403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102404. /**
  102405. * Detach the current controls from the specified dom element.
  102406. * @param element Defines the element to stop listening the inputs from
  102407. */
  102408. detachControl(element: Nullable<HTMLElement>): void;
  102409. /**
  102410. * Gets the class name of the current input.
  102411. * @returns the class name
  102412. */
  102413. getClassName(): string;
  102414. /**
  102415. * Get the friendly name associated with the input class.
  102416. * @returns the input friendly name
  102417. */
  102418. getSimpleName(): string;
  102419. /**
  102420. * Called on pointer POINTERDOUBLETAP event.
  102421. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102422. */
  102423. protected onDoubleTap(type: string): void;
  102424. /**
  102425. * Called on pointer POINTERMOVE event if only a single touch is active.
  102426. * Override this method to provide functionality.
  102427. */
  102428. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102429. /**
  102430. * Called on pointer POINTERMOVE event if multiple touches are active.
  102431. * Override this method to provide functionality.
  102432. */
  102433. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102434. /**
  102435. * Called on JS contextmenu event.
  102436. * Override this method to provide functionality.
  102437. */
  102438. protected onContextMenu(evt: PointerEvent): void;
  102439. /**
  102440. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102441. * press.
  102442. * Override this method to provide functionality.
  102443. */
  102444. protected onButtonDown(evt: PointerEvent): void;
  102445. /**
  102446. * Called each time a new POINTERUP event occurs. Ie, for each button
  102447. * release.
  102448. * Override this method to provide functionality.
  102449. */
  102450. protected onButtonUp(evt: PointerEvent): void;
  102451. /**
  102452. * Called when window becomes inactive.
  102453. * Override this method to provide functionality.
  102454. */
  102455. protected onLostFocus(): void;
  102456. private _pointerInput;
  102457. private _observer;
  102458. private _onLostFocus;
  102459. private pointA;
  102460. private pointB;
  102461. }
  102462. }
  102463. declare module BABYLON {
  102464. /**
  102465. * Manage the pointers inputs to control an arc rotate camera.
  102466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102467. */
  102468. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102469. /**
  102470. * Defines the camera the input is attached to.
  102471. */
  102472. camera: ArcRotateCamera;
  102473. /**
  102474. * Gets the class name of the current input.
  102475. * @returns the class name
  102476. */
  102477. getClassName(): string;
  102478. /**
  102479. * Defines the buttons associated with the input to handle camera move.
  102480. */
  102481. buttons: number[];
  102482. /**
  102483. * Defines the pointer angular sensibility along the X axis or how fast is
  102484. * the camera rotating.
  102485. */
  102486. angularSensibilityX: number;
  102487. /**
  102488. * Defines the pointer angular sensibility along the Y axis or how fast is
  102489. * the camera rotating.
  102490. */
  102491. angularSensibilityY: number;
  102492. /**
  102493. * Defines the pointer pinch precision or how fast is the camera zooming.
  102494. */
  102495. pinchPrecision: number;
  102496. /**
  102497. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102498. * from 0.
  102499. * It defines the percentage of current camera.radius to use as delta when
  102500. * pinch zoom is used.
  102501. */
  102502. pinchDeltaPercentage: number;
  102503. /**
  102504. * Defines the pointer panning sensibility or how fast is the camera moving.
  102505. */
  102506. panningSensibility: number;
  102507. /**
  102508. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102509. */
  102510. multiTouchPanning: boolean;
  102511. /**
  102512. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102513. * zoom (pinch) through multitouch.
  102514. */
  102515. multiTouchPanAndZoom: boolean;
  102516. /**
  102517. * Revers pinch action direction.
  102518. */
  102519. pinchInwards: boolean;
  102520. private _isPanClick;
  102521. private _twoFingerActivityCount;
  102522. private _isPinching;
  102523. /**
  102524. * Called on pointer POINTERMOVE event if only a single touch is active.
  102525. */
  102526. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102527. /**
  102528. * Called on pointer POINTERDOUBLETAP event.
  102529. */
  102530. protected onDoubleTap(type: string): void;
  102531. /**
  102532. * Called on pointer POINTERMOVE event if multiple touches are active.
  102533. */
  102534. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102535. /**
  102536. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102537. * press.
  102538. */
  102539. protected onButtonDown(evt: PointerEvent): void;
  102540. /**
  102541. * Called each time a new POINTERUP event occurs. Ie, for each button
  102542. * release.
  102543. */
  102544. protected onButtonUp(evt: PointerEvent): void;
  102545. /**
  102546. * Called when window becomes inactive.
  102547. */
  102548. protected onLostFocus(): void;
  102549. }
  102550. }
  102551. declare module BABYLON {
  102552. /**
  102553. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102555. */
  102556. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102557. /**
  102558. * Defines the camera the input is attached to.
  102559. */
  102560. camera: ArcRotateCamera;
  102561. /**
  102562. * Defines the list of key codes associated with the up action (increase alpha)
  102563. */
  102564. keysUp: number[];
  102565. /**
  102566. * Defines the list of key codes associated with the down action (decrease alpha)
  102567. */
  102568. keysDown: number[];
  102569. /**
  102570. * Defines the list of key codes associated with the left action (increase beta)
  102571. */
  102572. keysLeft: number[];
  102573. /**
  102574. * Defines the list of key codes associated with the right action (decrease beta)
  102575. */
  102576. keysRight: number[];
  102577. /**
  102578. * Defines the list of key codes associated with the reset action.
  102579. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102580. */
  102581. keysReset: number[];
  102582. /**
  102583. * Defines the panning sensibility of the inputs.
  102584. * (How fast is the camera paning)
  102585. */
  102586. panningSensibility: number;
  102587. /**
  102588. * Defines the zooming sensibility of the inputs.
  102589. * (How fast is the camera zooming)
  102590. */
  102591. zoomingSensibility: number;
  102592. /**
  102593. * Defines wether maintaining the alt key down switch the movement mode from
  102594. * orientation to zoom.
  102595. */
  102596. useAltToZoom: boolean;
  102597. /**
  102598. * Rotation speed of the camera
  102599. */
  102600. angularSpeed: number;
  102601. private _keys;
  102602. private _ctrlPressed;
  102603. private _altPressed;
  102604. private _onCanvasBlurObserver;
  102605. private _onKeyboardObserver;
  102606. private _engine;
  102607. private _scene;
  102608. /**
  102609. * Attach the input controls to a specific dom element to get the input from.
  102610. * @param element Defines the element the controls should be listened from
  102611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102612. */
  102613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102614. /**
  102615. * Detach the current controls from the specified dom element.
  102616. * @param element Defines the element to stop listening the inputs from
  102617. */
  102618. detachControl(element: Nullable<HTMLElement>): void;
  102619. /**
  102620. * Update the current camera state depending on the inputs that have been used this frame.
  102621. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102622. */
  102623. checkInputs(): void;
  102624. /**
  102625. * Gets the class name of the current intput.
  102626. * @returns the class name
  102627. */
  102628. getClassName(): string;
  102629. /**
  102630. * Get the friendly name associated with the input class.
  102631. * @returns the input friendly name
  102632. */
  102633. getSimpleName(): string;
  102634. }
  102635. }
  102636. declare module BABYLON {
  102637. /**
  102638. * Manage the mouse wheel inputs to control an arc rotate camera.
  102639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102640. */
  102641. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102642. /**
  102643. * Defines the camera the input is attached to.
  102644. */
  102645. camera: ArcRotateCamera;
  102646. /**
  102647. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102648. */
  102649. wheelPrecision: number;
  102650. /**
  102651. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102652. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102653. */
  102654. wheelDeltaPercentage: number;
  102655. private _wheel;
  102656. private _observer;
  102657. private computeDeltaFromMouseWheelLegacyEvent;
  102658. /**
  102659. * Attach the input controls to a specific dom element to get the input from.
  102660. * @param element Defines the element the controls should be listened from
  102661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102662. */
  102663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102664. /**
  102665. * Detach the current controls from the specified dom element.
  102666. * @param element Defines the element to stop listening the inputs from
  102667. */
  102668. detachControl(element: Nullable<HTMLElement>): void;
  102669. /**
  102670. * Gets the class name of the current intput.
  102671. * @returns the class name
  102672. */
  102673. getClassName(): string;
  102674. /**
  102675. * Get the friendly name associated with the input class.
  102676. * @returns the input friendly name
  102677. */
  102678. getSimpleName(): string;
  102679. }
  102680. }
  102681. declare module BABYLON {
  102682. /**
  102683. * Default Inputs manager for the ArcRotateCamera.
  102684. * It groups all the default supported inputs for ease of use.
  102685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102686. */
  102687. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  102688. /**
  102689. * Instantiates a new ArcRotateCameraInputsManager.
  102690. * @param camera Defines the camera the inputs belong to
  102691. */
  102692. constructor(camera: ArcRotateCamera);
  102693. /**
  102694. * Add mouse wheel input support to the input manager.
  102695. * @returns the current input manager
  102696. */
  102697. addMouseWheel(): ArcRotateCameraInputsManager;
  102698. /**
  102699. * Add pointers input support to the input manager.
  102700. * @returns the current input manager
  102701. */
  102702. addPointers(): ArcRotateCameraInputsManager;
  102703. /**
  102704. * Add keyboard input support to the input manager.
  102705. * @returns the current input manager
  102706. */
  102707. addKeyboard(): ArcRotateCameraInputsManager;
  102708. }
  102709. }
  102710. declare module BABYLON {
  102711. /**
  102712. * This represents an orbital type of camera.
  102713. *
  102714. * 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.
  102715. * 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.
  102716. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  102717. */
  102718. export class ArcRotateCamera extends TargetCamera {
  102719. /**
  102720. * Defines the rotation angle of the camera along the longitudinal axis.
  102721. */
  102722. alpha: number;
  102723. /**
  102724. * Defines the rotation angle of the camera along the latitudinal axis.
  102725. */
  102726. beta: number;
  102727. /**
  102728. * Defines the radius of the camera from it s target point.
  102729. */
  102730. radius: number;
  102731. protected _target: Vector3;
  102732. protected _targetHost: Nullable<AbstractMesh>;
  102733. /**
  102734. * Defines the target point of the camera.
  102735. * The camera looks towards it form the radius distance.
  102736. */
  102737. target: Vector3;
  102738. /**
  102739. * Define the current local position of the camera in the scene
  102740. */
  102741. position: Vector3;
  102742. protected _upVector: Vector3;
  102743. protected _upToYMatrix: Matrix;
  102744. protected _YToUpMatrix: Matrix;
  102745. /**
  102746. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  102747. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  102748. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  102749. */
  102750. upVector: Vector3;
  102751. /**
  102752. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  102753. */
  102754. setMatUp(): void;
  102755. /**
  102756. * Current inertia value on the longitudinal axis.
  102757. * The bigger this number the longer it will take for the camera to stop.
  102758. */
  102759. inertialAlphaOffset: number;
  102760. /**
  102761. * Current inertia value on the latitudinal axis.
  102762. * The bigger this number the longer it will take for the camera to stop.
  102763. */
  102764. inertialBetaOffset: number;
  102765. /**
  102766. * Current inertia value on the radius axis.
  102767. * The bigger this number the longer it will take for the camera to stop.
  102768. */
  102769. inertialRadiusOffset: number;
  102770. /**
  102771. * Minimum allowed angle on the longitudinal axis.
  102772. * This can help limiting how the Camera is able to move in the scene.
  102773. */
  102774. lowerAlphaLimit: Nullable<number>;
  102775. /**
  102776. * Maximum allowed angle on the longitudinal axis.
  102777. * This can help limiting how the Camera is able to move in the scene.
  102778. */
  102779. upperAlphaLimit: Nullable<number>;
  102780. /**
  102781. * Minimum allowed angle on the latitudinal axis.
  102782. * This can help limiting how the Camera is able to move in the scene.
  102783. */
  102784. lowerBetaLimit: number;
  102785. /**
  102786. * Maximum allowed angle on the latitudinal axis.
  102787. * This can help limiting how the Camera is able to move in the scene.
  102788. */
  102789. upperBetaLimit: number;
  102790. /**
  102791. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102792. * This can help limiting how the Camera is able to move in the scene.
  102793. */
  102794. lowerRadiusLimit: Nullable<number>;
  102795. /**
  102796. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102797. * This can help limiting how the Camera is able to move in the scene.
  102798. */
  102799. upperRadiusLimit: Nullable<number>;
  102800. /**
  102801. * Defines the current inertia value used during panning of the camera along the X axis.
  102802. */
  102803. inertialPanningX: number;
  102804. /**
  102805. * Defines the current inertia value used during panning of the camera along the Y axis.
  102806. */
  102807. inertialPanningY: number;
  102808. /**
  102809. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102810. * Basically if your fingers moves away from more than this distance you will be considered
  102811. * in pinch mode.
  102812. */
  102813. pinchToPanMaxDistance: number;
  102814. /**
  102815. * Defines the maximum distance the camera can pan.
  102816. * This could help keeping the cammera always in your scene.
  102817. */
  102818. panningDistanceLimit: Nullable<number>;
  102819. /**
  102820. * Defines the target of the camera before paning.
  102821. */
  102822. panningOriginTarget: Vector3;
  102823. /**
  102824. * Defines the value of the inertia used during panning.
  102825. * 0 would mean stop inertia and one would mean no decelleration at all.
  102826. */
  102827. panningInertia: number;
  102828. /**
  102829. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102830. */
  102831. angularSensibilityX: number;
  102832. /**
  102833. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102834. */
  102835. angularSensibilityY: number;
  102836. /**
  102837. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102838. */
  102839. pinchPrecision: number;
  102840. /**
  102841. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102842. * It will be used instead of pinchDeltaPrecision if different from 0.
  102843. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102844. */
  102845. pinchDeltaPercentage: number;
  102846. /**
  102847. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102848. */
  102849. panningSensibility: number;
  102850. /**
  102851. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102852. */
  102853. keysUp: number[];
  102854. /**
  102855. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102856. */
  102857. keysDown: number[];
  102858. /**
  102859. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102860. */
  102861. keysLeft: number[];
  102862. /**
  102863. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102864. */
  102865. keysRight: number[];
  102866. /**
  102867. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102868. */
  102869. wheelPrecision: number;
  102870. /**
  102871. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102872. * It will be used instead of pinchDeltaPrecision if different from 0.
  102873. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102874. */
  102875. wheelDeltaPercentage: number;
  102876. /**
  102877. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102878. */
  102879. zoomOnFactor: number;
  102880. /**
  102881. * Defines a screen offset for the camera position.
  102882. */
  102883. targetScreenOffset: Vector2;
  102884. /**
  102885. * Allows the camera to be completely reversed.
  102886. * If false the camera can not arrive upside down.
  102887. */
  102888. allowUpsideDown: boolean;
  102889. /**
  102890. * Define if double tap/click is used to restore the previously saved state of the camera.
  102891. */
  102892. useInputToRestoreState: boolean;
  102893. /** @hidden */
  102894. _viewMatrix: Matrix;
  102895. /** @hidden */
  102896. _useCtrlForPanning: boolean;
  102897. /** @hidden */
  102898. _panningMouseButton: number;
  102899. /**
  102900. * Defines the input associated to the camera.
  102901. */
  102902. inputs: ArcRotateCameraInputsManager;
  102903. /** @hidden */
  102904. _reset: () => void;
  102905. /**
  102906. * Defines the allowed panning axis.
  102907. */
  102908. panningAxis: Vector3;
  102909. protected _localDirection: Vector3;
  102910. protected _transformedDirection: Vector3;
  102911. private _bouncingBehavior;
  102912. /**
  102913. * Gets the bouncing behavior of the camera if it has been enabled.
  102914. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102915. */
  102916. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102917. /**
  102918. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102919. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102920. */
  102921. useBouncingBehavior: boolean;
  102922. private _framingBehavior;
  102923. /**
  102924. * Gets the framing behavior of the camera if it has been enabled.
  102925. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102926. */
  102927. readonly framingBehavior: Nullable<FramingBehavior>;
  102928. /**
  102929. * Defines if the framing behavior of the camera is enabled on the camera.
  102930. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102931. */
  102932. useFramingBehavior: boolean;
  102933. private _autoRotationBehavior;
  102934. /**
  102935. * Gets the auto rotation behavior of the camera if it has been enabled.
  102936. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102937. */
  102938. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102939. /**
  102940. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102941. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102942. */
  102943. useAutoRotationBehavior: boolean;
  102944. /**
  102945. * Observable triggered when the mesh target has been changed on the camera.
  102946. */
  102947. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102948. /**
  102949. * Event raised when the camera is colliding with a mesh.
  102950. */
  102951. onCollide: (collidedMesh: AbstractMesh) => void;
  102952. /**
  102953. * Defines whether the camera should check collision with the objects oh the scene.
  102954. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102955. */
  102956. checkCollisions: boolean;
  102957. /**
  102958. * Defines the collision radius of the camera.
  102959. * This simulates a sphere around the camera.
  102960. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102961. */
  102962. collisionRadius: Vector3;
  102963. protected _collider: Collider;
  102964. protected _previousPosition: Vector3;
  102965. protected _collisionVelocity: Vector3;
  102966. protected _newPosition: Vector3;
  102967. protected _previousAlpha: number;
  102968. protected _previousBeta: number;
  102969. protected _previousRadius: number;
  102970. protected _collisionTriggered: boolean;
  102971. protected _targetBoundingCenter: Nullable<Vector3>;
  102972. private _computationVector;
  102973. /**
  102974. * Instantiates a new ArcRotateCamera in a given scene
  102975. * @param name Defines the name of the camera
  102976. * @param alpha Defines the camera rotation along the logitudinal axis
  102977. * @param beta Defines the camera rotation along the latitudinal axis
  102978. * @param radius Defines the camera distance from its target
  102979. * @param target Defines the camera target
  102980. * @param scene Defines the scene the camera belongs to
  102981. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102982. */
  102983. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102984. /** @hidden */
  102985. _initCache(): void;
  102986. /** @hidden */
  102987. _updateCache(ignoreParentClass?: boolean): void;
  102988. protected _getTargetPosition(): Vector3;
  102989. private _storedAlpha;
  102990. private _storedBeta;
  102991. private _storedRadius;
  102992. private _storedTarget;
  102993. private _storedTargetScreenOffset;
  102994. /**
  102995. * Stores the current state of the camera (alpha, beta, radius and target)
  102996. * @returns the camera itself
  102997. */
  102998. storeState(): Camera;
  102999. /**
  103000. * @hidden
  103001. * Restored camera state. You must call storeState() first
  103002. */
  103003. _restoreStateValues(): boolean;
  103004. /** @hidden */
  103005. _isSynchronizedViewMatrix(): boolean;
  103006. /**
  103007. * Attached controls to the current camera.
  103008. * @param element Defines the element the controls should be listened from
  103009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103010. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103011. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103012. */
  103013. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103014. /**
  103015. * Detach the current controls from the camera.
  103016. * The camera will stop reacting to inputs.
  103017. * @param element Defines the element to stop listening the inputs from
  103018. */
  103019. detachControl(element: HTMLElement): void;
  103020. /** @hidden */
  103021. _checkInputs(): void;
  103022. protected _checkLimits(): void;
  103023. /**
  103024. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103025. */
  103026. rebuildAnglesAndRadius(): void;
  103027. /**
  103028. * Use a position to define the current camera related information like aplha, beta and radius
  103029. * @param position Defines the position to set the camera at
  103030. */
  103031. setPosition(position: Vector3): void;
  103032. /**
  103033. * Defines the target the camera should look at.
  103034. * This will automatically adapt alpha beta and radius to fit within the new target.
  103035. * @param target Defines the new target as a Vector or a mesh
  103036. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103037. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103038. */
  103039. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103040. /** @hidden */
  103041. _getViewMatrix(): Matrix;
  103042. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103043. /**
  103044. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103045. * @param meshes Defines the mesh to zoom on
  103046. * @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)
  103047. */
  103048. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103049. /**
  103050. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103051. * The target will be changed but the radius
  103052. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103053. * @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)
  103054. */
  103055. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103056. min: Vector3;
  103057. max: Vector3;
  103058. distance: number;
  103059. }, doNotUpdateMaxZ?: boolean): void;
  103060. /**
  103061. * @override
  103062. * Override Camera.createRigCamera
  103063. */
  103064. createRigCamera(name: string, cameraIndex: number): Camera;
  103065. /**
  103066. * @hidden
  103067. * @override
  103068. * Override Camera._updateRigCameras
  103069. */
  103070. _updateRigCameras(): void;
  103071. /**
  103072. * Destroy the camera and release the current resources hold by it.
  103073. */
  103074. dispose(): void;
  103075. /**
  103076. * Gets the current object class name.
  103077. * @return the class name
  103078. */
  103079. getClassName(): string;
  103080. }
  103081. }
  103082. declare module BABYLON {
  103083. /**
  103084. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103085. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103086. */
  103087. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103088. /**
  103089. * Gets the name of the behavior.
  103090. */
  103091. readonly name: string;
  103092. private _zoomStopsAnimation;
  103093. private _idleRotationSpeed;
  103094. private _idleRotationWaitTime;
  103095. private _idleRotationSpinupTime;
  103096. /**
  103097. * Sets the flag that indicates if user zooming should stop animation.
  103098. */
  103099. /**
  103100. * Gets the flag that indicates if user zooming should stop animation.
  103101. */
  103102. zoomStopsAnimation: boolean;
  103103. /**
  103104. * Sets the default speed at which the camera rotates around the model.
  103105. */
  103106. /**
  103107. * Gets the default speed at which the camera rotates around the model.
  103108. */
  103109. idleRotationSpeed: number;
  103110. /**
  103111. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103112. */
  103113. /**
  103114. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103115. */
  103116. idleRotationWaitTime: number;
  103117. /**
  103118. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103119. */
  103120. /**
  103121. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103122. */
  103123. idleRotationSpinupTime: number;
  103124. /**
  103125. * Gets a value indicating if the camera is currently rotating because of this behavior
  103126. */
  103127. readonly rotationInProgress: boolean;
  103128. private _onPrePointerObservableObserver;
  103129. private _onAfterCheckInputsObserver;
  103130. private _attachedCamera;
  103131. private _isPointerDown;
  103132. private _lastFrameTime;
  103133. private _lastInteractionTime;
  103134. private _cameraRotationSpeed;
  103135. /**
  103136. * Initializes the behavior.
  103137. */
  103138. init(): void;
  103139. /**
  103140. * Attaches the behavior to its arc rotate camera.
  103141. * @param camera Defines the camera to attach the behavior to
  103142. */
  103143. attach(camera: ArcRotateCamera): void;
  103144. /**
  103145. * Detaches the behavior from its current arc rotate camera.
  103146. */
  103147. detach(): void;
  103148. /**
  103149. * Returns true if user is scrolling.
  103150. * @return true if user is scrolling.
  103151. */
  103152. private _userIsZooming;
  103153. private _lastFrameRadius;
  103154. private _shouldAnimationStopForInteraction;
  103155. /**
  103156. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103157. */
  103158. private _applyUserInteraction;
  103159. private _userIsMoving;
  103160. }
  103161. }
  103162. declare module BABYLON {
  103163. /**
  103164. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103165. */
  103166. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103167. private ui;
  103168. /**
  103169. * The name of the behavior
  103170. */
  103171. name: string;
  103172. /**
  103173. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103174. */
  103175. distanceAwayFromFace: number;
  103176. /**
  103177. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103178. */
  103179. distanceAwayFromBottomOfFace: number;
  103180. private _faceVectors;
  103181. private _target;
  103182. private _scene;
  103183. private _onRenderObserver;
  103184. private _tmpMatrix;
  103185. private _tmpVector;
  103186. /**
  103187. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103188. * @param ui The transform node that should be attched to the mesh
  103189. */
  103190. constructor(ui: TransformNode);
  103191. /**
  103192. * Initializes the behavior
  103193. */
  103194. init(): void;
  103195. private _closestFace;
  103196. private _zeroVector;
  103197. private _lookAtTmpMatrix;
  103198. private _lookAtToRef;
  103199. /**
  103200. * Attaches the AttachToBoxBehavior to the passed in mesh
  103201. * @param target The mesh that the specified node will be attached to
  103202. */
  103203. attach(target: Mesh): void;
  103204. /**
  103205. * Detaches the behavior from the mesh
  103206. */
  103207. detach(): void;
  103208. }
  103209. }
  103210. declare module BABYLON {
  103211. /**
  103212. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103213. */
  103214. export class FadeInOutBehavior implements Behavior<Mesh> {
  103215. /**
  103216. * Time in milliseconds to delay before fading in (Default: 0)
  103217. */
  103218. delay: number;
  103219. /**
  103220. * Time in milliseconds for the mesh to fade in (Default: 300)
  103221. */
  103222. fadeInTime: number;
  103223. private _millisecondsPerFrame;
  103224. private _hovered;
  103225. private _hoverValue;
  103226. private _ownerNode;
  103227. /**
  103228. * Instatiates the FadeInOutBehavior
  103229. */
  103230. constructor();
  103231. /**
  103232. * The name of the behavior
  103233. */
  103234. readonly name: string;
  103235. /**
  103236. * Initializes the behavior
  103237. */
  103238. init(): void;
  103239. /**
  103240. * Attaches the fade behavior on the passed in mesh
  103241. * @param ownerNode The mesh that will be faded in/out once attached
  103242. */
  103243. attach(ownerNode: Mesh): void;
  103244. /**
  103245. * Detaches the behavior from the mesh
  103246. */
  103247. detach(): void;
  103248. /**
  103249. * Triggers the mesh to begin fading in or out
  103250. * @param value if the object should fade in or out (true to fade in)
  103251. */
  103252. fadeIn(value: boolean): void;
  103253. private _update;
  103254. private _setAllVisibility;
  103255. }
  103256. }
  103257. declare module BABYLON {
  103258. /**
  103259. * Class containing a set of static utilities functions for managing Pivots
  103260. * @hidden
  103261. */
  103262. export class PivotTools {
  103263. private static _PivotCached;
  103264. private static _OldPivotPoint;
  103265. private static _PivotTranslation;
  103266. private static _PivotTmpVector;
  103267. /** @hidden */
  103268. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103269. /** @hidden */
  103270. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103271. }
  103272. }
  103273. declare module BABYLON {
  103274. /**
  103275. * Class containing static functions to help procedurally build meshes
  103276. */
  103277. export class PlaneBuilder {
  103278. /**
  103279. * Creates a plane mesh
  103280. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103281. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103282. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103286. * @param name defines the name of the mesh
  103287. * @param options defines the options used to create the mesh
  103288. * @param scene defines the hosting scene
  103289. * @returns the plane mesh
  103290. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103291. */
  103292. static CreatePlane(name: string, options: {
  103293. size?: number;
  103294. width?: number;
  103295. height?: number;
  103296. sideOrientation?: number;
  103297. frontUVs?: Vector4;
  103298. backUVs?: Vector4;
  103299. updatable?: boolean;
  103300. sourcePlane?: Plane;
  103301. }, scene?: Nullable<Scene>): Mesh;
  103302. }
  103303. }
  103304. declare module BABYLON {
  103305. /**
  103306. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103307. */
  103308. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103309. private static _AnyMouseID;
  103310. /**
  103311. * Abstract mesh the behavior is set on
  103312. */
  103313. attachedNode: AbstractMesh;
  103314. private _dragPlane;
  103315. private _scene;
  103316. private _pointerObserver;
  103317. private _beforeRenderObserver;
  103318. private static _planeScene;
  103319. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103320. /**
  103321. * 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)
  103322. */
  103323. maxDragAngle: number;
  103324. /**
  103325. * @hidden
  103326. */
  103327. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103328. /**
  103329. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103330. */
  103331. currentDraggingPointerID: number;
  103332. /**
  103333. * The last position where the pointer hit the drag plane in world space
  103334. */
  103335. lastDragPosition: Vector3;
  103336. /**
  103337. * If the behavior is currently in a dragging state
  103338. */
  103339. dragging: boolean;
  103340. /**
  103341. * 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)
  103342. */
  103343. dragDeltaRatio: number;
  103344. /**
  103345. * If the drag plane orientation should be updated during the dragging (Default: true)
  103346. */
  103347. updateDragPlane: boolean;
  103348. private _debugMode;
  103349. private _moving;
  103350. /**
  103351. * Fires each time the attached mesh is dragged with the pointer
  103352. * * delta between last drag position and current drag position in world space
  103353. * * dragDistance along the drag axis
  103354. * * dragPlaneNormal normal of the current drag plane used during the drag
  103355. * * dragPlanePoint in world space where the drag intersects the drag plane
  103356. */
  103357. onDragObservable: Observable<{
  103358. delta: Vector3;
  103359. dragPlanePoint: Vector3;
  103360. dragPlaneNormal: Vector3;
  103361. dragDistance: number;
  103362. pointerId: number;
  103363. }>;
  103364. /**
  103365. * Fires each time a drag begins (eg. mouse down on mesh)
  103366. */
  103367. onDragStartObservable: Observable<{
  103368. dragPlanePoint: Vector3;
  103369. pointerId: number;
  103370. }>;
  103371. /**
  103372. * Fires each time a drag ends (eg. mouse release after drag)
  103373. */
  103374. onDragEndObservable: Observable<{
  103375. dragPlanePoint: Vector3;
  103376. pointerId: number;
  103377. }>;
  103378. /**
  103379. * If the attached mesh should be moved when dragged
  103380. */
  103381. moveAttached: boolean;
  103382. /**
  103383. * If the drag behavior will react to drag events (Default: true)
  103384. */
  103385. enabled: boolean;
  103386. /**
  103387. * If pointer events should start and release the drag (Default: true)
  103388. */
  103389. startAndReleaseDragOnPointerEvents: boolean;
  103390. /**
  103391. * If camera controls should be detached during the drag
  103392. */
  103393. detachCameraControls: boolean;
  103394. /**
  103395. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103396. */
  103397. useObjectOrienationForDragging: boolean;
  103398. private _options;
  103399. /**
  103400. * Creates a pointer drag behavior that can be attached to a mesh
  103401. * @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)
  103402. */
  103403. constructor(options?: {
  103404. dragAxis?: Vector3;
  103405. dragPlaneNormal?: Vector3;
  103406. });
  103407. /**
  103408. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103409. */
  103410. validateDrag: (targetPosition: Vector3) => boolean;
  103411. /**
  103412. * The name of the behavior
  103413. */
  103414. readonly name: string;
  103415. /**
  103416. * Initializes the behavior
  103417. */
  103418. init(): void;
  103419. private _tmpVector;
  103420. private _alternatePickedPoint;
  103421. private _worldDragAxis;
  103422. private _targetPosition;
  103423. private _attachedElement;
  103424. /**
  103425. * Attaches the drag behavior the passed in mesh
  103426. * @param ownerNode The mesh that will be dragged around once attached
  103427. * @param predicate Predicate to use for pick filtering
  103428. */
  103429. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103430. /**
  103431. * Force relase the drag action by code.
  103432. */
  103433. releaseDrag(): void;
  103434. private _startDragRay;
  103435. private _lastPointerRay;
  103436. /**
  103437. * Simulates the start of a pointer drag event on the behavior
  103438. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103439. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103440. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103441. */
  103442. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103443. private _startDrag;
  103444. private _dragDelta;
  103445. private _moveDrag;
  103446. private _pickWithRayOnDragPlane;
  103447. private _pointA;
  103448. private _pointB;
  103449. private _pointC;
  103450. private _lineA;
  103451. private _lineB;
  103452. private _localAxis;
  103453. private _lookAt;
  103454. private _updateDragPlanePosition;
  103455. /**
  103456. * Detaches the behavior from the mesh
  103457. */
  103458. detach(): void;
  103459. }
  103460. }
  103461. declare module BABYLON {
  103462. /**
  103463. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103464. */
  103465. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103466. private _dragBehaviorA;
  103467. private _dragBehaviorB;
  103468. private _startDistance;
  103469. private _initialScale;
  103470. private _targetScale;
  103471. private _ownerNode;
  103472. private _sceneRenderObserver;
  103473. /**
  103474. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103475. */
  103476. constructor();
  103477. /**
  103478. * The name of the behavior
  103479. */
  103480. readonly name: string;
  103481. /**
  103482. * Initializes the behavior
  103483. */
  103484. init(): void;
  103485. private _getCurrentDistance;
  103486. /**
  103487. * Attaches the scale behavior the passed in mesh
  103488. * @param ownerNode The mesh that will be scaled around once attached
  103489. */
  103490. attach(ownerNode: Mesh): void;
  103491. /**
  103492. * Detaches the behavior from the mesh
  103493. */
  103494. detach(): void;
  103495. }
  103496. }
  103497. declare module BABYLON {
  103498. /**
  103499. * 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
  103500. */
  103501. export class SixDofDragBehavior implements Behavior<Mesh> {
  103502. private static _virtualScene;
  103503. private _ownerNode;
  103504. private _sceneRenderObserver;
  103505. private _scene;
  103506. private _targetPosition;
  103507. private _virtualOriginMesh;
  103508. private _virtualDragMesh;
  103509. private _pointerObserver;
  103510. private _moving;
  103511. private _startingOrientation;
  103512. /**
  103513. * 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)
  103514. */
  103515. private zDragFactor;
  103516. /**
  103517. * If the object should rotate to face the drag origin
  103518. */
  103519. rotateDraggedObject: boolean;
  103520. /**
  103521. * If the behavior is currently in a dragging state
  103522. */
  103523. dragging: boolean;
  103524. /**
  103525. * 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)
  103526. */
  103527. dragDeltaRatio: number;
  103528. /**
  103529. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103530. */
  103531. currentDraggingPointerID: number;
  103532. /**
  103533. * If camera controls should be detached during the drag
  103534. */
  103535. detachCameraControls: boolean;
  103536. /**
  103537. * Fires each time a drag starts
  103538. */
  103539. onDragStartObservable: Observable<{}>;
  103540. /**
  103541. * Fires each time a drag ends (eg. mouse release after drag)
  103542. */
  103543. onDragEndObservable: Observable<{}>;
  103544. /**
  103545. * 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
  103546. */
  103547. constructor();
  103548. /**
  103549. * The name of the behavior
  103550. */
  103551. readonly name: string;
  103552. /**
  103553. * Initializes the behavior
  103554. */
  103555. init(): void;
  103556. /**
  103557. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103558. */
  103559. private readonly _pointerCamera;
  103560. /**
  103561. * Attaches the scale behavior the passed in mesh
  103562. * @param ownerNode The mesh that will be scaled around once attached
  103563. */
  103564. attach(ownerNode: Mesh): void;
  103565. /**
  103566. * Detaches the behavior from the mesh
  103567. */
  103568. detach(): void;
  103569. }
  103570. }
  103571. declare module BABYLON {
  103572. /**
  103573. * Class used to apply inverse kinematics to bones
  103574. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103575. */
  103576. export class BoneIKController {
  103577. private static _tmpVecs;
  103578. private static _tmpQuat;
  103579. private static _tmpMats;
  103580. /**
  103581. * Gets or sets the target mesh
  103582. */
  103583. targetMesh: AbstractMesh;
  103584. /** Gets or sets the mesh used as pole */
  103585. poleTargetMesh: AbstractMesh;
  103586. /**
  103587. * Gets or sets the bone used as pole
  103588. */
  103589. poleTargetBone: Nullable<Bone>;
  103590. /**
  103591. * Gets or sets the target position
  103592. */
  103593. targetPosition: Vector3;
  103594. /**
  103595. * Gets or sets the pole target position
  103596. */
  103597. poleTargetPosition: Vector3;
  103598. /**
  103599. * Gets or sets the pole target local offset
  103600. */
  103601. poleTargetLocalOffset: Vector3;
  103602. /**
  103603. * Gets or sets the pole angle
  103604. */
  103605. poleAngle: number;
  103606. /**
  103607. * Gets or sets the mesh associated with the controller
  103608. */
  103609. mesh: AbstractMesh;
  103610. /**
  103611. * 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)
  103612. */
  103613. slerpAmount: number;
  103614. private _bone1Quat;
  103615. private _bone1Mat;
  103616. private _bone2Ang;
  103617. private _bone1;
  103618. private _bone2;
  103619. private _bone1Length;
  103620. private _bone2Length;
  103621. private _maxAngle;
  103622. private _maxReach;
  103623. private _rightHandedSystem;
  103624. private _bendAxis;
  103625. private _slerping;
  103626. private _adjustRoll;
  103627. /**
  103628. * Gets or sets maximum allowed angle
  103629. */
  103630. maxAngle: number;
  103631. /**
  103632. * Creates a new BoneIKController
  103633. * @param mesh defines the mesh to control
  103634. * @param bone defines the bone to control
  103635. * @param options defines options to set up the controller
  103636. */
  103637. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103638. targetMesh?: AbstractMesh;
  103639. poleTargetMesh?: AbstractMesh;
  103640. poleTargetBone?: Bone;
  103641. poleTargetLocalOffset?: Vector3;
  103642. poleAngle?: number;
  103643. bendAxis?: Vector3;
  103644. maxAngle?: number;
  103645. slerpAmount?: number;
  103646. });
  103647. private _setMaxAngle;
  103648. /**
  103649. * Force the controller to update the bones
  103650. */
  103651. update(): void;
  103652. }
  103653. }
  103654. declare module BABYLON {
  103655. /**
  103656. * Class used to make a bone look toward a point in space
  103657. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  103658. */
  103659. export class BoneLookController {
  103660. private static _tmpVecs;
  103661. private static _tmpQuat;
  103662. private static _tmpMats;
  103663. /**
  103664. * The target Vector3 that the bone will look at
  103665. */
  103666. target: Vector3;
  103667. /**
  103668. * The mesh that the bone is attached to
  103669. */
  103670. mesh: AbstractMesh;
  103671. /**
  103672. * The bone that will be looking to the target
  103673. */
  103674. bone: Bone;
  103675. /**
  103676. * The up axis of the coordinate system that is used when the bone is rotated
  103677. */
  103678. upAxis: Vector3;
  103679. /**
  103680. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  103681. */
  103682. upAxisSpace: Space;
  103683. /**
  103684. * Used to make an adjustment to the yaw of the bone
  103685. */
  103686. adjustYaw: number;
  103687. /**
  103688. * Used to make an adjustment to the pitch of the bone
  103689. */
  103690. adjustPitch: number;
  103691. /**
  103692. * Used to make an adjustment to the roll of the bone
  103693. */
  103694. adjustRoll: number;
  103695. /**
  103696. * 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)
  103697. */
  103698. slerpAmount: number;
  103699. private _minYaw;
  103700. private _maxYaw;
  103701. private _minPitch;
  103702. private _maxPitch;
  103703. private _minYawSin;
  103704. private _minYawCos;
  103705. private _maxYawSin;
  103706. private _maxYawCos;
  103707. private _midYawConstraint;
  103708. private _minPitchTan;
  103709. private _maxPitchTan;
  103710. private _boneQuat;
  103711. private _slerping;
  103712. private _transformYawPitch;
  103713. private _transformYawPitchInv;
  103714. private _firstFrameSkipped;
  103715. private _yawRange;
  103716. private _fowardAxis;
  103717. /**
  103718. * Gets or sets the minimum yaw angle that the bone can look to
  103719. */
  103720. minYaw: number;
  103721. /**
  103722. * Gets or sets the maximum yaw angle that the bone can look to
  103723. */
  103724. maxYaw: number;
  103725. /**
  103726. * Gets or sets the minimum pitch angle that the bone can look to
  103727. */
  103728. minPitch: number;
  103729. /**
  103730. * Gets or sets the maximum pitch angle that the bone can look to
  103731. */
  103732. maxPitch: number;
  103733. /**
  103734. * Create a BoneLookController
  103735. * @param mesh the mesh that the bone belongs to
  103736. * @param bone the bone that will be looking to the target
  103737. * @param target the target Vector3 to look at
  103738. * @param options optional settings:
  103739. * * maxYaw: the maximum angle the bone will yaw to
  103740. * * minYaw: the minimum angle the bone will yaw to
  103741. * * maxPitch: the maximum angle the bone will pitch to
  103742. * * minPitch: the minimum angle the bone will yaw to
  103743. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  103744. * * upAxis: the up axis of the coordinate system
  103745. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  103746. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  103747. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  103748. * * adjustYaw: used to make an adjustment to the yaw of the bone
  103749. * * adjustPitch: used to make an adjustment to the pitch of the bone
  103750. * * adjustRoll: used to make an adjustment to the roll of the bone
  103751. **/
  103752. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  103753. maxYaw?: number;
  103754. minYaw?: number;
  103755. maxPitch?: number;
  103756. minPitch?: number;
  103757. slerpAmount?: number;
  103758. upAxis?: Vector3;
  103759. upAxisSpace?: Space;
  103760. yawAxis?: Vector3;
  103761. pitchAxis?: Vector3;
  103762. adjustYaw?: number;
  103763. adjustPitch?: number;
  103764. adjustRoll?: number;
  103765. });
  103766. /**
  103767. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  103768. */
  103769. update(): void;
  103770. private _getAngleDiff;
  103771. private _getAngleBetween;
  103772. private _isAngleBetween;
  103773. }
  103774. }
  103775. declare module BABYLON {
  103776. /**
  103777. * Manage the gamepad inputs to control an arc rotate camera.
  103778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103779. */
  103780. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103781. /**
  103782. * Defines the camera the input is attached to.
  103783. */
  103784. camera: ArcRotateCamera;
  103785. /**
  103786. * Defines the gamepad the input is gathering event from.
  103787. */
  103788. gamepad: Nullable<Gamepad>;
  103789. /**
  103790. * Defines the gamepad rotation sensiblity.
  103791. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103792. */
  103793. gamepadRotationSensibility: number;
  103794. /**
  103795. * Defines the gamepad move sensiblity.
  103796. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103797. */
  103798. gamepadMoveSensibility: number;
  103799. private _onGamepadConnectedObserver;
  103800. private _onGamepadDisconnectedObserver;
  103801. /**
  103802. * Attach the input controls to a specific dom element to get the input from.
  103803. * @param element Defines the element the controls should be listened from
  103804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103805. */
  103806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103807. /**
  103808. * Detach the current controls from the specified dom element.
  103809. * @param element Defines the element to stop listening the inputs from
  103810. */
  103811. detachControl(element: Nullable<HTMLElement>): void;
  103812. /**
  103813. * Update the current camera state depending on the inputs that have been used this frame.
  103814. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103815. */
  103816. checkInputs(): void;
  103817. /**
  103818. * Gets the class name of the current intput.
  103819. * @returns the class name
  103820. */
  103821. getClassName(): string;
  103822. /**
  103823. * Get the friendly name associated with the input class.
  103824. * @returns the input friendly name
  103825. */
  103826. getSimpleName(): string;
  103827. }
  103828. }
  103829. declare module BABYLON {
  103830. interface ArcRotateCameraInputsManager {
  103831. /**
  103832. * Add orientation input support to the input manager.
  103833. * @returns the current input manager
  103834. */
  103835. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103836. }
  103837. /**
  103838. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103840. */
  103841. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103842. /**
  103843. * Defines the camera the input is attached to.
  103844. */
  103845. camera: ArcRotateCamera;
  103846. /**
  103847. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103848. */
  103849. alphaCorrection: number;
  103850. /**
  103851. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103852. */
  103853. gammaCorrection: number;
  103854. private _alpha;
  103855. private _gamma;
  103856. private _dirty;
  103857. private _deviceOrientationHandler;
  103858. /**
  103859. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103860. */
  103861. constructor();
  103862. /**
  103863. * Attach the input controls to a specific dom element to get the input from.
  103864. * @param element Defines the element the controls should be listened from
  103865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103866. */
  103867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103868. /** @hidden */
  103869. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103870. /**
  103871. * Update the current camera state depending on the inputs that have been used this frame.
  103872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103873. */
  103874. checkInputs(): void;
  103875. /**
  103876. * Detach the current controls from the specified dom element.
  103877. * @param element Defines the element to stop listening the inputs from
  103878. */
  103879. detachControl(element: Nullable<HTMLElement>): void;
  103880. /**
  103881. * Gets the class name of the current intput.
  103882. * @returns the class name
  103883. */
  103884. getClassName(): string;
  103885. /**
  103886. * Get the friendly name associated with the input class.
  103887. * @returns the input friendly name
  103888. */
  103889. getSimpleName(): string;
  103890. }
  103891. }
  103892. declare module BABYLON {
  103893. /**
  103894. * Listen to mouse events to control the camera.
  103895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103896. */
  103897. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103898. /**
  103899. * Defines the camera the input is attached to.
  103900. */
  103901. camera: FlyCamera;
  103902. /**
  103903. * Defines if touch is enabled. (Default is true.)
  103904. */
  103905. touchEnabled: boolean;
  103906. /**
  103907. * Defines the buttons associated with the input to handle camera rotation.
  103908. */
  103909. buttons: number[];
  103910. /**
  103911. * Assign buttons for Yaw control.
  103912. */
  103913. buttonsYaw: number[];
  103914. /**
  103915. * Assign buttons for Pitch control.
  103916. */
  103917. buttonsPitch: number[];
  103918. /**
  103919. * Assign buttons for Roll control.
  103920. */
  103921. buttonsRoll: number[];
  103922. /**
  103923. * Detect if any button is being pressed while mouse is moved.
  103924. * -1 = Mouse locked.
  103925. * 0 = Left button.
  103926. * 1 = Middle Button.
  103927. * 2 = Right Button.
  103928. */
  103929. activeButton: number;
  103930. /**
  103931. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103932. * Higher values reduce its sensitivity.
  103933. */
  103934. angularSensibility: number;
  103935. private _mousemoveCallback;
  103936. private _observer;
  103937. private _rollObserver;
  103938. private previousPosition;
  103939. private noPreventDefault;
  103940. private element;
  103941. /**
  103942. * Listen to mouse events to control the camera.
  103943. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103945. */
  103946. constructor(touchEnabled?: boolean);
  103947. /**
  103948. * Attach the mouse control to the HTML DOM element.
  103949. * @param element Defines the element that listens to the input events.
  103950. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103951. */
  103952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103953. /**
  103954. * Detach the current controls from the specified dom element.
  103955. * @param element Defines the element to stop listening the inputs from
  103956. */
  103957. detachControl(element: Nullable<HTMLElement>): void;
  103958. /**
  103959. * Gets the class name of the current input.
  103960. * @returns the class name.
  103961. */
  103962. getClassName(): string;
  103963. /**
  103964. * Get the friendly name associated with the input class.
  103965. * @returns the input's friendly name.
  103966. */
  103967. getSimpleName(): string;
  103968. private _pointerInput;
  103969. private _onMouseMove;
  103970. /**
  103971. * Rotate camera by mouse offset.
  103972. */
  103973. private rotateCamera;
  103974. }
  103975. }
  103976. declare module BABYLON {
  103977. /**
  103978. * Default Inputs manager for the FlyCamera.
  103979. * It groups all the default supported inputs for ease of use.
  103980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103981. */
  103982. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103983. /**
  103984. * Instantiates a new FlyCameraInputsManager.
  103985. * @param camera Defines the camera the inputs belong to.
  103986. */
  103987. constructor(camera: FlyCamera);
  103988. /**
  103989. * Add keyboard input support to the input manager.
  103990. * @returns the new FlyCameraKeyboardMoveInput().
  103991. */
  103992. addKeyboard(): FlyCameraInputsManager;
  103993. /**
  103994. * Add mouse input support to the input manager.
  103995. * @param touchEnabled Enable touch screen support.
  103996. * @returns the new FlyCameraMouseInput().
  103997. */
  103998. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103999. }
  104000. }
  104001. declare module BABYLON {
  104002. /**
  104003. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104004. * such as in a 3D Space Shooter or a Flight Simulator.
  104005. */
  104006. export class FlyCamera extends TargetCamera {
  104007. /**
  104008. * Define the collision ellipsoid of the camera.
  104009. * This is helpful for simulating a camera body, like a player's body.
  104010. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104011. */
  104012. ellipsoid: Vector3;
  104013. /**
  104014. * Define an offset for the position of the ellipsoid around the camera.
  104015. * This can be helpful if the camera is attached away from the player's body center,
  104016. * such as at its head.
  104017. */
  104018. ellipsoidOffset: Vector3;
  104019. /**
  104020. * Enable or disable collisions of the camera with the rest of the scene objects.
  104021. */
  104022. checkCollisions: boolean;
  104023. /**
  104024. * Enable or disable gravity on the camera.
  104025. */
  104026. applyGravity: boolean;
  104027. /**
  104028. * Define the current direction the camera is moving to.
  104029. */
  104030. cameraDirection: Vector3;
  104031. /**
  104032. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104033. * This overrides and empties cameraRotation.
  104034. */
  104035. rotationQuaternion: Quaternion;
  104036. /**
  104037. * Track Roll to maintain the wanted Rolling when looking around.
  104038. */
  104039. _trackRoll: number;
  104040. /**
  104041. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104042. */
  104043. rollCorrect: number;
  104044. /**
  104045. * Mimic a banked turn, Rolling the camera when Yawing.
  104046. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104047. */
  104048. bankedTurn: boolean;
  104049. /**
  104050. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104051. */
  104052. bankedTurnLimit: number;
  104053. /**
  104054. * Value of 0 disables the banked Roll.
  104055. * Value of 1 is equal to the Yaw angle in radians.
  104056. */
  104057. bankedTurnMultiplier: number;
  104058. /**
  104059. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104060. */
  104061. inputs: FlyCameraInputsManager;
  104062. /**
  104063. * Gets the input sensibility for mouse input.
  104064. * Higher values reduce sensitivity.
  104065. */
  104066. /**
  104067. * Sets the input sensibility for a mouse input.
  104068. * Higher values reduce sensitivity.
  104069. */
  104070. angularSensibility: number;
  104071. /**
  104072. * Get the keys for camera movement forward.
  104073. */
  104074. /**
  104075. * Set the keys for camera movement forward.
  104076. */
  104077. keysForward: number[];
  104078. /**
  104079. * Get the keys for camera movement backward.
  104080. */
  104081. keysBackward: number[];
  104082. /**
  104083. * Get the keys for camera movement up.
  104084. */
  104085. /**
  104086. * Set the keys for camera movement up.
  104087. */
  104088. keysUp: number[];
  104089. /**
  104090. * Get the keys for camera movement down.
  104091. */
  104092. /**
  104093. * Set the keys for camera movement down.
  104094. */
  104095. keysDown: number[];
  104096. /**
  104097. * Get the keys for camera movement left.
  104098. */
  104099. /**
  104100. * Set the keys for camera movement left.
  104101. */
  104102. keysLeft: number[];
  104103. /**
  104104. * Set the keys for camera movement right.
  104105. */
  104106. /**
  104107. * Set the keys for camera movement right.
  104108. */
  104109. keysRight: number[];
  104110. /**
  104111. * Event raised when the camera collides with a mesh in the scene.
  104112. */
  104113. onCollide: (collidedMesh: AbstractMesh) => void;
  104114. private _collider;
  104115. private _needMoveForGravity;
  104116. private _oldPosition;
  104117. private _diffPosition;
  104118. private _newPosition;
  104119. /** @hidden */
  104120. _localDirection: Vector3;
  104121. /** @hidden */
  104122. _transformedDirection: Vector3;
  104123. /**
  104124. * Instantiates a FlyCamera.
  104125. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104126. * such as in a 3D Space Shooter or a Flight Simulator.
  104127. * @param name Define the name of the camera in the scene.
  104128. * @param position Define the starting position of the camera in the scene.
  104129. * @param scene Define the scene the camera belongs to.
  104130. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104131. */
  104132. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104133. /**
  104134. * Attach a control to the HTML DOM element.
  104135. * @param element Defines the element that listens to the input events.
  104136. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104137. */
  104138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104139. /**
  104140. * Detach a control from the HTML DOM element.
  104141. * The camera will stop reacting to that input.
  104142. * @param element Defines the element that listens to the input events.
  104143. */
  104144. detachControl(element: HTMLElement): void;
  104145. private _collisionMask;
  104146. /**
  104147. * Get the mask that the camera ignores in collision events.
  104148. */
  104149. /**
  104150. * Set the mask that the camera ignores in collision events.
  104151. */
  104152. collisionMask: number;
  104153. /** @hidden */
  104154. _collideWithWorld(displacement: Vector3): void;
  104155. /** @hidden */
  104156. private _onCollisionPositionChange;
  104157. /** @hidden */
  104158. _checkInputs(): void;
  104159. /** @hidden */
  104160. _decideIfNeedsToMove(): boolean;
  104161. /** @hidden */
  104162. _updatePosition(): void;
  104163. /**
  104164. * Restore the Roll to its target value at the rate specified.
  104165. * @param rate - Higher means slower restoring.
  104166. * @hidden
  104167. */
  104168. restoreRoll(rate: number): void;
  104169. /**
  104170. * Destroy the camera and release the current resources held by it.
  104171. */
  104172. dispose(): void;
  104173. /**
  104174. * Get the current object class name.
  104175. * @returns the class name.
  104176. */
  104177. getClassName(): string;
  104178. }
  104179. }
  104180. declare module BABYLON {
  104181. /**
  104182. * Listen to keyboard events to control the camera.
  104183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104184. */
  104185. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104186. /**
  104187. * Defines the camera the input is attached to.
  104188. */
  104189. camera: FlyCamera;
  104190. /**
  104191. * The list of keyboard keys used to control the forward move of the camera.
  104192. */
  104193. keysForward: number[];
  104194. /**
  104195. * The list of keyboard keys used to control the backward move of the camera.
  104196. */
  104197. keysBackward: number[];
  104198. /**
  104199. * The list of keyboard keys used to control the forward move of the camera.
  104200. */
  104201. keysUp: number[];
  104202. /**
  104203. * The list of keyboard keys used to control the backward move of the camera.
  104204. */
  104205. keysDown: number[];
  104206. /**
  104207. * The list of keyboard keys used to control the right strafe move of the camera.
  104208. */
  104209. keysRight: number[];
  104210. /**
  104211. * The list of keyboard keys used to control the left strafe move of the camera.
  104212. */
  104213. keysLeft: number[];
  104214. private _keys;
  104215. private _onCanvasBlurObserver;
  104216. private _onKeyboardObserver;
  104217. private _engine;
  104218. private _scene;
  104219. /**
  104220. * Attach the input controls to a specific dom element to get the input from.
  104221. * @param element Defines the element the controls should be listened from
  104222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104223. */
  104224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104225. /**
  104226. * Detach the current controls from the specified dom element.
  104227. * @param element Defines the element to stop listening the inputs from
  104228. */
  104229. detachControl(element: Nullable<HTMLElement>): void;
  104230. /**
  104231. * Gets the class name of the current intput.
  104232. * @returns the class name
  104233. */
  104234. getClassName(): string;
  104235. /** @hidden */
  104236. _onLostFocus(e: FocusEvent): void;
  104237. /**
  104238. * Get the friendly name associated with the input class.
  104239. * @returns the input friendly name
  104240. */
  104241. getSimpleName(): string;
  104242. /**
  104243. * Update the current camera state depending on the inputs that have been used this frame.
  104244. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104245. */
  104246. checkInputs(): void;
  104247. }
  104248. }
  104249. declare module BABYLON {
  104250. /**
  104251. * Manage the mouse wheel inputs to control a follow camera.
  104252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104253. */
  104254. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104255. /**
  104256. * Defines the camera the input is attached to.
  104257. */
  104258. camera: FollowCamera;
  104259. /**
  104260. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104261. */
  104262. axisControlRadius: boolean;
  104263. /**
  104264. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104265. */
  104266. axisControlHeight: boolean;
  104267. /**
  104268. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104269. */
  104270. axisControlRotation: boolean;
  104271. /**
  104272. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104273. * relation to mouseWheel events.
  104274. */
  104275. wheelPrecision: number;
  104276. /**
  104277. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104278. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104279. */
  104280. wheelDeltaPercentage: number;
  104281. private _wheel;
  104282. private _observer;
  104283. /**
  104284. * Attach the input controls to a specific dom element to get the input from.
  104285. * @param element Defines the element the controls should be listened from
  104286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104287. */
  104288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104289. /**
  104290. * Detach the current controls from the specified dom element.
  104291. * @param element Defines the element to stop listening the inputs from
  104292. */
  104293. detachControl(element: Nullable<HTMLElement>): void;
  104294. /**
  104295. * Gets the class name of the current intput.
  104296. * @returns the class name
  104297. */
  104298. getClassName(): string;
  104299. /**
  104300. * Get the friendly name associated with the input class.
  104301. * @returns the input friendly name
  104302. */
  104303. getSimpleName(): string;
  104304. }
  104305. }
  104306. declare module BABYLON {
  104307. /**
  104308. * Manage the pointers inputs to control an follow camera.
  104309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104310. */
  104311. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104312. /**
  104313. * Defines the camera the input is attached to.
  104314. */
  104315. camera: FollowCamera;
  104316. /**
  104317. * Gets the class name of the current input.
  104318. * @returns the class name
  104319. */
  104320. getClassName(): string;
  104321. /**
  104322. * Defines the pointer angular sensibility along the X axis or how fast is
  104323. * the camera rotating.
  104324. * A negative number will reverse the axis direction.
  104325. */
  104326. angularSensibilityX: number;
  104327. /**
  104328. * Defines the pointer angular sensibility along the Y axis or how fast is
  104329. * the camera rotating.
  104330. * A negative number will reverse the axis direction.
  104331. */
  104332. angularSensibilityY: number;
  104333. /**
  104334. * Defines the pointer pinch precision or how fast is the camera zooming.
  104335. * A negative number will reverse the axis direction.
  104336. */
  104337. pinchPrecision: number;
  104338. /**
  104339. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104340. * from 0.
  104341. * It defines the percentage of current camera.radius to use as delta when
  104342. * pinch zoom is used.
  104343. */
  104344. pinchDeltaPercentage: number;
  104345. /**
  104346. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104347. */
  104348. axisXControlRadius: boolean;
  104349. /**
  104350. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104351. */
  104352. axisXControlHeight: boolean;
  104353. /**
  104354. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104355. */
  104356. axisXControlRotation: boolean;
  104357. /**
  104358. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104359. */
  104360. axisYControlRadius: boolean;
  104361. /**
  104362. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104363. */
  104364. axisYControlHeight: boolean;
  104365. /**
  104366. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104367. */
  104368. axisYControlRotation: boolean;
  104369. /**
  104370. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104371. */
  104372. axisPinchControlRadius: boolean;
  104373. /**
  104374. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104375. */
  104376. axisPinchControlHeight: boolean;
  104377. /**
  104378. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104379. */
  104380. axisPinchControlRotation: boolean;
  104381. /**
  104382. * Log error messages if basic misconfiguration has occurred.
  104383. */
  104384. warningEnable: boolean;
  104385. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104386. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104387. private _warningCounter;
  104388. private _warning;
  104389. }
  104390. }
  104391. declare module BABYLON {
  104392. /**
  104393. * Default Inputs manager for the FollowCamera.
  104394. * It groups all the default supported inputs for ease of use.
  104395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104396. */
  104397. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104398. /**
  104399. * Instantiates a new FollowCameraInputsManager.
  104400. * @param camera Defines the camera the inputs belong to
  104401. */
  104402. constructor(camera: FollowCamera);
  104403. /**
  104404. * Add keyboard input support to the input manager.
  104405. * @returns the current input manager
  104406. */
  104407. addKeyboard(): FollowCameraInputsManager;
  104408. /**
  104409. * Add mouse wheel input support to the input manager.
  104410. * @returns the current input manager
  104411. */
  104412. addMouseWheel(): FollowCameraInputsManager;
  104413. /**
  104414. * Add pointers input support to the input manager.
  104415. * @returns the current input manager
  104416. */
  104417. addPointers(): FollowCameraInputsManager;
  104418. /**
  104419. * Add orientation input support to the input manager.
  104420. * @returns the current input manager
  104421. */
  104422. addVRDeviceOrientation(): FollowCameraInputsManager;
  104423. }
  104424. }
  104425. declare module BABYLON {
  104426. /**
  104427. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104428. * an arc rotate version arcFollowCamera are available.
  104429. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104430. */
  104431. export class FollowCamera extends TargetCamera {
  104432. /**
  104433. * Distance the follow camera should follow an object at
  104434. */
  104435. radius: number;
  104436. /**
  104437. * Minimum allowed distance of the camera to the axis of rotation
  104438. * (The camera can not get closer).
  104439. * This can help limiting how the Camera is able to move in the scene.
  104440. */
  104441. lowerRadiusLimit: Nullable<number>;
  104442. /**
  104443. * Maximum allowed distance of the camera to the axis of rotation
  104444. * (The camera can not get further).
  104445. * This can help limiting how the Camera is able to move in the scene.
  104446. */
  104447. upperRadiusLimit: Nullable<number>;
  104448. /**
  104449. * Define a rotation offset between the camera and the object it follows
  104450. */
  104451. rotationOffset: number;
  104452. /**
  104453. * Minimum allowed angle to camera position relative to target object.
  104454. * This can help limiting how the Camera is able to move in the scene.
  104455. */
  104456. lowerRotationOffsetLimit: Nullable<number>;
  104457. /**
  104458. * Maximum allowed angle to camera position relative to target object.
  104459. * This can help limiting how the Camera is able to move in the scene.
  104460. */
  104461. upperRotationOffsetLimit: Nullable<number>;
  104462. /**
  104463. * Define a height offset between the camera and the object it follows.
  104464. * It can help following an object from the top (like a car chaing a plane)
  104465. */
  104466. heightOffset: number;
  104467. /**
  104468. * Minimum allowed height of camera position relative to target object.
  104469. * This can help limiting how the Camera is able to move in the scene.
  104470. */
  104471. lowerHeightOffsetLimit: Nullable<number>;
  104472. /**
  104473. * Maximum allowed height of camera position relative to target object.
  104474. * This can help limiting how the Camera is able to move in the scene.
  104475. */
  104476. upperHeightOffsetLimit: Nullable<number>;
  104477. /**
  104478. * Define how fast the camera can accelerate to follow it s target.
  104479. */
  104480. cameraAcceleration: number;
  104481. /**
  104482. * Define the speed limit of the camera following an object.
  104483. */
  104484. maxCameraSpeed: number;
  104485. /**
  104486. * Define the target of the camera.
  104487. */
  104488. lockedTarget: Nullable<AbstractMesh>;
  104489. /**
  104490. * Defines the input associated with the camera.
  104491. */
  104492. inputs: FollowCameraInputsManager;
  104493. /**
  104494. * Instantiates the follow camera.
  104495. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104496. * @param name Define the name of the camera in the scene
  104497. * @param position Define the position of the camera
  104498. * @param scene Define the scene the camera belong to
  104499. * @param lockedTarget Define the target of the camera
  104500. */
  104501. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104502. private _follow;
  104503. /**
  104504. * Attached controls to the current camera.
  104505. * @param element Defines the element the controls should be listened from
  104506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104507. */
  104508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104509. /**
  104510. * Detach the current controls from the camera.
  104511. * The camera will stop reacting to inputs.
  104512. * @param element Defines the element to stop listening the inputs from
  104513. */
  104514. detachControl(element: HTMLElement): void;
  104515. /** @hidden */
  104516. _checkInputs(): void;
  104517. private _checkLimits;
  104518. /**
  104519. * Gets the camera class name.
  104520. * @returns the class name
  104521. */
  104522. getClassName(): string;
  104523. }
  104524. /**
  104525. * Arc Rotate version of the follow camera.
  104526. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104527. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104528. */
  104529. export class ArcFollowCamera extends TargetCamera {
  104530. /** The longitudinal angle of the camera */
  104531. alpha: number;
  104532. /** The latitudinal angle of the camera */
  104533. beta: number;
  104534. /** The radius of the camera from its target */
  104535. radius: number;
  104536. /** Define the camera target (the messh it should follow) */
  104537. target: Nullable<AbstractMesh>;
  104538. private _cartesianCoordinates;
  104539. /**
  104540. * Instantiates a new ArcFollowCamera
  104541. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104542. * @param name Define the name of the camera
  104543. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104544. * @param beta Define the rotation angle of the camera around the elevation axis
  104545. * @param radius Define the radius of the camera from its target point
  104546. * @param target Define the target of the camera
  104547. * @param scene Define the scene the camera belongs to
  104548. */
  104549. constructor(name: string,
  104550. /** The longitudinal angle of the camera */
  104551. alpha: number,
  104552. /** The latitudinal angle of the camera */
  104553. beta: number,
  104554. /** The radius of the camera from its target */
  104555. radius: number,
  104556. /** Define the camera target (the messh it should follow) */
  104557. target: Nullable<AbstractMesh>, scene: Scene);
  104558. private _follow;
  104559. /** @hidden */
  104560. _checkInputs(): void;
  104561. /**
  104562. * Returns the class name of the object.
  104563. * It is mostly used internally for serialization purposes.
  104564. */
  104565. getClassName(): string;
  104566. }
  104567. }
  104568. declare module BABYLON {
  104569. /**
  104570. * Manage the keyboard inputs to control the movement of a follow camera.
  104571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104572. */
  104573. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104574. /**
  104575. * Defines the camera the input is attached to.
  104576. */
  104577. camera: FollowCamera;
  104578. /**
  104579. * Defines the list of key codes associated with the up action (increase heightOffset)
  104580. */
  104581. keysHeightOffsetIncr: number[];
  104582. /**
  104583. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104584. */
  104585. keysHeightOffsetDecr: number[];
  104586. /**
  104587. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104588. */
  104589. keysHeightOffsetModifierAlt: boolean;
  104590. /**
  104591. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104592. */
  104593. keysHeightOffsetModifierCtrl: boolean;
  104594. /**
  104595. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104596. */
  104597. keysHeightOffsetModifierShift: boolean;
  104598. /**
  104599. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104600. */
  104601. keysRotationOffsetIncr: number[];
  104602. /**
  104603. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104604. */
  104605. keysRotationOffsetDecr: number[];
  104606. /**
  104607. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104608. */
  104609. keysRotationOffsetModifierAlt: boolean;
  104610. /**
  104611. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104612. */
  104613. keysRotationOffsetModifierCtrl: boolean;
  104614. /**
  104615. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104616. */
  104617. keysRotationOffsetModifierShift: boolean;
  104618. /**
  104619. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104620. */
  104621. keysRadiusIncr: number[];
  104622. /**
  104623. * Defines the list of key codes associated with the zoom-out action (increase radius)
  104624. */
  104625. keysRadiusDecr: number[];
  104626. /**
  104627. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  104628. */
  104629. keysRadiusModifierAlt: boolean;
  104630. /**
  104631. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  104632. */
  104633. keysRadiusModifierCtrl: boolean;
  104634. /**
  104635. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  104636. */
  104637. keysRadiusModifierShift: boolean;
  104638. /**
  104639. * Defines the rate of change of heightOffset.
  104640. */
  104641. heightSensibility: number;
  104642. /**
  104643. * Defines the rate of change of rotationOffset.
  104644. */
  104645. rotationSensibility: number;
  104646. /**
  104647. * Defines the rate of change of radius.
  104648. */
  104649. radiusSensibility: number;
  104650. private _keys;
  104651. private _ctrlPressed;
  104652. private _altPressed;
  104653. private _shiftPressed;
  104654. private _onCanvasBlurObserver;
  104655. private _onKeyboardObserver;
  104656. private _engine;
  104657. private _scene;
  104658. /**
  104659. * Attach the input controls to a specific dom element to get the input from.
  104660. * @param element Defines the element the controls should be listened from
  104661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104662. */
  104663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104664. /**
  104665. * Detach the current controls from the specified dom element.
  104666. * @param element Defines the element to stop listening the inputs from
  104667. */
  104668. detachControl(element: Nullable<HTMLElement>): void;
  104669. /**
  104670. * Update the current camera state depending on the inputs that have been used this frame.
  104671. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104672. */
  104673. checkInputs(): void;
  104674. /**
  104675. * Gets the class name of the current input.
  104676. * @returns the class name
  104677. */
  104678. getClassName(): string;
  104679. /**
  104680. * Get the friendly name associated with the input class.
  104681. * @returns the input friendly name
  104682. */
  104683. getSimpleName(): string;
  104684. /**
  104685. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104686. * allow modification of the heightOffset value.
  104687. */
  104688. private _modifierHeightOffset;
  104689. /**
  104690. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104691. * allow modification of the rotationOffset value.
  104692. */
  104693. private _modifierRotationOffset;
  104694. /**
  104695. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104696. * allow modification of the radius value.
  104697. */
  104698. private _modifierRadius;
  104699. }
  104700. }
  104701. declare module BABYLON {
  104702. interface FreeCameraInputsManager {
  104703. /**
  104704. * @hidden
  104705. */
  104706. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  104707. /**
  104708. * Add orientation input support to the input manager.
  104709. * @returns the current input manager
  104710. */
  104711. addDeviceOrientation(): FreeCameraInputsManager;
  104712. }
  104713. /**
  104714. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  104715. * Screen rotation is taken into account.
  104716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104717. */
  104718. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  104719. private _camera;
  104720. private _screenOrientationAngle;
  104721. private _constantTranform;
  104722. private _screenQuaternion;
  104723. private _alpha;
  104724. private _beta;
  104725. private _gamma;
  104726. /**
  104727. * Can be used to detect if a device orientation sensor is availible on a device
  104728. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  104729. * @returns a promise that will resolve on orientation change
  104730. */
  104731. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  104732. /**
  104733. * @hidden
  104734. */
  104735. _onDeviceOrientationChangedObservable: Observable<void>;
  104736. /**
  104737. * Instantiates a new input
  104738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104739. */
  104740. constructor();
  104741. /**
  104742. * Define the camera controlled by the input.
  104743. */
  104744. camera: FreeCamera;
  104745. /**
  104746. * Attach the input controls to a specific dom element to get the input from.
  104747. * @param element Defines the element the controls should be listened from
  104748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104749. */
  104750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104751. private _orientationChanged;
  104752. private _deviceOrientation;
  104753. /**
  104754. * Detach the current controls from the specified dom element.
  104755. * @param element Defines the element to stop listening the inputs from
  104756. */
  104757. detachControl(element: Nullable<HTMLElement>): void;
  104758. /**
  104759. * Update the current camera state depending on the inputs that have been used this frame.
  104760. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104761. */
  104762. checkInputs(): void;
  104763. /**
  104764. * Gets the class name of the current intput.
  104765. * @returns the class name
  104766. */
  104767. getClassName(): string;
  104768. /**
  104769. * Get the friendly name associated with the input class.
  104770. * @returns the input friendly name
  104771. */
  104772. getSimpleName(): string;
  104773. }
  104774. }
  104775. declare module BABYLON {
  104776. /**
  104777. * Manage the gamepad inputs to control a free camera.
  104778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104779. */
  104780. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104781. /**
  104782. * Define the camera the input is attached to.
  104783. */
  104784. camera: FreeCamera;
  104785. /**
  104786. * Define the Gamepad controlling the input
  104787. */
  104788. gamepad: Nullable<Gamepad>;
  104789. /**
  104790. * Defines the gamepad rotation sensiblity.
  104791. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104792. */
  104793. gamepadAngularSensibility: number;
  104794. /**
  104795. * Defines the gamepad move sensiblity.
  104796. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104797. */
  104798. gamepadMoveSensibility: number;
  104799. private _onGamepadConnectedObserver;
  104800. private _onGamepadDisconnectedObserver;
  104801. private _cameraTransform;
  104802. private _deltaTransform;
  104803. private _vector3;
  104804. private _vector2;
  104805. /**
  104806. * Attach the input controls to a specific dom element to get the input from.
  104807. * @param element Defines the element the controls should be listened from
  104808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104809. */
  104810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104811. /**
  104812. * Detach the current controls from the specified dom element.
  104813. * @param element Defines the element to stop listening the inputs from
  104814. */
  104815. detachControl(element: Nullable<HTMLElement>): void;
  104816. /**
  104817. * Update the current camera state depending on the inputs that have been used this frame.
  104818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104819. */
  104820. checkInputs(): void;
  104821. /**
  104822. * Gets the class name of the current intput.
  104823. * @returns the class name
  104824. */
  104825. getClassName(): string;
  104826. /**
  104827. * Get the friendly name associated with the input class.
  104828. * @returns the input friendly name
  104829. */
  104830. getSimpleName(): string;
  104831. }
  104832. }
  104833. declare module BABYLON {
  104834. /**
  104835. * Defines the potential axis of a Joystick
  104836. */
  104837. export enum JoystickAxis {
  104838. /** X axis */
  104839. X = 0,
  104840. /** Y axis */
  104841. Y = 1,
  104842. /** Z axis */
  104843. Z = 2
  104844. }
  104845. /**
  104846. * Class used to define virtual joystick (used in touch mode)
  104847. */
  104848. export class VirtualJoystick {
  104849. /**
  104850. * Gets or sets a boolean indicating that left and right values must be inverted
  104851. */
  104852. reverseLeftRight: boolean;
  104853. /**
  104854. * Gets or sets a boolean indicating that up and down values must be inverted
  104855. */
  104856. reverseUpDown: boolean;
  104857. /**
  104858. * Gets the offset value for the position (ie. the change of the position value)
  104859. */
  104860. deltaPosition: Vector3;
  104861. /**
  104862. * Gets a boolean indicating if the virtual joystick was pressed
  104863. */
  104864. pressed: boolean;
  104865. /**
  104866. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104867. */
  104868. static Canvas: Nullable<HTMLCanvasElement>;
  104869. private static _globalJoystickIndex;
  104870. private static vjCanvasContext;
  104871. private static vjCanvasWidth;
  104872. private static vjCanvasHeight;
  104873. private static halfWidth;
  104874. private _action;
  104875. private _axisTargetedByLeftAndRight;
  104876. private _axisTargetedByUpAndDown;
  104877. private _joystickSensibility;
  104878. private _inversedSensibility;
  104879. private _joystickPointerID;
  104880. private _joystickColor;
  104881. private _joystickPointerPos;
  104882. private _joystickPreviousPointerPos;
  104883. private _joystickPointerStartPos;
  104884. private _deltaJoystickVector;
  104885. private _leftJoystick;
  104886. private _touches;
  104887. private _onPointerDownHandlerRef;
  104888. private _onPointerMoveHandlerRef;
  104889. private _onPointerUpHandlerRef;
  104890. private _onResize;
  104891. /**
  104892. * Creates a new virtual joystick
  104893. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104894. */
  104895. constructor(leftJoystick?: boolean);
  104896. /**
  104897. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104898. * @param newJoystickSensibility defines the new sensibility
  104899. */
  104900. setJoystickSensibility(newJoystickSensibility: number): void;
  104901. private _onPointerDown;
  104902. private _onPointerMove;
  104903. private _onPointerUp;
  104904. /**
  104905. * Change the color of the virtual joystick
  104906. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104907. */
  104908. setJoystickColor(newColor: string): void;
  104909. /**
  104910. * Defines a callback to call when the joystick is touched
  104911. * @param action defines the callback
  104912. */
  104913. setActionOnTouch(action: () => any): void;
  104914. /**
  104915. * Defines which axis you'd like to control for left & right
  104916. * @param axis defines the axis to use
  104917. */
  104918. setAxisForLeftRight(axis: JoystickAxis): void;
  104919. /**
  104920. * Defines which axis you'd like to control for up & down
  104921. * @param axis defines the axis to use
  104922. */
  104923. setAxisForUpDown(axis: JoystickAxis): void;
  104924. private _drawVirtualJoystick;
  104925. /**
  104926. * Release internal HTML canvas
  104927. */
  104928. releaseCanvas(): void;
  104929. }
  104930. }
  104931. declare module BABYLON {
  104932. interface FreeCameraInputsManager {
  104933. /**
  104934. * Add virtual joystick input support to the input manager.
  104935. * @returns the current input manager
  104936. */
  104937. addVirtualJoystick(): FreeCameraInputsManager;
  104938. }
  104939. /**
  104940. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104942. */
  104943. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104944. /**
  104945. * Defines the camera the input is attached to.
  104946. */
  104947. camera: FreeCamera;
  104948. private _leftjoystick;
  104949. private _rightjoystick;
  104950. /**
  104951. * Gets the left stick of the virtual joystick.
  104952. * @returns The virtual Joystick
  104953. */
  104954. getLeftJoystick(): VirtualJoystick;
  104955. /**
  104956. * Gets the right stick of the virtual joystick.
  104957. * @returns The virtual Joystick
  104958. */
  104959. getRightJoystick(): VirtualJoystick;
  104960. /**
  104961. * Update the current camera state depending on the inputs that have been used this frame.
  104962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104963. */
  104964. checkInputs(): void;
  104965. /**
  104966. * Attach the input controls to a specific dom element to get the input from.
  104967. * @param element Defines the element the controls should be listened from
  104968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104969. */
  104970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104971. /**
  104972. * Detach the current controls from the specified dom element.
  104973. * @param element Defines the element to stop listening the inputs from
  104974. */
  104975. detachControl(element: Nullable<HTMLElement>): void;
  104976. /**
  104977. * Gets the class name of the current intput.
  104978. * @returns the class name
  104979. */
  104980. getClassName(): string;
  104981. /**
  104982. * Get the friendly name associated with the input class.
  104983. * @returns the input friendly name
  104984. */
  104985. getSimpleName(): string;
  104986. }
  104987. }
  104988. declare module BABYLON {
  104989. /**
  104990. * This represents a FPS type of camera controlled by touch.
  104991. * This is like a universal camera minus the Gamepad controls.
  104992. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104993. */
  104994. export class TouchCamera extends FreeCamera {
  104995. /**
  104996. * Defines the touch sensibility for rotation.
  104997. * The higher the faster.
  104998. */
  104999. touchAngularSensibility: number;
  105000. /**
  105001. * Defines the touch sensibility for move.
  105002. * The higher the faster.
  105003. */
  105004. touchMoveSensibility: number;
  105005. /**
  105006. * Instantiates a new touch camera.
  105007. * This represents a FPS type of camera controlled by touch.
  105008. * This is like a universal camera minus the Gamepad controls.
  105009. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105010. * @param name Define the name of the camera in the scene
  105011. * @param position Define the start position of the camera in the scene
  105012. * @param scene Define the scene the camera belongs to
  105013. */
  105014. constructor(name: string, position: Vector3, scene: Scene);
  105015. /**
  105016. * Gets the current object class name.
  105017. * @return the class name
  105018. */
  105019. getClassName(): string;
  105020. /** @hidden */
  105021. _setupInputs(): void;
  105022. }
  105023. }
  105024. declare module BABYLON {
  105025. /**
  105026. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105027. * being tilted forward or back and left or right.
  105028. */
  105029. export class DeviceOrientationCamera extends FreeCamera {
  105030. private _initialQuaternion;
  105031. private _quaternionCache;
  105032. private _tmpDragQuaternion;
  105033. private _disablePointerInputWhenUsingDeviceOrientation;
  105034. /**
  105035. * Creates a new device orientation camera
  105036. * @param name The name of the camera
  105037. * @param position The start position camera
  105038. * @param scene The scene the camera belongs to
  105039. */
  105040. constructor(name: string, position: Vector3, scene: Scene);
  105041. /**
  105042. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105043. */
  105044. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105045. private _dragFactor;
  105046. /**
  105047. * Enabled turning on the y axis when the orientation sensor is active
  105048. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105049. */
  105050. enableHorizontalDragging(dragFactor?: number): void;
  105051. /**
  105052. * Gets the current instance class name ("DeviceOrientationCamera").
  105053. * This helps avoiding instanceof at run time.
  105054. * @returns the class name
  105055. */
  105056. getClassName(): string;
  105057. /**
  105058. * @hidden
  105059. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105060. */
  105061. _checkInputs(): void;
  105062. /**
  105063. * Reset the camera to its default orientation on the specified axis only.
  105064. * @param axis The axis to reset
  105065. */
  105066. resetToCurrentRotation(axis?: Axis): void;
  105067. }
  105068. }
  105069. declare module BABYLON {
  105070. /**
  105071. * Defines supported buttons for XBox360 compatible gamepads
  105072. */
  105073. export enum Xbox360Button {
  105074. /** A */
  105075. A = 0,
  105076. /** B */
  105077. B = 1,
  105078. /** X */
  105079. X = 2,
  105080. /** Y */
  105081. Y = 3,
  105082. /** Start */
  105083. Start = 4,
  105084. /** Back */
  105085. Back = 5,
  105086. /** Left button */
  105087. LB = 6,
  105088. /** Right button */
  105089. RB = 7,
  105090. /** Left stick */
  105091. LeftStick = 8,
  105092. /** Right stick */
  105093. RightStick = 9
  105094. }
  105095. /** Defines values for XBox360 DPad */
  105096. export enum Xbox360Dpad {
  105097. /** Up */
  105098. Up = 0,
  105099. /** Down */
  105100. Down = 1,
  105101. /** Left */
  105102. Left = 2,
  105103. /** Right */
  105104. Right = 3
  105105. }
  105106. /**
  105107. * Defines a XBox360 gamepad
  105108. */
  105109. export class Xbox360Pad extends Gamepad {
  105110. private _leftTrigger;
  105111. private _rightTrigger;
  105112. private _onlefttriggerchanged;
  105113. private _onrighttriggerchanged;
  105114. private _onbuttondown;
  105115. private _onbuttonup;
  105116. private _ondpaddown;
  105117. private _ondpadup;
  105118. /** Observable raised when a button is pressed */
  105119. onButtonDownObservable: Observable<Xbox360Button>;
  105120. /** Observable raised when a button is released */
  105121. onButtonUpObservable: Observable<Xbox360Button>;
  105122. /** Observable raised when a pad is pressed */
  105123. onPadDownObservable: Observable<Xbox360Dpad>;
  105124. /** Observable raised when a pad is released */
  105125. onPadUpObservable: Observable<Xbox360Dpad>;
  105126. private _buttonA;
  105127. private _buttonB;
  105128. private _buttonX;
  105129. private _buttonY;
  105130. private _buttonBack;
  105131. private _buttonStart;
  105132. private _buttonLB;
  105133. private _buttonRB;
  105134. private _buttonLeftStick;
  105135. private _buttonRightStick;
  105136. private _dPadUp;
  105137. private _dPadDown;
  105138. private _dPadLeft;
  105139. private _dPadRight;
  105140. private _isXboxOnePad;
  105141. /**
  105142. * Creates a new XBox360 gamepad object
  105143. * @param id defines the id of this gamepad
  105144. * @param index defines its index
  105145. * @param gamepad defines the internal HTML gamepad object
  105146. * @param xboxOne defines if it is a XBox One gamepad
  105147. */
  105148. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105149. /**
  105150. * Defines the callback to call when left trigger is pressed
  105151. * @param callback defines the callback to use
  105152. */
  105153. onlefttriggerchanged(callback: (value: number) => void): void;
  105154. /**
  105155. * Defines the callback to call when right trigger is pressed
  105156. * @param callback defines the callback to use
  105157. */
  105158. onrighttriggerchanged(callback: (value: number) => void): void;
  105159. /**
  105160. * Gets the left trigger value
  105161. */
  105162. /**
  105163. * Sets the left trigger value
  105164. */
  105165. leftTrigger: number;
  105166. /**
  105167. * Gets the right trigger value
  105168. */
  105169. /**
  105170. * Sets the right trigger value
  105171. */
  105172. rightTrigger: number;
  105173. /**
  105174. * Defines the callback to call when a button is pressed
  105175. * @param callback defines the callback to use
  105176. */
  105177. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105178. /**
  105179. * Defines the callback to call when a button is released
  105180. * @param callback defines the callback to use
  105181. */
  105182. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105183. /**
  105184. * Defines the callback to call when a pad is pressed
  105185. * @param callback defines the callback to use
  105186. */
  105187. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105188. /**
  105189. * Defines the callback to call when a pad is released
  105190. * @param callback defines the callback to use
  105191. */
  105192. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105193. private _setButtonValue;
  105194. private _setDPadValue;
  105195. /**
  105196. * Gets the value of the `A` button
  105197. */
  105198. /**
  105199. * Sets the value of the `A` button
  105200. */
  105201. buttonA: number;
  105202. /**
  105203. * Gets the value of the `B` button
  105204. */
  105205. /**
  105206. * Sets the value of the `B` button
  105207. */
  105208. buttonB: number;
  105209. /**
  105210. * Gets the value of the `X` button
  105211. */
  105212. /**
  105213. * Sets the value of the `X` button
  105214. */
  105215. buttonX: number;
  105216. /**
  105217. * Gets the value of the `Y` button
  105218. */
  105219. /**
  105220. * Sets the value of the `Y` button
  105221. */
  105222. buttonY: number;
  105223. /**
  105224. * Gets the value of the `Start` button
  105225. */
  105226. /**
  105227. * Sets the value of the `Start` button
  105228. */
  105229. buttonStart: number;
  105230. /**
  105231. * Gets the value of the `Back` button
  105232. */
  105233. /**
  105234. * Sets the value of the `Back` button
  105235. */
  105236. buttonBack: number;
  105237. /**
  105238. * Gets the value of the `Left` button
  105239. */
  105240. /**
  105241. * Sets the value of the `Left` button
  105242. */
  105243. buttonLB: number;
  105244. /**
  105245. * Gets the value of the `Right` button
  105246. */
  105247. /**
  105248. * Sets the value of the `Right` button
  105249. */
  105250. buttonRB: number;
  105251. /**
  105252. * Gets the value of the Left joystick
  105253. */
  105254. /**
  105255. * Sets the value of the Left joystick
  105256. */
  105257. buttonLeftStick: number;
  105258. /**
  105259. * Gets the value of the Right joystick
  105260. */
  105261. /**
  105262. * Sets the value of the Right joystick
  105263. */
  105264. buttonRightStick: number;
  105265. /**
  105266. * Gets the value of D-pad up
  105267. */
  105268. /**
  105269. * Sets the value of D-pad up
  105270. */
  105271. dPadUp: number;
  105272. /**
  105273. * Gets the value of D-pad down
  105274. */
  105275. /**
  105276. * Sets the value of D-pad down
  105277. */
  105278. dPadDown: number;
  105279. /**
  105280. * Gets the value of D-pad left
  105281. */
  105282. /**
  105283. * Sets the value of D-pad left
  105284. */
  105285. dPadLeft: number;
  105286. /**
  105287. * Gets the value of D-pad right
  105288. */
  105289. /**
  105290. * Sets the value of D-pad right
  105291. */
  105292. dPadRight: number;
  105293. /**
  105294. * Force the gamepad to synchronize with device values
  105295. */
  105296. update(): void;
  105297. /**
  105298. * Disposes the gamepad
  105299. */
  105300. dispose(): void;
  105301. }
  105302. }
  105303. declare module BABYLON {
  105304. /**
  105305. * Defines supported buttons for DualShock compatible gamepads
  105306. */
  105307. export enum DualShockButton {
  105308. /** Cross */
  105309. Cross = 0,
  105310. /** Circle */
  105311. Circle = 1,
  105312. /** Square */
  105313. Square = 2,
  105314. /** Triangle */
  105315. Triangle = 3,
  105316. /** Options */
  105317. Options = 4,
  105318. /** Share */
  105319. Share = 5,
  105320. /** L1 */
  105321. L1 = 6,
  105322. /** R1 */
  105323. R1 = 7,
  105324. /** Left stick */
  105325. LeftStick = 8,
  105326. /** Right stick */
  105327. RightStick = 9
  105328. }
  105329. /** Defines values for DualShock DPad */
  105330. export enum DualShockDpad {
  105331. /** Up */
  105332. Up = 0,
  105333. /** Down */
  105334. Down = 1,
  105335. /** Left */
  105336. Left = 2,
  105337. /** Right */
  105338. Right = 3
  105339. }
  105340. /**
  105341. * Defines a DualShock gamepad
  105342. */
  105343. export class DualShockPad extends Gamepad {
  105344. private _leftTrigger;
  105345. private _rightTrigger;
  105346. private _onlefttriggerchanged;
  105347. private _onrighttriggerchanged;
  105348. private _onbuttondown;
  105349. private _onbuttonup;
  105350. private _ondpaddown;
  105351. private _ondpadup;
  105352. /** Observable raised when a button is pressed */
  105353. onButtonDownObservable: Observable<DualShockButton>;
  105354. /** Observable raised when a button is released */
  105355. onButtonUpObservable: Observable<DualShockButton>;
  105356. /** Observable raised when a pad is pressed */
  105357. onPadDownObservable: Observable<DualShockDpad>;
  105358. /** Observable raised when a pad is released */
  105359. onPadUpObservable: Observable<DualShockDpad>;
  105360. private _buttonCross;
  105361. private _buttonCircle;
  105362. private _buttonSquare;
  105363. private _buttonTriangle;
  105364. private _buttonShare;
  105365. private _buttonOptions;
  105366. private _buttonL1;
  105367. private _buttonR1;
  105368. private _buttonLeftStick;
  105369. private _buttonRightStick;
  105370. private _dPadUp;
  105371. private _dPadDown;
  105372. private _dPadLeft;
  105373. private _dPadRight;
  105374. /**
  105375. * Creates a new DualShock gamepad object
  105376. * @param id defines the id of this gamepad
  105377. * @param index defines its index
  105378. * @param gamepad defines the internal HTML gamepad object
  105379. */
  105380. constructor(id: string, index: number, gamepad: any);
  105381. /**
  105382. * Defines the callback to call when left trigger is pressed
  105383. * @param callback defines the callback to use
  105384. */
  105385. onlefttriggerchanged(callback: (value: number) => void): void;
  105386. /**
  105387. * Defines the callback to call when right trigger is pressed
  105388. * @param callback defines the callback to use
  105389. */
  105390. onrighttriggerchanged(callback: (value: number) => void): void;
  105391. /**
  105392. * Gets the left trigger value
  105393. */
  105394. /**
  105395. * Sets the left trigger value
  105396. */
  105397. leftTrigger: number;
  105398. /**
  105399. * Gets the right trigger value
  105400. */
  105401. /**
  105402. * Sets the right trigger value
  105403. */
  105404. rightTrigger: number;
  105405. /**
  105406. * Defines the callback to call when a button is pressed
  105407. * @param callback defines the callback to use
  105408. */
  105409. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105410. /**
  105411. * Defines the callback to call when a button is released
  105412. * @param callback defines the callback to use
  105413. */
  105414. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105415. /**
  105416. * Defines the callback to call when a pad is pressed
  105417. * @param callback defines the callback to use
  105418. */
  105419. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105420. /**
  105421. * Defines the callback to call when a pad is released
  105422. * @param callback defines the callback to use
  105423. */
  105424. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105425. private _setButtonValue;
  105426. private _setDPadValue;
  105427. /**
  105428. * Gets the value of the `Cross` button
  105429. */
  105430. /**
  105431. * Sets the value of the `Cross` button
  105432. */
  105433. buttonCross: number;
  105434. /**
  105435. * Gets the value of the `Circle` button
  105436. */
  105437. /**
  105438. * Sets the value of the `Circle` button
  105439. */
  105440. buttonCircle: number;
  105441. /**
  105442. * Gets the value of the `Square` button
  105443. */
  105444. /**
  105445. * Sets the value of the `Square` button
  105446. */
  105447. buttonSquare: number;
  105448. /**
  105449. * Gets the value of the `Triangle` button
  105450. */
  105451. /**
  105452. * Sets the value of the `Triangle` button
  105453. */
  105454. buttonTriangle: number;
  105455. /**
  105456. * Gets the value of the `Options` button
  105457. */
  105458. /**
  105459. * Sets the value of the `Options` button
  105460. */
  105461. buttonOptions: number;
  105462. /**
  105463. * Gets the value of the `Share` button
  105464. */
  105465. /**
  105466. * Sets the value of the `Share` button
  105467. */
  105468. buttonShare: number;
  105469. /**
  105470. * Gets the value of the `L1` button
  105471. */
  105472. /**
  105473. * Sets the value of the `L1` button
  105474. */
  105475. buttonL1: number;
  105476. /**
  105477. * Gets the value of the `R1` button
  105478. */
  105479. /**
  105480. * Sets the value of the `R1` button
  105481. */
  105482. buttonR1: number;
  105483. /**
  105484. * Gets the value of the Left joystick
  105485. */
  105486. /**
  105487. * Sets the value of the Left joystick
  105488. */
  105489. buttonLeftStick: number;
  105490. /**
  105491. * Gets the value of the Right joystick
  105492. */
  105493. /**
  105494. * Sets the value of the Right joystick
  105495. */
  105496. buttonRightStick: number;
  105497. /**
  105498. * Gets the value of D-pad up
  105499. */
  105500. /**
  105501. * Sets the value of D-pad up
  105502. */
  105503. dPadUp: number;
  105504. /**
  105505. * Gets the value of D-pad down
  105506. */
  105507. /**
  105508. * Sets the value of D-pad down
  105509. */
  105510. dPadDown: number;
  105511. /**
  105512. * Gets the value of D-pad left
  105513. */
  105514. /**
  105515. * Sets the value of D-pad left
  105516. */
  105517. dPadLeft: number;
  105518. /**
  105519. * Gets the value of D-pad right
  105520. */
  105521. /**
  105522. * Sets the value of D-pad right
  105523. */
  105524. dPadRight: number;
  105525. /**
  105526. * Force the gamepad to synchronize with device values
  105527. */
  105528. update(): void;
  105529. /**
  105530. * Disposes the gamepad
  105531. */
  105532. dispose(): void;
  105533. }
  105534. }
  105535. declare module BABYLON {
  105536. /**
  105537. * Manager for handling gamepads
  105538. */
  105539. export class GamepadManager {
  105540. private _scene?;
  105541. private _babylonGamepads;
  105542. private _oneGamepadConnected;
  105543. /** @hidden */
  105544. _isMonitoring: boolean;
  105545. private _gamepadEventSupported;
  105546. private _gamepadSupport;
  105547. /**
  105548. * observable to be triggered when the gamepad controller has been connected
  105549. */
  105550. onGamepadConnectedObservable: Observable<Gamepad>;
  105551. /**
  105552. * observable to be triggered when the gamepad controller has been disconnected
  105553. */
  105554. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105555. private _onGamepadConnectedEvent;
  105556. private _onGamepadDisconnectedEvent;
  105557. /**
  105558. * Initializes the gamepad manager
  105559. * @param _scene BabylonJS scene
  105560. */
  105561. constructor(_scene?: Scene | undefined);
  105562. /**
  105563. * The gamepads in the game pad manager
  105564. */
  105565. readonly gamepads: Gamepad[];
  105566. /**
  105567. * Get the gamepad controllers based on type
  105568. * @param type The type of gamepad controller
  105569. * @returns Nullable gamepad
  105570. */
  105571. getGamepadByType(type?: number): Nullable<Gamepad>;
  105572. /**
  105573. * Disposes the gamepad manager
  105574. */
  105575. dispose(): void;
  105576. private _addNewGamepad;
  105577. private _startMonitoringGamepads;
  105578. private _stopMonitoringGamepads;
  105579. /** @hidden */
  105580. _checkGamepadsStatus(): void;
  105581. private _updateGamepadObjects;
  105582. }
  105583. }
  105584. declare module BABYLON {
  105585. interface Scene {
  105586. /** @hidden */
  105587. _gamepadManager: Nullable<GamepadManager>;
  105588. /**
  105589. * Gets the gamepad manager associated with the scene
  105590. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105591. */
  105592. gamepadManager: GamepadManager;
  105593. }
  105594. /**
  105595. * Interface representing a free camera inputs manager
  105596. */
  105597. interface FreeCameraInputsManager {
  105598. /**
  105599. * Adds gamepad input support to the FreeCameraInputsManager.
  105600. * @returns the FreeCameraInputsManager
  105601. */
  105602. addGamepad(): FreeCameraInputsManager;
  105603. }
  105604. /**
  105605. * Interface representing an arc rotate camera inputs manager
  105606. */
  105607. interface ArcRotateCameraInputsManager {
  105608. /**
  105609. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105610. * @returns the camera inputs manager
  105611. */
  105612. addGamepad(): ArcRotateCameraInputsManager;
  105613. }
  105614. /**
  105615. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  105616. */
  105617. export class GamepadSystemSceneComponent implements ISceneComponent {
  105618. /**
  105619. * The component name helpfull to identify the component in the list of scene components.
  105620. */
  105621. readonly name: string;
  105622. /**
  105623. * The scene the component belongs to.
  105624. */
  105625. scene: Scene;
  105626. /**
  105627. * Creates a new instance of the component for the given scene
  105628. * @param scene Defines the scene to register the component in
  105629. */
  105630. constructor(scene: Scene);
  105631. /**
  105632. * Registers the component in a given scene
  105633. */
  105634. register(): void;
  105635. /**
  105636. * Rebuilds the elements related to this component in case of
  105637. * context lost for instance.
  105638. */
  105639. rebuild(): void;
  105640. /**
  105641. * Disposes the component and the associated ressources
  105642. */
  105643. dispose(): void;
  105644. private _beforeCameraUpdate;
  105645. }
  105646. }
  105647. declare module BABYLON {
  105648. /**
  105649. * 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,
  105650. * which still works and will still be found in many Playgrounds.
  105651. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105652. */
  105653. export class UniversalCamera extends TouchCamera {
  105654. /**
  105655. * Defines the gamepad rotation sensiblity.
  105656. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105657. */
  105658. gamepadAngularSensibility: number;
  105659. /**
  105660. * Defines the gamepad move sensiblity.
  105661. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105662. */
  105663. gamepadMoveSensibility: number;
  105664. /**
  105665. * 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,
  105666. * which still works and will still be found in many Playgrounds.
  105667. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105668. * @param name Define the name of the camera in the scene
  105669. * @param position Define the start position of the camera in the scene
  105670. * @param scene Define the scene the camera belongs to
  105671. */
  105672. constructor(name: string, position: Vector3, scene: Scene);
  105673. /**
  105674. * Gets the current object class name.
  105675. * @return the class name
  105676. */
  105677. getClassName(): string;
  105678. }
  105679. }
  105680. declare module BABYLON {
  105681. /**
  105682. * This represents a FPS type of camera. This is only here for back compat purpose.
  105683. * Please use the UniversalCamera instead as both are identical.
  105684. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105685. */
  105686. export class GamepadCamera extends UniversalCamera {
  105687. /**
  105688. * Instantiates a new Gamepad Camera
  105689. * This represents a FPS type of camera. This is only here for back compat purpose.
  105690. * Please use the UniversalCamera instead as both are identical.
  105691. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105692. * @param name Define the name of the camera in the scene
  105693. * @param position Define the start position of the camera in the scene
  105694. * @param scene Define the scene the camera belongs to
  105695. */
  105696. constructor(name: string, position: Vector3, scene: Scene);
  105697. /**
  105698. * Gets the current object class name.
  105699. * @return the class name
  105700. */
  105701. getClassName(): string;
  105702. }
  105703. }
  105704. declare module BABYLON {
  105705. /** @hidden */
  105706. export var passPixelShader: {
  105707. name: string;
  105708. shader: string;
  105709. };
  105710. }
  105711. declare module BABYLON {
  105712. /** @hidden */
  105713. export var passCubePixelShader: {
  105714. name: string;
  105715. shader: string;
  105716. };
  105717. }
  105718. declare module BABYLON {
  105719. /**
  105720. * PassPostProcess which produces an output the same as it's input
  105721. */
  105722. export class PassPostProcess extends PostProcess {
  105723. /**
  105724. * Creates the PassPostProcess
  105725. * @param name The name of the effect.
  105726. * @param options The required width/height ratio to downsize to before computing the render pass.
  105727. * @param camera The camera to apply the render pass to.
  105728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105729. * @param engine The engine which the post process will be applied. (default: current engine)
  105730. * @param reusable If the post process can be reused on the same frame. (default: false)
  105731. * @param textureType The type of texture to be used when performing the post processing.
  105732. * @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)
  105733. */
  105734. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105735. }
  105736. /**
  105737. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105738. */
  105739. export class PassCubePostProcess extends PostProcess {
  105740. private _face;
  105741. /**
  105742. * Gets or sets the cube face to display.
  105743. * * 0 is +X
  105744. * * 1 is -X
  105745. * * 2 is +Y
  105746. * * 3 is -Y
  105747. * * 4 is +Z
  105748. * * 5 is -Z
  105749. */
  105750. face: number;
  105751. /**
  105752. * Creates the PassCubePostProcess
  105753. * @param name The name of the effect.
  105754. * @param options The required width/height ratio to downsize to before computing the render pass.
  105755. * @param camera The camera to apply the render pass to.
  105756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105757. * @param engine The engine which the post process will be applied. (default: current engine)
  105758. * @param reusable If the post process can be reused on the same frame. (default: false)
  105759. * @param textureType The type of texture to be used when performing the post processing.
  105760. * @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)
  105761. */
  105762. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105763. }
  105764. }
  105765. declare module BABYLON {
  105766. /** @hidden */
  105767. export var anaglyphPixelShader: {
  105768. name: string;
  105769. shader: string;
  105770. };
  105771. }
  105772. declare module BABYLON {
  105773. /**
  105774. * Postprocess used to generate anaglyphic rendering
  105775. */
  105776. export class AnaglyphPostProcess extends PostProcess {
  105777. private _passedProcess;
  105778. /**
  105779. * Creates a new AnaglyphPostProcess
  105780. * @param name defines postprocess name
  105781. * @param options defines creation options or target ratio scale
  105782. * @param rigCameras defines cameras using this postprocess
  105783. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105784. * @param engine defines hosting engine
  105785. * @param reusable defines if the postprocess will be reused multiple times per frame
  105786. */
  105787. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105788. }
  105789. }
  105790. declare module BABYLON {
  105791. /**
  105792. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105793. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105794. */
  105795. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105796. /**
  105797. * Creates a new AnaglyphArcRotateCamera
  105798. * @param name defines camera name
  105799. * @param alpha defines alpha angle (in radians)
  105800. * @param beta defines beta angle (in radians)
  105801. * @param radius defines radius
  105802. * @param target defines camera target
  105803. * @param interaxialDistance defines distance between each color axis
  105804. * @param scene defines the hosting scene
  105805. */
  105806. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105807. /**
  105808. * Gets camera class name
  105809. * @returns AnaglyphArcRotateCamera
  105810. */
  105811. getClassName(): string;
  105812. }
  105813. }
  105814. declare module BABYLON {
  105815. /**
  105816. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105817. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105818. */
  105819. export class AnaglyphFreeCamera extends FreeCamera {
  105820. /**
  105821. * Creates a new AnaglyphFreeCamera
  105822. * @param name defines camera name
  105823. * @param position defines initial position
  105824. * @param interaxialDistance defines distance between each color axis
  105825. * @param scene defines the hosting scene
  105826. */
  105827. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105828. /**
  105829. * Gets camera class name
  105830. * @returns AnaglyphFreeCamera
  105831. */
  105832. getClassName(): string;
  105833. }
  105834. }
  105835. declare module BABYLON {
  105836. /**
  105837. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105838. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105839. */
  105840. export class AnaglyphGamepadCamera extends GamepadCamera {
  105841. /**
  105842. * Creates a new AnaglyphGamepadCamera
  105843. * @param name defines camera name
  105844. * @param position defines initial position
  105845. * @param interaxialDistance defines distance between each color axis
  105846. * @param scene defines the hosting scene
  105847. */
  105848. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105849. /**
  105850. * Gets camera class name
  105851. * @returns AnaglyphGamepadCamera
  105852. */
  105853. getClassName(): string;
  105854. }
  105855. }
  105856. declare module BABYLON {
  105857. /**
  105858. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105859. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105860. */
  105861. export class AnaglyphUniversalCamera extends UniversalCamera {
  105862. /**
  105863. * Creates a new AnaglyphUniversalCamera
  105864. * @param name defines camera name
  105865. * @param position defines initial position
  105866. * @param interaxialDistance defines distance between each color axis
  105867. * @param scene defines the hosting scene
  105868. */
  105869. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105870. /**
  105871. * Gets camera class name
  105872. * @returns AnaglyphUniversalCamera
  105873. */
  105874. getClassName(): string;
  105875. }
  105876. }
  105877. declare module BABYLON {
  105878. /** @hidden */
  105879. export var stereoscopicInterlacePixelShader: {
  105880. name: string;
  105881. shader: string;
  105882. };
  105883. }
  105884. declare module BABYLON {
  105885. /**
  105886. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105887. */
  105888. export class StereoscopicInterlacePostProcess extends PostProcess {
  105889. private _stepSize;
  105890. private _passedProcess;
  105891. /**
  105892. * Initializes a StereoscopicInterlacePostProcess
  105893. * @param name The name of the effect.
  105894. * @param rigCameras The rig cameras to be appled to the post process
  105895. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105897. * @param engine The engine which the post process will be applied. (default: current engine)
  105898. * @param reusable If the post process can be reused on the same frame. (default: false)
  105899. */
  105900. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105901. }
  105902. }
  105903. declare module BABYLON {
  105904. /**
  105905. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105906. * @see http://doc.babylonjs.com/features/cameras
  105907. */
  105908. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105909. /**
  105910. * Creates a new StereoscopicArcRotateCamera
  105911. * @param name defines camera name
  105912. * @param alpha defines alpha angle (in radians)
  105913. * @param beta defines beta angle (in radians)
  105914. * @param radius defines radius
  105915. * @param target defines camera target
  105916. * @param interaxialDistance defines distance between each color axis
  105917. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105918. * @param scene defines the hosting scene
  105919. */
  105920. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105921. /**
  105922. * Gets camera class name
  105923. * @returns StereoscopicArcRotateCamera
  105924. */
  105925. getClassName(): string;
  105926. }
  105927. }
  105928. declare module BABYLON {
  105929. /**
  105930. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105931. * @see http://doc.babylonjs.com/features/cameras
  105932. */
  105933. export class StereoscopicFreeCamera extends FreeCamera {
  105934. /**
  105935. * Creates a new StereoscopicFreeCamera
  105936. * @param name defines camera name
  105937. * @param position defines initial position
  105938. * @param interaxialDistance defines distance between each color axis
  105939. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105940. * @param scene defines the hosting scene
  105941. */
  105942. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105943. /**
  105944. * Gets camera class name
  105945. * @returns StereoscopicFreeCamera
  105946. */
  105947. getClassName(): string;
  105948. }
  105949. }
  105950. declare module BABYLON {
  105951. /**
  105952. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105953. * @see http://doc.babylonjs.com/features/cameras
  105954. */
  105955. export class StereoscopicGamepadCamera extends GamepadCamera {
  105956. /**
  105957. * Creates a new StereoscopicGamepadCamera
  105958. * @param name defines camera name
  105959. * @param position defines initial position
  105960. * @param interaxialDistance defines distance between each color axis
  105961. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105962. * @param scene defines the hosting scene
  105963. */
  105964. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105965. /**
  105966. * Gets camera class name
  105967. * @returns StereoscopicGamepadCamera
  105968. */
  105969. getClassName(): string;
  105970. }
  105971. }
  105972. declare module BABYLON {
  105973. /**
  105974. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105975. * @see http://doc.babylonjs.com/features/cameras
  105976. */
  105977. export class StereoscopicUniversalCamera extends UniversalCamera {
  105978. /**
  105979. * Creates a new StereoscopicUniversalCamera
  105980. * @param name defines camera name
  105981. * @param position defines initial position
  105982. * @param interaxialDistance defines distance between each color axis
  105983. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105984. * @param scene defines the hosting scene
  105985. */
  105986. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105987. /**
  105988. * Gets camera class name
  105989. * @returns StereoscopicUniversalCamera
  105990. */
  105991. getClassName(): string;
  105992. }
  105993. }
  105994. declare module BABYLON {
  105995. /**
  105996. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105997. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105998. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105999. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106000. */
  106001. export class VirtualJoysticksCamera extends FreeCamera {
  106002. /**
  106003. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106004. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106005. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106006. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106007. * @param name Define the name of the camera in the scene
  106008. * @param position Define the start position of the camera in the scene
  106009. * @param scene Define the scene the camera belongs to
  106010. */
  106011. constructor(name: string, position: Vector3, scene: Scene);
  106012. /**
  106013. * Gets the current object class name.
  106014. * @return the class name
  106015. */
  106016. getClassName(): string;
  106017. }
  106018. }
  106019. declare module BABYLON {
  106020. /**
  106021. * This represents all the required metrics to create a VR camera.
  106022. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106023. */
  106024. export class VRCameraMetrics {
  106025. /**
  106026. * Define the horizontal resolution off the screen.
  106027. */
  106028. hResolution: number;
  106029. /**
  106030. * Define the vertical resolution off the screen.
  106031. */
  106032. vResolution: number;
  106033. /**
  106034. * Define the horizontal screen size.
  106035. */
  106036. hScreenSize: number;
  106037. /**
  106038. * Define the vertical screen size.
  106039. */
  106040. vScreenSize: number;
  106041. /**
  106042. * Define the vertical screen center position.
  106043. */
  106044. vScreenCenter: number;
  106045. /**
  106046. * Define the distance of the eyes to the screen.
  106047. */
  106048. eyeToScreenDistance: number;
  106049. /**
  106050. * Define the distance between both lenses
  106051. */
  106052. lensSeparationDistance: number;
  106053. /**
  106054. * Define the distance between both viewer's eyes.
  106055. */
  106056. interpupillaryDistance: number;
  106057. /**
  106058. * Define the distortion factor of the VR postprocess.
  106059. * Please, touch with care.
  106060. */
  106061. distortionK: number[];
  106062. /**
  106063. * Define the chromatic aberration correction factors for the VR post process.
  106064. */
  106065. chromaAbCorrection: number[];
  106066. /**
  106067. * Define the scale factor of the post process.
  106068. * The smaller the better but the slower.
  106069. */
  106070. postProcessScaleFactor: number;
  106071. /**
  106072. * Define an offset for the lens center.
  106073. */
  106074. lensCenterOffset: number;
  106075. /**
  106076. * Define if the current vr camera should compensate the distortion of the lense or not.
  106077. */
  106078. compensateDistortion: boolean;
  106079. /**
  106080. * Defines if multiview should be enabled when rendering (Default: false)
  106081. */
  106082. multiviewEnabled: boolean;
  106083. /**
  106084. * Gets the rendering aspect ratio based on the provided resolutions.
  106085. */
  106086. readonly aspectRatio: number;
  106087. /**
  106088. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106089. */
  106090. readonly aspectRatioFov: number;
  106091. /**
  106092. * @hidden
  106093. */
  106094. readonly leftHMatrix: Matrix;
  106095. /**
  106096. * @hidden
  106097. */
  106098. readonly rightHMatrix: Matrix;
  106099. /**
  106100. * @hidden
  106101. */
  106102. readonly leftPreViewMatrix: Matrix;
  106103. /**
  106104. * @hidden
  106105. */
  106106. readonly rightPreViewMatrix: Matrix;
  106107. /**
  106108. * Get the default VRMetrics based on the most generic setup.
  106109. * @returns the default vr metrics
  106110. */
  106111. static GetDefault(): VRCameraMetrics;
  106112. }
  106113. }
  106114. declare module BABYLON {
  106115. /** @hidden */
  106116. export var vrDistortionCorrectionPixelShader: {
  106117. name: string;
  106118. shader: string;
  106119. };
  106120. }
  106121. declare module BABYLON {
  106122. /**
  106123. * VRDistortionCorrectionPostProcess used for mobile VR
  106124. */
  106125. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106126. private _isRightEye;
  106127. private _distortionFactors;
  106128. private _postProcessScaleFactor;
  106129. private _lensCenterOffset;
  106130. private _scaleIn;
  106131. private _scaleFactor;
  106132. private _lensCenter;
  106133. /**
  106134. * Initializes the VRDistortionCorrectionPostProcess
  106135. * @param name The name of the effect.
  106136. * @param camera The camera to apply the render pass to.
  106137. * @param isRightEye If this is for the right eye distortion
  106138. * @param vrMetrics All the required metrics for the VR camera
  106139. */
  106140. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106141. }
  106142. }
  106143. declare module BABYLON {
  106144. /**
  106145. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106146. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106147. */
  106148. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106149. /**
  106150. * Creates a new VRDeviceOrientationArcRotateCamera
  106151. * @param name defines camera name
  106152. * @param alpha defines the camera rotation along the logitudinal axis
  106153. * @param beta defines the camera rotation along the latitudinal axis
  106154. * @param radius defines the camera distance from its target
  106155. * @param target defines the camera target
  106156. * @param scene defines the scene the camera belongs to
  106157. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106158. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106159. */
  106160. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106161. /**
  106162. * Gets camera class name
  106163. * @returns VRDeviceOrientationArcRotateCamera
  106164. */
  106165. getClassName(): string;
  106166. }
  106167. }
  106168. declare module BABYLON {
  106169. /**
  106170. * Camera used to simulate VR rendering (based on FreeCamera)
  106171. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106172. */
  106173. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106174. /**
  106175. * Creates a new VRDeviceOrientationFreeCamera
  106176. * @param name defines camera name
  106177. * @param position defines the start position of the camera
  106178. * @param scene defines the scene the camera belongs to
  106179. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106180. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106181. */
  106182. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106183. /**
  106184. * Gets camera class name
  106185. * @returns VRDeviceOrientationFreeCamera
  106186. */
  106187. getClassName(): string;
  106188. }
  106189. }
  106190. declare module BABYLON {
  106191. /**
  106192. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106193. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106194. */
  106195. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106196. /**
  106197. * Creates a new VRDeviceOrientationGamepadCamera
  106198. * @param name defines camera name
  106199. * @param position defines the start position of the camera
  106200. * @param scene defines the scene the camera belongs to
  106201. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106202. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106203. */
  106204. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106205. /**
  106206. * Gets camera class name
  106207. * @returns VRDeviceOrientationGamepadCamera
  106208. */
  106209. getClassName(): string;
  106210. }
  106211. }
  106212. declare module BABYLON {
  106213. /**
  106214. * Base class of materials working in push mode in babylon JS
  106215. * @hidden
  106216. */
  106217. export class PushMaterial extends Material {
  106218. protected _activeEffect: Effect;
  106219. protected _normalMatrix: Matrix;
  106220. /**
  106221. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106222. * This means that the material can keep using a previous shader while a new one is being compiled.
  106223. * This is mostly used when shader parallel compilation is supported (true by default)
  106224. */
  106225. allowShaderHotSwapping: boolean;
  106226. constructor(name: string, scene: Scene);
  106227. getEffect(): Effect;
  106228. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106229. /**
  106230. * Binds the given world matrix to the active effect
  106231. *
  106232. * @param world the matrix to bind
  106233. */
  106234. bindOnlyWorldMatrix(world: Matrix): void;
  106235. /**
  106236. * Binds the given normal matrix to the active effect
  106237. *
  106238. * @param normalMatrix the matrix to bind
  106239. */
  106240. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106241. bind(world: Matrix, mesh?: Mesh): void;
  106242. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106243. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106244. }
  106245. }
  106246. declare module BABYLON {
  106247. /**
  106248. * This groups all the flags used to control the materials channel.
  106249. */
  106250. export class MaterialFlags {
  106251. private static _DiffuseTextureEnabled;
  106252. /**
  106253. * Are diffuse textures enabled in the application.
  106254. */
  106255. static DiffuseTextureEnabled: boolean;
  106256. private static _AmbientTextureEnabled;
  106257. /**
  106258. * Are ambient textures enabled in the application.
  106259. */
  106260. static AmbientTextureEnabled: boolean;
  106261. private static _OpacityTextureEnabled;
  106262. /**
  106263. * Are opacity textures enabled in the application.
  106264. */
  106265. static OpacityTextureEnabled: boolean;
  106266. private static _ReflectionTextureEnabled;
  106267. /**
  106268. * Are reflection textures enabled in the application.
  106269. */
  106270. static ReflectionTextureEnabled: boolean;
  106271. private static _EmissiveTextureEnabled;
  106272. /**
  106273. * Are emissive textures enabled in the application.
  106274. */
  106275. static EmissiveTextureEnabled: boolean;
  106276. private static _SpecularTextureEnabled;
  106277. /**
  106278. * Are specular textures enabled in the application.
  106279. */
  106280. static SpecularTextureEnabled: boolean;
  106281. private static _BumpTextureEnabled;
  106282. /**
  106283. * Are bump textures enabled in the application.
  106284. */
  106285. static BumpTextureEnabled: boolean;
  106286. private static _LightmapTextureEnabled;
  106287. /**
  106288. * Are lightmap textures enabled in the application.
  106289. */
  106290. static LightmapTextureEnabled: boolean;
  106291. private static _RefractionTextureEnabled;
  106292. /**
  106293. * Are refraction textures enabled in the application.
  106294. */
  106295. static RefractionTextureEnabled: boolean;
  106296. private static _ColorGradingTextureEnabled;
  106297. /**
  106298. * Are color grading textures enabled in the application.
  106299. */
  106300. static ColorGradingTextureEnabled: boolean;
  106301. private static _FresnelEnabled;
  106302. /**
  106303. * Are fresnels enabled in the application.
  106304. */
  106305. static FresnelEnabled: boolean;
  106306. private static _ClearCoatTextureEnabled;
  106307. /**
  106308. * Are clear coat textures enabled in the application.
  106309. */
  106310. static ClearCoatTextureEnabled: boolean;
  106311. private static _ClearCoatBumpTextureEnabled;
  106312. /**
  106313. * Are clear coat bump textures enabled in the application.
  106314. */
  106315. static ClearCoatBumpTextureEnabled: boolean;
  106316. private static _ClearCoatTintTextureEnabled;
  106317. /**
  106318. * Are clear coat tint textures enabled in the application.
  106319. */
  106320. static ClearCoatTintTextureEnabled: boolean;
  106321. private static _SheenTextureEnabled;
  106322. /**
  106323. * Are sheen textures enabled in the application.
  106324. */
  106325. static SheenTextureEnabled: boolean;
  106326. private static _AnisotropicTextureEnabled;
  106327. /**
  106328. * Are anisotropic textures enabled in the application.
  106329. */
  106330. static AnisotropicTextureEnabled: boolean;
  106331. private static _ThicknessTextureEnabled;
  106332. /**
  106333. * Are thickness textures enabled in the application.
  106334. */
  106335. static ThicknessTextureEnabled: boolean;
  106336. }
  106337. }
  106338. declare module BABYLON {
  106339. /** @hidden */
  106340. export var defaultFragmentDeclaration: {
  106341. name: string;
  106342. shader: string;
  106343. };
  106344. }
  106345. declare module BABYLON {
  106346. /** @hidden */
  106347. export var defaultUboDeclaration: {
  106348. name: string;
  106349. shader: string;
  106350. };
  106351. }
  106352. declare module BABYLON {
  106353. /** @hidden */
  106354. export var lightFragmentDeclaration: {
  106355. name: string;
  106356. shader: string;
  106357. };
  106358. }
  106359. declare module BABYLON {
  106360. /** @hidden */
  106361. export var lightUboDeclaration: {
  106362. name: string;
  106363. shader: string;
  106364. };
  106365. }
  106366. declare module BABYLON {
  106367. /** @hidden */
  106368. export var lightsFragmentFunctions: {
  106369. name: string;
  106370. shader: string;
  106371. };
  106372. }
  106373. declare module BABYLON {
  106374. /** @hidden */
  106375. export var shadowsFragmentFunctions: {
  106376. name: string;
  106377. shader: string;
  106378. };
  106379. }
  106380. declare module BABYLON {
  106381. /** @hidden */
  106382. export var fresnelFunction: {
  106383. name: string;
  106384. shader: string;
  106385. };
  106386. }
  106387. declare module BABYLON {
  106388. /** @hidden */
  106389. export var reflectionFunction: {
  106390. name: string;
  106391. shader: string;
  106392. };
  106393. }
  106394. declare module BABYLON {
  106395. /** @hidden */
  106396. export var bumpFragmentFunctions: {
  106397. name: string;
  106398. shader: string;
  106399. };
  106400. }
  106401. declare module BABYLON {
  106402. /** @hidden */
  106403. export var logDepthDeclaration: {
  106404. name: string;
  106405. shader: string;
  106406. };
  106407. }
  106408. declare module BABYLON {
  106409. /** @hidden */
  106410. export var bumpFragment: {
  106411. name: string;
  106412. shader: string;
  106413. };
  106414. }
  106415. declare module BABYLON {
  106416. /** @hidden */
  106417. export var depthPrePass: {
  106418. name: string;
  106419. shader: string;
  106420. };
  106421. }
  106422. declare module BABYLON {
  106423. /** @hidden */
  106424. export var lightFragment: {
  106425. name: string;
  106426. shader: string;
  106427. };
  106428. }
  106429. declare module BABYLON {
  106430. /** @hidden */
  106431. export var logDepthFragment: {
  106432. name: string;
  106433. shader: string;
  106434. };
  106435. }
  106436. declare module BABYLON {
  106437. /** @hidden */
  106438. export var defaultPixelShader: {
  106439. name: string;
  106440. shader: string;
  106441. };
  106442. }
  106443. declare module BABYLON {
  106444. /** @hidden */
  106445. export var defaultVertexDeclaration: {
  106446. name: string;
  106447. shader: string;
  106448. };
  106449. }
  106450. declare module BABYLON {
  106451. /** @hidden */
  106452. export var bumpVertexDeclaration: {
  106453. name: string;
  106454. shader: string;
  106455. };
  106456. }
  106457. declare module BABYLON {
  106458. /** @hidden */
  106459. export var bumpVertex: {
  106460. name: string;
  106461. shader: string;
  106462. };
  106463. }
  106464. declare module BABYLON {
  106465. /** @hidden */
  106466. export var fogVertex: {
  106467. name: string;
  106468. shader: string;
  106469. };
  106470. }
  106471. declare module BABYLON {
  106472. /** @hidden */
  106473. export var shadowsVertex: {
  106474. name: string;
  106475. shader: string;
  106476. };
  106477. }
  106478. declare module BABYLON {
  106479. /** @hidden */
  106480. export var pointCloudVertex: {
  106481. name: string;
  106482. shader: string;
  106483. };
  106484. }
  106485. declare module BABYLON {
  106486. /** @hidden */
  106487. export var logDepthVertex: {
  106488. name: string;
  106489. shader: string;
  106490. };
  106491. }
  106492. declare module BABYLON {
  106493. /** @hidden */
  106494. export var defaultVertexShader: {
  106495. name: string;
  106496. shader: string;
  106497. };
  106498. }
  106499. declare module BABYLON {
  106500. /** @hidden */
  106501. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106502. MAINUV1: boolean;
  106503. MAINUV2: boolean;
  106504. DIFFUSE: boolean;
  106505. DIFFUSEDIRECTUV: number;
  106506. AMBIENT: boolean;
  106507. AMBIENTDIRECTUV: number;
  106508. OPACITY: boolean;
  106509. OPACITYDIRECTUV: number;
  106510. OPACITYRGB: boolean;
  106511. REFLECTION: boolean;
  106512. EMISSIVE: boolean;
  106513. EMISSIVEDIRECTUV: number;
  106514. SPECULAR: boolean;
  106515. SPECULARDIRECTUV: number;
  106516. BUMP: boolean;
  106517. BUMPDIRECTUV: number;
  106518. PARALLAX: boolean;
  106519. PARALLAXOCCLUSION: boolean;
  106520. SPECULAROVERALPHA: boolean;
  106521. CLIPPLANE: boolean;
  106522. CLIPPLANE2: boolean;
  106523. CLIPPLANE3: boolean;
  106524. CLIPPLANE4: boolean;
  106525. ALPHATEST: boolean;
  106526. DEPTHPREPASS: boolean;
  106527. ALPHAFROMDIFFUSE: boolean;
  106528. POINTSIZE: boolean;
  106529. FOG: boolean;
  106530. SPECULARTERM: boolean;
  106531. DIFFUSEFRESNEL: boolean;
  106532. OPACITYFRESNEL: boolean;
  106533. REFLECTIONFRESNEL: boolean;
  106534. REFRACTIONFRESNEL: boolean;
  106535. EMISSIVEFRESNEL: boolean;
  106536. FRESNEL: boolean;
  106537. NORMAL: boolean;
  106538. UV1: boolean;
  106539. UV2: boolean;
  106540. VERTEXCOLOR: boolean;
  106541. VERTEXALPHA: boolean;
  106542. NUM_BONE_INFLUENCERS: number;
  106543. BonesPerMesh: number;
  106544. BONETEXTURE: boolean;
  106545. INSTANCES: boolean;
  106546. GLOSSINESS: boolean;
  106547. ROUGHNESS: boolean;
  106548. EMISSIVEASILLUMINATION: boolean;
  106549. LINKEMISSIVEWITHDIFFUSE: boolean;
  106550. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106551. LIGHTMAP: boolean;
  106552. LIGHTMAPDIRECTUV: number;
  106553. OBJECTSPACE_NORMALMAP: boolean;
  106554. USELIGHTMAPASSHADOWMAP: boolean;
  106555. REFLECTIONMAP_3D: boolean;
  106556. REFLECTIONMAP_SPHERICAL: boolean;
  106557. REFLECTIONMAP_PLANAR: boolean;
  106558. REFLECTIONMAP_CUBIC: boolean;
  106559. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106560. REFLECTIONMAP_PROJECTION: boolean;
  106561. REFLECTIONMAP_SKYBOX: boolean;
  106562. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106563. REFLECTIONMAP_EXPLICIT: boolean;
  106564. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106565. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106566. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106567. INVERTCUBICMAP: boolean;
  106568. LOGARITHMICDEPTH: boolean;
  106569. REFRACTION: boolean;
  106570. REFRACTIONMAP_3D: boolean;
  106571. REFLECTIONOVERALPHA: boolean;
  106572. TWOSIDEDLIGHTING: boolean;
  106573. SHADOWFLOAT: boolean;
  106574. MORPHTARGETS: boolean;
  106575. MORPHTARGETS_NORMAL: boolean;
  106576. MORPHTARGETS_TANGENT: boolean;
  106577. MORPHTARGETS_UV: boolean;
  106578. NUM_MORPH_INFLUENCERS: number;
  106579. NONUNIFORMSCALING: boolean;
  106580. PREMULTIPLYALPHA: boolean;
  106581. IMAGEPROCESSING: boolean;
  106582. VIGNETTE: boolean;
  106583. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106584. VIGNETTEBLENDMODEOPAQUE: boolean;
  106585. TONEMAPPING: boolean;
  106586. TONEMAPPING_ACES: boolean;
  106587. CONTRAST: boolean;
  106588. COLORCURVES: boolean;
  106589. COLORGRADING: boolean;
  106590. COLORGRADING3D: boolean;
  106591. SAMPLER3DGREENDEPTH: boolean;
  106592. SAMPLER3DBGRMAP: boolean;
  106593. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106594. MULTIVIEW: boolean;
  106595. /**
  106596. * If the reflection texture on this material is in linear color space
  106597. * @hidden
  106598. */
  106599. IS_REFLECTION_LINEAR: boolean;
  106600. /**
  106601. * If the refraction texture on this material is in linear color space
  106602. * @hidden
  106603. */
  106604. IS_REFRACTION_LINEAR: boolean;
  106605. EXPOSURE: boolean;
  106606. constructor();
  106607. setReflectionMode(modeToEnable: string): void;
  106608. }
  106609. /**
  106610. * This is the default material used in Babylon. It is the best trade off between quality
  106611. * and performances.
  106612. * @see http://doc.babylonjs.com/babylon101/materials
  106613. */
  106614. export class StandardMaterial extends PushMaterial {
  106615. private _diffuseTexture;
  106616. /**
  106617. * The basic texture of the material as viewed under a light.
  106618. */
  106619. diffuseTexture: Nullable<BaseTexture>;
  106620. private _ambientTexture;
  106621. /**
  106622. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106623. */
  106624. ambientTexture: Nullable<BaseTexture>;
  106625. private _opacityTexture;
  106626. /**
  106627. * Define the transparency of the material from a texture.
  106628. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106629. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106630. */
  106631. opacityTexture: Nullable<BaseTexture>;
  106632. private _reflectionTexture;
  106633. /**
  106634. * Define the texture used to display the reflection.
  106635. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106636. */
  106637. reflectionTexture: Nullable<BaseTexture>;
  106638. private _emissiveTexture;
  106639. /**
  106640. * Define texture of the material as if self lit.
  106641. * This will be mixed in the final result even in the absence of light.
  106642. */
  106643. emissiveTexture: Nullable<BaseTexture>;
  106644. private _specularTexture;
  106645. /**
  106646. * Define how the color and intensity of the highlight given by the light in the material.
  106647. */
  106648. specularTexture: Nullable<BaseTexture>;
  106649. private _bumpTexture;
  106650. /**
  106651. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106652. * 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.
  106653. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106654. */
  106655. bumpTexture: Nullable<BaseTexture>;
  106656. private _lightmapTexture;
  106657. /**
  106658. * Complex lighting can be computationally expensive to compute at runtime.
  106659. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106660. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106661. */
  106662. lightmapTexture: Nullable<BaseTexture>;
  106663. private _refractionTexture;
  106664. /**
  106665. * Define the texture used to display the refraction.
  106666. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106667. */
  106668. refractionTexture: Nullable<BaseTexture>;
  106669. /**
  106670. * The color of the material lit by the environmental background lighting.
  106671. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106672. */
  106673. ambientColor: Color3;
  106674. /**
  106675. * The basic color of the material as viewed under a light.
  106676. */
  106677. diffuseColor: Color3;
  106678. /**
  106679. * Define how the color and intensity of the highlight given by the light in the material.
  106680. */
  106681. specularColor: Color3;
  106682. /**
  106683. * Define the color of the material as if self lit.
  106684. * This will be mixed in the final result even in the absence of light.
  106685. */
  106686. emissiveColor: Color3;
  106687. /**
  106688. * Defines how sharp are the highlights in the material.
  106689. * The bigger the value the sharper giving a more glossy feeling to the result.
  106690. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106691. */
  106692. specularPower: number;
  106693. private _useAlphaFromDiffuseTexture;
  106694. /**
  106695. * Does the transparency come from the diffuse texture alpha channel.
  106696. */
  106697. useAlphaFromDiffuseTexture: boolean;
  106698. private _useEmissiveAsIllumination;
  106699. /**
  106700. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106701. */
  106702. useEmissiveAsIllumination: boolean;
  106703. private _linkEmissiveWithDiffuse;
  106704. /**
  106705. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106706. * the emissive level when the final color is close to one.
  106707. */
  106708. linkEmissiveWithDiffuse: boolean;
  106709. private _useSpecularOverAlpha;
  106710. /**
  106711. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106712. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106713. */
  106714. useSpecularOverAlpha: boolean;
  106715. private _useReflectionOverAlpha;
  106716. /**
  106717. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106718. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106719. */
  106720. useReflectionOverAlpha: boolean;
  106721. private _disableLighting;
  106722. /**
  106723. * Does lights from the scene impacts this material.
  106724. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106725. */
  106726. disableLighting: boolean;
  106727. private _useObjectSpaceNormalMap;
  106728. /**
  106729. * Allows using an object space normal map (instead of tangent space).
  106730. */
  106731. useObjectSpaceNormalMap: boolean;
  106732. private _useParallax;
  106733. /**
  106734. * Is parallax enabled or not.
  106735. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106736. */
  106737. useParallax: boolean;
  106738. private _useParallaxOcclusion;
  106739. /**
  106740. * Is parallax occlusion enabled or not.
  106741. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106742. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106743. */
  106744. useParallaxOcclusion: boolean;
  106745. /**
  106746. * 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.
  106747. */
  106748. parallaxScaleBias: number;
  106749. private _roughness;
  106750. /**
  106751. * Helps to define how blurry the reflections should appears in the material.
  106752. */
  106753. roughness: number;
  106754. /**
  106755. * In case of refraction, define the value of the index of refraction.
  106756. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106757. */
  106758. indexOfRefraction: number;
  106759. /**
  106760. * Invert the refraction texture alongside the y axis.
  106761. * It can be useful with procedural textures or probe for instance.
  106762. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106763. */
  106764. invertRefractionY: boolean;
  106765. /**
  106766. * Defines the alpha limits in alpha test mode.
  106767. */
  106768. alphaCutOff: number;
  106769. private _useLightmapAsShadowmap;
  106770. /**
  106771. * In case of light mapping, define whether the map contains light or shadow informations.
  106772. */
  106773. useLightmapAsShadowmap: boolean;
  106774. private _diffuseFresnelParameters;
  106775. /**
  106776. * Define the diffuse fresnel parameters of the material.
  106777. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106778. */
  106779. diffuseFresnelParameters: FresnelParameters;
  106780. private _opacityFresnelParameters;
  106781. /**
  106782. * Define the opacity fresnel parameters of the material.
  106783. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106784. */
  106785. opacityFresnelParameters: FresnelParameters;
  106786. private _reflectionFresnelParameters;
  106787. /**
  106788. * Define the reflection fresnel parameters of the material.
  106789. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106790. */
  106791. reflectionFresnelParameters: FresnelParameters;
  106792. private _refractionFresnelParameters;
  106793. /**
  106794. * Define the refraction fresnel parameters of the material.
  106795. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106796. */
  106797. refractionFresnelParameters: FresnelParameters;
  106798. private _emissiveFresnelParameters;
  106799. /**
  106800. * Define the emissive fresnel parameters of the material.
  106801. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106802. */
  106803. emissiveFresnelParameters: FresnelParameters;
  106804. private _useReflectionFresnelFromSpecular;
  106805. /**
  106806. * If true automatically deducts the fresnels values from the material specularity.
  106807. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106808. */
  106809. useReflectionFresnelFromSpecular: boolean;
  106810. private _useGlossinessFromSpecularMapAlpha;
  106811. /**
  106812. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106813. */
  106814. useGlossinessFromSpecularMapAlpha: boolean;
  106815. private _maxSimultaneousLights;
  106816. /**
  106817. * Defines the maximum number of lights that can be used in the material
  106818. */
  106819. maxSimultaneousLights: number;
  106820. private _invertNormalMapX;
  106821. /**
  106822. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106823. */
  106824. invertNormalMapX: boolean;
  106825. private _invertNormalMapY;
  106826. /**
  106827. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106828. */
  106829. invertNormalMapY: boolean;
  106830. private _twoSidedLighting;
  106831. /**
  106832. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106833. */
  106834. twoSidedLighting: boolean;
  106835. /**
  106836. * Default configuration related to image processing available in the standard Material.
  106837. */
  106838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106839. /**
  106840. * Gets the image processing configuration used either in this material.
  106841. */
  106842. /**
  106843. * Sets the Default image processing configuration used either in the this material.
  106844. *
  106845. * If sets to null, the scene one is in use.
  106846. */
  106847. imageProcessingConfiguration: ImageProcessingConfiguration;
  106848. /**
  106849. * Keep track of the image processing observer to allow dispose and replace.
  106850. */
  106851. private _imageProcessingObserver;
  106852. /**
  106853. * Attaches a new image processing configuration to the Standard Material.
  106854. * @param configuration
  106855. */
  106856. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106857. /**
  106858. * Gets wether the color curves effect is enabled.
  106859. */
  106860. /**
  106861. * Sets wether the color curves effect is enabled.
  106862. */
  106863. cameraColorCurvesEnabled: boolean;
  106864. /**
  106865. * Gets wether the color grading effect is enabled.
  106866. */
  106867. /**
  106868. * Gets wether the color grading effect is enabled.
  106869. */
  106870. cameraColorGradingEnabled: boolean;
  106871. /**
  106872. * Gets wether tonemapping is enabled or not.
  106873. */
  106874. /**
  106875. * Sets wether tonemapping is enabled or not
  106876. */
  106877. cameraToneMappingEnabled: boolean;
  106878. /**
  106879. * The camera exposure used on this material.
  106880. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106881. * This corresponds to a photographic exposure.
  106882. */
  106883. /**
  106884. * The camera exposure used on this material.
  106885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106886. * This corresponds to a photographic exposure.
  106887. */
  106888. cameraExposure: number;
  106889. /**
  106890. * Gets The camera contrast used on this material.
  106891. */
  106892. /**
  106893. * Sets The camera contrast used on this material.
  106894. */
  106895. cameraContrast: number;
  106896. /**
  106897. * Gets the Color Grading 2D Lookup Texture.
  106898. */
  106899. /**
  106900. * Sets the Color Grading 2D Lookup Texture.
  106901. */
  106902. cameraColorGradingTexture: Nullable<BaseTexture>;
  106903. /**
  106904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106906. * 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;
  106907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106908. */
  106909. /**
  106910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106912. * 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;
  106913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106914. */
  106915. cameraColorCurves: Nullable<ColorCurves>;
  106916. /**
  106917. * Custom callback helping to override the default shader used in the material.
  106918. */
  106919. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106920. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106921. protected _worldViewProjectionMatrix: Matrix;
  106922. protected _globalAmbientColor: Color3;
  106923. protected _useLogarithmicDepth: boolean;
  106924. protected _rebuildInParallel: boolean;
  106925. /**
  106926. * Instantiates a new standard material.
  106927. * This is the default material used in Babylon. It is the best trade off between quality
  106928. * and performances.
  106929. * @see http://doc.babylonjs.com/babylon101/materials
  106930. * @param name Define the name of the material in the scene
  106931. * @param scene Define the scene the material belong to
  106932. */
  106933. constructor(name: string, scene: Scene);
  106934. /**
  106935. * Gets a boolean indicating that current material needs to register RTT
  106936. */
  106937. readonly hasRenderTargetTextures: boolean;
  106938. /**
  106939. * Gets the current class name of the material e.g. "StandardMaterial"
  106940. * Mainly use in serialization.
  106941. * @returns the class name
  106942. */
  106943. getClassName(): string;
  106944. /**
  106945. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106946. * You can try switching to logarithmic depth.
  106947. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106948. */
  106949. useLogarithmicDepth: boolean;
  106950. /**
  106951. * Specifies if the material will require alpha blending
  106952. * @returns a boolean specifying if alpha blending is needed
  106953. */
  106954. needAlphaBlending(): boolean;
  106955. /**
  106956. * Specifies if this material should be rendered in alpha test mode
  106957. * @returns a boolean specifying if an alpha test is needed.
  106958. */
  106959. needAlphaTesting(): boolean;
  106960. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106961. /**
  106962. * Get the texture used for alpha test purpose.
  106963. * @returns the diffuse texture in case of the standard material.
  106964. */
  106965. getAlphaTestTexture(): Nullable<BaseTexture>;
  106966. /**
  106967. * Get if the submesh is ready to be used and all its information available.
  106968. * Child classes can use it to update shaders
  106969. * @param mesh defines the mesh to check
  106970. * @param subMesh defines which submesh to check
  106971. * @param useInstances specifies that instances should be used
  106972. * @returns a boolean indicating that the submesh is ready or not
  106973. */
  106974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106975. /**
  106976. * Builds the material UBO layouts.
  106977. * Used internally during the effect preparation.
  106978. */
  106979. buildUniformLayout(): void;
  106980. /**
  106981. * Unbinds the material from the mesh
  106982. */
  106983. unbind(): void;
  106984. /**
  106985. * Binds the submesh to this material by preparing the effect and shader to draw
  106986. * @param world defines the world transformation matrix
  106987. * @param mesh defines the mesh containing the submesh
  106988. * @param subMesh defines the submesh to bind the material to
  106989. */
  106990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106991. /**
  106992. * Get the list of animatables in the material.
  106993. * @returns the list of animatables object used in the material
  106994. */
  106995. getAnimatables(): IAnimatable[];
  106996. /**
  106997. * Gets the active textures from the material
  106998. * @returns an array of textures
  106999. */
  107000. getActiveTextures(): BaseTexture[];
  107001. /**
  107002. * Specifies if the material uses a texture
  107003. * @param texture defines the texture to check against the material
  107004. * @returns a boolean specifying if the material uses the texture
  107005. */
  107006. hasTexture(texture: BaseTexture): boolean;
  107007. /**
  107008. * Disposes the material
  107009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107010. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107011. */
  107012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107013. /**
  107014. * Makes a duplicate of the material, and gives it a new name
  107015. * @param name defines the new name for the duplicated material
  107016. * @returns the cloned material
  107017. */
  107018. clone(name: string): StandardMaterial;
  107019. /**
  107020. * Serializes this material in a JSON representation
  107021. * @returns the serialized material object
  107022. */
  107023. serialize(): any;
  107024. /**
  107025. * Creates a standard material from parsed material data
  107026. * @param source defines the JSON representation of the material
  107027. * @param scene defines the hosting scene
  107028. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107029. * @returns a new standard material
  107030. */
  107031. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107032. /**
  107033. * Are diffuse textures enabled in the application.
  107034. */
  107035. static DiffuseTextureEnabled: boolean;
  107036. /**
  107037. * Are ambient textures enabled in the application.
  107038. */
  107039. static AmbientTextureEnabled: boolean;
  107040. /**
  107041. * Are opacity textures enabled in the application.
  107042. */
  107043. static OpacityTextureEnabled: boolean;
  107044. /**
  107045. * Are reflection textures enabled in the application.
  107046. */
  107047. static ReflectionTextureEnabled: boolean;
  107048. /**
  107049. * Are emissive textures enabled in the application.
  107050. */
  107051. static EmissiveTextureEnabled: boolean;
  107052. /**
  107053. * Are specular textures enabled in the application.
  107054. */
  107055. static SpecularTextureEnabled: boolean;
  107056. /**
  107057. * Are bump textures enabled in the application.
  107058. */
  107059. static BumpTextureEnabled: boolean;
  107060. /**
  107061. * Are lightmap textures enabled in the application.
  107062. */
  107063. static LightmapTextureEnabled: boolean;
  107064. /**
  107065. * Are refraction textures enabled in the application.
  107066. */
  107067. static RefractionTextureEnabled: boolean;
  107068. /**
  107069. * Are color grading textures enabled in the application.
  107070. */
  107071. static ColorGradingTextureEnabled: boolean;
  107072. /**
  107073. * Are fresnels enabled in the application.
  107074. */
  107075. static FresnelEnabled: boolean;
  107076. }
  107077. }
  107078. declare module BABYLON {
  107079. /** @hidden */
  107080. export var imageProcessingPixelShader: {
  107081. name: string;
  107082. shader: string;
  107083. };
  107084. }
  107085. declare module BABYLON {
  107086. /**
  107087. * ImageProcessingPostProcess
  107088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107089. */
  107090. export class ImageProcessingPostProcess extends PostProcess {
  107091. /**
  107092. * Default configuration related to image processing available in the PBR Material.
  107093. */
  107094. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107095. /**
  107096. * Gets the image processing configuration used either in this material.
  107097. */
  107098. /**
  107099. * Sets the Default image processing configuration used either in the this material.
  107100. *
  107101. * If sets to null, the scene one is in use.
  107102. */
  107103. imageProcessingConfiguration: ImageProcessingConfiguration;
  107104. /**
  107105. * Keep track of the image processing observer to allow dispose and replace.
  107106. */
  107107. private _imageProcessingObserver;
  107108. /**
  107109. * Attaches a new image processing configuration to the PBR Material.
  107110. * @param configuration
  107111. */
  107112. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107113. /**
  107114. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107115. */
  107116. /**
  107117. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107118. */
  107119. colorCurves: Nullable<ColorCurves>;
  107120. /**
  107121. * Gets wether the color curves effect is enabled.
  107122. */
  107123. /**
  107124. * Sets wether the color curves effect is enabled.
  107125. */
  107126. colorCurvesEnabled: boolean;
  107127. /**
  107128. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107129. */
  107130. /**
  107131. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107132. */
  107133. colorGradingTexture: Nullable<BaseTexture>;
  107134. /**
  107135. * Gets wether the color grading effect is enabled.
  107136. */
  107137. /**
  107138. * Gets wether the color grading effect is enabled.
  107139. */
  107140. colorGradingEnabled: boolean;
  107141. /**
  107142. * Gets exposure used in the effect.
  107143. */
  107144. /**
  107145. * Sets exposure used in the effect.
  107146. */
  107147. exposure: number;
  107148. /**
  107149. * Gets wether tonemapping is enabled or not.
  107150. */
  107151. /**
  107152. * Sets wether tonemapping is enabled or not
  107153. */
  107154. toneMappingEnabled: boolean;
  107155. /**
  107156. * Gets the type of tone mapping effect.
  107157. */
  107158. /**
  107159. * Sets the type of tone mapping effect.
  107160. */
  107161. toneMappingType: number;
  107162. /**
  107163. * Gets contrast used in the effect.
  107164. */
  107165. /**
  107166. * Sets contrast used in the effect.
  107167. */
  107168. contrast: number;
  107169. /**
  107170. * Gets Vignette stretch size.
  107171. */
  107172. /**
  107173. * Sets Vignette stretch size.
  107174. */
  107175. vignetteStretch: number;
  107176. /**
  107177. * Gets Vignette centre X Offset.
  107178. */
  107179. /**
  107180. * Sets Vignette centre X Offset.
  107181. */
  107182. vignetteCentreX: number;
  107183. /**
  107184. * Gets Vignette centre Y Offset.
  107185. */
  107186. /**
  107187. * Sets Vignette centre Y Offset.
  107188. */
  107189. vignetteCentreY: number;
  107190. /**
  107191. * Gets Vignette weight or intensity of the vignette effect.
  107192. */
  107193. /**
  107194. * Sets Vignette weight or intensity of the vignette effect.
  107195. */
  107196. vignetteWeight: number;
  107197. /**
  107198. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107199. * if vignetteEnabled is set to true.
  107200. */
  107201. /**
  107202. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107203. * if vignetteEnabled is set to true.
  107204. */
  107205. vignetteColor: Color4;
  107206. /**
  107207. * Gets Camera field of view used by the Vignette effect.
  107208. */
  107209. /**
  107210. * Sets Camera field of view used by the Vignette effect.
  107211. */
  107212. vignetteCameraFov: number;
  107213. /**
  107214. * Gets the vignette blend mode allowing different kind of effect.
  107215. */
  107216. /**
  107217. * Sets the vignette blend mode allowing different kind of effect.
  107218. */
  107219. vignetteBlendMode: number;
  107220. /**
  107221. * Gets wether the vignette effect is enabled.
  107222. */
  107223. /**
  107224. * Sets wether the vignette effect is enabled.
  107225. */
  107226. vignetteEnabled: boolean;
  107227. private _fromLinearSpace;
  107228. /**
  107229. * Gets wether the input of the processing is in Gamma or Linear Space.
  107230. */
  107231. /**
  107232. * Sets wether the input of the processing is in Gamma or Linear Space.
  107233. */
  107234. fromLinearSpace: boolean;
  107235. /**
  107236. * Defines cache preventing GC.
  107237. */
  107238. private _defines;
  107239. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107240. /**
  107241. * "ImageProcessingPostProcess"
  107242. * @returns "ImageProcessingPostProcess"
  107243. */
  107244. getClassName(): string;
  107245. protected _updateParameters(): void;
  107246. dispose(camera?: Camera): void;
  107247. }
  107248. }
  107249. declare module BABYLON {
  107250. /**
  107251. * Class containing static functions to help procedurally build meshes
  107252. */
  107253. export class GroundBuilder {
  107254. /**
  107255. * Creates a ground mesh
  107256. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107257. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107259. * @param name defines the name of the mesh
  107260. * @param options defines the options used to create the mesh
  107261. * @param scene defines the hosting scene
  107262. * @returns the ground mesh
  107263. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107264. */
  107265. static CreateGround(name: string, options: {
  107266. width?: number;
  107267. height?: number;
  107268. subdivisions?: number;
  107269. subdivisionsX?: number;
  107270. subdivisionsY?: number;
  107271. updatable?: boolean;
  107272. }, scene: any): Mesh;
  107273. /**
  107274. * Creates a tiled ground mesh
  107275. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107276. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107277. * * 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
  107278. * * 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
  107279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107280. * @param name defines the name of the mesh
  107281. * @param options defines the options used to create the mesh
  107282. * @param scene defines the hosting scene
  107283. * @returns the tiled ground mesh
  107284. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107285. */
  107286. static CreateTiledGround(name: string, options: {
  107287. xmin: number;
  107288. zmin: number;
  107289. xmax: number;
  107290. zmax: number;
  107291. subdivisions?: {
  107292. w: number;
  107293. h: number;
  107294. };
  107295. precision?: {
  107296. w: number;
  107297. h: number;
  107298. };
  107299. updatable?: boolean;
  107300. }, scene?: Nullable<Scene>): Mesh;
  107301. /**
  107302. * Creates a ground mesh from a height map
  107303. * * The parameter `url` sets the URL of the height map image resource.
  107304. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107305. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107306. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107307. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107308. * * 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.
  107309. * * 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).
  107310. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107312. * @param name defines the name of the mesh
  107313. * @param url defines the url to the height map
  107314. * @param options defines the options used to create the mesh
  107315. * @param scene defines the hosting scene
  107316. * @returns the ground mesh
  107317. * @see https://doc.babylonjs.com/babylon101/height_map
  107318. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107319. */
  107320. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107321. width?: number;
  107322. height?: number;
  107323. subdivisions?: number;
  107324. minHeight?: number;
  107325. maxHeight?: number;
  107326. colorFilter?: Color3;
  107327. alphaFilter?: number;
  107328. updatable?: boolean;
  107329. onReady?: (mesh: GroundMesh) => void;
  107330. }, scene?: Nullable<Scene>): GroundMesh;
  107331. }
  107332. }
  107333. declare module BABYLON {
  107334. /**
  107335. * Class containing static functions to help procedurally build meshes
  107336. */
  107337. export class TorusBuilder {
  107338. /**
  107339. * Creates a torus mesh
  107340. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107341. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107342. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107346. * @param name defines the name of the mesh
  107347. * @param options defines the options used to create the mesh
  107348. * @param scene defines the hosting scene
  107349. * @returns the torus mesh
  107350. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107351. */
  107352. static CreateTorus(name: string, options: {
  107353. diameter?: number;
  107354. thickness?: number;
  107355. tessellation?: number;
  107356. updatable?: boolean;
  107357. sideOrientation?: number;
  107358. frontUVs?: Vector4;
  107359. backUVs?: Vector4;
  107360. }, scene: any): Mesh;
  107361. }
  107362. }
  107363. declare module BABYLON {
  107364. /**
  107365. * Class containing static functions to help procedurally build meshes
  107366. */
  107367. export class CylinderBuilder {
  107368. /**
  107369. * Creates a cylinder or a cone mesh
  107370. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107371. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107372. * * 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.
  107373. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107374. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107375. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107376. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107377. * * 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).
  107378. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107379. * * 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).
  107380. * * 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
  107381. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107382. * * 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
  107383. * * 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.
  107384. * * If `enclose` is false, a ring surface is one element.
  107385. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107386. * * 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
  107387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107390. * @param name defines the name of the mesh
  107391. * @param options defines the options used to create the mesh
  107392. * @param scene defines the hosting scene
  107393. * @returns the cylinder mesh
  107394. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107395. */
  107396. static CreateCylinder(name: string, options: {
  107397. height?: number;
  107398. diameterTop?: number;
  107399. diameterBottom?: number;
  107400. diameter?: number;
  107401. tessellation?: number;
  107402. subdivisions?: number;
  107403. arc?: number;
  107404. faceColors?: Color4[];
  107405. faceUV?: Vector4[];
  107406. updatable?: boolean;
  107407. hasRings?: boolean;
  107408. enclose?: boolean;
  107409. cap?: number;
  107410. sideOrientation?: number;
  107411. frontUVs?: Vector4;
  107412. backUVs?: Vector4;
  107413. }, scene: any): Mesh;
  107414. }
  107415. }
  107416. declare module BABYLON {
  107417. /**
  107418. * Options to modify the vr teleportation behavior.
  107419. */
  107420. export interface VRTeleportationOptions {
  107421. /**
  107422. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107423. */
  107424. floorMeshName?: string;
  107425. /**
  107426. * A list of meshes to be used as the teleportation floor. (default: empty)
  107427. */
  107428. floorMeshes?: Mesh[];
  107429. }
  107430. /**
  107431. * Options to modify the vr experience helper's behavior.
  107432. */
  107433. export interface VRExperienceHelperOptions extends WebVROptions {
  107434. /**
  107435. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107436. */
  107437. createDeviceOrientationCamera?: boolean;
  107438. /**
  107439. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107440. */
  107441. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107442. /**
  107443. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107444. */
  107445. laserToggle?: boolean;
  107446. /**
  107447. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107448. */
  107449. floorMeshes?: Mesh[];
  107450. /**
  107451. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107452. */
  107453. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107454. }
  107455. /**
  107456. * Event containing information after VR has been entered
  107457. */
  107458. export class OnAfterEnteringVRObservableEvent {
  107459. /**
  107460. * If entering vr was successful
  107461. */
  107462. success: boolean;
  107463. }
  107464. /**
  107465. * Helps to quickly add VR support to an existing scene.
  107466. * See http://doc.babylonjs.com/how_to/webvr_helper
  107467. */
  107468. export class VRExperienceHelper {
  107469. /** Options to modify the vr experience helper's behavior. */
  107470. webVROptions: VRExperienceHelperOptions;
  107471. private _scene;
  107472. private _position;
  107473. private _btnVR;
  107474. private _btnVRDisplayed;
  107475. private _webVRsupported;
  107476. private _webVRready;
  107477. private _webVRrequesting;
  107478. private _webVRpresenting;
  107479. private _hasEnteredVR;
  107480. private _fullscreenVRpresenting;
  107481. private _canvas;
  107482. private _webVRCamera;
  107483. private _vrDeviceOrientationCamera;
  107484. private _deviceOrientationCamera;
  107485. private _existingCamera;
  107486. private _onKeyDown;
  107487. private _onVrDisplayPresentChange;
  107488. private _onVRDisplayChanged;
  107489. private _onVRRequestPresentStart;
  107490. private _onVRRequestPresentComplete;
  107491. /**
  107492. * 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)
  107493. */
  107494. enableGazeEvenWhenNoPointerLock: boolean;
  107495. /**
  107496. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107497. */
  107498. exitVROnDoubleTap: boolean;
  107499. /**
  107500. * Observable raised right before entering VR.
  107501. */
  107502. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107503. /**
  107504. * Observable raised when entering VR has completed.
  107505. */
  107506. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107507. /**
  107508. * Observable raised when exiting VR.
  107509. */
  107510. onExitingVRObservable: Observable<VRExperienceHelper>;
  107511. /**
  107512. * Observable raised when controller mesh is loaded.
  107513. */
  107514. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107515. /** Return this.onEnteringVRObservable
  107516. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107517. */
  107518. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107519. /** Return this.onExitingVRObservable
  107520. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107521. */
  107522. readonly onExitingVR: Observable<VRExperienceHelper>;
  107523. /** Return this.onControllerMeshLoadedObservable
  107524. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107525. */
  107526. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107527. private _rayLength;
  107528. private _useCustomVRButton;
  107529. private _teleportationRequested;
  107530. private _teleportActive;
  107531. private _floorMeshName;
  107532. private _floorMeshesCollection;
  107533. private _rotationAllowed;
  107534. private _teleportBackwardsVector;
  107535. private _teleportationTarget;
  107536. private _isDefaultTeleportationTarget;
  107537. private _postProcessMove;
  107538. private _teleportationFillColor;
  107539. private _teleportationBorderColor;
  107540. private _rotationAngle;
  107541. private _haloCenter;
  107542. private _cameraGazer;
  107543. private _padSensibilityUp;
  107544. private _padSensibilityDown;
  107545. private _leftController;
  107546. private _rightController;
  107547. /**
  107548. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107549. */
  107550. onNewMeshSelected: Observable<AbstractMesh>;
  107551. /**
  107552. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107553. * This observable will provide the mesh and the controller used to select the mesh
  107554. */
  107555. onMeshSelectedWithController: Observable<{
  107556. mesh: AbstractMesh;
  107557. controller: WebVRController;
  107558. }>;
  107559. /**
  107560. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107561. */
  107562. onNewMeshPicked: Observable<PickingInfo>;
  107563. private _circleEase;
  107564. /**
  107565. * Observable raised before camera teleportation
  107566. */
  107567. onBeforeCameraTeleport: Observable<Vector3>;
  107568. /**
  107569. * Observable raised after camera teleportation
  107570. */
  107571. onAfterCameraTeleport: Observable<Vector3>;
  107572. /**
  107573. * Observable raised when current selected mesh gets unselected
  107574. */
  107575. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107576. private _raySelectionPredicate;
  107577. /**
  107578. * To be optionaly changed by user to define custom ray selection
  107579. */
  107580. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107581. /**
  107582. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107583. */
  107584. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107585. /**
  107586. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107587. */
  107588. teleportationEnabled: boolean;
  107589. private _defaultHeight;
  107590. private _teleportationInitialized;
  107591. private _interactionsEnabled;
  107592. private _interactionsRequested;
  107593. private _displayGaze;
  107594. private _displayLaserPointer;
  107595. /**
  107596. * The mesh used to display where the user is going to teleport.
  107597. */
  107598. /**
  107599. * Sets the mesh to be used to display where the user is going to teleport.
  107600. */
  107601. teleportationTarget: Mesh;
  107602. /**
  107603. * 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
  107604. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107605. * See http://doc.babylonjs.com/resources/baking_transformations
  107606. */
  107607. gazeTrackerMesh: Mesh;
  107608. /**
  107609. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107610. */
  107611. updateGazeTrackerScale: boolean;
  107612. /**
  107613. * If the gaze trackers color should be updated when selecting meshes
  107614. */
  107615. updateGazeTrackerColor: boolean;
  107616. /**
  107617. * If the controller laser color should be updated when selecting meshes
  107618. */
  107619. updateControllerLaserColor: boolean;
  107620. /**
  107621. * The gaze tracking mesh corresponding to the left controller
  107622. */
  107623. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  107624. /**
  107625. * The gaze tracking mesh corresponding to the right controller
  107626. */
  107627. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  107628. /**
  107629. * If the ray of the gaze should be displayed.
  107630. */
  107631. /**
  107632. * Sets if the ray of the gaze should be displayed.
  107633. */
  107634. displayGaze: boolean;
  107635. /**
  107636. * If the ray of the LaserPointer should be displayed.
  107637. */
  107638. /**
  107639. * Sets if the ray of the LaserPointer should be displayed.
  107640. */
  107641. displayLaserPointer: boolean;
  107642. /**
  107643. * The deviceOrientationCamera used as the camera when not in VR.
  107644. */
  107645. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  107646. /**
  107647. * Based on the current WebVR support, returns the current VR camera used.
  107648. */
  107649. readonly currentVRCamera: Nullable<Camera>;
  107650. /**
  107651. * The webVRCamera which is used when in VR.
  107652. */
  107653. readonly webVRCamera: WebVRFreeCamera;
  107654. /**
  107655. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  107656. */
  107657. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  107658. /**
  107659. * The html button that is used to trigger entering into VR.
  107660. */
  107661. readonly vrButton: Nullable<HTMLButtonElement>;
  107662. private readonly _teleportationRequestInitiated;
  107663. /**
  107664. * Defines wether or not Pointer lock should be requested when switching to
  107665. * full screen.
  107666. */
  107667. requestPointerLockOnFullScreen: boolean;
  107668. /**
  107669. * Instantiates a VRExperienceHelper.
  107670. * Helps to quickly add VR support to an existing scene.
  107671. * @param scene The scene the VRExperienceHelper belongs to.
  107672. * @param webVROptions Options to modify the vr experience helper's behavior.
  107673. */
  107674. constructor(scene: Scene,
  107675. /** Options to modify the vr experience helper's behavior. */
  107676. webVROptions?: VRExperienceHelperOptions);
  107677. private _onDefaultMeshLoaded;
  107678. private _onResize;
  107679. private _onFullscreenChange;
  107680. /**
  107681. * Gets a value indicating if we are currently in VR mode.
  107682. */
  107683. readonly isInVRMode: boolean;
  107684. private onVrDisplayPresentChange;
  107685. private onVRDisplayChanged;
  107686. private moveButtonToBottomRight;
  107687. private displayVRButton;
  107688. private updateButtonVisibility;
  107689. private _cachedAngularSensibility;
  107690. /**
  107691. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  107692. * Otherwise, will use the fullscreen API.
  107693. */
  107694. enterVR(): void;
  107695. /**
  107696. * Attempt to exit VR, or fullscreen.
  107697. */
  107698. exitVR(): void;
  107699. /**
  107700. * The position of the vr experience helper.
  107701. */
  107702. /**
  107703. * Sets the position of the vr experience helper.
  107704. */
  107705. position: Vector3;
  107706. /**
  107707. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  107708. */
  107709. enableInteractions(): void;
  107710. private readonly _noControllerIsActive;
  107711. private beforeRender;
  107712. private _isTeleportationFloor;
  107713. /**
  107714. * Adds a floor mesh to be used for teleportation.
  107715. * @param floorMesh the mesh to be used for teleportation.
  107716. */
  107717. addFloorMesh(floorMesh: Mesh): void;
  107718. /**
  107719. * Removes a floor mesh from being used for teleportation.
  107720. * @param floorMesh the mesh to be removed.
  107721. */
  107722. removeFloorMesh(floorMesh: Mesh): void;
  107723. /**
  107724. * Enables interactions and teleportation using the VR controllers and gaze.
  107725. * @param vrTeleportationOptions options to modify teleportation behavior.
  107726. */
  107727. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  107728. private _onNewGamepadConnected;
  107729. private _tryEnableInteractionOnController;
  107730. private _onNewGamepadDisconnected;
  107731. private _enableInteractionOnController;
  107732. private _checkTeleportWithRay;
  107733. private _checkRotate;
  107734. private _checkTeleportBackwards;
  107735. private _enableTeleportationOnController;
  107736. private _createTeleportationCircles;
  107737. private _displayTeleportationTarget;
  107738. private _hideTeleportationTarget;
  107739. private _rotateCamera;
  107740. private _moveTeleportationSelectorTo;
  107741. private _workingVector;
  107742. private _workingQuaternion;
  107743. private _workingMatrix;
  107744. /**
  107745. * Teleports the users feet to the desired location
  107746. * @param location The location where the user's feet should be placed
  107747. */
  107748. teleportCamera(location: Vector3): void;
  107749. private _convertNormalToDirectionOfRay;
  107750. private _castRayAndSelectObject;
  107751. private _notifySelectedMeshUnselected;
  107752. /**
  107753. * Sets the color of the laser ray from the vr controllers.
  107754. * @param color new color for the ray.
  107755. */
  107756. changeLaserColor(color: Color3): void;
  107757. /**
  107758. * Sets the color of the ray from the vr headsets gaze.
  107759. * @param color new color for the ray.
  107760. */
  107761. changeGazeColor(color: Color3): void;
  107762. /**
  107763. * Exits VR and disposes of the vr experience helper
  107764. */
  107765. dispose(): void;
  107766. /**
  107767. * Gets the name of the VRExperienceHelper class
  107768. * @returns "VRExperienceHelper"
  107769. */
  107770. getClassName(): string;
  107771. }
  107772. }
  107773. declare module BABYLON {
  107774. /**
  107775. * Manages an XRSession to work with Babylon's engine
  107776. * @see https://doc.babylonjs.com/how_to/webxr
  107777. */
  107778. export class WebXRSessionManager implements IDisposable {
  107779. private scene;
  107780. /**
  107781. * Fires every time a new xrFrame arrives which can be used to update the camera
  107782. */
  107783. onXRFrameObservable: Observable<any>;
  107784. /**
  107785. * Fires when the xr session is ended either by the device or manually done
  107786. */
  107787. onXRSessionEnded: Observable<any>;
  107788. /**
  107789. * Underlying xr session
  107790. */
  107791. session: XRSession;
  107792. /**
  107793. * Type of reference space used when creating the session
  107794. */
  107795. referenceSpace: XRReferenceSpace;
  107796. /** @hidden */
  107797. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107798. /**
  107799. * Current XR frame
  107800. */
  107801. currentFrame: Nullable<XRFrame>;
  107802. private _xrNavigator;
  107803. private baseLayer;
  107804. /**
  107805. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107806. * @param scene The scene which the session should be created for
  107807. */
  107808. constructor(scene: Scene);
  107809. /**
  107810. * Initializes the manager
  107811. * After initialization enterXR can be called to start an XR session
  107812. * @returns Promise which resolves after it is initialized
  107813. */
  107814. initializeAsync(): Promise<void>;
  107815. /**
  107816. * Initializes an xr session
  107817. * @param xrSessionMode mode to initialize
  107818. * @returns a promise which will resolve once the session has been initialized
  107819. */
  107820. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107821. /**
  107822. * Sets the reference space on the xr session
  107823. * @param referenceSpace space to set
  107824. * @returns a promise that will resolve once the reference space has been set
  107825. */
  107826. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107827. /**
  107828. * Updates the render state of the session
  107829. * @param state state to set
  107830. * @returns a promise that resolves once the render state has been updated
  107831. */
  107832. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107833. /**
  107834. * Starts rendering to the xr layer
  107835. * @returns a promise that will resolve once rendering has started
  107836. */
  107837. startRenderingToXRAsync(): Promise<void>;
  107838. /**
  107839. * Stops the xrSession and restores the renderloop
  107840. * @returns Promise which resolves after it exits XR
  107841. */
  107842. exitXRAsync(): Promise<unknown>;
  107843. /**
  107844. * Checks if a session would be supported for the creation options specified
  107845. * @param sessionMode session mode to check if supported eg. immersive-vr
  107846. * @returns true if supported
  107847. */
  107848. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107849. /**
  107850. * @hidden
  107851. * Converts the render layer of xrSession to a render target
  107852. * @param session session to create render target for
  107853. * @param scene scene the new render target should be created for
  107854. */
  107855. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107856. /**
  107857. * Disposes of the session manager
  107858. */
  107859. dispose(): void;
  107860. }
  107861. }
  107862. declare module BABYLON {
  107863. /**
  107864. * WebXR Camera which holds the views for the xrSession
  107865. * @see https://doc.babylonjs.com/how_to/webxr
  107866. */
  107867. export class WebXRCamera extends FreeCamera {
  107868. private static _TmpMatrix;
  107869. /**
  107870. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107871. * @param name the name of the camera
  107872. * @param scene the scene to add the camera to
  107873. */
  107874. constructor(name: string, scene: Scene);
  107875. private _updateNumberOfRigCameras;
  107876. /** @hidden */
  107877. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107878. /**
  107879. * Updates the cameras position from the current pose information of the XR session
  107880. * @param xrSessionManager the session containing pose information
  107881. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107882. */
  107883. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107884. }
  107885. }
  107886. declare module BABYLON {
  107887. /**
  107888. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107889. */
  107890. export class WebXRManagedOutputCanvas implements IDisposable {
  107891. private helper;
  107892. private _canvas;
  107893. /**
  107894. * xrpresent context of the canvas which can be used to display/mirror xr content
  107895. */
  107896. canvasContext: WebGLRenderingContext;
  107897. /**
  107898. * xr layer for the canvas
  107899. */
  107900. xrLayer: Nullable<XRWebGLLayer>;
  107901. /**
  107902. * Initializes the xr layer for the session
  107903. * @param xrSession xr session
  107904. * @returns a promise that will resolve once the XR Layer has been created
  107905. */
  107906. initializeXRLayerAsync(xrSession: any): any;
  107907. /**
  107908. * Initializes the canvas to be added/removed upon entering/exiting xr
  107909. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107910. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107911. */
  107912. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107913. /**
  107914. * Disposes of the object
  107915. */
  107916. dispose(): void;
  107917. private _setManagedOutputCanvas;
  107918. private _addCanvas;
  107919. private _removeCanvas;
  107920. }
  107921. }
  107922. declare module BABYLON {
  107923. /**
  107924. * States of the webXR experience
  107925. */
  107926. export enum WebXRState {
  107927. /**
  107928. * Transitioning to being in XR mode
  107929. */
  107930. ENTERING_XR = 0,
  107931. /**
  107932. * Transitioning to non XR mode
  107933. */
  107934. EXITING_XR = 1,
  107935. /**
  107936. * In XR mode and presenting
  107937. */
  107938. IN_XR = 2,
  107939. /**
  107940. * Not entered XR mode
  107941. */
  107942. NOT_IN_XR = 3
  107943. }
  107944. /**
  107945. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107946. * @see https://doc.babylonjs.com/how_to/webxr
  107947. */
  107948. export class WebXRExperienceHelper implements IDisposable {
  107949. private scene;
  107950. /**
  107951. * 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
  107952. */
  107953. container: AbstractMesh;
  107954. /**
  107955. * Camera used to render xr content
  107956. */
  107957. camera: WebXRCamera;
  107958. /**
  107959. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107960. */
  107961. state: WebXRState;
  107962. private _setState;
  107963. private static _TmpVector;
  107964. /**
  107965. * Fires when the state of the experience helper has changed
  107966. */
  107967. onStateChangedObservable: Observable<WebXRState>;
  107968. /** Session manager used to keep track of xr session */
  107969. sessionManager: WebXRSessionManager;
  107970. private _nonVRCamera;
  107971. private _originalSceneAutoClear;
  107972. private _supported;
  107973. /**
  107974. * Creates the experience helper
  107975. * @param scene the scene to attach the experience helper to
  107976. * @returns a promise for the experience helper
  107977. */
  107978. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107979. /**
  107980. * Creates a WebXRExperienceHelper
  107981. * @param scene The scene the helper should be created in
  107982. */
  107983. private constructor();
  107984. /**
  107985. * Exits XR mode and returns the scene to its original state
  107986. * @returns promise that resolves after xr mode has exited
  107987. */
  107988. exitXRAsync(): Promise<unknown>;
  107989. /**
  107990. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107991. * @param sessionCreationOptions options for the XR session
  107992. * @param referenceSpaceType frame of reference of the XR session
  107993. * @param outputCanvas the output canvas that will be used to enter XR mode
  107994. * @returns promise that resolves after xr mode has entered
  107995. */
  107996. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107997. /**
  107998. * Updates the global position of the camera by moving the camera's container
  107999. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108000. * @param position The desired global position of the camera
  108001. */
  108002. setPositionOfCameraUsingContainer(position: Vector3): void;
  108003. /**
  108004. * Rotates the xr camera by rotating the camera's container around the camera's position
  108005. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108006. * @param rotation the desired quaternion rotation to apply to the camera
  108007. */
  108008. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108009. /**
  108010. * Disposes of the experience helper
  108011. */
  108012. dispose(): void;
  108013. }
  108014. }
  108015. declare module BABYLON {
  108016. /**
  108017. * Button which can be used to enter a different mode of XR
  108018. */
  108019. export class WebXREnterExitUIButton {
  108020. /** button element */
  108021. element: HTMLElement;
  108022. /** XR initialization options for the button */
  108023. sessionMode: XRSessionMode;
  108024. /** Reference space type */
  108025. referenceSpaceType: XRReferenceSpaceType;
  108026. /**
  108027. * Creates a WebXREnterExitUIButton
  108028. * @param element button element
  108029. * @param sessionMode XR initialization session mode
  108030. * @param referenceSpaceType the type of reference space to be used
  108031. */
  108032. constructor(
  108033. /** button element */
  108034. element: HTMLElement,
  108035. /** XR initialization options for the button */
  108036. sessionMode: XRSessionMode,
  108037. /** Reference space type */
  108038. referenceSpaceType: XRReferenceSpaceType);
  108039. /**
  108040. * Overwritable function which can be used to update the button's visuals when the state changes
  108041. * @param activeButton the current active button in the UI
  108042. */
  108043. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108044. }
  108045. /**
  108046. * Options to create the webXR UI
  108047. */
  108048. export class WebXREnterExitUIOptions {
  108049. /**
  108050. * Context to enter xr with
  108051. */
  108052. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108053. /**
  108054. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108055. */
  108056. customButtons?: Array<WebXREnterExitUIButton>;
  108057. }
  108058. /**
  108059. * UI to allow the user to enter/exit XR mode
  108060. */
  108061. export class WebXREnterExitUI implements IDisposable {
  108062. private scene;
  108063. private _overlay;
  108064. private _buttons;
  108065. private _activeButton;
  108066. /**
  108067. * Fired every time the active button is changed.
  108068. *
  108069. * When xr is entered via a button that launches xr that button will be the callback parameter
  108070. *
  108071. * When exiting xr the callback parameter will be null)
  108072. */
  108073. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108074. /**
  108075. * Creates UI to allow the user to enter/exit XR mode
  108076. * @param scene the scene to add the ui to
  108077. * @param helper the xr experience helper to enter/exit xr with
  108078. * @param options options to configure the UI
  108079. * @returns the created ui
  108080. */
  108081. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108082. private constructor();
  108083. private _updateButtons;
  108084. /**
  108085. * Disposes of the object
  108086. */
  108087. dispose(): void;
  108088. }
  108089. }
  108090. declare module BABYLON {
  108091. /**
  108092. * Represents an XR input
  108093. */
  108094. export class WebXRController {
  108095. private scene;
  108096. /** The underlying input source for the controller */
  108097. inputSource: XRInputSource;
  108098. private parentContainer;
  108099. /**
  108100. * 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
  108101. */
  108102. grip?: AbstractMesh;
  108103. /**
  108104. * Pointer which can be used to select objects or attach a visible laser to
  108105. */
  108106. pointer: AbstractMesh;
  108107. /**
  108108. * Event that fires when the controller is removed/disposed
  108109. */
  108110. onDisposeObservable: Observable<{}>;
  108111. private _tmpMatrix;
  108112. private _tmpQuaternion;
  108113. private _tmpVector;
  108114. /**
  108115. * Creates the controller
  108116. * @see https://doc.babylonjs.com/how_to/webxr
  108117. * @param scene the scene which the controller should be associated to
  108118. * @param inputSource the underlying input source for the controller
  108119. * @param parentContainer parent that the controller meshes should be children of
  108120. */
  108121. constructor(scene: Scene,
  108122. /** The underlying input source for the controller */
  108123. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108124. /**
  108125. * Updates the controller pose based on the given XRFrame
  108126. * @param xrFrame xr frame to update the pose with
  108127. * @param referenceSpace reference space to use
  108128. */
  108129. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108130. /**
  108131. * Gets a world space ray coming from the controller
  108132. * @param result the resulting ray
  108133. */
  108134. getWorldPointerRayToRef(result: Ray): void;
  108135. /**
  108136. * Disposes of the object
  108137. */
  108138. dispose(): void;
  108139. }
  108140. }
  108141. declare module BABYLON {
  108142. /**
  108143. * XR input used to track XR inputs such as controllers/rays
  108144. */
  108145. export class WebXRInput implements IDisposable {
  108146. /**
  108147. * Base experience the input listens to
  108148. */
  108149. baseExperience: WebXRExperienceHelper;
  108150. /**
  108151. * XR controllers being tracked
  108152. */
  108153. controllers: Array<WebXRController>;
  108154. private _frameObserver;
  108155. private _stateObserver;
  108156. /**
  108157. * Event when a controller has been connected/added
  108158. */
  108159. onControllerAddedObservable: Observable<WebXRController>;
  108160. /**
  108161. * Event when a controller has been removed/disconnected
  108162. */
  108163. onControllerRemovedObservable: Observable<WebXRController>;
  108164. /**
  108165. * Initializes the WebXRInput
  108166. * @param baseExperience experience helper which the input should be created for
  108167. */
  108168. constructor(
  108169. /**
  108170. * Base experience the input listens to
  108171. */
  108172. baseExperience: WebXRExperienceHelper);
  108173. private _onInputSourcesChange;
  108174. private _addAndRemoveControllers;
  108175. /**
  108176. * Disposes of the object
  108177. */
  108178. dispose(): void;
  108179. }
  108180. }
  108181. declare module BABYLON {
  108182. /**
  108183. * Enables teleportation
  108184. */
  108185. export class WebXRControllerTeleportation {
  108186. private _teleportationFillColor;
  108187. private _teleportationBorderColor;
  108188. private _tmpRay;
  108189. private _tmpVector;
  108190. /**
  108191. * Creates a WebXRControllerTeleportation
  108192. * @param input input manager to add teleportation to
  108193. * @param floorMeshes floormeshes which can be teleported to
  108194. */
  108195. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108196. }
  108197. }
  108198. declare module BABYLON {
  108199. /**
  108200. * Handles pointer input automatically for the pointer of XR controllers
  108201. */
  108202. export class WebXRControllerPointerSelection {
  108203. private static _idCounter;
  108204. private _tmpRay;
  108205. /**
  108206. * Creates a WebXRControllerPointerSelection
  108207. * @param input input manager to setup pointer selection
  108208. */
  108209. constructor(input: WebXRInput);
  108210. private _convertNormalToDirectionOfRay;
  108211. private _updatePointerDistance;
  108212. }
  108213. }
  108214. declare module BABYLON {
  108215. /**
  108216. * Class used to represent data loading progression
  108217. */
  108218. export class SceneLoaderProgressEvent {
  108219. /** defines if data length to load can be evaluated */
  108220. readonly lengthComputable: boolean;
  108221. /** defines the loaded data length */
  108222. readonly loaded: number;
  108223. /** defines the data length to load */
  108224. readonly total: number;
  108225. /**
  108226. * Create a new progress event
  108227. * @param lengthComputable defines if data length to load can be evaluated
  108228. * @param loaded defines the loaded data length
  108229. * @param total defines the data length to load
  108230. */
  108231. constructor(
  108232. /** defines if data length to load can be evaluated */
  108233. lengthComputable: boolean,
  108234. /** defines the loaded data length */
  108235. loaded: number,
  108236. /** defines the data length to load */
  108237. total: number);
  108238. /**
  108239. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108240. * @param event defines the source event
  108241. * @returns a new SceneLoaderProgressEvent
  108242. */
  108243. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108244. }
  108245. /**
  108246. * Interface used by SceneLoader plugins to define supported file extensions
  108247. */
  108248. export interface ISceneLoaderPluginExtensions {
  108249. /**
  108250. * Defines the list of supported extensions
  108251. */
  108252. [extension: string]: {
  108253. isBinary: boolean;
  108254. };
  108255. }
  108256. /**
  108257. * Interface used by SceneLoader plugin factory
  108258. */
  108259. export interface ISceneLoaderPluginFactory {
  108260. /**
  108261. * Defines the name of the factory
  108262. */
  108263. name: string;
  108264. /**
  108265. * Function called to create a new plugin
  108266. * @return the new plugin
  108267. */
  108268. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108269. /**
  108270. * Boolean indicating if the plugin can direct load specific data
  108271. */
  108272. canDirectLoad?: (data: string) => boolean;
  108273. }
  108274. /**
  108275. * Interface used to define a SceneLoader plugin
  108276. */
  108277. export interface ISceneLoaderPlugin {
  108278. /**
  108279. * The friendly name of this plugin.
  108280. */
  108281. name: string;
  108282. /**
  108283. * The file extensions supported by this plugin.
  108284. */
  108285. extensions: string | ISceneLoaderPluginExtensions;
  108286. /**
  108287. * Import meshes into a scene.
  108288. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108289. * @param scene The scene to import into
  108290. * @param data The data to import
  108291. * @param rootUrl The root url for scene and resources
  108292. * @param meshes The meshes array to import into
  108293. * @param particleSystems The particle systems array to import into
  108294. * @param skeletons The skeletons array to import into
  108295. * @param onError The callback when import fails
  108296. * @returns True if successful or false otherwise
  108297. */
  108298. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108299. /**
  108300. * Load into a scene.
  108301. * @param scene The scene to load into
  108302. * @param data The data to import
  108303. * @param rootUrl The root url for scene and resources
  108304. * @param onError The callback when import fails
  108305. * @returns true if successful or false otherwise
  108306. */
  108307. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108308. /**
  108309. * The callback that returns true if the data can be directly loaded.
  108310. */
  108311. canDirectLoad?: (data: string) => boolean;
  108312. /**
  108313. * The callback that allows custom handling of the root url based on the response url.
  108314. */
  108315. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108316. /**
  108317. * Load into an asset container.
  108318. * @param scene The scene to load into
  108319. * @param data The data to import
  108320. * @param rootUrl The root url for scene and resources
  108321. * @param onError The callback when import fails
  108322. * @returns The loaded asset container
  108323. */
  108324. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108325. }
  108326. /**
  108327. * Interface used to define an async SceneLoader plugin
  108328. */
  108329. export interface ISceneLoaderPluginAsync {
  108330. /**
  108331. * The friendly name of this plugin.
  108332. */
  108333. name: string;
  108334. /**
  108335. * The file extensions supported by this plugin.
  108336. */
  108337. extensions: string | ISceneLoaderPluginExtensions;
  108338. /**
  108339. * Import meshes into a scene.
  108340. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108341. * @param scene The scene to import into
  108342. * @param data The data to import
  108343. * @param rootUrl The root url for scene and resources
  108344. * @param onProgress The callback when the load progresses
  108345. * @param fileName Defines the name of the file to load
  108346. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108347. */
  108348. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108349. meshes: AbstractMesh[];
  108350. particleSystems: IParticleSystem[];
  108351. skeletons: Skeleton[];
  108352. animationGroups: AnimationGroup[];
  108353. }>;
  108354. /**
  108355. * Load into a scene.
  108356. * @param scene The scene to load into
  108357. * @param data The data to import
  108358. * @param rootUrl The root url for scene and resources
  108359. * @param onProgress The callback when the load progresses
  108360. * @param fileName Defines the name of the file to load
  108361. * @returns Nothing
  108362. */
  108363. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108364. /**
  108365. * The callback that returns true if the data can be directly loaded.
  108366. */
  108367. canDirectLoad?: (data: string) => boolean;
  108368. /**
  108369. * The callback that allows custom handling of the root url based on the response url.
  108370. */
  108371. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108372. /**
  108373. * Load into an asset container.
  108374. * @param scene The scene to load into
  108375. * @param data The data to import
  108376. * @param rootUrl The root url for scene and resources
  108377. * @param onProgress The callback when the load progresses
  108378. * @param fileName Defines the name of the file to load
  108379. * @returns The loaded asset container
  108380. */
  108381. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108382. }
  108383. /**
  108384. * Class used to load scene from various file formats using registered plugins
  108385. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108386. */
  108387. export class SceneLoader {
  108388. /**
  108389. * No logging while loading
  108390. */
  108391. static readonly NO_LOGGING: number;
  108392. /**
  108393. * Minimal logging while loading
  108394. */
  108395. static readonly MINIMAL_LOGGING: number;
  108396. /**
  108397. * Summary logging while loading
  108398. */
  108399. static readonly SUMMARY_LOGGING: number;
  108400. /**
  108401. * Detailled logging while loading
  108402. */
  108403. static readonly DETAILED_LOGGING: number;
  108404. /**
  108405. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108406. */
  108407. static ForceFullSceneLoadingForIncremental: boolean;
  108408. /**
  108409. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108410. */
  108411. static ShowLoadingScreen: boolean;
  108412. /**
  108413. * Defines the current logging level (while loading the scene)
  108414. * @ignorenaming
  108415. */
  108416. static loggingLevel: number;
  108417. /**
  108418. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108419. */
  108420. static CleanBoneMatrixWeights: boolean;
  108421. /**
  108422. * Event raised when a plugin is used to load a scene
  108423. */
  108424. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108425. private static _registeredPlugins;
  108426. private static _getDefaultPlugin;
  108427. private static _getPluginForExtension;
  108428. private static _getPluginForDirectLoad;
  108429. private static _getPluginForFilename;
  108430. private static _getDirectLoad;
  108431. private static _loadData;
  108432. private static _getFileInfo;
  108433. /**
  108434. * Gets a plugin that can load the given extension
  108435. * @param extension defines the extension to load
  108436. * @returns a plugin or null if none works
  108437. */
  108438. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108439. /**
  108440. * Gets a boolean indicating that the given extension can be loaded
  108441. * @param extension defines the extension to load
  108442. * @returns true if the extension is supported
  108443. */
  108444. static IsPluginForExtensionAvailable(extension: string): boolean;
  108445. /**
  108446. * Adds a new plugin to the list of registered plugins
  108447. * @param plugin defines the plugin to add
  108448. */
  108449. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108450. /**
  108451. * Import meshes into a scene
  108452. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108453. * @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)
  108454. * @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)
  108455. * @param scene the instance of BABYLON.Scene to append to
  108456. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108457. * @param onProgress a callback with a progress event for each file being loaded
  108458. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108459. * @param pluginExtension the extension used to determine the plugin
  108460. * @returns The loaded plugin
  108461. */
  108462. 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>;
  108463. /**
  108464. * Import meshes into a scene
  108465. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108466. * @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)
  108467. * @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)
  108468. * @param scene the instance of BABYLON.Scene to append to
  108469. * @param onProgress a callback with a progress event for each file being loaded
  108470. * @param pluginExtension the extension used to determine the plugin
  108471. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108472. */
  108473. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108474. meshes: AbstractMesh[];
  108475. particleSystems: IParticleSystem[];
  108476. skeletons: Skeleton[];
  108477. animationGroups: AnimationGroup[];
  108478. }>;
  108479. /**
  108480. * Load a scene
  108481. * @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)
  108482. * @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)
  108483. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108484. * @param onSuccess a callback with the scene when import succeeds
  108485. * @param onProgress a callback with a progress event for each file being loaded
  108486. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108487. * @param pluginExtension the extension used to determine the plugin
  108488. * @returns The loaded plugin
  108489. */
  108490. 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>;
  108491. /**
  108492. * Load a scene
  108493. * @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)
  108494. * @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)
  108495. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108496. * @param onProgress a callback with a progress event for each file being loaded
  108497. * @param pluginExtension the extension used to determine the plugin
  108498. * @returns The loaded scene
  108499. */
  108500. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108501. /**
  108502. * Append a scene
  108503. * @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)
  108504. * @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)
  108505. * @param scene is the instance of BABYLON.Scene to append to
  108506. * @param onSuccess a callback with the scene when import succeeds
  108507. * @param onProgress a callback with a progress event for each file being loaded
  108508. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108509. * @param pluginExtension the extension used to determine the plugin
  108510. * @returns The loaded plugin
  108511. */
  108512. 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>;
  108513. /**
  108514. * Append a scene
  108515. * @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)
  108516. * @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)
  108517. * @param scene is the instance of BABYLON.Scene to append to
  108518. * @param onProgress a callback with a progress event for each file being loaded
  108519. * @param pluginExtension the extension used to determine the plugin
  108520. * @returns The given scene
  108521. */
  108522. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108523. /**
  108524. * Load a scene into an asset container
  108525. * @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)
  108526. * @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)
  108527. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108528. * @param onSuccess a callback with the scene when import succeeds
  108529. * @param onProgress a callback with a progress event for each file being loaded
  108530. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108531. * @param pluginExtension the extension used to determine the plugin
  108532. * @returns The loaded plugin
  108533. */
  108534. 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>;
  108535. /**
  108536. * Load a scene into an asset container
  108537. * @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)
  108538. * @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)
  108539. * @param scene is the instance of Scene to append to
  108540. * @param onProgress a callback with a progress event for each file being loaded
  108541. * @param pluginExtension the extension used to determine the plugin
  108542. * @returns The loaded asset container
  108543. */
  108544. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108545. }
  108546. }
  108547. declare module BABYLON {
  108548. /**
  108549. * Generic Controller
  108550. */
  108551. export class GenericController extends WebVRController {
  108552. /**
  108553. * Base Url for the controller model.
  108554. */
  108555. static readonly MODEL_BASE_URL: string;
  108556. /**
  108557. * File name for the controller model.
  108558. */
  108559. static readonly MODEL_FILENAME: string;
  108560. /**
  108561. * Creates a new GenericController from a gamepad
  108562. * @param vrGamepad the gamepad that the controller should be created from
  108563. */
  108564. constructor(vrGamepad: any);
  108565. /**
  108566. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108567. * @param scene scene in which to add meshes
  108568. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108569. */
  108570. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108571. /**
  108572. * Called once for each button that changed state since the last frame
  108573. * @param buttonIdx Which button index changed
  108574. * @param state New state of the button
  108575. * @param changes Which properties on the state changed since last frame
  108576. */
  108577. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108578. }
  108579. }
  108580. declare module BABYLON {
  108581. /**
  108582. * Defines the WindowsMotionController object that the state of the windows motion controller
  108583. */
  108584. export class WindowsMotionController extends WebVRController {
  108585. /**
  108586. * The base url used to load the left and right controller models
  108587. */
  108588. static MODEL_BASE_URL: string;
  108589. /**
  108590. * The name of the left controller model file
  108591. */
  108592. static MODEL_LEFT_FILENAME: string;
  108593. /**
  108594. * The name of the right controller model file
  108595. */
  108596. static MODEL_RIGHT_FILENAME: string;
  108597. /**
  108598. * The controller name prefix for this controller type
  108599. */
  108600. static readonly GAMEPAD_ID_PREFIX: string;
  108601. /**
  108602. * The controller id pattern for this controller type
  108603. */
  108604. private static readonly GAMEPAD_ID_PATTERN;
  108605. private _loadedMeshInfo;
  108606. private readonly _mapping;
  108607. /**
  108608. * Fired when the trackpad on this controller is clicked
  108609. */
  108610. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108611. /**
  108612. * Fired when the trackpad on this controller is modified
  108613. */
  108614. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108615. /**
  108616. * The current x and y values of this controller's trackpad
  108617. */
  108618. trackpad: StickValues;
  108619. /**
  108620. * Creates a new WindowsMotionController from a gamepad
  108621. * @param vrGamepad the gamepad that the controller should be created from
  108622. */
  108623. constructor(vrGamepad: any);
  108624. /**
  108625. * Fired when the trigger on this controller is modified
  108626. */
  108627. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108628. /**
  108629. * Fired when the menu button on this controller is modified
  108630. */
  108631. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108632. /**
  108633. * Fired when the grip button on this controller is modified
  108634. */
  108635. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108636. /**
  108637. * Fired when the thumbstick button on this controller is modified
  108638. */
  108639. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108640. /**
  108641. * Fired when the touchpad button on this controller is modified
  108642. */
  108643. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108644. /**
  108645. * Fired when the touchpad values on this controller are modified
  108646. */
  108647. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  108648. private _updateTrackpad;
  108649. /**
  108650. * Called once per frame by the engine.
  108651. */
  108652. update(): void;
  108653. /**
  108654. * Called once for each button that changed state since the last frame
  108655. * @param buttonIdx Which button index changed
  108656. * @param state New state of the button
  108657. * @param changes Which properties on the state changed since last frame
  108658. */
  108659. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108660. /**
  108661. * Moves the buttons on the controller mesh based on their current state
  108662. * @param buttonName the name of the button to move
  108663. * @param buttonValue the value of the button which determines the buttons new position
  108664. */
  108665. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108666. /**
  108667. * Moves the axis on the controller mesh based on its current state
  108668. * @param axis the index of the axis
  108669. * @param axisValue the value of the axis which determines the meshes new position
  108670. * @hidden
  108671. */
  108672. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108673. /**
  108674. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108675. * @param scene scene in which to add meshes
  108676. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108677. */
  108678. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  108679. /**
  108680. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  108681. * can be transformed by button presses and axes values, based on this._mapping.
  108682. *
  108683. * @param scene scene in which the meshes exist
  108684. * @param meshes list of meshes that make up the controller model to process
  108685. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  108686. */
  108687. private processModel;
  108688. private createMeshInfo;
  108689. /**
  108690. * Gets the ray of the controller in the direction the controller is pointing
  108691. * @param length the length the resulting ray should be
  108692. * @returns a ray in the direction the controller is pointing
  108693. */
  108694. getForwardRay(length?: number): Ray;
  108695. /**
  108696. * Disposes of the controller
  108697. */
  108698. dispose(): void;
  108699. }
  108700. }
  108701. declare module BABYLON {
  108702. /**
  108703. * Oculus Touch Controller
  108704. */
  108705. export class OculusTouchController extends WebVRController {
  108706. /**
  108707. * Base Url for the controller model.
  108708. */
  108709. static MODEL_BASE_URL: string;
  108710. /**
  108711. * File name for the left controller model.
  108712. */
  108713. static MODEL_LEFT_FILENAME: string;
  108714. /**
  108715. * File name for the right controller model.
  108716. */
  108717. static MODEL_RIGHT_FILENAME: string;
  108718. /**
  108719. * Base Url for the Quest controller model.
  108720. */
  108721. static QUEST_MODEL_BASE_URL: string;
  108722. /**
  108723. * @hidden
  108724. * If the controllers are running on a device that needs the updated Quest controller models
  108725. */
  108726. static _IsQuest: boolean;
  108727. /**
  108728. * Fired when the secondary trigger on this controller is modified
  108729. */
  108730. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108731. /**
  108732. * Fired when the thumb rest on this controller is modified
  108733. */
  108734. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  108735. /**
  108736. * Creates a new OculusTouchController from a gamepad
  108737. * @param vrGamepad the gamepad that the controller should be created from
  108738. */
  108739. constructor(vrGamepad: any);
  108740. /**
  108741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108742. * @param scene scene in which to add meshes
  108743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108744. */
  108745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108746. /**
  108747. * Fired when the A button on this controller is modified
  108748. */
  108749. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108750. /**
  108751. * Fired when the B button on this controller is modified
  108752. */
  108753. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108754. /**
  108755. * Fired when the X button on this controller is modified
  108756. */
  108757. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108758. /**
  108759. * Fired when the Y button on this controller is modified
  108760. */
  108761. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108762. /**
  108763. * Called once for each button that changed state since the last frame
  108764. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  108765. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  108766. * 2) secondary trigger (same)
  108767. * 3) A (right) X (left), touch, pressed = value
  108768. * 4) B / Y
  108769. * 5) thumb rest
  108770. * @param buttonIdx Which button index changed
  108771. * @param state New state of the button
  108772. * @param changes Which properties on the state changed since last frame
  108773. */
  108774. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108775. }
  108776. }
  108777. declare module BABYLON {
  108778. /**
  108779. * Vive Controller
  108780. */
  108781. export class ViveController extends WebVRController {
  108782. /**
  108783. * Base Url for the controller model.
  108784. */
  108785. static MODEL_BASE_URL: string;
  108786. /**
  108787. * File name for the controller model.
  108788. */
  108789. static MODEL_FILENAME: string;
  108790. /**
  108791. * Creates a new ViveController from a gamepad
  108792. * @param vrGamepad the gamepad that the controller should be created from
  108793. */
  108794. constructor(vrGamepad: any);
  108795. /**
  108796. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108797. * @param scene scene in which to add meshes
  108798. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108799. */
  108800. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108801. /**
  108802. * Fired when the left button on this controller is modified
  108803. */
  108804. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108805. /**
  108806. * Fired when the right button on this controller is modified
  108807. */
  108808. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108809. /**
  108810. * Fired when the menu button on this controller is modified
  108811. */
  108812. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108813. /**
  108814. * Called once for each button that changed state since the last frame
  108815. * Vive mapping:
  108816. * 0: touchpad
  108817. * 1: trigger
  108818. * 2: left AND right buttons
  108819. * 3: menu button
  108820. * @param buttonIdx Which button index changed
  108821. * @param state New state of the button
  108822. * @param changes Which properties on the state changed since last frame
  108823. */
  108824. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108825. }
  108826. }
  108827. declare module BABYLON {
  108828. /**
  108829. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108830. */
  108831. export class WebXRControllerModelLoader {
  108832. /**
  108833. * Creates the WebXRControllerModelLoader
  108834. * @param input xr input that creates the controllers
  108835. */
  108836. constructor(input: WebXRInput);
  108837. }
  108838. }
  108839. declare module BABYLON {
  108840. /**
  108841. * Contains an array of blocks representing the octree
  108842. */
  108843. export interface IOctreeContainer<T> {
  108844. /**
  108845. * Blocks within the octree
  108846. */
  108847. blocks: Array<OctreeBlock<T>>;
  108848. }
  108849. /**
  108850. * Class used to store a cell in an octree
  108851. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108852. */
  108853. export class OctreeBlock<T> {
  108854. /**
  108855. * Gets the content of the current block
  108856. */
  108857. entries: T[];
  108858. /**
  108859. * Gets the list of block children
  108860. */
  108861. blocks: Array<OctreeBlock<T>>;
  108862. private _depth;
  108863. private _maxDepth;
  108864. private _capacity;
  108865. private _minPoint;
  108866. private _maxPoint;
  108867. private _boundingVectors;
  108868. private _creationFunc;
  108869. /**
  108870. * Creates a new block
  108871. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108872. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108873. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108874. * @param depth defines the current depth of this block in the octree
  108875. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108876. * @param creationFunc defines a callback to call when an element is added to the block
  108877. */
  108878. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108879. /**
  108880. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108881. */
  108882. readonly capacity: number;
  108883. /**
  108884. * Gets the minimum vector (in world space) of the block's bounding box
  108885. */
  108886. readonly minPoint: Vector3;
  108887. /**
  108888. * Gets the maximum vector (in world space) of the block's bounding box
  108889. */
  108890. readonly maxPoint: Vector3;
  108891. /**
  108892. * Add a new element to this block
  108893. * @param entry defines the element to add
  108894. */
  108895. addEntry(entry: T): void;
  108896. /**
  108897. * Remove an element from this block
  108898. * @param entry defines the element to remove
  108899. */
  108900. removeEntry(entry: T): void;
  108901. /**
  108902. * Add an array of elements to this block
  108903. * @param entries defines the array of elements to add
  108904. */
  108905. addEntries(entries: T[]): void;
  108906. /**
  108907. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108908. * @param frustumPlanes defines the frustum planes to test
  108909. * @param selection defines the array to store current content if selection is positive
  108910. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108911. */
  108912. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108913. /**
  108914. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108915. * @param sphereCenter defines the bounding sphere center
  108916. * @param sphereRadius defines the bounding sphere radius
  108917. * @param selection defines the array to store current content if selection is positive
  108918. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108919. */
  108920. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108921. /**
  108922. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108923. * @param ray defines the ray to test with
  108924. * @param selection defines the array to store current content if selection is positive
  108925. */
  108926. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108927. /**
  108928. * Subdivide the content into child blocks (this block will then be empty)
  108929. */
  108930. createInnerBlocks(): void;
  108931. /**
  108932. * @hidden
  108933. */
  108934. 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;
  108935. }
  108936. }
  108937. declare module BABYLON {
  108938. /**
  108939. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108940. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108941. */
  108942. export class Octree<T> {
  108943. /** 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.) */
  108944. maxDepth: number;
  108945. /**
  108946. * Blocks within the octree containing objects
  108947. */
  108948. blocks: Array<OctreeBlock<T>>;
  108949. /**
  108950. * Content stored in the octree
  108951. */
  108952. dynamicContent: T[];
  108953. private _maxBlockCapacity;
  108954. private _selectionContent;
  108955. private _creationFunc;
  108956. /**
  108957. * Creates a octree
  108958. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108959. * @param creationFunc function to be used to instatiate the octree
  108960. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108961. * @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.)
  108962. */
  108963. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108964. /** 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.) */
  108965. maxDepth?: number);
  108966. /**
  108967. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108968. * @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);
  108969. * @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);
  108970. * @param entries meshes to be added to the octree blocks
  108971. */
  108972. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108973. /**
  108974. * Adds a mesh to the octree
  108975. * @param entry Mesh to add to the octree
  108976. */
  108977. addMesh(entry: T): void;
  108978. /**
  108979. * Remove an element from the octree
  108980. * @param entry defines the element to remove
  108981. */
  108982. removeMesh(entry: T): void;
  108983. /**
  108984. * Selects an array of meshes within the frustum
  108985. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108986. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108987. * @returns array of meshes within the frustum
  108988. */
  108989. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108990. /**
  108991. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108992. * @param sphereCenter defines the bounding sphere center
  108993. * @param sphereRadius defines the bounding sphere radius
  108994. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108995. * @returns an array of objects that intersect the sphere
  108996. */
  108997. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108998. /**
  108999. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109000. * @param ray defines the ray to test with
  109001. * @returns array of intersected objects
  109002. */
  109003. intersectsRay(ray: Ray): SmartArray<T>;
  109004. /**
  109005. * Adds a mesh into the octree block if it intersects the block
  109006. */
  109007. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109008. /**
  109009. * Adds a submesh into the octree block if it intersects the block
  109010. */
  109011. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109012. }
  109013. }
  109014. declare module BABYLON {
  109015. interface Scene {
  109016. /**
  109017. * @hidden
  109018. * Backing Filed
  109019. */
  109020. _selectionOctree: Octree<AbstractMesh>;
  109021. /**
  109022. * Gets the octree used to boost mesh selection (picking)
  109023. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109024. */
  109025. selectionOctree: Octree<AbstractMesh>;
  109026. /**
  109027. * Creates or updates the octree used to boost selection (picking)
  109028. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109029. * @param maxCapacity defines the maximum capacity per leaf
  109030. * @param maxDepth defines the maximum depth of the octree
  109031. * @returns an octree of AbstractMesh
  109032. */
  109033. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109034. }
  109035. interface AbstractMesh {
  109036. /**
  109037. * @hidden
  109038. * Backing Field
  109039. */
  109040. _submeshesOctree: Octree<SubMesh>;
  109041. /**
  109042. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109043. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109044. * @param maxCapacity defines the maximum size of each block (64 by default)
  109045. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109046. * @returns the new octree
  109047. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109049. */
  109050. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109051. }
  109052. /**
  109053. * Defines the octree scene component responsible to manage any octrees
  109054. * in a given scene.
  109055. */
  109056. export class OctreeSceneComponent {
  109057. /**
  109058. * The component name help to identify the component in the list of scene components.
  109059. */
  109060. readonly name: string;
  109061. /**
  109062. * The scene the component belongs to.
  109063. */
  109064. scene: Scene;
  109065. /**
  109066. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109067. */
  109068. readonly checksIsEnabled: boolean;
  109069. /**
  109070. * Creates a new instance of the component for the given scene
  109071. * @param scene Defines the scene to register the component in
  109072. */
  109073. constructor(scene: Scene);
  109074. /**
  109075. * Registers the component in a given scene
  109076. */
  109077. register(): void;
  109078. /**
  109079. * Return the list of active meshes
  109080. * @returns the list of active meshes
  109081. */
  109082. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109083. /**
  109084. * Return the list of active sub meshes
  109085. * @param mesh The mesh to get the candidates sub meshes from
  109086. * @returns the list of active sub meshes
  109087. */
  109088. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109089. private _tempRay;
  109090. /**
  109091. * Return the list of sub meshes intersecting with a given local ray
  109092. * @param mesh defines the mesh to find the submesh for
  109093. * @param localRay defines the ray in local space
  109094. * @returns the list of intersecting sub meshes
  109095. */
  109096. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109097. /**
  109098. * Return the list of sub meshes colliding with a collider
  109099. * @param mesh defines the mesh to find the submesh for
  109100. * @param collider defines the collider to evaluate the collision against
  109101. * @returns the list of colliding sub meshes
  109102. */
  109103. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109104. /**
  109105. * Rebuilds the elements related to this component in case of
  109106. * context lost for instance.
  109107. */
  109108. rebuild(): void;
  109109. /**
  109110. * Disposes the component and the associated ressources.
  109111. */
  109112. dispose(): void;
  109113. }
  109114. }
  109115. declare module BABYLON {
  109116. /**
  109117. * Renders a layer on top of an existing scene
  109118. */
  109119. export class UtilityLayerRenderer implements IDisposable {
  109120. /** the original scene that will be rendered on top of */
  109121. originalScene: Scene;
  109122. private _pointerCaptures;
  109123. private _lastPointerEvents;
  109124. private static _DefaultUtilityLayer;
  109125. private static _DefaultKeepDepthUtilityLayer;
  109126. private _sharedGizmoLight;
  109127. private _renderCamera;
  109128. /**
  109129. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109130. * @returns the camera that is used when rendering the utility layer
  109131. */
  109132. getRenderCamera(): Nullable<Camera>;
  109133. /**
  109134. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109135. * @param cam the camera that should be used when rendering the utility layer
  109136. */
  109137. setRenderCamera(cam: Nullable<Camera>): void;
  109138. /**
  109139. * @hidden
  109140. * Light which used by gizmos to get light shading
  109141. */
  109142. _getSharedGizmoLight(): HemisphericLight;
  109143. /**
  109144. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109145. */
  109146. pickUtilitySceneFirst: boolean;
  109147. /**
  109148. * 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)
  109149. */
  109150. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109151. /**
  109152. * 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)
  109153. */
  109154. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109155. /**
  109156. * The scene that is rendered on top of the original scene
  109157. */
  109158. utilityLayerScene: Scene;
  109159. /**
  109160. * If the utility layer should automatically be rendered on top of existing scene
  109161. */
  109162. shouldRender: boolean;
  109163. /**
  109164. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109165. */
  109166. onlyCheckPointerDownEvents: boolean;
  109167. /**
  109168. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109169. */
  109170. processAllEvents: boolean;
  109171. /**
  109172. * Observable raised when the pointer move from the utility layer scene to the main scene
  109173. */
  109174. onPointerOutObservable: Observable<number>;
  109175. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109176. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109177. private _afterRenderObserver;
  109178. private _sceneDisposeObserver;
  109179. private _originalPointerObserver;
  109180. /**
  109181. * Instantiates a UtilityLayerRenderer
  109182. * @param originalScene the original scene that will be rendered on top of
  109183. * @param handleEvents boolean indicating if the utility layer should handle events
  109184. */
  109185. constructor(
  109186. /** the original scene that will be rendered on top of */
  109187. originalScene: Scene, handleEvents?: boolean);
  109188. private _notifyObservers;
  109189. /**
  109190. * Renders the utility layers scene on top of the original scene
  109191. */
  109192. render(): void;
  109193. /**
  109194. * Disposes of the renderer
  109195. */
  109196. dispose(): void;
  109197. private _updateCamera;
  109198. }
  109199. }
  109200. declare module BABYLON {
  109201. /**
  109202. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109203. */
  109204. export class Gizmo implements IDisposable {
  109205. /** The utility layer the gizmo will be added to */
  109206. gizmoLayer: UtilityLayerRenderer;
  109207. /**
  109208. * The root mesh of the gizmo
  109209. */
  109210. _rootMesh: Mesh;
  109211. private _attachedMesh;
  109212. /**
  109213. * Ratio for the scale of the gizmo (Default: 1)
  109214. */
  109215. scaleRatio: number;
  109216. /**
  109217. * If a custom mesh has been set (Default: false)
  109218. */
  109219. protected _customMeshSet: boolean;
  109220. /**
  109221. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109222. * * When set, interactions will be enabled
  109223. */
  109224. attachedMesh: Nullable<AbstractMesh>;
  109225. /**
  109226. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109227. * @param mesh The mesh to replace the default mesh of the gizmo
  109228. */
  109229. setCustomMesh(mesh: Mesh): void;
  109230. /**
  109231. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109232. */
  109233. updateGizmoRotationToMatchAttachedMesh: boolean;
  109234. /**
  109235. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109236. */
  109237. updateGizmoPositionToMatchAttachedMesh: boolean;
  109238. /**
  109239. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109240. */
  109241. updateScale: boolean;
  109242. protected _interactionsEnabled: boolean;
  109243. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109244. private _beforeRenderObserver;
  109245. private _tempVector;
  109246. /**
  109247. * Creates a gizmo
  109248. * @param gizmoLayer The utility layer the gizmo will be added to
  109249. */
  109250. constructor(
  109251. /** The utility layer the gizmo will be added to */
  109252. gizmoLayer?: UtilityLayerRenderer);
  109253. /**
  109254. * Updates the gizmo to match the attached mesh's position/rotation
  109255. */
  109256. protected _update(): void;
  109257. /**
  109258. * Disposes of the gizmo
  109259. */
  109260. dispose(): void;
  109261. }
  109262. }
  109263. declare module BABYLON {
  109264. /**
  109265. * Single plane drag gizmo
  109266. */
  109267. export class PlaneDragGizmo extends Gizmo {
  109268. /**
  109269. * Drag behavior responsible for the gizmos dragging interactions
  109270. */
  109271. dragBehavior: PointerDragBehavior;
  109272. private _pointerObserver;
  109273. /**
  109274. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109275. */
  109276. snapDistance: number;
  109277. /**
  109278. * Event that fires each time the gizmo snaps to a new location.
  109279. * * snapDistance is the the change in distance
  109280. */
  109281. onSnapObservable: Observable<{
  109282. snapDistance: number;
  109283. }>;
  109284. private _plane;
  109285. private _coloredMaterial;
  109286. private _hoverMaterial;
  109287. private _isEnabled;
  109288. private _parent;
  109289. /** @hidden */
  109290. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109291. /** @hidden */
  109292. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109293. /**
  109294. * Creates a PlaneDragGizmo
  109295. * @param gizmoLayer The utility layer the gizmo will be added to
  109296. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109297. * @param color The color of the gizmo
  109298. */
  109299. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109300. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109301. /**
  109302. * If the gizmo is enabled
  109303. */
  109304. isEnabled: boolean;
  109305. /**
  109306. * Disposes of the gizmo
  109307. */
  109308. dispose(): void;
  109309. }
  109310. }
  109311. declare module BABYLON {
  109312. /**
  109313. * Gizmo that enables dragging a mesh along 3 axis
  109314. */
  109315. export class PositionGizmo extends Gizmo {
  109316. /**
  109317. * Internal gizmo used for interactions on the x axis
  109318. */
  109319. xGizmo: AxisDragGizmo;
  109320. /**
  109321. * Internal gizmo used for interactions on the y axis
  109322. */
  109323. yGizmo: AxisDragGizmo;
  109324. /**
  109325. * Internal gizmo used for interactions on the z axis
  109326. */
  109327. zGizmo: AxisDragGizmo;
  109328. /**
  109329. * Internal gizmo used for interactions on the yz plane
  109330. */
  109331. xPlaneGizmo: PlaneDragGizmo;
  109332. /**
  109333. * Internal gizmo used for interactions on the xz plane
  109334. */
  109335. yPlaneGizmo: PlaneDragGizmo;
  109336. /**
  109337. * Internal gizmo used for interactions on the xy plane
  109338. */
  109339. zPlaneGizmo: PlaneDragGizmo;
  109340. /**
  109341. * private variables
  109342. */
  109343. private _meshAttached;
  109344. private _updateGizmoRotationToMatchAttachedMesh;
  109345. private _snapDistance;
  109346. private _scaleRatio;
  109347. /** Fires an event when any of it's sub gizmos are dragged */
  109348. onDragStartObservable: Observable<unknown>;
  109349. /** Fires an event when any of it's sub gizmos are released from dragging */
  109350. onDragEndObservable: Observable<unknown>;
  109351. /**
  109352. * If set to true, planar drag is enabled
  109353. */
  109354. private _planarGizmoEnabled;
  109355. attachedMesh: Nullable<AbstractMesh>;
  109356. /**
  109357. * Creates a PositionGizmo
  109358. * @param gizmoLayer The utility layer the gizmo will be added to
  109359. */
  109360. constructor(gizmoLayer?: UtilityLayerRenderer);
  109361. /**
  109362. * If the planar drag gizmo is enabled
  109363. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109364. */
  109365. planarGizmoEnabled: boolean;
  109366. updateGizmoRotationToMatchAttachedMesh: boolean;
  109367. /**
  109368. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109369. */
  109370. snapDistance: number;
  109371. /**
  109372. * Ratio for the scale of the gizmo (Default: 1)
  109373. */
  109374. scaleRatio: number;
  109375. /**
  109376. * Disposes of the gizmo
  109377. */
  109378. dispose(): void;
  109379. /**
  109380. * CustomMeshes are not supported by this gizmo
  109381. * @param mesh The mesh to replace the default mesh of the gizmo
  109382. */
  109383. setCustomMesh(mesh: Mesh): void;
  109384. }
  109385. }
  109386. declare module BABYLON {
  109387. /**
  109388. * Single axis drag gizmo
  109389. */
  109390. export class AxisDragGizmo extends Gizmo {
  109391. /**
  109392. * Drag behavior responsible for the gizmos dragging interactions
  109393. */
  109394. dragBehavior: PointerDragBehavior;
  109395. private _pointerObserver;
  109396. /**
  109397. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109398. */
  109399. snapDistance: number;
  109400. /**
  109401. * Event that fires each time the gizmo snaps to a new location.
  109402. * * snapDistance is the the change in distance
  109403. */
  109404. onSnapObservable: Observable<{
  109405. snapDistance: number;
  109406. }>;
  109407. private _isEnabled;
  109408. private _parent;
  109409. private _arrow;
  109410. private _coloredMaterial;
  109411. private _hoverMaterial;
  109412. /** @hidden */
  109413. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109414. /** @hidden */
  109415. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109416. /**
  109417. * Creates an AxisDragGizmo
  109418. * @param gizmoLayer The utility layer the gizmo will be added to
  109419. * @param dragAxis The axis which the gizmo will be able to drag on
  109420. * @param color The color of the gizmo
  109421. */
  109422. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109423. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109424. /**
  109425. * If the gizmo is enabled
  109426. */
  109427. isEnabled: boolean;
  109428. /**
  109429. * Disposes of the gizmo
  109430. */
  109431. dispose(): void;
  109432. }
  109433. }
  109434. declare module BABYLON.Debug {
  109435. /**
  109436. * The Axes viewer will show 3 axes in a specific point in space
  109437. */
  109438. export class AxesViewer {
  109439. private _xAxis;
  109440. private _yAxis;
  109441. private _zAxis;
  109442. private _scaleLinesFactor;
  109443. private _instanced;
  109444. /**
  109445. * Gets the hosting scene
  109446. */
  109447. scene: Scene;
  109448. /**
  109449. * Gets or sets a number used to scale line length
  109450. */
  109451. scaleLines: number;
  109452. /** Gets the node hierarchy used to render x-axis */
  109453. readonly xAxis: TransformNode;
  109454. /** Gets the node hierarchy used to render y-axis */
  109455. readonly yAxis: TransformNode;
  109456. /** Gets the node hierarchy used to render z-axis */
  109457. readonly zAxis: TransformNode;
  109458. /**
  109459. * Creates a new AxesViewer
  109460. * @param scene defines the hosting scene
  109461. * @param scaleLines defines a number used to scale line length (1 by default)
  109462. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109463. * @param xAxis defines the node hierarchy used to render the x-axis
  109464. * @param yAxis defines the node hierarchy used to render the y-axis
  109465. * @param zAxis defines the node hierarchy used to render the z-axis
  109466. */
  109467. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109468. /**
  109469. * Force the viewer to update
  109470. * @param position defines the position of the viewer
  109471. * @param xaxis defines the x axis of the viewer
  109472. * @param yaxis defines the y axis of the viewer
  109473. * @param zaxis defines the z axis of the viewer
  109474. */
  109475. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109476. /**
  109477. * Creates an instance of this axes viewer.
  109478. * @returns a new axes viewer with instanced meshes
  109479. */
  109480. createInstance(): AxesViewer;
  109481. /** Releases resources */
  109482. dispose(): void;
  109483. private static _SetRenderingGroupId;
  109484. }
  109485. }
  109486. declare module BABYLON.Debug {
  109487. /**
  109488. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109489. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109490. */
  109491. export class BoneAxesViewer extends AxesViewer {
  109492. /**
  109493. * Gets or sets the target mesh where to display the axes viewer
  109494. */
  109495. mesh: Nullable<Mesh>;
  109496. /**
  109497. * Gets or sets the target bone where to display the axes viewer
  109498. */
  109499. bone: Nullable<Bone>;
  109500. /** Gets current position */
  109501. pos: Vector3;
  109502. /** Gets direction of X axis */
  109503. xaxis: Vector3;
  109504. /** Gets direction of Y axis */
  109505. yaxis: Vector3;
  109506. /** Gets direction of Z axis */
  109507. zaxis: Vector3;
  109508. /**
  109509. * Creates a new BoneAxesViewer
  109510. * @param scene defines the hosting scene
  109511. * @param bone defines the target bone
  109512. * @param mesh defines the target mesh
  109513. * @param scaleLines defines a scaling factor for line length (1 by default)
  109514. */
  109515. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109516. /**
  109517. * Force the viewer to update
  109518. */
  109519. update(): void;
  109520. /** Releases resources */
  109521. dispose(): void;
  109522. }
  109523. }
  109524. declare module BABYLON {
  109525. /**
  109526. * Interface used to define scene explorer extensibility option
  109527. */
  109528. export interface IExplorerExtensibilityOption {
  109529. /**
  109530. * Define the option label
  109531. */
  109532. label: string;
  109533. /**
  109534. * Defines the action to execute on click
  109535. */
  109536. action: (entity: any) => void;
  109537. }
  109538. /**
  109539. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109540. */
  109541. export interface IExplorerExtensibilityGroup {
  109542. /**
  109543. * Defines a predicate to test if a given type mut be extended
  109544. */
  109545. predicate: (entity: any) => boolean;
  109546. /**
  109547. * Gets the list of options added to a type
  109548. */
  109549. entries: IExplorerExtensibilityOption[];
  109550. }
  109551. /**
  109552. * Interface used to define the options to use to create the Inspector
  109553. */
  109554. export interface IInspectorOptions {
  109555. /**
  109556. * Display in overlay mode (default: false)
  109557. */
  109558. overlay?: boolean;
  109559. /**
  109560. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109561. */
  109562. globalRoot?: HTMLElement;
  109563. /**
  109564. * Display the Scene explorer
  109565. */
  109566. showExplorer?: boolean;
  109567. /**
  109568. * Display the property inspector
  109569. */
  109570. showInspector?: boolean;
  109571. /**
  109572. * Display in embed mode (both panes on the right)
  109573. */
  109574. embedMode?: boolean;
  109575. /**
  109576. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109577. */
  109578. handleResize?: boolean;
  109579. /**
  109580. * Allow the panes to popup (default: true)
  109581. */
  109582. enablePopup?: boolean;
  109583. /**
  109584. * Allow the panes to be closed by users (default: true)
  109585. */
  109586. enableClose?: boolean;
  109587. /**
  109588. * Optional list of extensibility entries
  109589. */
  109590. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109591. /**
  109592. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109593. */
  109594. inspectorURL?: string;
  109595. }
  109596. interface Scene {
  109597. /**
  109598. * @hidden
  109599. * Backing field
  109600. */
  109601. _debugLayer: DebugLayer;
  109602. /**
  109603. * Gets the debug layer (aka Inspector) associated with the scene
  109604. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109605. */
  109606. debugLayer: DebugLayer;
  109607. }
  109608. /**
  109609. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109610. * what is happening in your scene
  109611. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109612. */
  109613. export class DebugLayer {
  109614. /**
  109615. * Define the url to get the inspector script from.
  109616. * By default it uses the babylonjs CDN.
  109617. * @ignoreNaming
  109618. */
  109619. static InspectorURL: string;
  109620. private _scene;
  109621. private BJSINSPECTOR;
  109622. private _onPropertyChangedObservable?;
  109623. /**
  109624. * Observable triggered when a property is changed through the inspector.
  109625. */
  109626. readonly onPropertyChangedObservable: any;
  109627. /**
  109628. * Instantiates a new debug layer.
  109629. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109630. * what is happening in your scene
  109631. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109632. * @param scene Defines the scene to inspect
  109633. */
  109634. constructor(scene: Scene);
  109635. /** Creates the inspector window. */
  109636. private _createInspector;
  109637. /**
  109638. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  109639. * @param entity defines the entity to select
  109640. * @param lineContainerTitle defines the specific block to highlight
  109641. */
  109642. select(entity: any, lineContainerTitle?: string): void;
  109643. /** Get the inspector from bundle or global */
  109644. private _getGlobalInspector;
  109645. /**
  109646. * Get if the inspector is visible or not.
  109647. * @returns true if visible otherwise, false
  109648. */
  109649. isVisible(): boolean;
  109650. /**
  109651. * Hide the inspector and close its window.
  109652. */
  109653. hide(): void;
  109654. /**
  109655. * Launch the debugLayer.
  109656. * @param config Define the configuration of the inspector
  109657. * @return a promise fulfilled when the debug layer is visible
  109658. */
  109659. show(config?: IInspectorOptions): Promise<DebugLayer>;
  109660. }
  109661. }
  109662. declare module BABYLON {
  109663. /**
  109664. * Class containing static functions to help procedurally build meshes
  109665. */
  109666. export class BoxBuilder {
  109667. /**
  109668. * Creates a box mesh
  109669. * * The parameter `size` sets the size (float) of each box side (default 1)
  109670. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109671. * * 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)
  109672. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109676. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109677. * @param name defines the name of the mesh
  109678. * @param options defines the options used to create the mesh
  109679. * @param scene defines the hosting scene
  109680. * @returns the box mesh
  109681. */
  109682. static CreateBox(name: string, options: {
  109683. size?: number;
  109684. width?: number;
  109685. height?: number;
  109686. depth?: number;
  109687. faceUV?: Vector4[];
  109688. faceColors?: Color4[];
  109689. sideOrientation?: number;
  109690. frontUVs?: Vector4;
  109691. backUVs?: Vector4;
  109692. wrap?: boolean;
  109693. topBaseAt?: number;
  109694. bottomBaseAt?: number;
  109695. updatable?: boolean;
  109696. }, scene?: Nullable<Scene>): Mesh;
  109697. }
  109698. }
  109699. declare module BABYLON {
  109700. /**
  109701. * Class containing static functions to help procedurally build meshes
  109702. */
  109703. export class SphereBuilder {
  109704. /**
  109705. * Creates a sphere mesh
  109706. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109707. * * 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`)
  109708. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109709. * * 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
  109710. * * 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)
  109711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109714. * @param name defines the name of the mesh
  109715. * @param options defines the options used to create the mesh
  109716. * @param scene defines the hosting scene
  109717. * @returns the sphere mesh
  109718. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109719. */
  109720. static CreateSphere(name: string, options: {
  109721. segments?: number;
  109722. diameter?: number;
  109723. diameterX?: number;
  109724. diameterY?: number;
  109725. diameterZ?: number;
  109726. arc?: number;
  109727. slice?: number;
  109728. sideOrientation?: number;
  109729. frontUVs?: Vector4;
  109730. backUVs?: Vector4;
  109731. updatable?: boolean;
  109732. }, scene?: Nullable<Scene>): Mesh;
  109733. }
  109734. }
  109735. declare module BABYLON.Debug {
  109736. /**
  109737. * Used to show the physics impostor around the specific mesh
  109738. */
  109739. export class PhysicsViewer {
  109740. /** @hidden */
  109741. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  109742. /** @hidden */
  109743. protected _meshes: Array<Nullable<AbstractMesh>>;
  109744. /** @hidden */
  109745. protected _scene: Nullable<Scene>;
  109746. /** @hidden */
  109747. protected _numMeshes: number;
  109748. /** @hidden */
  109749. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  109750. private _renderFunction;
  109751. private _utilityLayer;
  109752. private _debugBoxMesh;
  109753. private _debugSphereMesh;
  109754. private _debugCylinderMesh;
  109755. private _debugMaterial;
  109756. private _debugMeshMeshes;
  109757. /**
  109758. * Creates a new PhysicsViewer
  109759. * @param scene defines the hosting scene
  109760. */
  109761. constructor(scene: Scene);
  109762. /** @hidden */
  109763. protected _updateDebugMeshes(): void;
  109764. /**
  109765. * Renders a specified physic impostor
  109766. * @param impostor defines the impostor to render
  109767. * @param targetMesh defines the mesh represented by the impostor
  109768. * @returns the new debug mesh used to render the impostor
  109769. */
  109770. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  109771. /**
  109772. * Hides a specified physic impostor
  109773. * @param impostor defines the impostor to hide
  109774. */
  109775. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109776. private _getDebugMaterial;
  109777. private _getDebugBoxMesh;
  109778. private _getDebugSphereMesh;
  109779. private _getDebugCylinderMesh;
  109780. private _getDebugMeshMesh;
  109781. private _getDebugMesh;
  109782. /** Releases all resources */
  109783. dispose(): void;
  109784. }
  109785. }
  109786. declare module BABYLON {
  109787. /**
  109788. * Class containing static functions to help procedurally build meshes
  109789. */
  109790. export class LinesBuilder {
  109791. /**
  109792. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109793. * * 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
  109794. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109795. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109796. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109797. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109798. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109799. * * 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
  109800. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109803. * @param name defines the name of the new line system
  109804. * @param options defines the options used to create the line system
  109805. * @param scene defines the hosting scene
  109806. * @returns a new line system mesh
  109807. */
  109808. static CreateLineSystem(name: string, options: {
  109809. lines: Vector3[][];
  109810. updatable?: boolean;
  109811. instance?: Nullable<LinesMesh>;
  109812. colors?: Nullable<Color4[][]>;
  109813. useVertexAlpha?: boolean;
  109814. }, scene: Nullable<Scene>): LinesMesh;
  109815. /**
  109816. * Creates a line mesh
  109817. * 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
  109818. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109819. * * The parameter `points` is an array successive Vector3
  109820. * * 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
  109821. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109822. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109823. * * When updating an instance, remember that only point positions can change, not the number of points
  109824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109826. * @param name defines the name of the new line system
  109827. * @param options defines the options used to create the line system
  109828. * @param scene defines the hosting scene
  109829. * @returns a new line mesh
  109830. */
  109831. static CreateLines(name: string, options: {
  109832. points: Vector3[];
  109833. updatable?: boolean;
  109834. instance?: Nullable<LinesMesh>;
  109835. colors?: Color4[];
  109836. useVertexAlpha?: boolean;
  109837. }, scene?: Nullable<Scene>): LinesMesh;
  109838. /**
  109839. * Creates a dashed line mesh
  109840. * * 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
  109841. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109842. * * The parameter `points` is an array successive Vector3
  109843. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109844. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109845. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109846. * * 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
  109847. * * When updating an instance, remember that only point positions can change, not the number of points
  109848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109849. * @param name defines the name of the mesh
  109850. * @param options defines the options used to create the mesh
  109851. * @param scene defines the hosting scene
  109852. * @returns the dashed line mesh
  109853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109854. */
  109855. static CreateDashedLines(name: string, options: {
  109856. points: Vector3[];
  109857. dashSize?: number;
  109858. gapSize?: number;
  109859. dashNb?: number;
  109860. updatable?: boolean;
  109861. instance?: LinesMesh;
  109862. }, scene?: Nullable<Scene>): LinesMesh;
  109863. }
  109864. }
  109865. declare module BABYLON {
  109866. /**
  109867. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109868. * in order to better appreciate the issue one might have.
  109869. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109870. */
  109871. export class RayHelper {
  109872. /**
  109873. * Defines the ray we are currently tryin to visualize.
  109874. */
  109875. ray: Nullable<Ray>;
  109876. private _renderPoints;
  109877. private _renderLine;
  109878. private _renderFunction;
  109879. private _scene;
  109880. private _updateToMeshFunction;
  109881. private _attachedToMesh;
  109882. private _meshSpaceDirection;
  109883. private _meshSpaceOrigin;
  109884. /**
  109885. * Helper function to create a colored helper in a scene in one line.
  109886. * @param ray Defines the ray we are currently tryin to visualize
  109887. * @param scene Defines the scene the ray is used in
  109888. * @param color Defines the color we want to see the ray in
  109889. * @returns The newly created ray helper.
  109890. */
  109891. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109892. /**
  109893. * Instantiate a new ray helper.
  109894. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109895. * in order to better appreciate the issue one might have.
  109896. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109897. * @param ray Defines the ray we are currently tryin to visualize
  109898. */
  109899. constructor(ray: Ray);
  109900. /**
  109901. * Shows the ray we are willing to debug.
  109902. * @param scene Defines the scene the ray needs to be rendered in
  109903. * @param color Defines the color the ray needs to be rendered in
  109904. */
  109905. show(scene: Scene, color?: Color3): void;
  109906. /**
  109907. * Hides the ray we are debugging.
  109908. */
  109909. hide(): void;
  109910. private _render;
  109911. /**
  109912. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109913. * @param mesh Defines the mesh we want the helper attached to
  109914. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109915. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109916. * @param length Defines the length of the ray
  109917. */
  109918. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109919. /**
  109920. * Detach the ray helper from the mesh it has previously been attached to.
  109921. */
  109922. detachFromMesh(): void;
  109923. private _updateToMesh;
  109924. /**
  109925. * Dispose the helper and release its associated resources.
  109926. */
  109927. dispose(): void;
  109928. }
  109929. }
  109930. declare module BABYLON.Debug {
  109931. /**
  109932. * Class used to render a debug view of a given skeleton
  109933. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109934. */
  109935. export class SkeletonViewer {
  109936. /** defines the skeleton to render */
  109937. skeleton: Skeleton;
  109938. /** defines the mesh attached to the skeleton */
  109939. mesh: AbstractMesh;
  109940. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109941. autoUpdateBonesMatrices: boolean;
  109942. /** defines the rendering group id to use with the viewer */
  109943. renderingGroupId: number;
  109944. /** Gets or sets the color used to render the skeleton */
  109945. color: Color3;
  109946. private _scene;
  109947. private _debugLines;
  109948. private _debugMesh;
  109949. private _isEnabled;
  109950. private _renderFunction;
  109951. private _utilityLayer;
  109952. /**
  109953. * Returns the mesh used to render the bones
  109954. */
  109955. readonly debugMesh: Nullable<LinesMesh>;
  109956. /**
  109957. * Creates a new SkeletonViewer
  109958. * @param skeleton defines the skeleton to render
  109959. * @param mesh defines the mesh attached to the skeleton
  109960. * @param scene defines the hosting scene
  109961. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109962. * @param renderingGroupId defines the rendering group id to use with the viewer
  109963. */
  109964. constructor(
  109965. /** defines the skeleton to render */
  109966. skeleton: Skeleton,
  109967. /** defines the mesh attached to the skeleton */
  109968. mesh: AbstractMesh, scene: Scene,
  109969. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109970. autoUpdateBonesMatrices?: boolean,
  109971. /** defines the rendering group id to use with the viewer */
  109972. renderingGroupId?: number);
  109973. /** Gets or sets a boolean indicating if the viewer is enabled */
  109974. isEnabled: boolean;
  109975. private _getBonePosition;
  109976. private _getLinesForBonesWithLength;
  109977. private _getLinesForBonesNoLength;
  109978. /** Update the viewer to sync with current skeleton state */
  109979. update(): void;
  109980. /** Release associated resources */
  109981. dispose(): void;
  109982. }
  109983. }
  109984. declare module BABYLON {
  109985. /**
  109986. * Options to create the null engine
  109987. */
  109988. export class NullEngineOptions {
  109989. /**
  109990. * Render width (Default: 512)
  109991. */
  109992. renderWidth: number;
  109993. /**
  109994. * Render height (Default: 256)
  109995. */
  109996. renderHeight: number;
  109997. /**
  109998. * Texture size (Default: 512)
  109999. */
  110000. textureSize: number;
  110001. /**
  110002. * If delta time between frames should be constant
  110003. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110004. */
  110005. deterministicLockstep: boolean;
  110006. /**
  110007. * Maximum about of steps between frames (Default: 4)
  110008. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110009. */
  110010. lockstepMaxSteps: number;
  110011. }
  110012. /**
  110013. * The null engine class provides support for headless version of babylon.js.
  110014. * This can be used in server side scenario or for testing purposes
  110015. */
  110016. export class NullEngine extends Engine {
  110017. private _options;
  110018. /**
  110019. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110021. * @returns true if engine is in deterministic lock step mode
  110022. */
  110023. isDeterministicLockStep(): boolean;
  110024. /**
  110025. * Gets the max steps when engine is running in deterministic lock step
  110026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110027. * @returns the max steps
  110028. */
  110029. getLockstepMaxSteps(): number;
  110030. /**
  110031. * Gets the current hardware scaling level.
  110032. * By default the hardware scaling level is computed from the window device ratio.
  110033. * 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.
  110034. * @returns a number indicating the current hardware scaling level
  110035. */
  110036. getHardwareScalingLevel(): number;
  110037. constructor(options?: NullEngineOptions);
  110038. /**
  110039. * Creates a vertex buffer
  110040. * @param vertices the data for the vertex buffer
  110041. * @returns the new WebGL static buffer
  110042. */
  110043. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110044. /**
  110045. * Creates a new index buffer
  110046. * @param indices defines the content of the index buffer
  110047. * @param updatable defines if the index buffer must be updatable
  110048. * @returns a new webGL buffer
  110049. */
  110050. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110051. /**
  110052. * Clear the current render buffer or the current render target (if any is set up)
  110053. * @param color defines the color to use
  110054. * @param backBuffer defines if the back buffer must be cleared
  110055. * @param depth defines if the depth buffer must be cleared
  110056. * @param stencil defines if the stencil buffer must be cleared
  110057. */
  110058. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110059. /**
  110060. * Gets the current render width
  110061. * @param useScreen defines if screen size must be used (or the current render target if any)
  110062. * @returns a number defining the current render width
  110063. */
  110064. getRenderWidth(useScreen?: boolean): number;
  110065. /**
  110066. * Gets the current render height
  110067. * @param useScreen defines if screen size must be used (or the current render target if any)
  110068. * @returns a number defining the current render height
  110069. */
  110070. getRenderHeight(useScreen?: boolean): number;
  110071. /**
  110072. * Set the WebGL's viewport
  110073. * @param viewport defines the viewport element to be used
  110074. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110075. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110076. */
  110077. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110078. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110079. /**
  110080. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110081. * @param pipelineContext defines the pipeline context to use
  110082. * @param uniformsNames defines the list of uniform names
  110083. * @returns an array of webGL uniform locations
  110084. */
  110085. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110086. /**
  110087. * Gets the lsit of active attributes for a given webGL program
  110088. * @param pipelineContext defines the pipeline context to use
  110089. * @param attributesNames defines the list of attribute names to get
  110090. * @returns an array of indices indicating the offset of each attribute
  110091. */
  110092. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110093. /**
  110094. * Binds an effect to the webGL context
  110095. * @param effect defines the effect to bind
  110096. */
  110097. bindSamplers(effect: Effect): void;
  110098. /**
  110099. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110100. * @param effect defines the effect to activate
  110101. */
  110102. enableEffect(effect: Effect): void;
  110103. /**
  110104. * Set various states to the webGL context
  110105. * @param culling defines backface culling state
  110106. * @param zOffset defines the value to apply to zOffset (0 by default)
  110107. * @param force defines if states must be applied even if cache is up to date
  110108. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110109. */
  110110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110111. /**
  110112. * Set the value of an uniform to an array of int32
  110113. * @param uniform defines the webGL uniform location where to store the value
  110114. * @param array defines the array of int32 to store
  110115. */
  110116. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110117. /**
  110118. * Set the value of an uniform to an array of int32 (stored as vec2)
  110119. * @param uniform defines the webGL uniform location where to store the value
  110120. * @param array defines the array of int32 to store
  110121. */
  110122. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110123. /**
  110124. * Set the value of an uniform to an array of int32 (stored as vec3)
  110125. * @param uniform defines the webGL uniform location where to store the value
  110126. * @param array defines the array of int32 to store
  110127. */
  110128. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110129. /**
  110130. * Set the value of an uniform to an array of int32 (stored as vec4)
  110131. * @param uniform defines the webGL uniform location where to store the value
  110132. * @param array defines the array of int32 to store
  110133. */
  110134. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110135. /**
  110136. * Set the value of an uniform to an array of float32
  110137. * @param uniform defines the webGL uniform location where to store the value
  110138. * @param array defines the array of float32 to store
  110139. */
  110140. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110141. /**
  110142. * Set the value of an uniform to an array of float32 (stored as vec2)
  110143. * @param uniform defines the webGL uniform location where to store the value
  110144. * @param array defines the array of float32 to store
  110145. */
  110146. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110147. /**
  110148. * Set the value of an uniform to an array of float32 (stored as vec3)
  110149. * @param uniform defines the webGL uniform location where to store the value
  110150. * @param array defines the array of float32 to store
  110151. */
  110152. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110153. /**
  110154. * Set the value of an uniform to an array of float32 (stored as vec4)
  110155. * @param uniform defines the webGL uniform location where to store the value
  110156. * @param array defines the array of float32 to store
  110157. */
  110158. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110159. /**
  110160. * Set the value of an uniform to an array of number
  110161. * @param uniform defines the webGL uniform location where to store the value
  110162. * @param array defines the array of number to store
  110163. */
  110164. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110165. /**
  110166. * Set the value of an uniform to an array of number (stored as vec2)
  110167. * @param uniform defines the webGL uniform location where to store the value
  110168. * @param array defines the array of number to store
  110169. */
  110170. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110171. /**
  110172. * Set the value of an uniform to an array of number (stored as vec3)
  110173. * @param uniform defines the webGL uniform location where to store the value
  110174. * @param array defines the array of number to store
  110175. */
  110176. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110177. /**
  110178. * Set the value of an uniform to an array of number (stored as vec4)
  110179. * @param uniform defines the webGL uniform location where to store the value
  110180. * @param array defines the array of number to store
  110181. */
  110182. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110183. /**
  110184. * Set the value of an uniform to an array of float32 (stored as matrices)
  110185. * @param uniform defines the webGL uniform location where to store the value
  110186. * @param matrices defines the array of float32 to store
  110187. */
  110188. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110189. /**
  110190. * Set the value of an uniform to a matrix (3x3)
  110191. * @param uniform defines the webGL uniform location where to store the value
  110192. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110193. */
  110194. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110195. /**
  110196. * Set the value of an uniform to a matrix (2x2)
  110197. * @param uniform defines the webGL uniform location where to store the value
  110198. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110199. */
  110200. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110201. /**
  110202. * Set the value of an uniform to a number (float)
  110203. * @param uniform defines the webGL uniform location where to store the value
  110204. * @param value defines the float number to store
  110205. */
  110206. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110207. /**
  110208. * Set the value of an uniform to a vec2
  110209. * @param uniform defines the webGL uniform location where to store the value
  110210. * @param x defines the 1st component of the value
  110211. * @param y defines the 2nd component of the value
  110212. */
  110213. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110214. /**
  110215. * Set the value of an uniform to a vec3
  110216. * @param uniform defines the webGL uniform location where to store the value
  110217. * @param x defines the 1st component of the value
  110218. * @param y defines the 2nd component of the value
  110219. * @param z defines the 3rd component of the value
  110220. */
  110221. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110222. /**
  110223. * Set the value of an uniform to a boolean
  110224. * @param uniform defines the webGL uniform location where to store the value
  110225. * @param bool defines the boolean to store
  110226. */
  110227. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110228. /**
  110229. * Set the value of an uniform to a vec4
  110230. * @param uniform defines the webGL uniform location where to store the value
  110231. * @param x defines the 1st component of the value
  110232. * @param y defines the 2nd component of the value
  110233. * @param z defines the 3rd component of the value
  110234. * @param w defines the 4th component of the value
  110235. */
  110236. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110237. /**
  110238. * Sets the current alpha mode
  110239. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110240. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110241. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110242. */
  110243. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110244. /**
  110245. * Bind webGl buffers directly to the webGL context
  110246. * @param vertexBuffers defines the vertex buffer to bind
  110247. * @param indexBuffer defines the index buffer to bind
  110248. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110249. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110250. * @param effect defines the effect associated with the vertex buffer
  110251. */
  110252. bindBuffers(vertexBuffers: {
  110253. [key: string]: VertexBuffer;
  110254. }, indexBuffer: DataBuffer, effect: Effect): void;
  110255. /**
  110256. * Force the entire cache to be cleared
  110257. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110258. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110259. */
  110260. wipeCaches(bruteForce?: boolean): void;
  110261. /**
  110262. * Send a draw order
  110263. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110264. * @param indexStart defines the starting index
  110265. * @param indexCount defines the number of index to draw
  110266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110267. */
  110268. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110269. /**
  110270. * Draw a list of indexed primitives
  110271. * @param fillMode defines the primitive to use
  110272. * @param indexStart defines the starting index
  110273. * @param indexCount defines the number of index to draw
  110274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110275. */
  110276. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110277. /**
  110278. * Draw a list of unindexed primitives
  110279. * @param fillMode defines the primitive to use
  110280. * @param verticesStart defines the index of first vertex to draw
  110281. * @param verticesCount defines the count of vertices to draw
  110282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110283. */
  110284. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110285. /** @hidden */
  110286. _createTexture(): WebGLTexture;
  110287. /** @hidden */
  110288. _releaseTexture(texture: InternalTexture): void;
  110289. /**
  110290. * Usually called from Texture.ts.
  110291. * Passed information to create a WebGLTexture
  110292. * @param urlArg defines a value which contains one of the following:
  110293. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110294. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110295. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110296. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110297. * @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)
  110298. * @param scene needed for loading to the correct scene
  110299. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110300. * @param onLoad optional callback to be called upon successful completion
  110301. * @param onError optional callback to be called upon failure
  110302. * @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
  110303. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110304. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110305. * @param forcedExtension defines the extension to use to pick the right loader
  110306. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110307. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110308. */
  110309. 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;
  110310. /**
  110311. * Creates a new render target texture
  110312. * @param size defines the size of the texture
  110313. * @param options defines the options used to create the texture
  110314. * @returns a new render target texture stored in an InternalTexture
  110315. */
  110316. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110317. /**
  110318. * Update the sampling mode of a given texture
  110319. * @param samplingMode defines the required sampling mode
  110320. * @param texture defines the texture to update
  110321. */
  110322. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110323. /**
  110324. * Binds the frame buffer to the specified texture.
  110325. * @param texture The texture to render to or null for the default canvas
  110326. * @param faceIndex The face of the texture to render to in case of cube texture
  110327. * @param requiredWidth The width of the target to render to
  110328. * @param requiredHeight The height of the target to render to
  110329. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110330. * @param depthStencilTexture The depth stencil texture to use to render
  110331. * @param lodLevel defines le lod level to bind to the frame buffer
  110332. */
  110333. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110334. /**
  110335. * Unbind the current render target texture from the webGL context
  110336. * @param texture defines the render target texture to unbind
  110337. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110338. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110339. */
  110340. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110341. /**
  110342. * Creates a dynamic vertex buffer
  110343. * @param vertices the data for the dynamic vertex buffer
  110344. * @returns the new WebGL dynamic buffer
  110345. */
  110346. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110347. /**
  110348. * Update the content of a dynamic texture
  110349. * @param texture defines the texture to update
  110350. * @param canvas defines the canvas containing the source
  110351. * @param invertY defines if data must be stored with Y axis inverted
  110352. * @param premulAlpha defines if alpha is stored as premultiplied
  110353. * @param format defines the format of the data
  110354. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110355. */
  110356. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110357. /**
  110358. * Gets a boolean indicating if all created effects are ready
  110359. * @returns true if all effects are ready
  110360. */
  110361. areAllEffectsReady(): boolean;
  110362. /**
  110363. * @hidden
  110364. * Get the current error code of the webGL context
  110365. * @returns the error code
  110366. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110367. */
  110368. getError(): number;
  110369. /** @hidden */
  110370. _getUnpackAlignement(): number;
  110371. /** @hidden */
  110372. _unpackFlipY(value: boolean): void;
  110373. /**
  110374. * Update a dynamic index buffer
  110375. * @param indexBuffer defines the target index buffer
  110376. * @param indices defines the data to update
  110377. * @param offset defines the offset in the target index buffer where update should start
  110378. */
  110379. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110380. /**
  110381. * Updates a dynamic vertex buffer.
  110382. * @param vertexBuffer the vertex buffer to update
  110383. * @param vertices the data used to update the vertex buffer
  110384. * @param byteOffset the byte offset of the data (optional)
  110385. * @param byteLength the byte length of the data (optional)
  110386. */
  110387. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110388. /** @hidden */
  110389. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110390. /** @hidden */
  110391. _bindTexture(channel: number, texture: InternalTexture): void;
  110392. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110393. /**
  110394. * 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
  110395. */
  110396. releaseEffects(): void;
  110397. displayLoadingUI(): void;
  110398. hideLoadingUI(): void;
  110399. /** @hidden */
  110400. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110401. /** @hidden */
  110402. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110403. /** @hidden */
  110404. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110405. /** @hidden */
  110406. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110407. }
  110408. }
  110409. declare module BABYLON {
  110410. /** @hidden */
  110411. export class _OcclusionDataStorage {
  110412. /** @hidden */
  110413. occlusionInternalRetryCounter: number;
  110414. /** @hidden */
  110415. isOcclusionQueryInProgress: boolean;
  110416. /** @hidden */
  110417. isOccluded: boolean;
  110418. /** @hidden */
  110419. occlusionRetryCount: number;
  110420. /** @hidden */
  110421. occlusionType: number;
  110422. /** @hidden */
  110423. occlusionQueryAlgorithmType: number;
  110424. }
  110425. interface Engine {
  110426. /**
  110427. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110428. * @return the new query
  110429. */
  110430. createQuery(): WebGLQuery;
  110431. /**
  110432. * Delete and release a webGL query
  110433. * @param query defines the query to delete
  110434. * @return the current engine
  110435. */
  110436. deleteQuery(query: WebGLQuery): Engine;
  110437. /**
  110438. * Check if a given query has resolved and got its value
  110439. * @param query defines the query to check
  110440. * @returns true if the query got its value
  110441. */
  110442. isQueryResultAvailable(query: WebGLQuery): boolean;
  110443. /**
  110444. * Gets the value of a given query
  110445. * @param query defines the query to check
  110446. * @returns the value of the query
  110447. */
  110448. getQueryResult(query: WebGLQuery): number;
  110449. /**
  110450. * Initiates an occlusion query
  110451. * @param algorithmType defines the algorithm to use
  110452. * @param query defines the query to use
  110453. * @returns the current engine
  110454. * @see http://doc.babylonjs.com/features/occlusionquery
  110455. */
  110456. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110457. /**
  110458. * Ends an occlusion query
  110459. * @see http://doc.babylonjs.com/features/occlusionquery
  110460. * @param algorithmType defines the algorithm to use
  110461. * @returns the current engine
  110462. */
  110463. endOcclusionQuery(algorithmType: number): Engine;
  110464. /**
  110465. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110466. * Please note that only one query can be issued at a time
  110467. * @returns a time token used to track the time span
  110468. */
  110469. startTimeQuery(): Nullable<_TimeToken>;
  110470. /**
  110471. * Ends a time query
  110472. * @param token defines the token used to measure the time span
  110473. * @returns the time spent (in ns)
  110474. */
  110475. endTimeQuery(token: _TimeToken): int;
  110476. /** @hidden */
  110477. _currentNonTimestampToken: Nullable<_TimeToken>;
  110478. /** @hidden */
  110479. _createTimeQuery(): WebGLQuery;
  110480. /** @hidden */
  110481. _deleteTimeQuery(query: WebGLQuery): void;
  110482. /** @hidden */
  110483. _getGlAlgorithmType(algorithmType: number): number;
  110484. /** @hidden */
  110485. _getTimeQueryResult(query: WebGLQuery): any;
  110486. /** @hidden */
  110487. _getTimeQueryAvailability(query: WebGLQuery): any;
  110488. }
  110489. interface AbstractMesh {
  110490. /**
  110491. * Backing filed
  110492. * @hidden
  110493. */
  110494. __occlusionDataStorage: _OcclusionDataStorage;
  110495. /**
  110496. * Access property
  110497. * @hidden
  110498. */
  110499. _occlusionDataStorage: _OcclusionDataStorage;
  110500. /**
  110501. * 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.
  110502. * The default value is -1 which means don't break the query and wait till the result
  110503. * @see http://doc.babylonjs.com/features/occlusionquery
  110504. */
  110505. occlusionRetryCount: number;
  110506. /**
  110507. * 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:
  110508. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110509. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110510. * * 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.
  110511. * @see http://doc.babylonjs.com/features/occlusionquery
  110512. */
  110513. occlusionType: number;
  110514. /**
  110515. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110516. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110517. * * 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.
  110518. * @see http://doc.babylonjs.com/features/occlusionquery
  110519. */
  110520. occlusionQueryAlgorithmType: number;
  110521. /**
  110522. * 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
  110523. * @see http://doc.babylonjs.com/features/occlusionquery
  110524. */
  110525. isOccluded: boolean;
  110526. /**
  110527. * Flag to check the progress status of the query
  110528. * @see http://doc.babylonjs.com/features/occlusionquery
  110529. */
  110530. isOcclusionQueryInProgress: boolean;
  110531. }
  110532. }
  110533. declare module BABYLON {
  110534. /** @hidden */
  110535. export var _forceTransformFeedbackToBundle: boolean;
  110536. interface Engine {
  110537. /**
  110538. * Creates a webGL transform feedback object
  110539. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110540. * @returns the webGL transform feedback object
  110541. */
  110542. createTransformFeedback(): WebGLTransformFeedback;
  110543. /**
  110544. * Delete a webGL transform feedback object
  110545. * @param value defines the webGL transform feedback object to delete
  110546. */
  110547. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110548. /**
  110549. * Bind a webGL transform feedback object to the webgl context
  110550. * @param value defines the webGL transform feedback object to bind
  110551. */
  110552. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110553. /**
  110554. * Begins a transform feedback operation
  110555. * @param usePoints defines if points or triangles must be used
  110556. */
  110557. beginTransformFeedback(usePoints: boolean): void;
  110558. /**
  110559. * Ends a transform feedback operation
  110560. */
  110561. endTransformFeedback(): void;
  110562. /**
  110563. * Specify the varyings to use with transform feedback
  110564. * @param program defines the associated webGL program
  110565. * @param value defines the list of strings representing the varying names
  110566. */
  110567. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110568. /**
  110569. * Bind a webGL buffer for a transform feedback operation
  110570. * @param value defines the webGL buffer to bind
  110571. */
  110572. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110573. }
  110574. }
  110575. declare module BABYLON {
  110576. /**
  110577. * Creation options of the multi render target texture.
  110578. */
  110579. export interface IMultiRenderTargetOptions {
  110580. /**
  110581. * Define if the texture needs to create mip maps after render.
  110582. */
  110583. generateMipMaps?: boolean;
  110584. /**
  110585. * Define the types of all the draw buffers we want to create
  110586. */
  110587. types?: number[];
  110588. /**
  110589. * Define the sampling modes of all the draw buffers we want to create
  110590. */
  110591. samplingModes?: number[];
  110592. /**
  110593. * Define if a depth buffer is required
  110594. */
  110595. generateDepthBuffer?: boolean;
  110596. /**
  110597. * Define if a stencil buffer is required
  110598. */
  110599. generateStencilBuffer?: boolean;
  110600. /**
  110601. * Define if a depth texture is required instead of a depth buffer
  110602. */
  110603. generateDepthTexture?: boolean;
  110604. /**
  110605. * Define the number of desired draw buffers
  110606. */
  110607. textureCount?: number;
  110608. /**
  110609. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110610. */
  110611. doNotChangeAspectRatio?: boolean;
  110612. /**
  110613. * Define the default type of the buffers we are creating
  110614. */
  110615. defaultType?: number;
  110616. }
  110617. /**
  110618. * A multi render target, like a render target provides the ability to render to a texture.
  110619. * Unlike the render target, it can render to several draw buffers in one draw.
  110620. * This is specially interesting in deferred rendering or for any effects requiring more than
  110621. * just one color from a single pass.
  110622. */
  110623. export class MultiRenderTarget extends RenderTargetTexture {
  110624. private _internalTextures;
  110625. private _textures;
  110626. private _multiRenderTargetOptions;
  110627. /**
  110628. * Get if draw buffers are currently supported by the used hardware and browser.
  110629. */
  110630. readonly isSupported: boolean;
  110631. /**
  110632. * Get the list of textures generated by the multi render target.
  110633. */
  110634. readonly textures: Texture[];
  110635. /**
  110636. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  110637. */
  110638. readonly depthTexture: Texture;
  110639. /**
  110640. * Set the wrapping mode on U of all the textures we are rendering to.
  110641. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110642. */
  110643. wrapU: number;
  110644. /**
  110645. * Set the wrapping mode on V of all the textures we are rendering to.
  110646. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110647. */
  110648. wrapV: number;
  110649. /**
  110650. * Instantiate a new multi render target texture.
  110651. * A multi render target, like a render target provides the ability to render to a texture.
  110652. * Unlike the render target, it can render to several draw buffers in one draw.
  110653. * This is specially interesting in deferred rendering or for any effects requiring more than
  110654. * just one color from a single pass.
  110655. * @param name Define the name of the texture
  110656. * @param size Define the size of the buffers to render to
  110657. * @param count Define the number of target we are rendering into
  110658. * @param scene Define the scene the texture belongs to
  110659. * @param options Define the options used to create the multi render target
  110660. */
  110661. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  110662. /** @hidden */
  110663. _rebuild(): void;
  110664. private _createInternalTextures;
  110665. private _createTextures;
  110666. /**
  110667. * Define the number of samples used if MSAA is enabled.
  110668. */
  110669. samples: number;
  110670. /**
  110671. * Resize all the textures in the multi render target.
  110672. * Be carrefull as it will recreate all the data in the new texture.
  110673. * @param size Define the new size
  110674. */
  110675. resize(size: any): void;
  110676. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110677. /**
  110678. * Dispose the render targets and their associated resources
  110679. */
  110680. dispose(): void;
  110681. /**
  110682. * Release all the underlying texture used as draw buffers.
  110683. */
  110684. releaseInternalTextures(): void;
  110685. }
  110686. }
  110687. declare module BABYLON {
  110688. interface ThinEngine {
  110689. /**
  110690. * Unbind a list of render target textures from the webGL context
  110691. * This is used only when drawBuffer extension or webGL2 are active
  110692. * @param textures defines the render target textures to unbind
  110693. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110694. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110695. */
  110696. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  110697. /**
  110698. * Create a multi render target texture
  110699. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  110700. * @param size defines the size of the texture
  110701. * @param options defines the creation options
  110702. * @returns the cube texture as an InternalTexture
  110703. */
  110704. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  110705. /**
  110706. * Update the sample count for a given multiple render target texture
  110707. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110708. * @param textures defines the textures to update
  110709. * @param samples defines the sample count to set
  110710. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110711. */
  110712. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  110713. }
  110714. }
  110715. declare module BABYLON {
  110716. /** @hidden */
  110717. export var rgbdEncodePixelShader: {
  110718. name: string;
  110719. shader: string;
  110720. };
  110721. }
  110722. declare module BABYLON {
  110723. /** @hidden */
  110724. export var rgbdDecodePixelShader: {
  110725. name: string;
  110726. shader: string;
  110727. };
  110728. }
  110729. declare module BABYLON {
  110730. /**
  110731. * Raw texture data and descriptor sufficient for WebGL texture upload
  110732. */
  110733. export interface EnvironmentTextureInfo {
  110734. /**
  110735. * Version of the environment map
  110736. */
  110737. version: number;
  110738. /**
  110739. * Width of image
  110740. */
  110741. width: number;
  110742. /**
  110743. * Irradiance information stored in the file.
  110744. */
  110745. irradiance: any;
  110746. /**
  110747. * Specular information stored in the file.
  110748. */
  110749. specular: any;
  110750. }
  110751. /**
  110752. * Defines One Image in the file. It requires only the position in the file
  110753. * as well as the length.
  110754. */
  110755. interface BufferImageData {
  110756. /**
  110757. * Length of the image data.
  110758. */
  110759. length: number;
  110760. /**
  110761. * Position of the data from the null terminator delimiting the end of the JSON.
  110762. */
  110763. position: number;
  110764. }
  110765. /**
  110766. * Defines the specular data enclosed in the file.
  110767. * This corresponds to the version 1 of the data.
  110768. */
  110769. export interface EnvironmentTextureSpecularInfoV1 {
  110770. /**
  110771. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  110772. */
  110773. specularDataPosition?: number;
  110774. /**
  110775. * This contains all the images data needed to reconstruct the cubemap.
  110776. */
  110777. mipmaps: Array<BufferImageData>;
  110778. /**
  110779. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  110780. */
  110781. lodGenerationScale: number;
  110782. }
  110783. /**
  110784. * Sets of helpers addressing the serialization and deserialization of environment texture
  110785. * stored in a BabylonJS env file.
  110786. * Those files are usually stored as .env files.
  110787. */
  110788. export class EnvironmentTextureTools {
  110789. /**
  110790. * Magic number identifying the env file.
  110791. */
  110792. private static _MagicBytes;
  110793. /**
  110794. * Gets the environment info from an env file.
  110795. * @param data The array buffer containing the .env bytes.
  110796. * @returns the environment file info (the json header) if successfully parsed.
  110797. */
  110798. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  110799. /**
  110800. * Creates an environment texture from a loaded cube texture.
  110801. * @param texture defines the cube texture to convert in env file
  110802. * @return a promise containing the environment data if succesfull.
  110803. */
  110804. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  110805. /**
  110806. * Creates a JSON representation of the spherical data.
  110807. * @param texture defines the texture containing the polynomials
  110808. * @return the JSON representation of the spherical info
  110809. */
  110810. private static _CreateEnvTextureIrradiance;
  110811. /**
  110812. * Creates the ArrayBufferViews used for initializing environment texture image data.
  110813. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  110814. * @param info parameters that determine what views will be created for accessing the underlying buffer
  110815. * @return the views described by info providing access to the underlying buffer
  110816. */
  110817. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  110818. /**
  110819. * Uploads the texture info contained in the env file to the GPU.
  110820. * @param texture defines the internal texture to upload to
  110821. * @param arrayBuffer defines the buffer cotaining the data to load
  110822. * @param info defines the texture info retrieved through the GetEnvInfo method
  110823. * @returns a promise
  110824. */
  110825. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  110826. /**
  110827. * Uploads the levels of image data to the GPU.
  110828. * @param texture defines the internal texture to upload to
  110829. * @param imageData defines the array buffer views of image data [mipmap][face]
  110830. * @returns a promise
  110831. */
  110832. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  110833. /**
  110834. * Uploads spherical polynomials information to the texture.
  110835. * @param texture defines the texture we are trying to upload the information to
  110836. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  110837. */
  110838. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  110839. /** @hidden */
  110840. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  110841. }
  110842. }
  110843. declare module BABYLON {
  110844. /**
  110845. * Contains position and normal vectors for a vertex
  110846. */
  110847. export class PositionNormalVertex {
  110848. /** the position of the vertex (defaut: 0,0,0) */
  110849. position: Vector3;
  110850. /** the normal of the vertex (defaut: 0,1,0) */
  110851. normal: Vector3;
  110852. /**
  110853. * Creates a PositionNormalVertex
  110854. * @param position the position of the vertex (defaut: 0,0,0)
  110855. * @param normal the normal of the vertex (defaut: 0,1,0)
  110856. */
  110857. constructor(
  110858. /** the position of the vertex (defaut: 0,0,0) */
  110859. position?: Vector3,
  110860. /** the normal of the vertex (defaut: 0,1,0) */
  110861. normal?: Vector3);
  110862. /**
  110863. * Clones the PositionNormalVertex
  110864. * @returns the cloned PositionNormalVertex
  110865. */
  110866. clone(): PositionNormalVertex;
  110867. }
  110868. /**
  110869. * Contains position, normal and uv vectors for a vertex
  110870. */
  110871. export class PositionNormalTextureVertex {
  110872. /** the position of the vertex (defaut: 0,0,0) */
  110873. position: Vector3;
  110874. /** the normal of the vertex (defaut: 0,1,0) */
  110875. normal: Vector3;
  110876. /** the uv of the vertex (default: 0,0) */
  110877. uv: Vector2;
  110878. /**
  110879. * Creates a PositionNormalTextureVertex
  110880. * @param position the position of the vertex (defaut: 0,0,0)
  110881. * @param normal the normal of the vertex (defaut: 0,1,0)
  110882. * @param uv the uv of the vertex (default: 0,0)
  110883. */
  110884. constructor(
  110885. /** the position of the vertex (defaut: 0,0,0) */
  110886. position?: Vector3,
  110887. /** the normal of the vertex (defaut: 0,1,0) */
  110888. normal?: Vector3,
  110889. /** the uv of the vertex (default: 0,0) */
  110890. uv?: Vector2);
  110891. /**
  110892. * Clones the PositionNormalTextureVertex
  110893. * @returns the cloned PositionNormalTextureVertex
  110894. */
  110895. clone(): PositionNormalTextureVertex;
  110896. }
  110897. }
  110898. declare module BABYLON {
  110899. /** @hidden */
  110900. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  110901. private _genericAttributeLocation;
  110902. private _varyingLocationCount;
  110903. private _varyingLocationMap;
  110904. private _replacements;
  110905. private _textureCount;
  110906. private _uniforms;
  110907. lineProcessor(line: string): string;
  110908. attributeProcessor(attribute: string): string;
  110909. varyingProcessor(varying: string, isFragment: boolean): string;
  110910. uniformProcessor(uniform: string): string;
  110911. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  110912. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  110913. }
  110914. }
  110915. declare module BABYLON {
  110916. /**
  110917. * Container for accessors for natively-stored mesh data buffers.
  110918. */
  110919. class NativeDataBuffer extends DataBuffer {
  110920. /**
  110921. * Accessor value used to identify/retrieve a natively-stored index buffer.
  110922. */
  110923. nativeIndexBuffer?: any;
  110924. /**
  110925. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  110926. */
  110927. nativeVertexBuffer?: any;
  110928. }
  110929. /** @hidden */
  110930. export class NativeEngine extends Engine {
  110931. private readonly _native;
  110932. getHardwareScalingLevel(): number;
  110933. constructor();
  110934. /**
  110935. * Can be used to override the current requestAnimationFrame requester.
  110936. * @hidden
  110937. */
  110938. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  110939. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110940. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  110941. createVertexBuffer(data: DataArray): NativeDataBuffer;
  110942. recordVertexArrayObject(vertexBuffers: {
  110943. [key: string]: VertexBuffer;
  110944. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  110945. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110946. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110947. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110948. /**
  110949. * Draw a list of indexed primitives
  110950. * @param fillMode defines the primitive to use
  110951. * @param indexStart defines the starting index
  110952. * @param indexCount defines the number of index to draw
  110953. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110954. */
  110955. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110956. /**
  110957. * Draw a list of unindexed primitives
  110958. * @param fillMode defines the primitive to use
  110959. * @param verticesStart defines the index of first vertex to draw
  110960. * @param verticesCount defines the count of vertices to draw
  110961. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110962. */
  110963. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110964. createPipelineContext(): IPipelineContext;
  110965. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  110966. /** @hidden */
  110967. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  110968. /** @hidden */
  110969. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  110970. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110971. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110972. protected _setProgram(program: WebGLProgram): void;
  110973. _releaseEffect(effect: Effect): void;
  110974. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110975. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  110976. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  110977. bindSamplers(effect: Effect): void;
  110978. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  110979. getRenderWidth(useScreen?: boolean): number;
  110980. getRenderHeight(useScreen?: boolean): number;
  110981. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  110982. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110983. /**
  110984. * Set the z offset to apply to current rendering
  110985. * @param value defines the offset to apply
  110986. */
  110987. setZOffset(value: number): void;
  110988. /**
  110989. * Gets the current value of the zOffset
  110990. * @returns the current zOffset state
  110991. */
  110992. getZOffset(): number;
  110993. /**
  110994. * Enable or disable depth buffering
  110995. * @param enable defines the state to set
  110996. */
  110997. setDepthBuffer(enable: boolean): void;
  110998. /**
  110999. * Gets a boolean indicating if depth writing is enabled
  111000. * @returns the current depth writing state
  111001. */
  111002. getDepthWrite(): boolean;
  111003. /**
  111004. * Enable or disable depth writing
  111005. * @param enable defines the state to set
  111006. */
  111007. setDepthWrite(enable: boolean): void;
  111008. /**
  111009. * Enable or disable color writing
  111010. * @param enable defines the state to set
  111011. */
  111012. setColorWrite(enable: boolean): void;
  111013. /**
  111014. * Gets a boolean indicating if color writing is enabled
  111015. * @returns the current color writing state
  111016. */
  111017. getColorWrite(): boolean;
  111018. /**
  111019. * Sets alpha constants used by some alpha blending modes
  111020. * @param r defines the red component
  111021. * @param g defines the green component
  111022. * @param b defines the blue component
  111023. * @param a defines the alpha component
  111024. */
  111025. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111026. /**
  111027. * Sets the current alpha mode
  111028. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111029. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111030. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111031. */
  111032. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111033. /**
  111034. * Gets the current alpha mode
  111035. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111036. * @returns the current alpha mode
  111037. */
  111038. getAlphaMode(): number;
  111039. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111040. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111041. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111042. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111043. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111044. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111045. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111046. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111047. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111048. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111049. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111050. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111051. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111052. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111053. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111054. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111055. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111056. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111057. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111058. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111059. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111060. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111061. wipeCaches(bruteForce?: boolean): void;
  111062. _createTexture(): WebGLTexture;
  111063. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111064. /**
  111065. * Usually called from BABYLON.Texture.ts.
  111066. * Passed information to create a WebGLTexture
  111067. * @param urlArg defines a value which contains one of the following:
  111068. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111069. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111070. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111071. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111072. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111073. * @param scene needed for loading to the correct scene
  111074. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111075. * @param onLoad optional callback to be called upon successful completion
  111076. * @param onError optional callback to be called upon failure
  111077. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111078. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111079. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111080. * @param forcedExtension defines the extension to use to pick the right loader
  111081. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111082. */
  111083. 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;
  111084. /**
  111085. * Creates a cube texture
  111086. * @param rootUrl defines the url where the files to load is located
  111087. * @param scene defines the current scene
  111088. * @param files defines the list of files to load (1 per face)
  111089. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111090. * @param onLoad defines an optional callback raised when the texture is loaded
  111091. * @param onError defines an optional callback raised if there is an issue to load the texture
  111092. * @param format defines the format of the data
  111093. * @param forcedExtension defines the extension to use to pick the right loader
  111094. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111095. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111096. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111097. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111098. * @returns the cube texture as an InternalTexture
  111099. */
  111100. 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;
  111101. private _getSamplingFilter;
  111102. private static _GetNativeTextureFormat;
  111103. createRenderTargetTexture(size: number | {
  111104. width: number;
  111105. height: number;
  111106. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111107. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111108. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111109. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111110. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111111. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111112. /**
  111113. * Updates a dynamic vertex buffer.
  111114. * @param vertexBuffer the vertex buffer to update
  111115. * @param data the data used to update the vertex buffer
  111116. * @param byteOffset the byte offset of the data (optional)
  111117. * @param byteLength the byte length of the data (optional)
  111118. */
  111119. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111120. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111121. private _updateAnisotropicLevel;
  111122. private _getAddressMode;
  111123. /** @hidden */
  111124. _bindTexture(channel: number, texture: InternalTexture): void;
  111125. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111126. releaseEffects(): void;
  111127. /** @hidden */
  111128. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111129. /** @hidden */
  111130. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111131. /** @hidden */
  111132. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111133. /** @hidden */
  111134. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111135. }
  111136. }
  111137. declare module BABYLON {
  111138. /**
  111139. * Gather the list of clipboard event types as constants.
  111140. */
  111141. export class ClipboardEventTypes {
  111142. /**
  111143. * The clipboard event is fired when a copy command is active (pressed).
  111144. */
  111145. static readonly COPY: number;
  111146. /**
  111147. * The clipboard event is fired when a cut command is active (pressed).
  111148. */
  111149. static readonly CUT: number;
  111150. /**
  111151. * The clipboard event is fired when a paste command is active (pressed).
  111152. */
  111153. static readonly PASTE: number;
  111154. }
  111155. /**
  111156. * This class is used to store clipboard related info for the onClipboardObservable event.
  111157. */
  111158. export class ClipboardInfo {
  111159. /**
  111160. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111161. */
  111162. type: number;
  111163. /**
  111164. * Defines the related dom event
  111165. */
  111166. event: ClipboardEvent;
  111167. /**
  111168. *Creates an instance of ClipboardInfo.
  111169. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111170. * @param event Defines the related dom event
  111171. */
  111172. constructor(
  111173. /**
  111174. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111175. */
  111176. type: number,
  111177. /**
  111178. * Defines the related dom event
  111179. */
  111180. event: ClipboardEvent);
  111181. /**
  111182. * Get the clipboard event's type from the keycode.
  111183. * @param keyCode Defines the keyCode for the current keyboard event.
  111184. * @return {number}
  111185. */
  111186. static GetTypeFromCharacter(keyCode: number): number;
  111187. }
  111188. }
  111189. declare module BABYLON {
  111190. /**
  111191. * Google Daydream controller
  111192. */
  111193. export class DaydreamController extends WebVRController {
  111194. /**
  111195. * Base Url for the controller model.
  111196. */
  111197. static MODEL_BASE_URL: string;
  111198. /**
  111199. * File name for the controller model.
  111200. */
  111201. static MODEL_FILENAME: string;
  111202. /**
  111203. * Gamepad Id prefix used to identify Daydream Controller.
  111204. */
  111205. static readonly GAMEPAD_ID_PREFIX: string;
  111206. /**
  111207. * Creates a new DaydreamController from a gamepad
  111208. * @param vrGamepad the gamepad that the controller should be created from
  111209. */
  111210. constructor(vrGamepad: any);
  111211. /**
  111212. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111213. * @param scene scene in which to add meshes
  111214. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111215. */
  111216. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111217. /**
  111218. * Called once for each button that changed state since the last frame
  111219. * @param buttonIdx Which button index changed
  111220. * @param state New state of the button
  111221. * @param changes Which properties on the state changed since last frame
  111222. */
  111223. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111224. }
  111225. }
  111226. declare module BABYLON {
  111227. /**
  111228. * Gear VR Controller
  111229. */
  111230. export class GearVRController extends WebVRController {
  111231. /**
  111232. * Base Url for the controller model.
  111233. */
  111234. static MODEL_BASE_URL: string;
  111235. /**
  111236. * File name for the controller model.
  111237. */
  111238. static MODEL_FILENAME: string;
  111239. /**
  111240. * Gamepad Id prefix used to identify this controller.
  111241. */
  111242. static readonly GAMEPAD_ID_PREFIX: string;
  111243. private readonly _buttonIndexToObservableNameMap;
  111244. /**
  111245. * Creates a new GearVRController from a gamepad
  111246. * @param vrGamepad the gamepad that the controller should be created from
  111247. */
  111248. constructor(vrGamepad: any);
  111249. /**
  111250. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111251. * @param scene scene in which to add meshes
  111252. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111253. */
  111254. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111255. /**
  111256. * Called once for each button that changed state since the last frame
  111257. * @param buttonIdx Which button index changed
  111258. * @param state New state of the button
  111259. * @param changes Which properties on the state changed since last frame
  111260. */
  111261. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111262. }
  111263. }
  111264. declare module BABYLON {
  111265. /**
  111266. * Class containing static functions to help procedurally build meshes
  111267. */
  111268. export class PolyhedronBuilder {
  111269. /**
  111270. * Creates a polyhedron mesh
  111271. * * 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
  111272. * * The parameter `size` (positive float, default 1) sets the polygon size
  111273. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111274. * * 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`
  111275. * * 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
  111276. * * 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)`)
  111277. * * 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
  111278. * * 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
  111279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111282. * @param name defines the name of the mesh
  111283. * @param options defines the options used to create the mesh
  111284. * @param scene defines the hosting scene
  111285. * @returns the polyhedron mesh
  111286. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111287. */
  111288. static CreatePolyhedron(name: string, options: {
  111289. type?: number;
  111290. size?: number;
  111291. sizeX?: number;
  111292. sizeY?: number;
  111293. sizeZ?: number;
  111294. custom?: any;
  111295. faceUV?: Vector4[];
  111296. faceColors?: Color4[];
  111297. flat?: boolean;
  111298. updatable?: boolean;
  111299. sideOrientation?: number;
  111300. frontUVs?: Vector4;
  111301. backUVs?: Vector4;
  111302. }, scene?: Nullable<Scene>): Mesh;
  111303. }
  111304. }
  111305. declare module BABYLON {
  111306. /**
  111307. * Gizmo that enables scaling a mesh along 3 axis
  111308. */
  111309. export class ScaleGizmo extends Gizmo {
  111310. /**
  111311. * Internal gizmo used for interactions on the x axis
  111312. */
  111313. xGizmo: AxisScaleGizmo;
  111314. /**
  111315. * Internal gizmo used for interactions on the y axis
  111316. */
  111317. yGizmo: AxisScaleGizmo;
  111318. /**
  111319. * Internal gizmo used for interactions on the z axis
  111320. */
  111321. zGizmo: AxisScaleGizmo;
  111322. /**
  111323. * Internal gizmo used to scale all axis equally
  111324. */
  111325. uniformScaleGizmo: AxisScaleGizmo;
  111326. private _meshAttached;
  111327. private _updateGizmoRotationToMatchAttachedMesh;
  111328. private _snapDistance;
  111329. private _scaleRatio;
  111330. private _uniformScalingMesh;
  111331. private _octahedron;
  111332. /** Fires an event when any of it's sub gizmos are dragged */
  111333. onDragStartObservable: Observable<unknown>;
  111334. /** Fires an event when any of it's sub gizmos are released from dragging */
  111335. onDragEndObservable: Observable<unknown>;
  111336. attachedMesh: Nullable<AbstractMesh>;
  111337. /**
  111338. * Creates a ScaleGizmo
  111339. * @param gizmoLayer The utility layer the gizmo will be added to
  111340. */
  111341. constructor(gizmoLayer?: UtilityLayerRenderer);
  111342. updateGizmoRotationToMatchAttachedMesh: boolean;
  111343. /**
  111344. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111345. */
  111346. snapDistance: number;
  111347. /**
  111348. * Ratio for the scale of the gizmo (Default: 1)
  111349. */
  111350. scaleRatio: number;
  111351. /**
  111352. * Disposes of the gizmo
  111353. */
  111354. dispose(): void;
  111355. }
  111356. }
  111357. declare module BABYLON {
  111358. /**
  111359. * Single axis scale gizmo
  111360. */
  111361. export class AxisScaleGizmo extends Gizmo {
  111362. /**
  111363. * Drag behavior responsible for the gizmos dragging interactions
  111364. */
  111365. dragBehavior: PointerDragBehavior;
  111366. private _pointerObserver;
  111367. /**
  111368. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111369. */
  111370. snapDistance: number;
  111371. /**
  111372. * Event that fires each time the gizmo snaps to a new location.
  111373. * * snapDistance is the the change in distance
  111374. */
  111375. onSnapObservable: Observable<{
  111376. snapDistance: number;
  111377. }>;
  111378. /**
  111379. * If the scaling operation should be done on all axis (default: false)
  111380. */
  111381. uniformScaling: boolean;
  111382. private _isEnabled;
  111383. private _parent;
  111384. private _arrow;
  111385. private _coloredMaterial;
  111386. private _hoverMaterial;
  111387. /**
  111388. * Creates an AxisScaleGizmo
  111389. * @param gizmoLayer The utility layer the gizmo will be added to
  111390. * @param dragAxis The axis which the gizmo will be able to scale on
  111391. * @param color The color of the gizmo
  111392. */
  111393. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111394. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111395. /**
  111396. * If the gizmo is enabled
  111397. */
  111398. isEnabled: boolean;
  111399. /**
  111400. * Disposes of the gizmo
  111401. */
  111402. dispose(): void;
  111403. /**
  111404. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111405. * @param mesh The mesh to replace the default mesh of the gizmo
  111406. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111407. */
  111408. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111409. }
  111410. }
  111411. declare module BABYLON {
  111412. /**
  111413. * Bounding box gizmo
  111414. */
  111415. export class BoundingBoxGizmo extends Gizmo {
  111416. private _lineBoundingBox;
  111417. private _rotateSpheresParent;
  111418. private _scaleBoxesParent;
  111419. private _boundingDimensions;
  111420. private _renderObserver;
  111421. private _pointerObserver;
  111422. private _scaleDragSpeed;
  111423. private _tmpQuaternion;
  111424. private _tmpVector;
  111425. private _tmpRotationMatrix;
  111426. /**
  111427. * 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)
  111428. */
  111429. ignoreChildren: boolean;
  111430. /**
  111431. * 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)
  111432. */
  111433. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111434. /**
  111435. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111436. */
  111437. rotationSphereSize: number;
  111438. /**
  111439. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111440. */
  111441. scaleBoxSize: number;
  111442. /**
  111443. * 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)
  111444. */
  111445. fixedDragMeshScreenSize: boolean;
  111446. /**
  111447. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111448. */
  111449. fixedDragMeshScreenSizeDistanceFactor: number;
  111450. /**
  111451. * Fired when a rotation sphere or scale box is dragged
  111452. */
  111453. onDragStartObservable: Observable<{}>;
  111454. /**
  111455. * Fired when a scale box is dragged
  111456. */
  111457. onScaleBoxDragObservable: Observable<{}>;
  111458. /**
  111459. * Fired when a scale box drag is ended
  111460. */
  111461. onScaleBoxDragEndObservable: Observable<{}>;
  111462. /**
  111463. * Fired when a rotation sphere is dragged
  111464. */
  111465. onRotationSphereDragObservable: Observable<{}>;
  111466. /**
  111467. * Fired when a rotation sphere drag is ended
  111468. */
  111469. onRotationSphereDragEndObservable: Observable<{}>;
  111470. /**
  111471. * 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)
  111472. */
  111473. scalePivot: Nullable<Vector3>;
  111474. /**
  111475. * Mesh used as a pivot to rotate the attached mesh
  111476. */
  111477. private _anchorMesh;
  111478. private _existingMeshScale;
  111479. private _dragMesh;
  111480. private pointerDragBehavior;
  111481. private coloredMaterial;
  111482. private hoverColoredMaterial;
  111483. /**
  111484. * Sets the color of the bounding box gizmo
  111485. * @param color the color to set
  111486. */
  111487. setColor(color: Color3): void;
  111488. /**
  111489. * Creates an BoundingBoxGizmo
  111490. * @param gizmoLayer The utility layer the gizmo will be added to
  111491. * @param color The color of the gizmo
  111492. */
  111493. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111494. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111495. private _selectNode;
  111496. /**
  111497. * Updates the bounding box information for the Gizmo
  111498. */
  111499. updateBoundingBox(): void;
  111500. private _updateRotationSpheres;
  111501. private _updateScaleBoxes;
  111502. /**
  111503. * Enables rotation on the specified axis and disables rotation on the others
  111504. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111505. */
  111506. setEnabledRotationAxis(axis: string): void;
  111507. /**
  111508. * Enables/disables scaling
  111509. * @param enable if scaling should be enabled
  111510. */
  111511. setEnabledScaling(enable: boolean): void;
  111512. private _updateDummy;
  111513. /**
  111514. * Enables a pointer drag behavior on the bounding box of the gizmo
  111515. */
  111516. enableDragBehavior(): void;
  111517. /**
  111518. * Disposes of the gizmo
  111519. */
  111520. dispose(): void;
  111521. /**
  111522. * 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)
  111523. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  111524. * @returns the bounding box mesh with the passed in mesh as a child
  111525. */
  111526. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  111527. /**
  111528. * CustomMeshes are not supported by this gizmo
  111529. * @param mesh The mesh to replace the default mesh of the gizmo
  111530. */
  111531. setCustomMesh(mesh: Mesh): void;
  111532. }
  111533. }
  111534. declare module BABYLON {
  111535. /**
  111536. * Single plane rotation gizmo
  111537. */
  111538. export class PlaneRotationGizmo extends Gizmo {
  111539. /**
  111540. * Drag behavior responsible for the gizmos dragging interactions
  111541. */
  111542. dragBehavior: PointerDragBehavior;
  111543. private _pointerObserver;
  111544. /**
  111545. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  111546. */
  111547. snapDistance: number;
  111548. /**
  111549. * Event that fires each time the gizmo snaps to a new location.
  111550. * * snapDistance is the the change in distance
  111551. */
  111552. onSnapObservable: Observable<{
  111553. snapDistance: number;
  111554. }>;
  111555. private _isEnabled;
  111556. private _parent;
  111557. /**
  111558. * Creates a PlaneRotationGizmo
  111559. * @param gizmoLayer The utility layer the gizmo will be added to
  111560. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  111561. * @param color The color of the gizmo
  111562. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111563. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111564. */
  111565. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  111566. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111567. /**
  111568. * If the gizmo is enabled
  111569. */
  111570. isEnabled: boolean;
  111571. /**
  111572. * Disposes of the gizmo
  111573. */
  111574. dispose(): void;
  111575. }
  111576. }
  111577. declare module BABYLON {
  111578. /**
  111579. * Gizmo that enables rotating a mesh along 3 axis
  111580. */
  111581. export class RotationGizmo extends Gizmo {
  111582. /**
  111583. * Internal gizmo used for interactions on the x axis
  111584. */
  111585. xGizmo: PlaneRotationGizmo;
  111586. /**
  111587. * Internal gizmo used for interactions on the y axis
  111588. */
  111589. yGizmo: PlaneRotationGizmo;
  111590. /**
  111591. * Internal gizmo used for interactions on the z axis
  111592. */
  111593. zGizmo: PlaneRotationGizmo;
  111594. /** Fires an event when any of it's sub gizmos are dragged */
  111595. onDragStartObservable: Observable<unknown>;
  111596. /** Fires an event when any of it's sub gizmos are released from dragging */
  111597. onDragEndObservable: Observable<unknown>;
  111598. private _meshAttached;
  111599. attachedMesh: Nullable<AbstractMesh>;
  111600. /**
  111601. * Creates a RotationGizmo
  111602. * @param gizmoLayer The utility layer the gizmo will be added to
  111603. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111604. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111605. */
  111606. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  111607. updateGizmoRotationToMatchAttachedMesh: boolean;
  111608. /**
  111609. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111610. */
  111611. snapDistance: number;
  111612. /**
  111613. * Ratio for the scale of the gizmo (Default: 1)
  111614. */
  111615. scaleRatio: number;
  111616. /**
  111617. * Disposes of the gizmo
  111618. */
  111619. dispose(): void;
  111620. /**
  111621. * CustomMeshes are not supported by this gizmo
  111622. * @param mesh The mesh to replace the default mesh of the gizmo
  111623. */
  111624. setCustomMesh(mesh: Mesh): void;
  111625. }
  111626. }
  111627. declare module BABYLON {
  111628. /**
  111629. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  111630. */
  111631. export class GizmoManager implements IDisposable {
  111632. private scene;
  111633. /**
  111634. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  111635. */
  111636. gizmos: {
  111637. positionGizmo: Nullable<PositionGizmo>;
  111638. rotationGizmo: Nullable<RotationGizmo>;
  111639. scaleGizmo: Nullable<ScaleGizmo>;
  111640. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  111641. };
  111642. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  111643. clearGizmoOnEmptyPointerEvent: boolean;
  111644. /** Fires an event when the manager is attached to a mesh */
  111645. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  111646. private _gizmosEnabled;
  111647. private _pointerObserver;
  111648. private _attachedMesh;
  111649. private _boundingBoxColor;
  111650. private _defaultUtilityLayer;
  111651. private _defaultKeepDepthUtilityLayer;
  111652. /**
  111653. * When bounding box gizmo is enabled, this can be used to track drag/end events
  111654. */
  111655. boundingBoxDragBehavior: SixDofDragBehavior;
  111656. /**
  111657. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  111658. */
  111659. attachableMeshes: Nullable<Array<AbstractMesh>>;
  111660. /**
  111661. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  111662. */
  111663. usePointerToAttachGizmos: boolean;
  111664. /**
  111665. * Utility layer that the bounding box gizmo belongs to
  111666. */
  111667. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  111668. /**
  111669. * Utility layer that all gizmos besides bounding box belong to
  111670. */
  111671. readonly utilityLayer: UtilityLayerRenderer;
  111672. /**
  111673. * Instatiates a gizmo manager
  111674. * @param scene the scene to overlay the gizmos on top of
  111675. */
  111676. constructor(scene: Scene);
  111677. /**
  111678. * Attaches a set of gizmos to the specified mesh
  111679. * @param mesh The mesh the gizmo's should be attached to
  111680. */
  111681. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111682. /**
  111683. * If the position gizmo is enabled
  111684. */
  111685. positionGizmoEnabled: boolean;
  111686. /**
  111687. * If the rotation gizmo is enabled
  111688. */
  111689. rotationGizmoEnabled: boolean;
  111690. /**
  111691. * If the scale gizmo is enabled
  111692. */
  111693. scaleGizmoEnabled: boolean;
  111694. /**
  111695. * If the boundingBox gizmo is enabled
  111696. */
  111697. boundingBoxGizmoEnabled: boolean;
  111698. /**
  111699. * Disposes of the gizmo manager
  111700. */
  111701. dispose(): void;
  111702. }
  111703. }
  111704. declare module BABYLON {
  111705. /**
  111706. * A directional light is defined by a direction (what a surprise!).
  111707. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  111708. * 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.
  111709. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111710. */
  111711. export class DirectionalLight extends ShadowLight {
  111712. private _shadowFrustumSize;
  111713. /**
  111714. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  111715. */
  111716. /**
  111717. * Specifies a fix frustum size for the shadow generation.
  111718. */
  111719. shadowFrustumSize: number;
  111720. private _shadowOrthoScale;
  111721. /**
  111722. * Gets the shadow projection scale against the optimal computed one.
  111723. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111724. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111725. */
  111726. /**
  111727. * Sets the shadow projection scale against the optimal computed one.
  111728. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111729. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111730. */
  111731. shadowOrthoScale: number;
  111732. /**
  111733. * Automatically compute the projection matrix to best fit (including all the casters)
  111734. * on each frame.
  111735. */
  111736. autoUpdateExtends: boolean;
  111737. private _orthoLeft;
  111738. private _orthoRight;
  111739. private _orthoTop;
  111740. private _orthoBottom;
  111741. /**
  111742. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  111743. * The directional light is emitted from everywhere in the given direction.
  111744. * It can cast shadows.
  111745. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111746. * @param name The friendly name of the light
  111747. * @param direction The direction of the light
  111748. * @param scene The scene the light belongs to
  111749. */
  111750. constructor(name: string, direction: Vector3, scene: Scene);
  111751. /**
  111752. * Returns the string "DirectionalLight".
  111753. * @return The class name
  111754. */
  111755. getClassName(): string;
  111756. /**
  111757. * Returns the integer 1.
  111758. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111759. */
  111760. getTypeID(): number;
  111761. /**
  111762. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  111763. * Returns the DirectionalLight Shadow projection matrix.
  111764. */
  111765. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111766. /**
  111767. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  111768. * Returns the DirectionalLight Shadow projection matrix.
  111769. */
  111770. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  111771. /**
  111772. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  111773. * Returns the DirectionalLight Shadow projection matrix.
  111774. */
  111775. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111776. protected _buildUniformLayout(): void;
  111777. /**
  111778. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  111779. * @param effect The effect to update
  111780. * @param lightIndex The index of the light in the effect to update
  111781. * @returns The directional light
  111782. */
  111783. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  111784. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  111785. /**
  111786. * Gets the minZ used for shadow according to both the scene and the light.
  111787. *
  111788. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  111789. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  111790. * @param activeCamera The camera we are returning the min for
  111791. * @returns the depth min z
  111792. */
  111793. getDepthMinZ(activeCamera: Camera): number;
  111794. /**
  111795. * Gets the maxZ used for shadow according to both the scene and the light.
  111796. *
  111797. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  111798. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  111799. * @param activeCamera The camera we are returning the max for
  111800. * @returns the depth max z
  111801. */
  111802. getDepthMaxZ(activeCamera: Camera): number;
  111803. /**
  111804. * Prepares the list of defines specific to the light type.
  111805. * @param defines the list of defines
  111806. * @param lightIndex defines the index of the light for the effect
  111807. */
  111808. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111809. }
  111810. }
  111811. declare module BABYLON {
  111812. /**
  111813. * Class containing static functions to help procedurally build meshes
  111814. */
  111815. export class HemisphereBuilder {
  111816. /**
  111817. * Creates a hemisphere mesh
  111818. * @param name defines the name of the mesh
  111819. * @param options defines the options used to create the mesh
  111820. * @param scene defines the hosting scene
  111821. * @returns the hemisphere mesh
  111822. */
  111823. static CreateHemisphere(name: string, options: {
  111824. segments?: number;
  111825. diameter?: number;
  111826. sideOrientation?: number;
  111827. }, scene: any): Mesh;
  111828. }
  111829. }
  111830. declare module BABYLON {
  111831. /**
  111832. * A spot light is defined by a position, a direction, an angle, and an exponent.
  111833. * These values define a cone of light starting from the position, emitting toward the direction.
  111834. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  111835. * and the exponent defines the speed of the decay of the light with distance (reach).
  111836. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111837. */
  111838. export class SpotLight extends ShadowLight {
  111839. private _angle;
  111840. private _innerAngle;
  111841. private _cosHalfAngle;
  111842. private _lightAngleScale;
  111843. private _lightAngleOffset;
  111844. /**
  111845. * Gets the cone angle of the spot light in Radians.
  111846. */
  111847. /**
  111848. * Sets the cone angle of the spot light in Radians.
  111849. */
  111850. angle: number;
  111851. /**
  111852. * Only used in gltf falloff mode, this defines the angle where
  111853. * the directional falloff will start before cutting at angle which could be seen
  111854. * as outer angle.
  111855. */
  111856. /**
  111857. * Only used in gltf falloff mode, this defines the angle where
  111858. * the directional falloff will start before cutting at angle which could be seen
  111859. * as outer angle.
  111860. */
  111861. innerAngle: number;
  111862. private _shadowAngleScale;
  111863. /**
  111864. * Allows scaling the angle of the light for shadow generation only.
  111865. */
  111866. /**
  111867. * Allows scaling the angle of the light for shadow generation only.
  111868. */
  111869. shadowAngleScale: number;
  111870. /**
  111871. * The light decay speed with the distance from the emission spot.
  111872. */
  111873. exponent: number;
  111874. private _projectionTextureMatrix;
  111875. /**
  111876. * Allows reading the projecton texture
  111877. */
  111878. readonly projectionTextureMatrix: Matrix;
  111879. protected _projectionTextureLightNear: number;
  111880. /**
  111881. * Gets the near clip of the Spotlight for texture projection.
  111882. */
  111883. /**
  111884. * Sets the near clip of the Spotlight for texture projection.
  111885. */
  111886. projectionTextureLightNear: number;
  111887. protected _projectionTextureLightFar: number;
  111888. /**
  111889. * Gets the far clip of the Spotlight for texture projection.
  111890. */
  111891. /**
  111892. * Sets the far clip of the Spotlight for texture projection.
  111893. */
  111894. projectionTextureLightFar: number;
  111895. protected _projectionTextureUpDirection: Vector3;
  111896. /**
  111897. * Gets the Up vector of the Spotlight for texture projection.
  111898. */
  111899. /**
  111900. * Sets the Up vector of the Spotlight for texture projection.
  111901. */
  111902. projectionTextureUpDirection: Vector3;
  111903. private _projectionTexture;
  111904. /**
  111905. * Gets the projection texture of the light.
  111906. */
  111907. /**
  111908. * Sets the projection texture of the light.
  111909. */
  111910. projectionTexture: Nullable<BaseTexture>;
  111911. private _projectionTextureViewLightDirty;
  111912. private _projectionTextureProjectionLightDirty;
  111913. private _projectionTextureDirty;
  111914. private _projectionTextureViewTargetVector;
  111915. private _projectionTextureViewLightMatrix;
  111916. private _projectionTextureProjectionLightMatrix;
  111917. private _projectionTextureScalingMatrix;
  111918. /**
  111919. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  111920. * It can cast shadows.
  111921. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111922. * @param name The light friendly name
  111923. * @param position The position of the spot light in the scene
  111924. * @param direction The direction of the light in the scene
  111925. * @param angle The cone angle of the light in Radians
  111926. * @param exponent The light decay speed with the distance from the emission spot
  111927. * @param scene The scene the lights belongs to
  111928. */
  111929. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  111930. /**
  111931. * Returns the string "SpotLight".
  111932. * @returns the class name
  111933. */
  111934. getClassName(): string;
  111935. /**
  111936. * Returns the integer 2.
  111937. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111938. */
  111939. getTypeID(): number;
  111940. /**
  111941. * Overrides the direction setter to recompute the projection texture view light Matrix.
  111942. */
  111943. protected _setDirection(value: Vector3): void;
  111944. /**
  111945. * Overrides the position setter to recompute the projection texture view light Matrix.
  111946. */
  111947. protected _setPosition(value: Vector3): void;
  111948. /**
  111949. * 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.
  111950. * Returns the SpotLight.
  111951. */
  111952. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111953. protected _computeProjectionTextureViewLightMatrix(): void;
  111954. protected _computeProjectionTextureProjectionLightMatrix(): void;
  111955. /**
  111956. * Main function for light texture projection matrix computing.
  111957. */
  111958. protected _computeProjectionTextureMatrix(): void;
  111959. protected _buildUniformLayout(): void;
  111960. private _computeAngleValues;
  111961. /**
  111962. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  111963. * @param effect The effect to update
  111964. * @param lightIndex The index of the light in the effect to update
  111965. * @returns The spot light
  111966. */
  111967. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  111968. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  111969. /**
  111970. * Disposes the light and the associated resources.
  111971. */
  111972. dispose(): void;
  111973. /**
  111974. * Prepares the list of defines specific to the light type.
  111975. * @param defines the list of defines
  111976. * @param lightIndex defines the index of the light for the effect
  111977. */
  111978. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111979. }
  111980. }
  111981. declare module BABYLON {
  111982. /**
  111983. * Gizmo that enables viewing a light
  111984. */
  111985. export class LightGizmo extends Gizmo {
  111986. private _lightMesh;
  111987. private _material;
  111988. private cachedPosition;
  111989. private cachedForward;
  111990. /**
  111991. * Creates a LightGizmo
  111992. * @param gizmoLayer The utility layer the gizmo will be added to
  111993. */
  111994. constructor(gizmoLayer?: UtilityLayerRenderer);
  111995. private _light;
  111996. /**
  111997. * The light that the gizmo is attached to
  111998. */
  111999. light: Nullable<Light>;
  112000. /**
  112001. * Gets the material used to render the light gizmo
  112002. */
  112003. readonly material: StandardMaterial;
  112004. /**
  112005. * @hidden
  112006. * Updates the gizmo to match the attached mesh's position/rotation
  112007. */
  112008. protected _update(): void;
  112009. private static _Scale;
  112010. /**
  112011. * Creates the lines for a light mesh
  112012. */
  112013. private static _createLightLines;
  112014. /**
  112015. * Disposes of the light gizmo
  112016. */
  112017. dispose(): void;
  112018. private static _CreateHemisphericLightMesh;
  112019. private static _CreatePointLightMesh;
  112020. private static _CreateSpotLightMesh;
  112021. private static _CreateDirectionalLightMesh;
  112022. }
  112023. }
  112024. declare module BABYLON {
  112025. /** @hidden */
  112026. export var backgroundFragmentDeclaration: {
  112027. name: string;
  112028. shader: string;
  112029. };
  112030. }
  112031. declare module BABYLON {
  112032. /** @hidden */
  112033. export var backgroundUboDeclaration: {
  112034. name: string;
  112035. shader: string;
  112036. };
  112037. }
  112038. declare module BABYLON {
  112039. /** @hidden */
  112040. export var backgroundPixelShader: {
  112041. name: string;
  112042. shader: string;
  112043. };
  112044. }
  112045. declare module BABYLON {
  112046. /** @hidden */
  112047. export var backgroundVertexDeclaration: {
  112048. name: string;
  112049. shader: string;
  112050. };
  112051. }
  112052. declare module BABYLON {
  112053. /** @hidden */
  112054. export var backgroundVertexShader: {
  112055. name: string;
  112056. shader: string;
  112057. };
  112058. }
  112059. declare module BABYLON {
  112060. /**
  112061. * Background material used to create an efficient environement around your scene.
  112062. */
  112063. export class BackgroundMaterial extends PushMaterial {
  112064. /**
  112065. * Standard reflectance value at parallel view angle.
  112066. */
  112067. static StandardReflectance0: number;
  112068. /**
  112069. * Standard reflectance value at grazing angle.
  112070. */
  112071. static StandardReflectance90: number;
  112072. protected _primaryColor: Color3;
  112073. /**
  112074. * Key light Color (multiply against the environement texture)
  112075. */
  112076. primaryColor: Color3;
  112077. protected __perceptualColor: Nullable<Color3>;
  112078. /**
  112079. * Experimental Internal Use Only.
  112080. *
  112081. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112082. * This acts as a helper to set the primary color to a more "human friendly" value.
  112083. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112084. * output color as close as possible from the chosen value.
  112085. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112086. * part of lighting setup.)
  112087. */
  112088. _perceptualColor: Nullable<Color3>;
  112089. protected _primaryColorShadowLevel: float;
  112090. /**
  112091. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112092. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112093. */
  112094. primaryColorShadowLevel: float;
  112095. protected _primaryColorHighlightLevel: float;
  112096. /**
  112097. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112098. * The primary color is used at the level chosen to define what the white area would look.
  112099. */
  112100. primaryColorHighlightLevel: float;
  112101. protected _reflectionTexture: Nullable<BaseTexture>;
  112102. /**
  112103. * Reflection Texture used in the material.
  112104. * Should be author in a specific way for the best result (refer to the documentation).
  112105. */
  112106. reflectionTexture: Nullable<BaseTexture>;
  112107. protected _reflectionBlur: float;
  112108. /**
  112109. * Reflection Texture level of blur.
  112110. *
  112111. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112112. * texture twice.
  112113. */
  112114. reflectionBlur: float;
  112115. protected _diffuseTexture: Nullable<BaseTexture>;
  112116. /**
  112117. * Diffuse Texture used in the material.
  112118. * Should be author in a specific way for the best result (refer to the documentation).
  112119. */
  112120. diffuseTexture: Nullable<BaseTexture>;
  112121. protected _shadowLights: Nullable<IShadowLight[]>;
  112122. /**
  112123. * Specify the list of lights casting shadow on the material.
  112124. * All scene shadow lights will be included if null.
  112125. */
  112126. shadowLights: Nullable<IShadowLight[]>;
  112127. protected _shadowLevel: float;
  112128. /**
  112129. * Helps adjusting the shadow to a softer level if required.
  112130. * 0 means black shadows and 1 means no shadows.
  112131. */
  112132. shadowLevel: float;
  112133. protected _sceneCenter: Vector3;
  112134. /**
  112135. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112136. * It is usually zero but might be interesting to modify according to your setup.
  112137. */
  112138. sceneCenter: Vector3;
  112139. protected _opacityFresnel: boolean;
  112140. /**
  112141. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112142. * This helps ensuring a nice transition when the camera goes under the ground.
  112143. */
  112144. opacityFresnel: boolean;
  112145. protected _reflectionFresnel: boolean;
  112146. /**
  112147. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112148. * This helps adding a mirror texture on the ground.
  112149. */
  112150. reflectionFresnel: boolean;
  112151. protected _reflectionFalloffDistance: number;
  112152. /**
  112153. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112154. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112155. */
  112156. reflectionFalloffDistance: number;
  112157. protected _reflectionAmount: number;
  112158. /**
  112159. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112160. */
  112161. reflectionAmount: number;
  112162. protected _reflectionReflectance0: number;
  112163. /**
  112164. * This specifies the weight of the reflection at grazing angle.
  112165. */
  112166. reflectionReflectance0: number;
  112167. protected _reflectionReflectance90: number;
  112168. /**
  112169. * This specifies the weight of the reflection at a perpendicular point of view.
  112170. */
  112171. reflectionReflectance90: number;
  112172. /**
  112173. * Sets the reflection reflectance fresnel values according to the default standard
  112174. * empirically know to work well :-)
  112175. */
  112176. reflectionStandardFresnelWeight: number;
  112177. protected _useRGBColor: boolean;
  112178. /**
  112179. * Helps to directly use the maps channels instead of their level.
  112180. */
  112181. useRGBColor: boolean;
  112182. protected _enableNoise: boolean;
  112183. /**
  112184. * This helps reducing the banding effect that could occur on the background.
  112185. */
  112186. enableNoise: boolean;
  112187. /**
  112188. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112189. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112190. * Recommended to be keep at 1.0 except for special cases.
  112191. */
  112192. fovMultiplier: number;
  112193. private _fovMultiplier;
  112194. /**
  112195. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112196. */
  112197. useEquirectangularFOV: boolean;
  112198. private _maxSimultaneousLights;
  112199. /**
  112200. * Number of Simultaneous lights allowed on the material.
  112201. */
  112202. maxSimultaneousLights: int;
  112203. /**
  112204. * Default configuration related to image processing available in the Background Material.
  112205. */
  112206. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112207. /**
  112208. * Keep track of the image processing observer to allow dispose and replace.
  112209. */
  112210. private _imageProcessingObserver;
  112211. /**
  112212. * Attaches a new image processing configuration to the PBR Material.
  112213. * @param configuration (if null the scene configuration will be use)
  112214. */
  112215. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112216. /**
  112217. * Gets the image processing configuration used either in this material.
  112218. */
  112219. /**
  112220. * Sets the Default image processing configuration used either in the this material.
  112221. *
  112222. * If sets to null, the scene one is in use.
  112223. */
  112224. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112225. /**
  112226. * Gets wether the color curves effect is enabled.
  112227. */
  112228. /**
  112229. * Sets wether the color curves effect is enabled.
  112230. */
  112231. cameraColorCurvesEnabled: boolean;
  112232. /**
  112233. * Gets wether the color grading effect is enabled.
  112234. */
  112235. /**
  112236. * Gets wether the color grading effect is enabled.
  112237. */
  112238. cameraColorGradingEnabled: boolean;
  112239. /**
  112240. * Gets wether tonemapping is enabled or not.
  112241. */
  112242. /**
  112243. * Sets wether tonemapping is enabled or not
  112244. */
  112245. cameraToneMappingEnabled: boolean;
  112246. /**
  112247. * The camera exposure used on this material.
  112248. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112249. * This corresponds to a photographic exposure.
  112250. */
  112251. /**
  112252. * The camera exposure used on this material.
  112253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112254. * This corresponds to a photographic exposure.
  112255. */
  112256. cameraExposure: float;
  112257. /**
  112258. * Gets The camera contrast used on this material.
  112259. */
  112260. /**
  112261. * Sets The camera contrast used on this material.
  112262. */
  112263. cameraContrast: float;
  112264. /**
  112265. * Gets the Color Grading 2D Lookup Texture.
  112266. */
  112267. /**
  112268. * Sets the Color Grading 2D Lookup Texture.
  112269. */
  112270. cameraColorGradingTexture: Nullable<BaseTexture>;
  112271. /**
  112272. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112273. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112274. * 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;
  112275. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112276. */
  112277. /**
  112278. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112279. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112280. * 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;
  112281. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112282. */
  112283. cameraColorCurves: Nullable<ColorCurves>;
  112284. /**
  112285. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112286. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112287. */
  112288. switchToBGR: boolean;
  112289. private _renderTargets;
  112290. private _reflectionControls;
  112291. private _white;
  112292. private _primaryShadowColor;
  112293. private _primaryHighlightColor;
  112294. /**
  112295. * Instantiates a Background Material in the given scene
  112296. * @param name The friendly name of the material
  112297. * @param scene The scene to add the material to
  112298. */
  112299. constructor(name: string, scene: Scene);
  112300. /**
  112301. * Gets a boolean indicating that current material needs to register RTT
  112302. */
  112303. readonly hasRenderTargetTextures: boolean;
  112304. /**
  112305. * The entire material has been created in order to prevent overdraw.
  112306. * @returns false
  112307. */
  112308. needAlphaTesting(): boolean;
  112309. /**
  112310. * The entire material has been created in order to prevent overdraw.
  112311. * @returns true if blending is enable
  112312. */
  112313. needAlphaBlending(): boolean;
  112314. /**
  112315. * Checks wether the material is ready to be rendered for a given mesh.
  112316. * @param mesh The mesh to render
  112317. * @param subMesh The submesh to check against
  112318. * @param useInstances Specify wether or not the material is used with instances
  112319. * @returns true if all the dependencies are ready (Textures, Effects...)
  112320. */
  112321. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112322. /**
  112323. * Compute the primary color according to the chosen perceptual color.
  112324. */
  112325. private _computePrimaryColorFromPerceptualColor;
  112326. /**
  112327. * Compute the highlights and shadow colors according to their chosen levels.
  112328. */
  112329. private _computePrimaryColors;
  112330. /**
  112331. * Build the uniform buffer used in the material.
  112332. */
  112333. buildUniformLayout(): void;
  112334. /**
  112335. * Unbind the material.
  112336. */
  112337. unbind(): void;
  112338. /**
  112339. * Bind only the world matrix to the material.
  112340. * @param world The world matrix to bind.
  112341. */
  112342. bindOnlyWorldMatrix(world: Matrix): void;
  112343. /**
  112344. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112345. * @param world The world matrix to bind.
  112346. * @param subMesh The submesh to bind for.
  112347. */
  112348. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112349. /**
  112350. * Checks to see if a texture is used in the material.
  112351. * @param texture - Base texture to use.
  112352. * @returns - Boolean specifying if a texture is used in the material.
  112353. */
  112354. hasTexture(texture: BaseTexture): boolean;
  112355. /**
  112356. * Dispose the material.
  112357. * @param forceDisposeEffect Force disposal of the associated effect.
  112358. * @param forceDisposeTextures Force disposal of the associated textures.
  112359. */
  112360. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112361. /**
  112362. * Clones the material.
  112363. * @param name The cloned name.
  112364. * @returns The cloned material.
  112365. */
  112366. clone(name: string): BackgroundMaterial;
  112367. /**
  112368. * Serializes the current material to its JSON representation.
  112369. * @returns The JSON representation.
  112370. */
  112371. serialize(): any;
  112372. /**
  112373. * Gets the class name of the material
  112374. * @returns "BackgroundMaterial"
  112375. */
  112376. getClassName(): string;
  112377. /**
  112378. * Parse a JSON input to create back a background material.
  112379. * @param source The JSON data to parse
  112380. * @param scene The scene to create the parsed material in
  112381. * @param rootUrl The root url of the assets the material depends upon
  112382. * @returns the instantiated BackgroundMaterial.
  112383. */
  112384. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112385. }
  112386. }
  112387. declare module BABYLON {
  112388. /**
  112389. * Represents the different options available during the creation of
  112390. * a Environment helper.
  112391. *
  112392. * This can control the default ground, skybox and image processing setup of your scene.
  112393. */
  112394. export interface IEnvironmentHelperOptions {
  112395. /**
  112396. * Specifies wether or not to create a ground.
  112397. * True by default.
  112398. */
  112399. createGround: boolean;
  112400. /**
  112401. * Specifies the ground size.
  112402. * 15 by default.
  112403. */
  112404. groundSize: number;
  112405. /**
  112406. * The texture used on the ground for the main color.
  112407. * Comes from the BabylonJS CDN by default.
  112408. *
  112409. * Remarks: Can be either a texture or a url.
  112410. */
  112411. groundTexture: string | BaseTexture;
  112412. /**
  112413. * The color mixed in the ground texture by default.
  112414. * BabylonJS clearColor by default.
  112415. */
  112416. groundColor: Color3;
  112417. /**
  112418. * Specifies the ground opacity.
  112419. * 1 by default.
  112420. */
  112421. groundOpacity: number;
  112422. /**
  112423. * Enables the ground to receive shadows.
  112424. * True by default.
  112425. */
  112426. enableGroundShadow: boolean;
  112427. /**
  112428. * Helps preventing the shadow to be fully black on the ground.
  112429. * 0.5 by default.
  112430. */
  112431. groundShadowLevel: number;
  112432. /**
  112433. * Creates a mirror texture attach to the ground.
  112434. * false by default.
  112435. */
  112436. enableGroundMirror: boolean;
  112437. /**
  112438. * Specifies the ground mirror size ratio.
  112439. * 0.3 by default as the default kernel is 64.
  112440. */
  112441. groundMirrorSizeRatio: number;
  112442. /**
  112443. * Specifies the ground mirror blur kernel size.
  112444. * 64 by default.
  112445. */
  112446. groundMirrorBlurKernel: number;
  112447. /**
  112448. * Specifies the ground mirror visibility amount.
  112449. * 1 by default
  112450. */
  112451. groundMirrorAmount: number;
  112452. /**
  112453. * Specifies the ground mirror reflectance weight.
  112454. * This uses the standard weight of the background material to setup the fresnel effect
  112455. * of the mirror.
  112456. * 1 by default.
  112457. */
  112458. groundMirrorFresnelWeight: number;
  112459. /**
  112460. * Specifies the ground mirror Falloff distance.
  112461. * This can helps reducing the size of the reflection.
  112462. * 0 by Default.
  112463. */
  112464. groundMirrorFallOffDistance: number;
  112465. /**
  112466. * Specifies the ground mirror texture type.
  112467. * Unsigned Int by Default.
  112468. */
  112469. groundMirrorTextureType: number;
  112470. /**
  112471. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112472. * the shown objects.
  112473. */
  112474. groundYBias: number;
  112475. /**
  112476. * Specifies wether or not to create a skybox.
  112477. * True by default.
  112478. */
  112479. createSkybox: boolean;
  112480. /**
  112481. * Specifies the skybox size.
  112482. * 20 by default.
  112483. */
  112484. skyboxSize: number;
  112485. /**
  112486. * The texture used on the skybox for the main color.
  112487. * Comes from the BabylonJS CDN by default.
  112488. *
  112489. * Remarks: Can be either a texture or a url.
  112490. */
  112491. skyboxTexture: string | BaseTexture;
  112492. /**
  112493. * The color mixed in the skybox texture by default.
  112494. * BabylonJS clearColor by default.
  112495. */
  112496. skyboxColor: Color3;
  112497. /**
  112498. * The background rotation around the Y axis of the scene.
  112499. * This helps aligning the key lights of your scene with the background.
  112500. * 0 by default.
  112501. */
  112502. backgroundYRotation: number;
  112503. /**
  112504. * Compute automatically the size of the elements to best fit with the scene.
  112505. */
  112506. sizeAuto: boolean;
  112507. /**
  112508. * Default position of the rootMesh if autoSize is not true.
  112509. */
  112510. rootPosition: Vector3;
  112511. /**
  112512. * Sets up the image processing in the scene.
  112513. * true by default.
  112514. */
  112515. setupImageProcessing: boolean;
  112516. /**
  112517. * The texture used as your environment texture in the scene.
  112518. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  112519. *
  112520. * Remarks: Can be either a texture or a url.
  112521. */
  112522. environmentTexture: string | BaseTexture;
  112523. /**
  112524. * The value of the exposure to apply to the scene.
  112525. * 0.6 by default if setupImageProcessing is true.
  112526. */
  112527. cameraExposure: number;
  112528. /**
  112529. * The value of the contrast to apply to the scene.
  112530. * 1.6 by default if setupImageProcessing is true.
  112531. */
  112532. cameraContrast: number;
  112533. /**
  112534. * Specifies wether or not tonemapping should be enabled in the scene.
  112535. * true by default if setupImageProcessing is true.
  112536. */
  112537. toneMappingEnabled: boolean;
  112538. }
  112539. /**
  112540. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  112541. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  112542. * It also helps with the default setup of your imageProcessing configuration.
  112543. */
  112544. export class EnvironmentHelper {
  112545. /**
  112546. * Default ground texture URL.
  112547. */
  112548. private static _groundTextureCDNUrl;
  112549. /**
  112550. * Default skybox texture URL.
  112551. */
  112552. private static _skyboxTextureCDNUrl;
  112553. /**
  112554. * Default environment texture URL.
  112555. */
  112556. private static _environmentTextureCDNUrl;
  112557. /**
  112558. * Creates the default options for the helper.
  112559. */
  112560. private static _getDefaultOptions;
  112561. private _rootMesh;
  112562. /**
  112563. * Gets the root mesh created by the helper.
  112564. */
  112565. readonly rootMesh: Mesh;
  112566. private _skybox;
  112567. /**
  112568. * Gets the skybox created by the helper.
  112569. */
  112570. readonly skybox: Nullable<Mesh>;
  112571. private _skyboxTexture;
  112572. /**
  112573. * Gets the skybox texture created by the helper.
  112574. */
  112575. readonly skyboxTexture: Nullable<BaseTexture>;
  112576. private _skyboxMaterial;
  112577. /**
  112578. * Gets the skybox material created by the helper.
  112579. */
  112580. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  112581. private _ground;
  112582. /**
  112583. * Gets the ground mesh created by the helper.
  112584. */
  112585. readonly ground: Nullable<Mesh>;
  112586. private _groundTexture;
  112587. /**
  112588. * Gets the ground texture created by the helper.
  112589. */
  112590. readonly groundTexture: Nullable<BaseTexture>;
  112591. private _groundMirror;
  112592. /**
  112593. * Gets the ground mirror created by the helper.
  112594. */
  112595. readonly groundMirror: Nullable<MirrorTexture>;
  112596. /**
  112597. * Gets the ground mirror render list to helps pushing the meshes
  112598. * you wish in the ground reflection.
  112599. */
  112600. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  112601. private _groundMaterial;
  112602. /**
  112603. * Gets the ground material created by the helper.
  112604. */
  112605. readonly groundMaterial: Nullable<BackgroundMaterial>;
  112606. /**
  112607. * Stores the creation options.
  112608. */
  112609. private readonly _scene;
  112610. private _options;
  112611. /**
  112612. * This observable will be notified with any error during the creation of the environment,
  112613. * mainly texture creation errors.
  112614. */
  112615. onErrorObservable: Observable<{
  112616. message?: string;
  112617. exception?: any;
  112618. }>;
  112619. /**
  112620. * constructor
  112621. * @param options Defines the options we want to customize the helper
  112622. * @param scene The scene to add the material to
  112623. */
  112624. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  112625. /**
  112626. * Updates the background according to the new options
  112627. * @param options
  112628. */
  112629. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  112630. /**
  112631. * Sets the primary color of all the available elements.
  112632. * @param color the main color to affect to the ground and the background
  112633. */
  112634. setMainColor(color: Color3): void;
  112635. /**
  112636. * Setup the image processing according to the specified options.
  112637. */
  112638. private _setupImageProcessing;
  112639. /**
  112640. * Setup the environment texture according to the specified options.
  112641. */
  112642. private _setupEnvironmentTexture;
  112643. /**
  112644. * Setup the background according to the specified options.
  112645. */
  112646. private _setupBackground;
  112647. /**
  112648. * Get the scene sizes according to the setup.
  112649. */
  112650. private _getSceneSize;
  112651. /**
  112652. * Setup the ground according to the specified options.
  112653. */
  112654. private _setupGround;
  112655. /**
  112656. * Setup the ground material according to the specified options.
  112657. */
  112658. private _setupGroundMaterial;
  112659. /**
  112660. * Setup the ground diffuse texture according to the specified options.
  112661. */
  112662. private _setupGroundDiffuseTexture;
  112663. /**
  112664. * Setup the ground mirror texture according to the specified options.
  112665. */
  112666. private _setupGroundMirrorTexture;
  112667. /**
  112668. * Setup the ground to receive the mirror texture.
  112669. */
  112670. private _setupMirrorInGroundMaterial;
  112671. /**
  112672. * Setup the skybox according to the specified options.
  112673. */
  112674. private _setupSkybox;
  112675. /**
  112676. * Setup the skybox material according to the specified options.
  112677. */
  112678. private _setupSkyboxMaterial;
  112679. /**
  112680. * Setup the skybox reflection texture according to the specified options.
  112681. */
  112682. private _setupSkyboxReflectionTexture;
  112683. private _errorHandler;
  112684. /**
  112685. * Dispose all the elements created by the Helper.
  112686. */
  112687. dispose(): void;
  112688. }
  112689. }
  112690. declare module BABYLON {
  112691. /**
  112692. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  112693. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  112694. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  112695. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112696. */
  112697. export class PhotoDome extends TransformNode {
  112698. /**
  112699. * Define the image as a Monoscopic panoramic 360 image.
  112700. */
  112701. static readonly MODE_MONOSCOPIC: number;
  112702. /**
  112703. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  112704. */
  112705. static readonly MODE_TOPBOTTOM: number;
  112706. /**
  112707. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  112708. */
  112709. static readonly MODE_SIDEBYSIDE: number;
  112710. private _useDirectMapping;
  112711. /**
  112712. * The texture being displayed on the sphere
  112713. */
  112714. protected _photoTexture: Texture;
  112715. /**
  112716. * Gets or sets the texture being displayed on the sphere
  112717. */
  112718. photoTexture: Texture;
  112719. /**
  112720. * Observable raised when an error occured while loading the 360 image
  112721. */
  112722. onLoadErrorObservable: Observable<string>;
  112723. /**
  112724. * The skybox material
  112725. */
  112726. protected _material: BackgroundMaterial;
  112727. /**
  112728. * The surface used for the skybox
  112729. */
  112730. protected _mesh: Mesh;
  112731. /**
  112732. * Gets the mesh used for the skybox.
  112733. */
  112734. readonly mesh: Mesh;
  112735. /**
  112736. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112737. * Also see the options.resolution property.
  112738. */
  112739. fovMultiplier: number;
  112740. private _imageMode;
  112741. /**
  112742. * Gets or set the current video mode for the video. It can be:
  112743. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  112744. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  112745. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  112746. */
  112747. imageMode: number;
  112748. /**
  112749. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  112750. * @param name Element's name, child elements will append suffixes for their own names.
  112751. * @param urlsOfPhoto defines the url of the photo to display
  112752. * @param options defines an object containing optional or exposed sub element properties
  112753. * @param onError defines a callback called when an error occured while loading the texture
  112754. */
  112755. constructor(name: string, urlOfPhoto: string, options: {
  112756. resolution?: number;
  112757. size?: number;
  112758. useDirectMapping?: boolean;
  112759. faceForward?: boolean;
  112760. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  112761. private _onBeforeCameraRenderObserver;
  112762. private _changeImageMode;
  112763. /**
  112764. * Releases resources associated with this node.
  112765. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112766. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112767. */
  112768. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112769. }
  112770. }
  112771. declare module BABYLON {
  112772. /**
  112773. * Class used to host RGBD texture specific utilities
  112774. */
  112775. export class RGBDTextureTools {
  112776. /**
  112777. * Expand the RGBD Texture from RGBD to Half Float if possible.
  112778. * @param texture the texture to expand.
  112779. */
  112780. static ExpandRGBDTexture(texture: Texture): void;
  112781. }
  112782. }
  112783. declare module BABYLON {
  112784. /**
  112785. * Class used to host texture specific utilities
  112786. */
  112787. export class BRDFTextureTools {
  112788. /**
  112789. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  112790. * @param scene defines the hosting scene
  112791. * @returns the environment BRDF texture
  112792. */
  112793. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  112794. private static _environmentBRDFBase64Texture;
  112795. }
  112796. }
  112797. declare module BABYLON {
  112798. /**
  112799. * @hidden
  112800. */
  112801. export interface IMaterialClearCoatDefines {
  112802. CLEARCOAT: boolean;
  112803. CLEARCOAT_DEFAULTIOR: boolean;
  112804. CLEARCOAT_TEXTURE: boolean;
  112805. CLEARCOAT_TEXTUREDIRECTUV: number;
  112806. CLEARCOAT_BUMP: boolean;
  112807. CLEARCOAT_BUMPDIRECTUV: number;
  112808. CLEARCOAT_TINT: boolean;
  112809. CLEARCOAT_TINT_TEXTURE: boolean;
  112810. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112811. /** @hidden */
  112812. _areTexturesDirty: boolean;
  112813. }
  112814. /**
  112815. * Define the code related to the clear coat parameters of the pbr material.
  112816. */
  112817. export class PBRClearCoatConfiguration {
  112818. /**
  112819. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  112820. * The default fits with a polyurethane material.
  112821. */
  112822. private static readonly _DefaultIndexOfRefraction;
  112823. private _isEnabled;
  112824. /**
  112825. * Defines if the clear coat is enabled in the material.
  112826. */
  112827. isEnabled: boolean;
  112828. /**
  112829. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  112830. */
  112831. intensity: number;
  112832. /**
  112833. * Defines the clear coat layer roughness.
  112834. */
  112835. roughness: number;
  112836. private _indexOfRefraction;
  112837. /**
  112838. * Defines the index of refraction of the clear coat.
  112839. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  112840. * The default fits with a polyurethane material.
  112841. * Changing the default value is more performance intensive.
  112842. */
  112843. indexOfRefraction: number;
  112844. private _texture;
  112845. /**
  112846. * Stores the clear coat values in a texture.
  112847. */
  112848. texture: Nullable<BaseTexture>;
  112849. private _bumpTexture;
  112850. /**
  112851. * Define the clear coat specific bump texture.
  112852. */
  112853. bumpTexture: Nullable<BaseTexture>;
  112854. private _isTintEnabled;
  112855. /**
  112856. * Defines if the clear coat tint is enabled in the material.
  112857. */
  112858. isTintEnabled: boolean;
  112859. /**
  112860. * Defines the clear coat tint of the material.
  112861. * This is only use if tint is enabled
  112862. */
  112863. tintColor: Color3;
  112864. /**
  112865. * Defines the distance at which the tint color should be found in the
  112866. * clear coat media.
  112867. * This is only use if tint is enabled
  112868. */
  112869. tintColorAtDistance: number;
  112870. /**
  112871. * Defines the clear coat layer thickness.
  112872. * This is only use if tint is enabled
  112873. */
  112874. tintThickness: number;
  112875. private _tintTexture;
  112876. /**
  112877. * Stores the clear tint values in a texture.
  112878. * rgb is tint
  112879. * a is a thickness factor
  112880. */
  112881. tintTexture: Nullable<BaseTexture>;
  112882. /** @hidden */
  112883. private _internalMarkAllSubMeshesAsTexturesDirty;
  112884. /** @hidden */
  112885. _markAllSubMeshesAsTexturesDirty(): void;
  112886. /**
  112887. * Instantiate a new istance of clear coat configuration.
  112888. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112889. */
  112890. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112891. /**
  112892. * Gets wehter the submesh is ready to be used or not.
  112893. * @param defines the list of "defines" to update.
  112894. * @param scene defines the scene the material belongs to.
  112895. * @param engine defines the engine the material belongs to.
  112896. * @param disableBumpMap defines wether the material disables bump or not.
  112897. * @returns - boolean indicating that the submesh is ready or not.
  112898. */
  112899. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  112900. /**
  112901. * Checks to see if a texture is used in the material.
  112902. * @param defines the list of "defines" to update.
  112903. * @param scene defines the scene to the material belongs to.
  112904. */
  112905. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  112906. /**
  112907. * Binds the material data.
  112908. * @param uniformBuffer defines the Uniform buffer to fill in.
  112909. * @param scene defines the scene the material belongs to.
  112910. * @param engine defines the engine the material belongs to.
  112911. * @param disableBumpMap defines wether the material disables bump or not.
  112912. * @param isFrozen defines wether the material is frozen or not.
  112913. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  112914. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  112915. */
  112916. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  112917. /**
  112918. * Checks to see if a texture is used in the material.
  112919. * @param texture - Base texture to use.
  112920. * @returns - Boolean specifying if a texture is used in the material.
  112921. */
  112922. hasTexture(texture: BaseTexture): boolean;
  112923. /**
  112924. * Returns an array of the actively used textures.
  112925. * @param activeTextures Array of BaseTextures
  112926. */
  112927. getActiveTextures(activeTextures: BaseTexture[]): void;
  112928. /**
  112929. * Returns the animatable textures.
  112930. * @param animatables Array of animatable textures.
  112931. */
  112932. getAnimatables(animatables: IAnimatable[]): void;
  112933. /**
  112934. * Disposes the resources of the material.
  112935. * @param forceDisposeTextures - Forces the disposal of all textures.
  112936. */
  112937. dispose(forceDisposeTextures?: boolean): void;
  112938. /**
  112939. * Get the current class name of the texture useful for serialization or dynamic coding.
  112940. * @returns "PBRClearCoatConfiguration"
  112941. */
  112942. getClassName(): string;
  112943. /**
  112944. * Add fallbacks to the effect fallbacks list.
  112945. * @param defines defines the Base texture to use.
  112946. * @param fallbacks defines the current fallback list.
  112947. * @param currentRank defines the current fallback rank.
  112948. * @returns the new fallback rank.
  112949. */
  112950. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112951. /**
  112952. * Add the required uniforms to the current list.
  112953. * @param uniforms defines the current uniform list.
  112954. */
  112955. static AddUniforms(uniforms: string[]): void;
  112956. /**
  112957. * Add the required samplers to the current list.
  112958. * @param samplers defines the current sampler list.
  112959. */
  112960. static AddSamplers(samplers: string[]): void;
  112961. /**
  112962. * Add the required uniforms to the current buffer.
  112963. * @param uniformBuffer defines the current uniform buffer.
  112964. */
  112965. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112966. /**
  112967. * Makes a duplicate of the current configuration into another one.
  112968. * @param clearCoatConfiguration define the config where to copy the info
  112969. */
  112970. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  112971. /**
  112972. * Serializes this clear coat configuration.
  112973. * @returns - An object with the serialized config.
  112974. */
  112975. serialize(): any;
  112976. /**
  112977. * Parses a anisotropy Configuration from a serialized object.
  112978. * @param source - Serialized object.
  112979. * @param scene Defines the scene we are parsing for
  112980. * @param rootUrl Defines the rootUrl to load from
  112981. */
  112982. parse(source: any, scene: Scene, rootUrl: string): void;
  112983. }
  112984. }
  112985. declare module BABYLON {
  112986. /**
  112987. * @hidden
  112988. */
  112989. export interface IMaterialAnisotropicDefines {
  112990. ANISOTROPIC: boolean;
  112991. ANISOTROPIC_TEXTURE: boolean;
  112992. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112993. MAINUV1: boolean;
  112994. _areTexturesDirty: boolean;
  112995. _needUVs: boolean;
  112996. }
  112997. /**
  112998. * Define the code related to the anisotropic parameters of the pbr material.
  112999. */
  113000. export class PBRAnisotropicConfiguration {
  113001. private _isEnabled;
  113002. /**
  113003. * Defines if the anisotropy is enabled in the material.
  113004. */
  113005. isEnabled: boolean;
  113006. /**
  113007. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113008. */
  113009. intensity: number;
  113010. /**
  113011. * Defines if the effect is along the tangents, bitangents or in between.
  113012. * By default, the effect is "strectching" the highlights along the tangents.
  113013. */
  113014. direction: Vector2;
  113015. private _texture;
  113016. /**
  113017. * Stores the anisotropy values in a texture.
  113018. * rg is direction (like normal from -1 to 1)
  113019. * b is a intensity
  113020. */
  113021. texture: Nullable<BaseTexture>;
  113022. /** @hidden */
  113023. private _internalMarkAllSubMeshesAsTexturesDirty;
  113024. /** @hidden */
  113025. _markAllSubMeshesAsTexturesDirty(): void;
  113026. /**
  113027. * Instantiate a new istance of anisotropy configuration.
  113028. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113029. */
  113030. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113031. /**
  113032. * Specifies that the submesh is ready to be used.
  113033. * @param defines the list of "defines" to update.
  113034. * @param scene defines the scene the material belongs to.
  113035. * @returns - boolean indicating that the submesh is ready or not.
  113036. */
  113037. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113038. /**
  113039. * Checks to see if a texture is used in the material.
  113040. * @param defines the list of "defines" to update.
  113041. * @param mesh the mesh we are preparing the defines for.
  113042. * @param scene defines the scene the material belongs to.
  113043. */
  113044. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113045. /**
  113046. * Binds the material data.
  113047. * @param uniformBuffer defines the Uniform buffer to fill in.
  113048. * @param scene defines the scene the material belongs to.
  113049. * @param isFrozen defines wether the material is frozen or not.
  113050. */
  113051. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113052. /**
  113053. * Checks to see if a texture is used in the material.
  113054. * @param texture - Base texture to use.
  113055. * @returns - Boolean specifying if a texture is used in the material.
  113056. */
  113057. hasTexture(texture: BaseTexture): boolean;
  113058. /**
  113059. * Returns an array of the actively used textures.
  113060. * @param activeTextures Array of BaseTextures
  113061. */
  113062. getActiveTextures(activeTextures: BaseTexture[]): void;
  113063. /**
  113064. * Returns the animatable textures.
  113065. * @param animatables Array of animatable textures.
  113066. */
  113067. getAnimatables(animatables: IAnimatable[]): void;
  113068. /**
  113069. * Disposes the resources of the material.
  113070. * @param forceDisposeTextures - Forces the disposal of all textures.
  113071. */
  113072. dispose(forceDisposeTextures?: boolean): void;
  113073. /**
  113074. * Get the current class name of the texture useful for serialization or dynamic coding.
  113075. * @returns "PBRAnisotropicConfiguration"
  113076. */
  113077. getClassName(): string;
  113078. /**
  113079. * Add fallbacks to the effect fallbacks list.
  113080. * @param defines defines the Base texture to use.
  113081. * @param fallbacks defines the current fallback list.
  113082. * @param currentRank defines the current fallback rank.
  113083. * @returns the new fallback rank.
  113084. */
  113085. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113086. /**
  113087. * Add the required uniforms to the current list.
  113088. * @param uniforms defines the current uniform list.
  113089. */
  113090. static AddUniforms(uniforms: string[]): void;
  113091. /**
  113092. * Add the required uniforms to the current buffer.
  113093. * @param uniformBuffer defines the current uniform buffer.
  113094. */
  113095. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113096. /**
  113097. * Add the required samplers to the current list.
  113098. * @param samplers defines the current sampler list.
  113099. */
  113100. static AddSamplers(samplers: string[]): void;
  113101. /**
  113102. * Makes a duplicate of the current configuration into another one.
  113103. * @param anisotropicConfiguration define the config where to copy the info
  113104. */
  113105. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113106. /**
  113107. * Serializes this anisotropy configuration.
  113108. * @returns - An object with the serialized config.
  113109. */
  113110. serialize(): any;
  113111. /**
  113112. * Parses a anisotropy Configuration from a serialized object.
  113113. * @param source - Serialized object.
  113114. * @param scene Defines the scene we are parsing for
  113115. * @param rootUrl Defines the rootUrl to load from
  113116. */
  113117. parse(source: any, scene: Scene, rootUrl: string): void;
  113118. }
  113119. }
  113120. declare module BABYLON {
  113121. /**
  113122. * @hidden
  113123. */
  113124. export interface IMaterialBRDFDefines {
  113125. BRDF_V_HEIGHT_CORRELATED: boolean;
  113126. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113127. SPHERICAL_HARMONICS: boolean;
  113128. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113129. /** @hidden */
  113130. _areMiscDirty: boolean;
  113131. }
  113132. /**
  113133. * Define the code related to the BRDF parameters of the pbr material.
  113134. */
  113135. export class PBRBRDFConfiguration {
  113136. /**
  113137. * Default value used for the energy conservation.
  113138. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113139. */
  113140. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113141. /**
  113142. * Default value used for the Smith Visibility Height Correlated mode.
  113143. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113144. */
  113145. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113146. /**
  113147. * Default value used for the IBL diffuse part.
  113148. * This can help switching back to the polynomials mode globally which is a tiny bit
  113149. * less GPU intensive at the drawback of a lower quality.
  113150. */
  113151. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113152. /**
  113153. * Default value used for activating energy conservation for the specular workflow.
  113154. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113155. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113156. */
  113157. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113158. private _useEnergyConservation;
  113159. /**
  113160. * Defines if the material uses energy conservation.
  113161. */
  113162. useEnergyConservation: boolean;
  113163. private _useSmithVisibilityHeightCorrelated;
  113164. /**
  113165. * LEGACY Mode set to false
  113166. * Defines if the material uses height smith correlated visibility term.
  113167. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113168. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113169. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113170. * Not relying on height correlated will also disable energy conservation.
  113171. */
  113172. useSmithVisibilityHeightCorrelated: boolean;
  113173. private _useSphericalHarmonics;
  113174. /**
  113175. * LEGACY Mode set to false
  113176. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113177. * diffuse part of the IBL.
  113178. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113179. * to the ground truth.
  113180. */
  113181. useSphericalHarmonics: boolean;
  113182. private _useSpecularGlossinessInputEnergyConservation;
  113183. /**
  113184. * Defines if the material uses energy conservation, when the specular workflow is active.
  113185. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113186. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113187. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113188. */
  113189. useSpecularGlossinessInputEnergyConservation: boolean;
  113190. /** @hidden */
  113191. private _internalMarkAllSubMeshesAsMiscDirty;
  113192. /** @hidden */
  113193. _markAllSubMeshesAsMiscDirty(): void;
  113194. /**
  113195. * Instantiate a new istance of clear coat configuration.
  113196. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113197. */
  113198. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113199. /**
  113200. * Checks to see if a texture is used in the material.
  113201. * @param defines the list of "defines" to update.
  113202. */
  113203. prepareDefines(defines: IMaterialBRDFDefines): void;
  113204. /**
  113205. * Get the current class name of the texture useful for serialization or dynamic coding.
  113206. * @returns "PBRClearCoatConfiguration"
  113207. */
  113208. getClassName(): string;
  113209. /**
  113210. * Makes a duplicate of the current configuration into another one.
  113211. * @param brdfConfiguration define the config where to copy the info
  113212. */
  113213. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113214. /**
  113215. * Serializes this BRDF configuration.
  113216. * @returns - An object with the serialized config.
  113217. */
  113218. serialize(): any;
  113219. /**
  113220. * Parses a anisotropy Configuration from a serialized object.
  113221. * @param source - Serialized object.
  113222. * @param scene Defines the scene we are parsing for
  113223. * @param rootUrl Defines the rootUrl to load from
  113224. */
  113225. parse(source: any, scene: Scene, rootUrl: string): void;
  113226. }
  113227. }
  113228. declare module BABYLON {
  113229. /**
  113230. * @hidden
  113231. */
  113232. export interface IMaterialSheenDefines {
  113233. SHEEN: boolean;
  113234. SHEEN_TEXTURE: boolean;
  113235. SHEEN_TEXTUREDIRECTUV: number;
  113236. SHEEN_LINKWITHALBEDO: boolean;
  113237. /** @hidden */
  113238. _areTexturesDirty: boolean;
  113239. }
  113240. /**
  113241. * Define the code related to the Sheen parameters of the pbr material.
  113242. */
  113243. export class PBRSheenConfiguration {
  113244. private _isEnabled;
  113245. /**
  113246. * Defines if the material uses sheen.
  113247. */
  113248. isEnabled: boolean;
  113249. private _linkSheenWithAlbedo;
  113250. /**
  113251. * Defines if the sheen is linked to the sheen color.
  113252. */
  113253. linkSheenWithAlbedo: boolean;
  113254. /**
  113255. * Defines the sheen intensity.
  113256. */
  113257. intensity: number;
  113258. /**
  113259. * Defines the sheen color.
  113260. */
  113261. color: Color3;
  113262. private _texture;
  113263. /**
  113264. * Stores the sheen tint values in a texture.
  113265. * rgb is tint
  113266. * a is a intensity
  113267. */
  113268. texture: Nullable<BaseTexture>;
  113269. /** @hidden */
  113270. private _internalMarkAllSubMeshesAsTexturesDirty;
  113271. /** @hidden */
  113272. _markAllSubMeshesAsTexturesDirty(): void;
  113273. /**
  113274. * Instantiate a new istance of clear coat configuration.
  113275. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113276. */
  113277. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113278. /**
  113279. * Specifies that the submesh is ready to be used.
  113280. * @param defines the list of "defines" to update.
  113281. * @param scene defines the scene the material belongs to.
  113282. * @returns - boolean indicating that the submesh is ready or not.
  113283. */
  113284. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113285. /**
  113286. * Checks to see if a texture is used in the material.
  113287. * @param defines the list of "defines" to update.
  113288. * @param scene defines the scene the material belongs to.
  113289. */
  113290. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113291. /**
  113292. * Binds the material data.
  113293. * @param uniformBuffer defines the Uniform buffer to fill in.
  113294. * @param scene defines the scene the material belongs to.
  113295. * @param isFrozen defines wether the material is frozen or not.
  113296. */
  113297. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113298. /**
  113299. * Checks to see if a texture is used in the material.
  113300. * @param texture - Base texture to use.
  113301. * @returns - Boolean specifying if a texture is used in the material.
  113302. */
  113303. hasTexture(texture: BaseTexture): boolean;
  113304. /**
  113305. * Returns an array of the actively used textures.
  113306. * @param activeTextures Array of BaseTextures
  113307. */
  113308. getActiveTextures(activeTextures: BaseTexture[]): void;
  113309. /**
  113310. * Returns the animatable textures.
  113311. * @param animatables Array of animatable textures.
  113312. */
  113313. getAnimatables(animatables: IAnimatable[]): void;
  113314. /**
  113315. * Disposes the resources of the material.
  113316. * @param forceDisposeTextures - Forces the disposal of all textures.
  113317. */
  113318. dispose(forceDisposeTextures?: boolean): void;
  113319. /**
  113320. * Get the current class name of the texture useful for serialization or dynamic coding.
  113321. * @returns "PBRSheenConfiguration"
  113322. */
  113323. getClassName(): string;
  113324. /**
  113325. * Add fallbacks to the effect fallbacks list.
  113326. * @param defines defines the Base texture to use.
  113327. * @param fallbacks defines the current fallback list.
  113328. * @param currentRank defines the current fallback rank.
  113329. * @returns the new fallback rank.
  113330. */
  113331. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113332. /**
  113333. * Add the required uniforms to the current list.
  113334. * @param uniforms defines the current uniform list.
  113335. */
  113336. static AddUniforms(uniforms: string[]): void;
  113337. /**
  113338. * Add the required uniforms to the current buffer.
  113339. * @param uniformBuffer defines the current uniform buffer.
  113340. */
  113341. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113342. /**
  113343. * Add the required samplers to the current list.
  113344. * @param samplers defines the current sampler list.
  113345. */
  113346. static AddSamplers(samplers: string[]): void;
  113347. /**
  113348. * Makes a duplicate of the current configuration into another one.
  113349. * @param sheenConfiguration define the config where to copy the info
  113350. */
  113351. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113352. /**
  113353. * Serializes this BRDF configuration.
  113354. * @returns - An object with the serialized config.
  113355. */
  113356. serialize(): any;
  113357. /**
  113358. * Parses a anisotropy Configuration from a serialized object.
  113359. * @param source - Serialized object.
  113360. * @param scene Defines the scene we are parsing for
  113361. * @param rootUrl Defines the rootUrl to load from
  113362. */
  113363. parse(source: any, scene: Scene, rootUrl: string): void;
  113364. }
  113365. }
  113366. declare module BABYLON {
  113367. /**
  113368. * @hidden
  113369. */
  113370. export interface IMaterialSubSurfaceDefines {
  113371. SUBSURFACE: boolean;
  113372. SS_REFRACTION: boolean;
  113373. SS_TRANSLUCENCY: boolean;
  113374. SS_SCATERRING: boolean;
  113375. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113376. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113377. SS_REFRACTIONMAP_3D: boolean;
  113378. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113379. SS_LODINREFRACTIONALPHA: boolean;
  113380. SS_GAMMAREFRACTION: boolean;
  113381. SS_RGBDREFRACTION: boolean;
  113382. SS_LINEARSPECULARREFRACTION: boolean;
  113383. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113384. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113385. /** @hidden */
  113386. _areTexturesDirty: boolean;
  113387. }
  113388. /**
  113389. * Define the code related to the sub surface parameters of the pbr material.
  113390. */
  113391. export class PBRSubSurfaceConfiguration {
  113392. private _isRefractionEnabled;
  113393. /**
  113394. * Defines if the refraction is enabled in the material.
  113395. */
  113396. isRefractionEnabled: boolean;
  113397. private _isTranslucencyEnabled;
  113398. /**
  113399. * Defines if the translucency is enabled in the material.
  113400. */
  113401. isTranslucencyEnabled: boolean;
  113402. private _isScatteringEnabled;
  113403. /**
  113404. * Defines the refraction intensity of the material.
  113405. * The refraction when enabled replaces the Diffuse part of the material.
  113406. * The intensity helps transitionning between diffuse and refraction.
  113407. */
  113408. refractionIntensity: number;
  113409. /**
  113410. * Defines the translucency intensity of the material.
  113411. * When translucency has been enabled, this defines how much of the "translucency"
  113412. * is addded to the diffuse part of the material.
  113413. */
  113414. translucencyIntensity: number;
  113415. /**
  113416. * Defines the scattering intensity of the material.
  113417. * When scattering has been enabled, this defines how much of the "scattered light"
  113418. * is addded to the diffuse part of the material.
  113419. */
  113420. scatteringIntensity: number;
  113421. private _thicknessTexture;
  113422. /**
  113423. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113424. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113425. * 0 would mean minimumThickness
  113426. * 1 would mean maximumThickness
  113427. * The other channels might be use as a mask to vary the different effects intensity.
  113428. */
  113429. thicknessTexture: Nullable<BaseTexture>;
  113430. private _refractionTexture;
  113431. /**
  113432. * Defines the texture to use for refraction.
  113433. */
  113434. refractionTexture: Nullable<BaseTexture>;
  113435. private _indexOfRefraction;
  113436. /**
  113437. * Defines the index of refraction used in the material.
  113438. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113439. */
  113440. indexOfRefraction: number;
  113441. private _invertRefractionY;
  113442. /**
  113443. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113444. */
  113445. invertRefractionY: boolean;
  113446. private _linkRefractionWithTransparency;
  113447. /**
  113448. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113449. * Materials half opaque for instance using refraction could benefit from this control.
  113450. */
  113451. linkRefractionWithTransparency: boolean;
  113452. /**
  113453. * Defines the minimum thickness stored in the thickness map.
  113454. * If no thickness map is defined, this value will be used to simulate thickness.
  113455. */
  113456. minimumThickness: number;
  113457. /**
  113458. * Defines the maximum thickness stored in the thickness map.
  113459. */
  113460. maximumThickness: number;
  113461. /**
  113462. * Defines the volume tint of the material.
  113463. * This is used for both translucency and scattering.
  113464. */
  113465. tintColor: Color3;
  113466. /**
  113467. * Defines the distance at which the tint color should be found in the media.
  113468. * This is used for refraction only.
  113469. */
  113470. tintColorAtDistance: number;
  113471. /**
  113472. * Defines how far each channel transmit through the media.
  113473. * It is defined as a color to simplify it selection.
  113474. */
  113475. diffusionDistance: Color3;
  113476. private _useMaskFromThicknessTexture;
  113477. /**
  113478. * Stores the intensity of the different subsurface effects in the thickness texture.
  113479. * * the green channel is the translucency intensity.
  113480. * * the blue channel is the scattering intensity.
  113481. * * the alpha channel is the refraction intensity.
  113482. */
  113483. useMaskFromThicknessTexture: boolean;
  113484. /** @hidden */
  113485. private _internalMarkAllSubMeshesAsTexturesDirty;
  113486. /** @hidden */
  113487. _markAllSubMeshesAsTexturesDirty(): void;
  113488. /**
  113489. * Instantiate a new istance of sub surface configuration.
  113490. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113491. */
  113492. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113493. /**
  113494. * Gets wehter the submesh is ready to be used or not.
  113495. * @param defines the list of "defines" to update.
  113496. * @param scene defines the scene the material belongs to.
  113497. * @returns - boolean indicating that the submesh is ready or not.
  113498. */
  113499. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113500. /**
  113501. * Checks to see if a texture is used in the material.
  113502. * @param defines the list of "defines" to update.
  113503. * @param scene defines the scene to the material belongs to.
  113504. */
  113505. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113506. /**
  113507. * Binds the material data.
  113508. * @param uniformBuffer defines the Uniform buffer to fill in.
  113509. * @param scene defines the scene the material belongs to.
  113510. * @param engine defines the engine the material belongs to.
  113511. * @param isFrozen defines wether the material is frozen or not.
  113512. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113513. */
  113514. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113515. /**
  113516. * Unbinds the material from the mesh.
  113517. * @param activeEffect defines the effect that should be unbound from.
  113518. * @returns true if unbound, otherwise false
  113519. */
  113520. unbind(activeEffect: Effect): boolean;
  113521. /**
  113522. * Returns the texture used for refraction or null if none is used.
  113523. * @param scene defines the scene the material belongs to.
  113524. * @returns - Refraction texture if present. If no refraction texture and refraction
  113525. * is linked with transparency, returns environment texture. Otherwise, returns null.
  113526. */
  113527. private _getRefractionTexture;
  113528. /**
  113529. * Returns true if alpha blending should be disabled.
  113530. */
  113531. readonly disableAlphaBlending: boolean;
  113532. /**
  113533. * Fills the list of render target textures.
  113534. * @param renderTargets the list of render targets to update
  113535. */
  113536. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  113537. /**
  113538. * Checks to see if a texture is used in the material.
  113539. * @param texture - Base texture to use.
  113540. * @returns - Boolean specifying if a texture is used in the material.
  113541. */
  113542. hasTexture(texture: BaseTexture): boolean;
  113543. /**
  113544. * Gets a boolean indicating that current material needs to register RTT
  113545. * @returns true if this uses a render target otherwise false.
  113546. */
  113547. hasRenderTargetTextures(): boolean;
  113548. /**
  113549. * Returns an array of the actively used textures.
  113550. * @param activeTextures Array of BaseTextures
  113551. */
  113552. getActiveTextures(activeTextures: BaseTexture[]): void;
  113553. /**
  113554. * Returns the animatable textures.
  113555. * @param animatables Array of animatable textures.
  113556. */
  113557. getAnimatables(animatables: IAnimatable[]): void;
  113558. /**
  113559. * Disposes the resources of the material.
  113560. * @param forceDisposeTextures - Forces the disposal of all textures.
  113561. */
  113562. dispose(forceDisposeTextures?: boolean): void;
  113563. /**
  113564. * Get the current class name of the texture useful for serialization or dynamic coding.
  113565. * @returns "PBRSubSurfaceConfiguration"
  113566. */
  113567. getClassName(): string;
  113568. /**
  113569. * Add fallbacks to the effect fallbacks list.
  113570. * @param defines defines the Base texture to use.
  113571. * @param fallbacks defines the current fallback list.
  113572. * @param currentRank defines the current fallback rank.
  113573. * @returns the new fallback rank.
  113574. */
  113575. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113576. /**
  113577. * Add the required uniforms to the current list.
  113578. * @param uniforms defines the current uniform list.
  113579. */
  113580. static AddUniforms(uniforms: string[]): void;
  113581. /**
  113582. * Add the required samplers to the current list.
  113583. * @param samplers defines the current sampler list.
  113584. */
  113585. static AddSamplers(samplers: string[]): void;
  113586. /**
  113587. * Add the required uniforms to the current buffer.
  113588. * @param uniformBuffer defines the current uniform buffer.
  113589. */
  113590. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113591. /**
  113592. * Makes a duplicate of the current configuration into another one.
  113593. * @param configuration define the config where to copy the info
  113594. */
  113595. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  113596. /**
  113597. * Serializes this Sub Surface configuration.
  113598. * @returns - An object with the serialized config.
  113599. */
  113600. serialize(): any;
  113601. /**
  113602. * Parses a anisotropy Configuration from a serialized object.
  113603. * @param source - Serialized object.
  113604. * @param scene Defines the scene we are parsing for
  113605. * @param rootUrl Defines the rootUrl to load from
  113606. */
  113607. parse(source: any, scene: Scene, rootUrl: string): void;
  113608. }
  113609. }
  113610. declare module BABYLON {
  113611. /** @hidden */
  113612. export var pbrFragmentDeclaration: {
  113613. name: string;
  113614. shader: string;
  113615. };
  113616. }
  113617. declare module BABYLON {
  113618. /** @hidden */
  113619. export var pbrUboDeclaration: {
  113620. name: string;
  113621. shader: string;
  113622. };
  113623. }
  113624. declare module BABYLON {
  113625. /** @hidden */
  113626. export var pbrFragmentExtraDeclaration: {
  113627. name: string;
  113628. shader: string;
  113629. };
  113630. }
  113631. declare module BABYLON {
  113632. /** @hidden */
  113633. export var pbrFragmentSamplersDeclaration: {
  113634. name: string;
  113635. shader: string;
  113636. };
  113637. }
  113638. declare module BABYLON {
  113639. /** @hidden */
  113640. export var pbrHelperFunctions: {
  113641. name: string;
  113642. shader: string;
  113643. };
  113644. }
  113645. declare module BABYLON {
  113646. /** @hidden */
  113647. export var harmonicsFunctions: {
  113648. name: string;
  113649. shader: string;
  113650. };
  113651. }
  113652. declare module BABYLON {
  113653. /** @hidden */
  113654. export var pbrDirectLightingSetupFunctions: {
  113655. name: string;
  113656. shader: string;
  113657. };
  113658. }
  113659. declare module BABYLON {
  113660. /** @hidden */
  113661. export var pbrDirectLightingFalloffFunctions: {
  113662. name: string;
  113663. shader: string;
  113664. };
  113665. }
  113666. declare module BABYLON {
  113667. /** @hidden */
  113668. export var pbrBRDFFunctions: {
  113669. name: string;
  113670. shader: string;
  113671. };
  113672. }
  113673. declare module BABYLON {
  113674. /** @hidden */
  113675. export var pbrDirectLightingFunctions: {
  113676. name: string;
  113677. shader: string;
  113678. };
  113679. }
  113680. declare module BABYLON {
  113681. /** @hidden */
  113682. export var pbrIBLFunctions: {
  113683. name: string;
  113684. shader: string;
  113685. };
  113686. }
  113687. declare module BABYLON {
  113688. /** @hidden */
  113689. export var pbrDebug: {
  113690. name: string;
  113691. shader: string;
  113692. };
  113693. }
  113694. declare module BABYLON {
  113695. /** @hidden */
  113696. export var pbrPixelShader: {
  113697. name: string;
  113698. shader: string;
  113699. };
  113700. }
  113701. declare module BABYLON {
  113702. /** @hidden */
  113703. export var pbrVertexDeclaration: {
  113704. name: string;
  113705. shader: string;
  113706. };
  113707. }
  113708. declare module BABYLON {
  113709. /** @hidden */
  113710. export var pbrVertexShader: {
  113711. name: string;
  113712. shader: string;
  113713. };
  113714. }
  113715. declare module BABYLON {
  113716. /**
  113717. * Manages the defines for the PBR Material.
  113718. * @hidden
  113719. */
  113720. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  113721. PBR: boolean;
  113722. MAINUV1: boolean;
  113723. MAINUV2: boolean;
  113724. UV1: boolean;
  113725. UV2: boolean;
  113726. ALBEDO: boolean;
  113727. ALBEDODIRECTUV: number;
  113728. VERTEXCOLOR: boolean;
  113729. AMBIENT: boolean;
  113730. AMBIENTDIRECTUV: number;
  113731. AMBIENTINGRAYSCALE: boolean;
  113732. OPACITY: boolean;
  113733. VERTEXALPHA: boolean;
  113734. OPACITYDIRECTUV: number;
  113735. OPACITYRGB: boolean;
  113736. ALPHATEST: boolean;
  113737. DEPTHPREPASS: boolean;
  113738. ALPHABLEND: boolean;
  113739. ALPHAFROMALBEDO: boolean;
  113740. ALPHATESTVALUE: string;
  113741. SPECULAROVERALPHA: boolean;
  113742. RADIANCEOVERALPHA: boolean;
  113743. ALPHAFRESNEL: boolean;
  113744. LINEARALPHAFRESNEL: boolean;
  113745. PREMULTIPLYALPHA: boolean;
  113746. EMISSIVE: boolean;
  113747. EMISSIVEDIRECTUV: number;
  113748. REFLECTIVITY: boolean;
  113749. REFLECTIVITYDIRECTUV: number;
  113750. SPECULARTERM: boolean;
  113751. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  113752. MICROSURFACEAUTOMATIC: boolean;
  113753. LODBASEDMICROSFURACE: boolean;
  113754. MICROSURFACEMAP: boolean;
  113755. MICROSURFACEMAPDIRECTUV: number;
  113756. METALLICWORKFLOW: boolean;
  113757. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  113758. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  113759. METALLNESSSTOREINMETALMAPBLUE: boolean;
  113760. AOSTOREINMETALMAPRED: boolean;
  113761. ENVIRONMENTBRDF: boolean;
  113762. ENVIRONMENTBRDF_RGBD: boolean;
  113763. NORMAL: boolean;
  113764. TANGENT: boolean;
  113765. BUMP: boolean;
  113766. BUMPDIRECTUV: number;
  113767. OBJECTSPACE_NORMALMAP: boolean;
  113768. PARALLAX: boolean;
  113769. PARALLAXOCCLUSION: boolean;
  113770. NORMALXYSCALE: boolean;
  113771. LIGHTMAP: boolean;
  113772. LIGHTMAPDIRECTUV: number;
  113773. USELIGHTMAPASSHADOWMAP: boolean;
  113774. GAMMALIGHTMAP: boolean;
  113775. RGBDLIGHTMAP: boolean;
  113776. REFLECTION: boolean;
  113777. REFLECTIONMAP_3D: boolean;
  113778. REFLECTIONMAP_SPHERICAL: boolean;
  113779. REFLECTIONMAP_PLANAR: boolean;
  113780. REFLECTIONMAP_CUBIC: boolean;
  113781. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  113782. REFLECTIONMAP_PROJECTION: boolean;
  113783. REFLECTIONMAP_SKYBOX: boolean;
  113784. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  113785. REFLECTIONMAP_EXPLICIT: boolean;
  113786. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  113787. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  113788. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  113789. INVERTCUBICMAP: boolean;
  113790. USESPHERICALFROMREFLECTIONMAP: boolean;
  113791. USEIRRADIANCEMAP: boolean;
  113792. SPHERICAL_HARMONICS: boolean;
  113793. USESPHERICALINVERTEX: boolean;
  113794. REFLECTIONMAP_OPPOSITEZ: boolean;
  113795. LODINREFLECTIONALPHA: boolean;
  113796. GAMMAREFLECTION: boolean;
  113797. RGBDREFLECTION: boolean;
  113798. LINEARSPECULARREFLECTION: boolean;
  113799. RADIANCEOCCLUSION: boolean;
  113800. HORIZONOCCLUSION: boolean;
  113801. INSTANCES: boolean;
  113802. NUM_BONE_INFLUENCERS: number;
  113803. BonesPerMesh: number;
  113804. BONETEXTURE: boolean;
  113805. NONUNIFORMSCALING: boolean;
  113806. MORPHTARGETS: boolean;
  113807. MORPHTARGETS_NORMAL: boolean;
  113808. MORPHTARGETS_TANGENT: boolean;
  113809. MORPHTARGETS_UV: boolean;
  113810. NUM_MORPH_INFLUENCERS: number;
  113811. IMAGEPROCESSING: boolean;
  113812. VIGNETTE: boolean;
  113813. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113814. VIGNETTEBLENDMODEOPAQUE: boolean;
  113815. TONEMAPPING: boolean;
  113816. TONEMAPPING_ACES: boolean;
  113817. CONTRAST: boolean;
  113818. COLORCURVES: boolean;
  113819. COLORGRADING: boolean;
  113820. COLORGRADING3D: boolean;
  113821. SAMPLER3DGREENDEPTH: boolean;
  113822. SAMPLER3DBGRMAP: boolean;
  113823. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113824. EXPOSURE: boolean;
  113825. MULTIVIEW: boolean;
  113826. USEPHYSICALLIGHTFALLOFF: boolean;
  113827. USEGLTFLIGHTFALLOFF: boolean;
  113828. TWOSIDEDLIGHTING: boolean;
  113829. SHADOWFLOAT: boolean;
  113830. CLIPPLANE: boolean;
  113831. CLIPPLANE2: boolean;
  113832. CLIPPLANE3: boolean;
  113833. CLIPPLANE4: boolean;
  113834. POINTSIZE: boolean;
  113835. FOG: boolean;
  113836. LOGARITHMICDEPTH: boolean;
  113837. FORCENORMALFORWARD: boolean;
  113838. SPECULARAA: boolean;
  113839. CLEARCOAT: boolean;
  113840. CLEARCOAT_DEFAULTIOR: boolean;
  113841. CLEARCOAT_TEXTURE: boolean;
  113842. CLEARCOAT_TEXTUREDIRECTUV: number;
  113843. CLEARCOAT_BUMP: boolean;
  113844. CLEARCOAT_BUMPDIRECTUV: number;
  113845. CLEARCOAT_TINT: boolean;
  113846. CLEARCOAT_TINT_TEXTURE: boolean;
  113847. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113848. ANISOTROPIC: boolean;
  113849. ANISOTROPIC_TEXTURE: boolean;
  113850. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113851. BRDF_V_HEIGHT_CORRELATED: boolean;
  113852. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113853. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113854. SHEEN: boolean;
  113855. SHEEN_TEXTURE: boolean;
  113856. SHEEN_TEXTUREDIRECTUV: number;
  113857. SHEEN_LINKWITHALBEDO: boolean;
  113858. SUBSURFACE: boolean;
  113859. SS_REFRACTION: boolean;
  113860. SS_TRANSLUCENCY: boolean;
  113861. SS_SCATERRING: boolean;
  113862. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113863. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113864. SS_REFRACTIONMAP_3D: boolean;
  113865. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113866. SS_LODINREFRACTIONALPHA: boolean;
  113867. SS_GAMMAREFRACTION: boolean;
  113868. SS_RGBDREFRACTION: boolean;
  113869. SS_LINEARSPECULARREFRACTION: boolean;
  113870. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113871. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113872. UNLIT: boolean;
  113873. DEBUGMODE: number;
  113874. /**
  113875. * Initializes the PBR Material defines.
  113876. */
  113877. constructor();
  113878. /**
  113879. * Resets the PBR Material defines.
  113880. */
  113881. reset(): void;
  113882. }
  113883. /**
  113884. * The Physically based material base class of BJS.
  113885. *
  113886. * This offers the main features of a standard PBR material.
  113887. * For more information, please refer to the documentation :
  113888. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113889. */
  113890. export abstract class PBRBaseMaterial extends PushMaterial {
  113891. /**
  113892. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113893. */
  113894. static readonly PBRMATERIAL_OPAQUE: number;
  113895. /**
  113896. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113897. */
  113898. static readonly PBRMATERIAL_ALPHATEST: number;
  113899. /**
  113900. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113901. */
  113902. static readonly PBRMATERIAL_ALPHABLEND: number;
  113903. /**
  113904. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113905. * They are also discarded below the alpha cutoff threshold to improve performances.
  113906. */
  113907. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113908. /**
  113909. * Defines the default value of how much AO map is occluding the analytical lights
  113910. * (point spot...).
  113911. */
  113912. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113913. /**
  113914. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  113915. */
  113916. static readonly LIGHTFALLOFF_PHYSICAL: number;
  113917. /**
  113918. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  113919. * to enhance interoperability with other engines.
  113920. */
  113921. static readonly LIGHTFALLOFF_GLTF: number;
  113922. /**
  113923. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  113924. * to enhance interoperability with other materials.
  113925. */
  113926. static readonly LIGHTFALLOFF_STANDARD: number;
  113927. /**
  113928. * Intensity of the direct lights e.g. the four lights available in your scene.
  113929. * This impacts both the direct diffuse and specular highlights.
  113930. */
  113931. protected _directIntensity: number;
  113932. /**
  113933. * Intensity of the emissive part of the material.
  113934. * This helps controlling the emissive effect without modifying the emissive color.
  113935. */
  113936. protected _emissiveIntensity: number;
  113937. /**
  113938. * Intensity of the environment e.g. how much the environment will light the object
  113939. * either through harmonics for rough material or through the refelction for shiny ones.
  113940. */
  113941. protected _environmentIntensity: number;
  113942. /**
  113943. * This is a special control allowing the reduction of the specular highlights coming from the
  113944. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113945. */
  113946. protected _specularIntensity: number;
  113947. /**
  113948. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  113949. */
  113950. private _lightingInfos;
  113951. /**
  113952. * Debug Control allowing disabling the bump map on this material.
  113953. */
  113954. protected _disableBumpMap: boolean;
  113955. /**
  113956. * AKA Diffuse Texture in standard nomenclature.
  113957. */
  113958. protected _albedoTexture: Nullable<BaseTexture>;
  113959. /**
  113960. * AKA Occlusion Texture in other nomenclature.
  113961. */
  113962. protected _ambientTexture: Nullable<BaseTexture>;
  113963. /**
  113964. * AKA Occlusion Texture Intensity in other nomenclature.
  113965. */
  113966. protected _ambientTextureStrength: number;
  113967. /**
  113968. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113969. * 1 means it completely occludes it
  113970. * 0 mean it has no impact
  113971. */
  113972. protected _ambientTextureImpactOnAnalyticalLights: number;
  113973. /**
  113974. * Stores the alpha values in a texture.
  113975. */
  113976. protected _opacityTexture: Nullable<BaseTexture>;
  113977. /**
  113978. * Stores the reflection values in a texture.
  113979. */
  113980. protected _reflectionTexture: Nullable<BaseTexture>;
  113981. /**
  113982. * Stores the emissive values in a texture.
  113983. */
  113984. protected _emissiveTexture: Nullable<BaseTexture>;
  113985. /**
  113986. * AKA Specular texture in other nomenclature.
  113987. */
  113988. protected _reflectivityTexture: Nullable<BaseTexture>;
  113989. /**
  113990. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113991. */
  113992. protected _metallicTexture: Nullable<BaseTexture>;
  113993. /**
  113994. * Specifies the metallic scalar of the metallic/roughness workflow.
  113995. * Can also be used to scale the metalness values of the metallic texture.
  113996. */
  113997. protected _metallic: Nullable<number>;
  113998. /**
  113999. * Specifies the roughness scalar of the metallic/roughness workflow.
  114000. * Can also be used to scale the roughness values of the metallic texture.
  114001. */
  114002. protected _roughness: Nullable<number>;
  114003. /**
  114004. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114005. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114006. */
  114007. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114008. /**
  114009. * Stores surface normal data used to displace a mesh in a texture.
  114010. */
  114011. protected _bumpTexture: Nullable<BaseTexture>;
  114012. /**
  114013. * Stores the pre-calculated light information of a mesh in a texture.
  114014. */
  114015. protected _lightmapTexture: Nullable<BaseTexture>;
  114016. /**
  114017. * The color of a material in ambient lighting.
  114018. */
  114019. protected _ambientColor: Color3;
  114020. /**
  114021. * AKA Diffuse Color in other nomenclature.
  114022. */
  114023. protected _albedoColor: Color3;
  114024. /**
  114025. * AKA Specular Color in other nomenclature.
  114026. */
  114027. protected _reflectivityColor: Color3;
  114028. /**
  114029. * The color applied when light is reflected from a material.
  114030. */
  114031. protected _reflectionColor: Color3;
  114032. /**
  114033. * The color applied when light is emitted from a material.
  114034. */
  114035. protected _emissiveColor: Color3;
  114036. /**
  114037. * AKA Glossiness in other nomenclature.
  114038. */
  114039. protected _microSurface: number;
  114040. /**
  114041. * Specifies that the material will use the light map as a show map.
  114042. */
  114043. protected _useLightmapAsShadowmap: boolean;
  114044. /**
  114045. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114046. * makes the reflect vector face the model (under horizon).
  114047. */
  114048. protected _useHorizonOcclusion: boolean;
  114049. /**
  114050. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114051. * too much the area relying on ambient texture to define their ambient occlusion.
  114052. */
  114053. protected _useRadianceOcclusion: boolean;
  114054. /**
  114055. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114056. */
  114057. protected _useAlphaFromAlbedoTexture: boolean;
  114058. /**
  114059. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114060. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114061. */
  114062. protected _useSpecularOverAlpha: boolean;
  114063. /**
  114064. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114065. */
  114066. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114067. /**
  114068. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114069. */
  114070. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114071. /**
  114072. * Specifies if the metallic texture contains the roughness information in its green channel.
  114073. */
  114074. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114075. /**
  114076. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114077. */
  114078. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114079. /**
  114080. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114081. */
  114082. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114083. /**
  114084. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114085. */
  114086. protected _useAmbientInGrayScale: boolean;
  114087. /**
  114088. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114089. * The material will try to infer what glossiness each pixel should be.
  114090. */
  114091. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114092. /**
  114093. * Defines the falloff type used in this material.
  114094. * It by default is Physical.
  114095. */
  114096. protected _lightFalloff: number;
  114097. /**
  114098. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114099. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114100. */
  114101. protected _useRadianceOverAlpha: boolean;
  114102. /**
  114103. * Allows using an object space normal map (instead of tangent space).
  114104. */
  114105. protected _useObjectSpaceNormalMap: boolean;
  114106. /**
  114107. * Allows using the bump map in parallax mode.
  114108. */
  114109. protected _useParallax: boolean;
  114110. /**
  114111. * Allows using the bump map in parallax occlusion mode.
  114112. */
  114113. protected _useParallaxOcclusion: boolean;
  114114. /**
  114115. * Controls the scale bias of the parallax mode.
  114116. */
  114117. protected _parallaxScaleBias: number;
  114118. /**
  114119. * If sets to true, disables all the lights affecting the material.
  114120. */
  114121. protected _disableLighting: boolean;
  114122. /**
  114123. * Number of Simultaneous lights allowed on the material.
  114124. */
  114125. protected _maxSimultaneousLights: number;
  114126. /**
  114127. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114128. */
  114129. protected _invertNormalMapX: boolean;
  114130. /**
  114131. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114132. */
  114133. protected _invertNormalMapY: boolean;
  114134. /**
  114135. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114136. */
  114137. protected _twoSidedLighting: boolean;
  114138. /**
  114139. * Defines the alpha limits in alpha test mode.
  114140. */
  114141. protected _alphaCutOff: number;
  114142. /**
  114143. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114144. */
  114145. protected _forceAlphaTest: boolean;
  114146. /**
  114147. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114148. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114149. */
  114150. protected _useAlphaFresnel: boolean;
  114151. /**
  114152. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114153. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114154. */
  114155. protected _useLinearAlphaFresnel: boolean;
  114156. /**
  114157. * The transparency mode of the material.
  114158. */
  114159. protected _transparencyMode: Nullable<number>;
  114160. /**
  114161. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114162. * from cos thetav and roughness:
  114163. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114164. */
  114165. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114166. /**
  114167. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114168. */
  114169. protected _forceIrradianceInFragment: boolean;
  114170. /**
  114171. * Force normal to face away from face.
  114172. */
  114173. protected _forceNormalForward: boolean;
  114174. /**
  114175. * Enables specular anti aliasing in the PBR shader.
  114176. * It will both interacts on the Geometry for analytical and IBL lighting.
  114177. * It also prefilter the roughness map based on the bump values.
  114178. */
  114179. protected _enableSpecularAntiAliasing: boolean;
  114180. /**
  114181. * Default configuration related to image processing available in the PBR Material.
  114182. */
  114183. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114184. /**
  114185. * Keep track of the image processing observer to allow dispose and replace.
  114186. */
  114187. private _imageProcessingObserver;
  114188. /**
  114189. * Attaches a new image processing configuration to the PBR Material.
  114190. * @param configuration
  114191. */
  114192. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114193. /**
  114194. * Stores the available render targets.
  114195. */
  114196. private _renderTargets;
  114197. /**
  114198. * Sets the global ambient color for the material used in lighting calculations.
  114199. */
  114200. private _globalAmbientColor;
  114201. /**
  114202. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114203. */
  114204. private _useLogarithmicDepth;
  114205. /**
  114206. * If set to true, no lighting calculations will be applied.
  114207. */
  114208. private _unlit;
  114209. private _debugMode;
  114210. /**
  114211. * @hidden
  114212. * This is reserved for the inspector.
  114213. * Defines the material debug mode.
  114214. * It helps seeing only some components of the material while troubleshooting.
  114215. */
  114216. debugMode: number;
  114217. /**
  114218. * @hidden
  114219. * This is reserved for the inspector.
  114220. * Specify from where on screen the debug mode should start.
  114221. * The value goes from -1 (full screen) to 1 (not visible)
  114222. * It helps with side by side comparison against the final render
  114223. * This defaults to -1
  114224. */
  114225. private debugLimit;
  114226. /**
  114227. * @hidden
  114228. * This is reserved for the inspector.
  114229. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114230. * You can use the factor to better multiply the final value.
  114231. */
  114232. private debugFactor;
  114233. /**
  114234. * Defines the clear coat layer parameters for the material.
  114235. */
  114236. readonly clearCoat: PBRClearCoatConfiguration;
  114237. /**
  114238. * Defines the anisotropic parameters for the material.
  114239. */
  114240. readonly anisotropy: PBRAnisotropicConfiguration;
  114241. /**
  114242. * Defines the BRDF parameters for the material.
  114243. */
  114244. readonly brdf: PBRBRDFConfiguration;
  114245. /**
  114246. * Defines the Sheen parameters for the material.
  114247. */
  114248. readonly sheen: PBRSheenConfiguration;
  114249. /**
  114250. * Defines the SubSurface parameters for the material.
  114251. */
  114252. readonly subSurface: PBRSubSurfaceConfiguration;
  114253. /**
  114254. * Custom callback helping to override the default shader used in the material.
  114255. */
  114256. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114257. protected _rebuildInParallel: boolean;
  114258. /**
  114259. * Instantiates a new PBRMaterial instance.
  114260. *
  114261. * @param name The material name
  114262. * @param scene The scene the material will be use in.
  114263. */
  114264. constructor(name: string, scene: Scene);
  114265. /**
  114266. * Gets a boolean indicating that current material needs to register RTT
  114267. */
  114268. readonly hasRenderTargetTextures: boolean;
  114269. /**
  114270. * Gets the name of the material class.
  114271. */
  114272. getClassName(): string;
  114273. /**
  114274. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114275. */
  114276. /**
  114277. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114278. */
  114279. useLogarithmicDepth: boolean;
  114280. /**
  114281. * Gets the current transparency mode.
  114282. */
  114283. /**
  114284. * Sets the transparency mode of the material.
  114285. *
  114286. * | Value | Type | Description |
  114287. * | ----- | ----------------------------------- | ----------- |
  114288. * | 0 | OPAQUE | |
  114289. * | 1 | ALPHATEST | |
  114290. * | 2 | ALPHABLEND | |
  114291. * | 3 | ALPHATESTANDBLEND | |
  114292. *
  114293. */
  114294. transparencyMode: Nullable<number>;
  114295. /**
  114296. * Returns true if alpha blending should be disabled.
  114297. */
  114298. private readonly _disableAlphaBlending;
  114299. /**
  114300. * Specifies whether or not this material should be rendered in alpha blend mode.
  114301. */
  114302. needAlphaBlending(): boolean;
  114303. /**
  114304. * Specifies if the mesh will require alpha blending.
  114305. * @param mesh - BJS mesh.
  114306. */
  114307. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114308. /**
  114309. * Specifies whether or not this material should be rendered in alpha test mode.
  114310. */
  114311. needAlphaTesting(): boolean;
  114312. /**
  114313. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114314. */
  114315. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114316. /**
  114317. * Gets the texture used for the alpha test.
  114318. */
  114319. getAlphaTestTexture(): Nullable<BaseTexture>;
  114320. /**
  114321. * Specifies that the submesh is ready to be used.
  114322. * @param mesh - BJS mesh.
  114323. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114324. * @param useInstances - Specifies that instances should be used.
  114325. * @returns - boolean indicating that the submesh is ready or not.
  114326. */
  114327. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114328. /**
  114329. * Specifies if the material uses metallic roughness workflow.
  114330. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114331. */
  114332. isMetallicWorkflow(): boolean;
  114333. private _prepareEffect;
  114334. private _prepareDefines;
  114335. /**
  114336. * Force shader compilation
  114337. */
  114338. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114339. clipPlane: boolean;
  114340. }>): void;
  114341. /**
  114342. * Initializes the uniform buffer layout for the shader.
  114343. */
  114344. buildUniformLayout(): void;
  114345. /**
  114346. * Unbinds the material from the mesh
  114347. */
  114348. unbind(): void;
  114349. /**
  114350. * Binds the submesh data.
  114351. * @param world - The world matrix.
  114352. * @param mesh - The BJS mesh.
  114353. * @param subMesh - A submesh of the BJS mesh.
  114354. */
  114355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114356. /**
  114357. * Returns the animatable textures.
  114358. * @returns - Array of animatable textures.
  114359. */
  114360. getAnimatables(): IAnimatable[];
  114361. /**
  114362. * Returns the texture used for reflections.
  114363. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114364. */
  114365. private _getReflectionTexture;
  114366. /**
  114367. * Returns an array of the actively used textures.
  114368. * @returns - Array of BaseTextures
  114369. */
  114370. getActiveTextures(): BaseTexture[];
  114371. /**
  114372. * Checks to see if a texture is used in the material.
  114373. * @param texture - Base texture to use.
  114374. * @returns - Boolean specifying if a texture is used in the material.
  114375. */
  114376. hasTexture(texture: BaseTexture): boolean;
  114377. /**
  114378. * Disposes the resources of the material.
  114379. * @param forceDisposeEffect - Forces the disposal of effects.
  114380. * @param forceDisposeTextures - Forces the disposal of all textures.
  114381. */
  114382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114383. }
  114384. }
  114385. declare module BABYLON {
  114386. /**
  114387. * The Physically based material of BJS.
  114388. *
  114389. * This offers the main features of a standard PBR material.
  114390. * For more information, please refer to the documentation :
  114391. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114392. */
  114393. export class PBRMaterial extends PBRBaseMaterial {
  114394. /**
  114395. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114396. */
  114397. static readonly PBRMATERIAL_OPAQUE: number;
  114398. /**
  114399. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114400. */
  114401. static readonly PBRMATERIAL_ALPHATEST: number;
  114402. /**
  114403. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114404. */
  114405. static readonly PBRMATERIAL_ALPHABLEND: number;
  114406. /**
  114407. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114408. * They are also discarded below the alpha cutoff threshold to improve performances.
  114409. */
  114410. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114411. /**
  114412. * Defines the default value of how much AO map is occluding the analytical lights
  114413. * (point spot...).
  114414. */
  114415. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114416. /**
  114417. * Intensity of the direct lights e.g. the four lights available in your scene.
  114418. * This impacts both the direct diffuse and specular highlights.
  114419. */
  114420. directIntensity: number;
  114421. /**
  114422. * Intensity of the emissive part of the material.
  114423. * This helps controlling the emissive effect without modifying the emissive color.
  114424. */
  114425. emissiveIntensity: number;
  114426. /**
  114427. * Intensity of the environment e.g. how much the environment will light the object
  114428. * either through harmonics for rough material or through the refelction for shiny ones.
  114429. */
  114430. environmentIntensity: number;
  114431. /**
  114432. * This is a special control allowing the reduction of the specular highlights coming from the
  114433. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114434. */
  114435. specularIntensity: number;
  114436. /**
  114437. * Debug Control allowing disabling the bump map on this material.
  114438. */
  114439. disableBumpMap: boolean;
  114440. /**
  114441. * AKA Diffuse Texture in standard nomenclature.
  114442. */
  114443. albedoTexture: BaseTexture;
  114444. /**
  114445. * AKA Occlusion Texture in other nomenclature.
  114446. */
  114447. ambientTexture: BaseTexture;
  114448. /**
  114449. * AKA Occlusion Texture Intensity in other nomenclature.
  114450. */
  114451. ambientTextureStrength: number;
  114452. /**
  114453. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114454. * 1 means it completely occludes it
  114455. * 0 mean it has no impact
  114456. */
  114457. ambientTextureImpactOnAnalyticalLights: number;
  114458. /**
  114459. * Stores the alpha values in a texture.
  114460. */
  114461. opacityTexture: BaseTexture;
  114462. /**
  114463. * Stores the reflection values in a texture.
  114464. */
  114465. reflectionTexture: Nullable<BaseTexture>;
  114466. /**
  114467. * Stores the emissive values in a texture.
  114468. */
  114469. emissiveTexture: BaseTexture;
  114470. /**
  114471. * AKA Specular texture in other nomenclature.
  114472. */
  114473. reflectivityTexture: BaseTexture;
  114474. /**
  114475. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114476. */
  114477. metallicTexture: BaseTexture;
  114478. /**
  114479. * Specifies the metallic scalar of the metallic/roughness workflow.
  114480. * Can also be used to scale the metalness values of the metallic texture.
  114481. */
  114482. metallic: Nullable<number>;
  114483. /**
  114484. * Specifies the roughness scalar of the metallic/roughness workflow.
  114485. * Can also be used to scale the roughness values of the metallic texture.
  114486. */
  114487. roughness: Nullable<number>;
  114488. /**
  114489. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114490. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114491. */
  114492. microSurfaceTexture: BaseTexture;
  114493. /**
  114494. * Stores surface normal data used to displace a mesh in a texture.
  114495. */
  114496. bumpTexture: BaseTexture;
  114497. /**
  114498. * Stores the pre-calculated light information of a mesh in a texture.
  114499. */
  114500. lightmapTexture: BaseTexture;
  114501. /**
  114502. * Stores the refracted light information in a texture.
  114503. */
  114504. refractionTexture: Nullable<BaseTexture>;
  114505. /**
  114506. * The color of a material in ambient lighting.
  114507. */
  114508. ambientColor: Color3;
  114509. /**
  114510. * AKA Diffuse Color in other nomenclature.
  114511. */
  114512. albedoColor: Color3;
  114513. /**
  114514. * AKA Specular Color in other nomenclature.
  114515. */
  114516. reflectivityColor: Color3;
  114517. /**
  114518. * The color reflected from the material.
  114519. */
  114520. reflectionColor: Color3;
  114521. /**
  114522. * The color emitted from the material.
  114523. */
  114524. emissiveColor: Color3;
  114525. /**
  114526. * AKA Glossiness in other nomenclature.
  114527. */
  114528. microSurface: number;
  114529. /**
  114530. * source material index of refraction (IOR)' / 'destination material IOR.
  114531. */
  114532. indexOfRefraction: number;
  114533. /**
  114534. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114535. */
  114536. invertRefractionY: boolean;
  114537. /**
  114538. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114539. * Materials half opaque for instance using refraction could benefit from this control.
  114540. */
  114541. linkRefractionWithTransparency: boolean;
  114542. /**
  114543. * If true, the light map contains occlusion information instead of lighting info.
  114544. */
  114545. useLightmapAsShadowmap: boolean;
  114546. /**
  114547. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114548. */
  114549. useAlphaFromAlbedoTexture: boolean;
  114550. /**
  114551. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114552. */
  114553. forceAlphaTest: boolean;
  114554. /**
  114555. * Defines the alpha limits in alpha test mode.
  114556. */
  114557. alphaCutOff: number;
  114558. /**
  114559. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  114560. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114561. */
  114562. useSpecularOverAlpha: boolean;
  114563. /**
  114564. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114565. */
  114566. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114567. /**
  114568. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114569. */
  114570. useRoughnessFromMetallicTextureAlpha: boolean;
  114571. /**
  114572. * Specifies if the metallic texture contains the roughness information in its green channel.
  114573. */
  114574. useRoughnessFromMetallicTextureGreen: boolean;
  114575. /**
  114576. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114577. */
  114578. useMetallnessFromMetallicTextureBlue: boolean;
  114579. /**
  114580. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114581. */
  114582. useAmbientOcclusionFromMetallicTextureRed: boolean;
  114583. /**
  114584. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114585. */
  114586. useAmbientInGrayScale: boolean;
  114587. /**
  114588. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114589. * The material will try to infer what glossiness each pixel should be.
  114590. */
  114591. useAutoMicroSurfaceFromReflectivityMap: boolean;
  114592. /**
  114593. * BJS is using an harcoded light falloff based on a manually sets up range.
  114594. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114595. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114596. */
  114597. /**
  114598. * BJS is using an harcoded light falloff based on a manually sets up range.
  114599. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114600. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114601. */
  114602. usePhysicalLightFalloff: boolean;
  114603. /**
  114604. * In order to support the falloff compatibility with gltf, a special mode has been added
  114605. * to reproduce the gltf light falloff.
  114606. */
  114607. /**
  114608. * In order to support the falloff compatibility with gltf, a special mode has been added
  114609. * to reproduce the gltf light falloff.
  114610. */
  114611. useGLTFLightFalloff: boolean;
  114612. /**
  114613. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114614. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114615. */
  114616. useRadianceOverAlpha: boolean;
  114617. /**
  114618. * Allows using an object space normal map (instead of tangent space).
  114619. */
  114620. useObjectSpaceNormalMap: boolean;
  114621. /**
  114622. * Allows using the bump map in parallax mode.
  114623. */
  114624. useParallax: boolean;
  114625. /**
  114626. * Allows using the bump map in parallax occlusion mode.
  114627. */
  114628. useParallaxOcclusion: boolean;
  114629. /**
  114630. * Controls the scale bias of the parallax mode.
  114631. */
  114632. parallaxScaleBias: number;
  114633. /**
  114634. * If sets to true, disables all the lights affecting the material.
  114635. */
  114636. disableLighting: boolean;
  114637. /**
  114638. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114639. */
  114640. forceIrradianceInFragment: boolean;
  114641. /**
  114642. * Number of Simultaneous lights allowed on the material.
  114643. */
  114644. maxSimultaneousLights: number;
  114645. /**
  114646. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114647. */
  114648. invertNormalMapX: boolean;
  114649. /**
  114650. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114651. */
  114652. invertNormalMapY: boolean;
  114653. /**
  114654. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114655. */
  114656. twoSidedLighting: boolean;
  114657. /**
  114658. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114659. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114660. */
  114661. useAlphaFresnel: boolean;
  114662. /**
  114663. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114664. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114665. */
  114666. useLinearAlphaFresnel: boolean;
  114667. /**
  114668. * Let user defines the brdf lookup texture used for IBL.
  114669. * A default 8bit version is embedded but you could point at :
  114670. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  114671. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  114672. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  114673. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  114674. */
  114675. environmentBRDFTexture: Nullable<BaseTexture>;
  114676. /**
  114677. * Force normal to face away from face.
  114678. */
  114679. forceNormalForward: boolean;
  114680. /**
  114681. * Enables specular anti aliasing in the PBR shader.
  114682. * It will both interacts on the Geometry for analytical and IBL lighting.
  114683. * It also prefilter the roughness map based on the bump values.
  114684. */
  114685. enableSpecularAntiAliasing: boolean;
  114686. /**
  114687. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114688. * makes the reflect vector face the model (under horizon).
  114689. */
  114690. useHorizonOcclusion: boolean;
  114691. /**
  114692. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114693. * too much the area relying on ambient texture to define their ambient occlusion.
  114694. */
  114695. useRadianceOcclusion: boolean;
  114696. /**
  114697. * If set to true, no lighting calculations will be applied.
  114698. */
  114699. unlit: boolean;
  114700. /**
  114701. * Gets the image processing configuration used either in this material.
  114702. */
  114703. /**
  114704. * Sets the Default image processing configuration used either in the this material.
  114705. *
  114706. * If sets to null, the scene one is in use.
  114707. */
  114708. imageProcessingConfiguration: ImageProcessingConfiguration;
  114709. /**
  114710. * Gets wether the color curves effect is enabled.
  114711. */
  114712. /**
  114713. * Sets wether the color curves effect is enabled.
  114714. */
  114715. cameraColorCurvesEnabled: boolean;
  114716. /**
  114717. * Gets wether the color grading effect is enabled.
  114718. */
  114719. /**
  114720. * Gets wether the color grading effect is enabled.
  114721. */
  114722. cameraColorGradingEnabled: boolean;
  114723. /**
  114724. * Gets wether tonemapping is enabled or not.
  114725. */
  114726. /**
  114727. * Sets wether tonemapping is enabled or not
  114728. */
  114729. cameraToneMappingEnabled: boolean;
  114730. /**
  114731. * The camera exposure used on this material.
  114732. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114733. * This corresponds to a photographic exposure.
  114734. */
  114735. /**
  114736. * The camera exposure used on this material.
  114737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114738. * This corresponds to a photographic exposure.
  114739. */
  114740. cameraExposure: number;
  114741. /**
  114742. * Gets The camera contrast used on this material.
  114743. */
  114744. /**
  114745. * Sets The camera contrast used on this material.
  114746. */
  114747. cameraContrast: number;
  114748. /**
  114749. * Gets the Color Grading 2D Lookup Texture.
  114750. */
  114751. /**
  114752. * Sets the Color Grading 2D Lookup Texture.
  114753. */
  114754. cameraColorGradingTexture: Nullable<BaseTexture>;
  114755. /**
  114756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114758. * 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;
  114759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114760. */
  114761. /**
  114762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114764. * 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;
  114765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114766. */
  114767. cameraColorCurves: Nullable<ColorCurves>;
  114768. /**
  114769. * Instantiates a new PBRMaterial instance.
  114770. *
  114771. * @param name The material name
  114772. * @param scene The scene the material will be use in.
  114773. */
  114774. constructor(name: string, scene: Scene);
  114775. /**
  114776. * Returns the name of this material class.
  114777. */
  114778. getClassName(): string;
  114779. /**
  114780. * Makes a duplicate of the current material.
  114781. * @param name - name to use for the new material.
  114782. */
  114783. clone(name: string): PBRMaterial;
  114784. /**
  114785. * Serializes this PBR Material.
  114786. * @returns - An object with the serialized material.
  114787. */
  114788. serialize(): any;
  114789. /**
  114790. * Parses a PBR Material from a serialized object.
  114791. * @param source - Serialized object.
  114792. * @param scene - BJS scene instance.
  114793. * @param rootUrl - url for the scene object
  114794. * @returns - PBRMaterial
  114795. */
  114796. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  114797. }
  114798. }
  114799. declare module BABYLON {
  114800. /**
  114801. * Direct draw surface info
  114802. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  114803. */
  114804. export interface DDSInfo {
  114805. /**
  114806. * Width of the texture
  114807. */
  114808. width: number;
  114809. /**
  114810. * Width of the texture
  114811. */
  114812. height: number;
  114813. /**
  114814. * Number of Mipmaps for the texture
  114815. * @see https://en.wikipedia.org/wiki/Mipmap
  114816. */
  114817. mipmapCount: number;
  114818. /**
  114819. * If the textures format is a known fourCC format
  114820. * @see https://www.fourcc.org/
  114821. */
  114822. isFourCC: boolean;
  114823. /**
  114824. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  114825. */
  114826. isRGB: boolean;
  114827. /**
  114828. * If the texture is a lumincance format
  114829. */
  114830. isLuminance: boolean;
  114831. /**
  114832. * If this is a cube texture
  114833. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  114834. */
  114835. isCube: boolean;
  114836. /**
  114837. * If the texture is a compressed format eg. FOURCC_DXT1
  114838. */
  114839. isCompressed: boolean;
  114840. /**
  114841. * The dxgiFormat of the texture
  114842. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  114843. */
  114844. dxgiFormat: number;
  114845. /**
  114846. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  114847. */
  114848. textureType: number;
  114849. /**
  114850. * Sphericle polynomial created for the dds texture
  114851. */
  114852. sphericalPolynomial?: SphericalPolynomial;
  114853. }
  114854. /**
  114855. * Class used to provide DDS decompression tools
  114856. */
  114857. export class DDSTools {
  114858. /**
  114859. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  114860. */
  114861. static StoreLODInAlphaChannel: boolean;
  114862. /**
  114863. * Gets DDS information from an array buffer
  114864. * @param arrayBuffer defines the array buffer to read data from
  114865. * @returns the DDS information
  114866. */
  114867. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  114868. private static _FloatView;
  114869. private static _Int32View;
  114870. private static _ToHalfFloat;
  114871. private static _FromHalfFloat;
  114872. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  114873. private static _GetHalfFloatRGBAArrayBuffer;
  114874. private static _GetFloatRGBAArrayBuffer;
  114875. private static _GetFloatAsUIntRGBAArrayBuffer;
  114876. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  114877. private static _GetRGBAArrayBuffer;
  114878. private static _ExtractLongWordOrder;
  114879. private static _GetRGBArrayBuffer;
  114880. private static _GetLuminanceArrayBuffer;
  114881. /**
  114882. * Uploads DDS Levels to a Babylon Texture
  114883. * @hidden
  114884. */
  114885. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  114886. }
  114887. interface ThinEngine {
  114888. /**
  114889. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  114890. * @param rootUrl defines the url where the file to load is located
  114891. * @param scene defines the current scene
  114892. * @param lodScale defines scale to apply to the mip map selection
  114893. * @param lodOffset defines offset to apply to the mip map selection
  114894. * @param onLoad defines an optional callback raised when the texture is loaded
  114895. * @param onError defines an optional callback raised if there is an issue to load the texture
  114896. * @param format defines the format of the data
  114897. * @param forcedExtension defines the extension to use to pick the right loader
  114898. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  114899. * @returns the cube texture as an InternalTexture
  114900. */
  114901. 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;
  114902. }
  114903. }
  114904. declare module BABYLON {
  114905. /**
  114906. * Implementation of the DDS Texture Loader.
  114907. * @hidden
  114908. */
  114909. export class _DDSTextureLoader implements IInternalTextureLoader {
  114910. /**
  114911. * Defines wether the loader supports cascade loading the different faces.
  114912. */
  114913. readonly supportCascades: boolean;
  114914. /**
  114915. * This returns if the loader support the current file information.
  114916. * @param extension defines the file extension of the file being loaded
  114917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114918. * @param fallback defines the fallback internal texture if any
  114919. * @param isBase64 defines whether the texture is encoded as a base64
  114920. * @param isBuffer defines whether the texture data are stored as a buffer
  114921. * @returns true if the loader can load the specified file
  114922. */
  114923. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114924. /**
  114925. * Transform the url before loading if required.
  114926. * @param rootUrl the url of the texture
  114927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114928. * @returns the transformed texture
  114929. */
  114930. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114931. /**
  114932. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114933. * @param rootUrl the url of the texture
  114934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114935. * @returns the fallback texture
  114936. */
  114937. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114938. /**
  114939. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114940. * @param data contains the texture data
  114941. * @param texture defines the BabylonJS internal texture
  114942. * @param createPolynomials will be true if polynomials have been requested
  114943. * @param onLoad defines the callback to trigger once the texture is ready
  114944. * @param onError defines the callback to trigger in case of error
  114945. */
  114946. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114947. /**
  114948. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114949. * @param data contains the texture data
  114950. * @param texture defines the BabylonJS internal texture
  114951. * @param callback defines the method to call once ready to upload
  114952. */
  114953. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114954. }
  114955. }
  114956. declare module BABYLON {
  114957. /**
  114958. * Implementation of the ENV Texture Loader.
  114959. * @hidden
  114960. */
  114961. export class _ENVTextureLoader implements IInternalTextureLoader {
  114962. /**
  114963. * Defines wether the loader supports cascade loading the different faces.
  114964. */
  114965. readonly supportCascades: boolean;
  114966. /**
  114967. * This returns if the loader support the current file information.
  114968. * @param extension defines the file extension of the file being loaded
  114969. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114970. * @param fallback defines the fallback internal texture if any
  114971. * @param isBase64 defines whether the texture is encoded as a base64
  114972. * @param isBuffer defines whether the texture data are stored as a buffer
  114973. * @returns true if the loader can load the specified file
  114974. */
  114975. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114976. /**
  114977. * Transform the url before loading if required.
  114978. * @param rootUrl the url of the texture
  114979. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114980. * @returns the transformed texture
  114981. */
  114982. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114983. /**
  114984. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114985. * @param rootUrl the url of the texture
  114986. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114987. * @returns the fallback texture
  114988. */
  114989. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114990. /**
  114991. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114992. * @param data contains the texture data
  114993. * @param texture defines the BabylonJS internal texture
  114994. * @param createPolynomials will be true if polynomials have been requested
  114995. * @param onLoad defines the callback to trigger once the texture is ready
  114996. * @param onError defines the callback to trigger in case of error
  114997. */
  114998. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114999. /**
  115000. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115001. * @param data contains the texture data
  115002. * @param texture defines the BabylonJS internal texture
  115003. * @param callback defines the method to call once ready to upload
  115004. */
  115005. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115006. }
  115007. }
  115008. declare module BABYLON {
  115009. /**
  115010. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115011. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115012. */
  115013. export class KhronosTextureContainer {
  115014. /** contents of the KTX container file */
  115015. arrayBuffer: any;
  115016. private static HEADER_LEN;
  115017. private static COMPRESSED_2D;
  115018. private static COMPRESSED_3D;
  115019. private static TEX_2D;
  115020. private static TEX_3D;
  115021. /**
  115022. * Gets the openGL type
  115023. */
  115024. glType: number;
  115025. /**
  115026. * Gets the openGL type size
  115027. */
  115028. glTypeSize: number;
  115029. /**
  115030. * Gets the openGL format
  115031. */
  115032. glFormat: number;
  115033. /**
  115034. * Gets the openGL internal format
  115035. */
  115036. glInternalFormat: number;
  115037. /**
  115038. * Gets the base internal format
  115039. */
  115040. glBaseInternalFormat: number;
  115041. /**
  115042. * Gets image width in pixel
  115043. */
  115044. pixelWidth: number;
  115045. /**
  115046. * Gets image height in pixel
  115047. */
  115048. pixelHeight: number;
  115049. /**
  115050. * Gets image depth in pixels
  115051. */
  115052. pixelDepth: number;
  115053. /**
  115054. * Gets the number of array elements
  115055. */
  115056. numberOfArrayElements: number;
  115057. /**
  115058. * Gets the number of faces
  115059. */
  115060. numberOfFaces: number;
  115061. /**
  115062. * Gets the number of mipmap levels
  115063. */
  115064. numberOfMipmapLevels: number;
  115065. /**
  115066. * Gets the bytes of key value data
  115067. */
  115068. bytesOfKeyValueData: number;
  115069. /**
  115070. * Gets the load type
  115071. */
  115072. loadType: number;
  115073. /**
  115074. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115075. */
  115076. isInvalid: boolean;
  115077. /**
  115078. * Creates a new KhronosTextureContainer
  115079. * @param arrayBuffer contents of the KTX container file
  115080. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115081. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115082. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115083. */
  115084. constructor(
  115085. /** contents of the KTX container file */
  115086. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115087. /**
  115088. * Uploads KTX content to a Babylon Texture.
  115089. * It is assumed that the texture has already been created & is currently bound
  115090. * @hidden
  115091. */
  115092. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115093. private _upload2DCompressedLevels;
  115094. }
  115095. }
  115096. declare module BABYLON {
  115097. /**
  115098. * Implementation of the KTX Texture Loader.
  115099. * @hidden
  115100. */
  115101. export class _KTXTextureLoader implements IInternalTextureLoader {
  115102. /**
  115103. * Defines wether the loader supports cascade loading the different faces.
  115104. */
  115105. readonly supportCascades: boolean;
  115106. /**
  115107. * This returns if the loader support the current file information.
  115108. * @param extension defines the file extension of the file being loaded
  115109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115110. * @param fallback defines the fallback internal texture if any
  115111. * @param isBase64 defines whether the texture is encoded as a base64
  115112. * @param isBuffer defines whether the texture data are stored as a buffer
  115113. * @returns true if the loader can load the specified file
  115114. */
  115115. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115116. /**
  115117. * Transform the url before loading if required.
  115118. * @param rootUrl the url of the texture
  115119. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115120. * @returns the transformed texture
  115121. */
  115122. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115123. /**
  115124. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115125. * @param rootUrl the url of the texture
  115126. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115127. * @returns the fallback texture
  115128. */
  115129. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115130. /**
  115131. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115132. * @param data contains the texture data
  115133. * @param texture defines the BabylonJS internal texture
  115134. * @param createPolynomials will be true if polynomials have been requested
  115135. * @param onLoad defines the callback to trigger once the texture is ready
  115136. * @param onError defines the callback to trigger in case of error
  115137. */
  115138. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115139. /**
  115140. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115141. * @param data contains the texture data
  115142. * @param texture defines the BabylonJS internal texture
  115143. * @param callback defines the method to call once ready to upload
  115144. */
  115145. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115146. }
  115147. }
  115148. declare module BABYLON {
  115149. /**
  115150. * Options for the default xr helper
  115151. */
  115152. export class WebXRDefaultExperienceOptions {
  115153. /**
  115154. * Floor meshes that should be used for teleporting
  115155. */
  115156. floorMeshes: Array<AbstractMesh>;
  115157. }
  115158. /**
  115159. * Default experience which provides a similar setup to the previous webVRExperience
  115160. */
  115161. export class WebXRDefaultExperience {
  115162. /**
  115163. * Base experience
  115164. */
  115165. baseExperience: WebXRExperienceHelper;
  115166. /**
  115167. * Input experience extension
  115168. */
  115169. input: WebXRInput;
  115170. /**
  115171. * Loads the controller models
  115172. */
  115173. controllerModelLoader: WebXRControllerModelLoader;
  115174. /**
  115175. * Enables laser pointer and selection
  115176. */
  115177. pointerSelection: WebXRControllerPointerSelection;
  115178. /**
  115179. * Enables teleportation
  115180. */
  115181. teleportation: WebXRControllerTeleportation;
  115182. /**
  115183. * Enables ui for enetering/exiting xr
  115184. */
  115185. enterExitUI: WebXREnterExitUI;
  115186. /**
  115187. * Default output canvas xr should render to
  115188. */
  115189. outputCanvas: WebXRManagedOutputCanvas;
  115190. /**
  115191. * Creates the default xr experience
  115192. * @param scene scene
  115193. * @param options options for basic configuration
  115194. * @returns resulting WebXRDefaultExperience
  115195. */
  115196. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115197. private constructor();
  115198. /**
  115199. * DIsposes of the experience helper
  115200. */
  115201. dispose(): void;
  115202. }
  115203. }
  115204. declare module BABYLON {
  115205. /** @hidden */
  115206. export var _forceSceneHelpersToBundle: boolean;
  115207. interface Scene {
  115208. /**
  115209. * Creates a default light for the scene.
  115210. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115211. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115212. */
  115213. createDefaultLight(replace?: boolean): void;
  115214. /**
  115215. * Creates a default camera for the scene.
  115216. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115217. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115218. * @param replace has default false, when true replaces the active camera in the scene
  115219. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115220. */
  115221. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115222. /**
  115223. * Creates a default camera and a default light.
  115224. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115225. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115226. * @param replace has the default false, when true replaces the active camera/light in the scene
  115227. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115228. */
  115229. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115230. /**
  115231. * Creates a new sky box
  115232. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115233. * @param environmentTexture defines the texture to use as environment texture
  115234. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115235. * @param scale defines the overall scale of the skybox
  115236. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115237. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115238. * @returns a new mesh holding the sky box
  115239. */
  115240. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115241. /**
  115242. * Creates a new environment
  115243. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115244. * @param options defines the options you can use to configure the environment
  115245. * @returns the new EnvironmentHelper
  115246. */
  115247. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115248. /**
  115249. * Creates a new VREXperienceHelper
  115250. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115251. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115252. * @returns a new VREXperienceHelper
  115253. */
  115254. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115255. /**
  115256. * Creates a new WebXRDefaultExperience
  115257. * @see http://doc.babylonjs.com/how_to/webxr
  115258. * @param options experience options
  115259. * @returns a promise for a new WebXRDefaultExperience
  115260. */
  115261. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115262. }
  115263. }
  115264. declare module BABYLON {
  115265. /**
  115266. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115267. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115268. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115269. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115270. */
  115271. export class VideoDome extends TransformNode {
  115272. /**
  115273. * Define the video source as a Monoscopic panoramic 360 video.
  115274. */
  115275. static readonly MODE_MONOSCOPIC: number;
  115276. /**
  115277. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115278. */
  115279. static readonly MODE_TOPBOTTOM: number;
  115280. /**
  115281. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115282. */
  115283. static readonly MODE_SIDEBYSIDE: number;
  115284. private _halfDome;
  115285. private _useDirectMapping;
  115286. /**
  115287. * The video texture being displayed on the sphere
  115288. */
  115289. protected _videoTexture: VideoTexture;
  115290. /**
  115291. * Gets the video texture being displayed on the sphere
  115292. */
  115293. readonly videoTexture: VideoTexture;
  115294. /**
  115295. * The skybox material
  115296. */
  115297. protected _material: BackgroundMaterial;
  115298. /**
  115299. * The surface used for the skybox
  115300. */
  115301. protected _mesh: Mesh;
  115302. /**
  115303. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115304. */
  115305. private _halfDomeMask;
  115306. /**
  115307. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115308. * Also see the options.resolution property.
  115309. */
  115310. fovMultiplier: number;
  115311. private _videoMode;
  115312. /**
  115313. * Gets or set the current video mode for the video. It can be:
  115314. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115315. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115316. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115317. */
  115318. videoMode: number;
  115319. /**
  115320. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115321. *
  115322. */
  115323. /**
  115324. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115325. */
  115326. halfDome: boolean;
  115327. /**
  115328. * Oberserver used in Stereoscopic VR Mode.
  115329. */
  115330. private _onBeforeCameraRenderObserver;
  115331. /**
  115332. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115333. * @param name Element's name, child elements will append suffixes for their own names.
  115334. * @param urlsOrVideo defines the url(s) or the video element to use
  115335. * @param options An object containing optional or exposed sub element properties
  115336. */
  115337. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115338. resolution?: number;
  115339. clickToPlay?: boolean;
  115340. autoPlay?: boolean;
  115341. loop?: boolean;
  115342. size?: number;
  115343. poster?: string;
  115344. faceForward?: boolean;
  115345. useDirectMapping?: boolean;
  115346. halfDomeMode?: boolean;
  115347. }, scene: Scene);
  115348. private _changeVideoMode;
  115349. /**
  115350. * Releases resources associated with this node.
  115351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115353. */
  115354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115355. }
  115356. }
  115357. declare module BABYLON {
  115358. /**
  115359. * This class can be used to get instrumentation data from a Babylon engine
  115360. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115361. */
  115362. export class EngineInstrumentation implements IDisposable {
  115363. /**
  115364. * Define the instrumented engine.
  115365. */
  115366. engine: Engine;
  115367. private _captureGPUFrameTime;
  115368. private _gpuFrameTimeToken;
  115369. private _gpuFrameTime;
  115370. private _captureShaderCompilationTime;
  115371. private _shaderCompilationTime;
  115372. private _onBeginFrameObserver;
  115373. private _onEndFrameObserver;
  115374. private _onBeforeShaderCompilationObserver;
  115375. private _onAfterShaderCompilationObserver;
  115376. /**
  115377. * Gets the perf counter used for GPU frame time
  115378. */
  115379. readonly gpuFrameTimeCounter: PerfCounter;
  115380. /**
  115381. * Gets the GPU frame time capture status
  115382. */
  115383. /**
  115384. * Enable or disable the GPU frame time capture
  115385. */
  115386. captureGPUFrameTime: boolean;
  115387. /**
  115388. * Gets the perf counter used for shader compilation time
  115389. */
  115390. readonly shaderCompilationTimeCounter: PerfCounter;
  115391. /**
  115392. * Gets the shader compilation time capture status
  115393. */
  115394. /**
  115395. * Enable or disable the shader compilation time capture
  115396. */
  115397. captureShaderCompilationTime: boolean;
  115398. /**
  115399. * Instantiates a new engine instrumentation.
  115400. * This class can be used to get instrumentation data from a Babylon engine
  115401. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115402. * @param engine Defines the engine to instrument
  115403. */
  115404. constructor(
  115405. /**
  115406. * Define the instrumented engine.
  115407. */
  115408. engine: Engine);
  115409. /**
  115410. * Dispose and release associated resources.
  115411. */
  115412. dispose(): void;
  115413. }
  115414. }
  115415. declare module BABYLON {
  115416. /**
  115417. * This class can be used to get instrumentation data from a Babylon engine
  115418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115419. */
  115420. export class SceneInstrumentation implements IDisposable {
  115421. /**
  115422. * Defines the scene to instrument
  115423. */
  115424. scene: Scene;
  115425. private _captureActiveMeshesEvaluationTime;
  115426. private _activeMeshesEvaluationTime;
  115427. private _captureRenderTargetsRenderTime;
  115428. private _renderTargetsRenderTime;
  115429. private _captureFrameTime;
  115430. private _frameTime;
  115431. private _captureRenderTime;
  115432. private _renderTime;
  115433. private _captureInterFrameTime;
  115434. private _interFrameTime;
  115435. private _captureParticlesRenderTime;
  115436. private _particlesRenderTime;
  115437. private _captureSpritesRenderTime;
  115438. private _spritesRenderTime;
  115439. private _capturePhysicsTime;
  115440. private _physicsTime;
  115441. private _captureAnimationsTime;
  115442. private _animationsTime;
  115443. private _captureCameraRenderTime;
  115444. private _cameraRenderTime;
  115445. private _onBeforeActiveMeshesEvaluationObserver;
  115446. private _onAfterActiveMeshesEvaluationObserver;
  115447. private _onBeforeRenderTargetsRenderObserver;
  115448. private _onAfterRenderTargetsRenderObserver;
  115449. private _onAfterRenderObserver;
  115450. private _onBeforeDrawPhaseObserver;
  115451. private _onAfterDrawPhaseObserver;
  115452. private _onBeforeAnimationsObserver;
  115453. private _onBeforeParticlesRenderingObserver;
  115454. private _onAfterParticlesRenderingObserver;
  115455. private _onBeforeSpritesRenderingObserver;
  115456. private _onAfterSpritesRenderingObserver;
  115457. private _onBeforePhysicsObserver;
  115458. private _onAfterPhysicsObserver;
  115459. private _onAfterAnimationsObserver;
  115460. private _onBeforeCameraRenderObserver;
  115461. private _onAfterCameraRenderObserver;
  115462. /**
  115463. * Gets the perf counter used for active meshes evaluation time
  115464. */
  115465. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115466. /**
  115467. * Gets the active meshes evaluation time capture status
  115468. */
  115469. /**
  115470. * Enable or disable the active meshes evaluation time capture
  115471. */
  115472. captureActiveMeshesEvaluationTime: boolean;
  115473. /**
  115474. * Gets the perf counter used for render targets render time
  115475. */
  115476. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115477. /**
  115478. * Gets the render targets render time capture status
  115479. */
  115480. /**
  115481. * Enable or disable the render targets render time capture
  115482. */
  115483. captureRenderTargetsRenderTime: boolean;
  115484. /**
  115485. * Gets the perf counter used for particles render time
  115486. */
  115487. readonly particlesRenderTimeCounter: PerfCounter;
  115488. /**
  115489. * Gets the particles render time capture status
  115490. */
  115491. /**
  115492. * Enable or disable the particles render time capture
  115493. */
  115494. captureParticlesRenderTime: boolean;
  115495. /**
  115496. * Gets the perf counter used for sprites render time
  115497. */
  115498. readonly spritesRenderTimeCounter: PerfCounter;
  115499. /**
  115500. * Gets the sprites render time capture status
  115501. */
  115502. /**
  115503. * Enable or disable the sprites render time capture
  115504. */
  115505. captureSpritesRenderTime: boolean;
  115506. /**
  115507. * Gets the perf counter used for physics time
  115508. */
  115509. readonly physicsTimeCounter: PerfCounter;
  115510. /**
  115511. * Gets the physics time capture status
  115512. */
  115513. /**
  115514. * Enable or disable the physics time capture
  115515. */
  115516. capturePhysicsTime: boolean;
  115517. /**
  115518. * Gets the perf counter used for animations time
  115519. */
  115520. readonly animationsTimeCounter: PerfCounter;
  115521. /**
  115522. * Gets the animations time capture status
  115523. */
  115524. /**
  115525. * Enable or disable the animations time capture
  115526. */
  115527. captureAnimationsTime: boolean;
  115528. /**
  115529. * Gets the perf counter used for frame time capture
  115530. */
  115531. readonly frameTimeCounter: PerfCounter;
  115532. /**
  115533. * Gets the frame time capture status
  115534. */
  115535. /**
  115536. * Enable or disable the frame time capture
  115537. */
  115538. captureFrameTime: boolean;
  115539. /**
  115540. * Gets the perf counter used for inter-frames time capture
  115541. */
  115542. readonly interFrameTimeCounter: PerfCounter;
  115543. /**
  115544. * Gets the inter-frames time capture status
  115545. */
  115546. /**
  115547. * Enable or disable the inter-frames time capture
  115548. */
  115549. captureInterFrameTime: boolean;
  115550. /**
  115551. * Gets the perf counter used for render time capture
  115552. */
  115553. readonly renderTimeCounter: PerfCounter;
  115554. /**
  115555. * Gets the render time capture status
  115556. */
  115557. /**
  115558. * Enable or disable the render time capture
  115559. */
  115560. captureRenderTime: boolean;
  115561. /**
  115562. * Gets the perf counter used for camera render time capture
  115563. */
  115564. readonly cameraRenderTimeCounter: PerfCounter;
  115565. /**
  115566. * Gets the camera render time capture status
  115567. */
  115568. /**
  115569. * Enable or disable the camera render time capture
  115570. */
  115571. captureCameraRenderTime: boolean;
  115572. /**
  115573. * Gets the perf counter used for draw calls
  115574. */
  115575. readonly drawCallsCounter: PerfCounter;
  115576. /**
  115577. * Instantiates a new scene instrumentation.
  115578. * This class can be used to get instrumentation data from a Babylon engine
  115579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115580. * @param scene Defines the scene to instrument
  115581. */
  115582. constructor(
  115583. /**
  115584. * Defines the scene to instrument
  115585. */
  115586. scene: Scene);
  115587. /**
  115588. * Dispose and release associated resources.
  115589. */
  115590. dispose(): void;
  115591. }
  115592. }
  115593. declare module BABYLON {
  115594. /** @hidden */
  115595. export var glowMapGenerationPixelShader: {
  115596. name: string;
  115597. shader: string;
  115598. };
  115599. }
  115600. declare module BABYLON {
  115601. /** @hidden */
  115602. export var glowMapGenerationVertexShader: {
  115603. name: string;
  115604. shader: string;
  115605. };
  115606. }
  115607. declare module BABYLON {
  115608. /**
  115609. * Effect layer options. This helps customizing the behaviour
  115610. * of the effect layer.
  115611. */
  115612. export interface IEffectLayerOptions {
  115613. /**
  115614. * Multiplication factor apply to the canvas size to compute the render target size
  115615. * used to generated the objects (the smaller the faster).
  115616. */
  115617. mainTextureRatio: number;
  115618. /**
  115619. * Enforces a fixed size texture to ensure effect stability across devices.
  115620. */
  115621. mainTextureFixedSize?: number;
  115622. /**
  115623. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  115624. */
  115625. alphaBlendingMode: number;
  115626. /**
  115627. * The camera attached to the layer.
  115628. */
  115629. camera: Nullable<Camera>;
  115630. /**
  115631. * The rendering group to draw the layer in.
  115632. */
  115633. renderingGroupId: number;
  115634. }
  115635. /**
  115636. * The effect layer Helps adding post process effect blended with the main pass.
  115637. *
  115638. * This can be for instance use to generate glow or higlight effects on the scene.
  115639. *
  115640. * The effect layer class can not be used directly and is intented to inherited from to be
  115641. * customized per effects.
  115642. */
  115643. export abstract class EffectLayer {
  115644. private _vertexBuffers;
  115645. private _indexBuffer;
  115646. private _cachedDefines;
  115647. private _effectLayerMapGenerationEffect;
  115648. private _effectLayerOptions;
  115649. private _mergeEffect;
  115650. protected _scene: Scene;
  115651. protected _engine: Engine;
  115652. protected _maxSize: number;
  115653. protected _mainTextureDesiredSize: ISize;
  115654. protected _mainTexture: RenderTargetTexture;
  115655. protected _shouldRender: boolean;
  115656. protected _postProcesses: PostProcess[];
  115657. protected _textures: BaseTexture[];
  115658. protected _emissiveTextureAndColor: {
  115659. texture: Nullable<BaseTexture>;
  115660. color: Color4;
  115661. };
  115662. /**
  115663. * The name of the layer
  115664. */
  115665. name: string;
  115666. /**
  115667. * The clear color of the texture used to generate the glow map.
  115668. */
  115669. neutralColor: Color4;
  115670. /**
  115671. * Specifies wether the highlight layer is enabled or not.
  115672. */
  115673. isEnabled: boolean;
  115674. /**
  115675. * Gets the camera attached to the layer.
  115676. */
  115677. readonly camera: Nullable<Camera>;
  115678. /**
  115679. * Gets the rendering group id the layer should render in.
  115680. */
  115681. renderingGroupId: number;
  115682. /**
  115683. * An event triggered when the effect layer has been disposed.
  115684. */
  115685. onDisposeObservable: Observable<EffectLayer>;
  115686. /**
  115687. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  115688. */
  115689. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  115690. /**
  115691. * An event triggered when the generated texture is being merged in the scene.
  115692. */
  115693. onBeforeComposeObservable: Observable<EffectLayer>;
  115694. /**
  115695. * An event triggered when the generated texture has been merged in the scene.
  115696. */
  115697. onAfterComposeObservable: Observable<EffectLayer>;
  115698. /**
  115699. * An event triggered when the efffect layer changes its size.
  115700. */
  115701. onSizeChangedObservable: Observable<EffectLayer>;
  115702. /** @hidden */
  115703. static _SceneComponentInitialization: (scene: Scene) => void;
  115704. /**
  115705. * Instantiates a new effect Layer and references it in the scene.
  115706. * @param name The name of the layer
  115707. * @param scene The scene to use the layer in
  115708. */
  115709. constructor(
  115710. /** The Friendly of the effect in the scene */
  115711. name: string, scene: Scene);
  115712. /**
  115713. * Get the effect name of the layer.
  115714. * @return The effect name
  115715. */
  115716. abstract getEffectName(): string;
  115717. /**
  115718. * Checks for the readiness of the element composing the layer.
  115719. * @param subMesh the mesh to check for
  115720. * @param useInstances specify wether or not to use instances to render the mesh
  115721. * @return true if ready otherwise, false
  115722. */
  115723. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115724. /**
  115725. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115726. * @returns true if the effect requires stencil during the main canvas render pass.
  115727. */
  115728. abstract needStencil(): boolean;
  115729. /**
  115730. * Create the merge effect. This is the shader use to blit the information back
  115731. * to the main canvas at the end of the scene rendering.
  115732. * @returns The effect containing the shader used to merge the effect on the main canvas
  115733. */
  115734. protected abstract _createMergeEffect(): Effect;
  115735. /**
  115736. * Creates the render target textures and post processes used in the effect layer.
  115737. */
  115738. protected abstract _createTextureAndPostProcesses(): void;
  115739. /**
  115740. * Implementation specific of rendering the generating effect on the main canvas.
  115741. * @param effect The effect used to render through
  115742. */
  115743. protected abstract _internalRender(effect: Effect): void;
  115744. /**
  115745. * Sets the required values for both the emissive texture and and the main color.
  115746. */
  115747. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115748. /**
  115749. * Free any resources and references associated to a mesh.
  115750. * Internal use
  115751. * @param mesh The mesh to free.
  115752. */
  115753. abstract _disposeMesh(mesh: Mesh): void;
  115754. /**
  115755. * Serializes this layer (Glow or Highlight for example)
  115756. * @returns a serialized layer object
  115757. */
  115758. abstract serialize?(): any;
  115759. /**
  115760. * Initializes the effect layer with the required options.
  115761. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  115762. */
  115763. protected _init(options: Partial<IEffectLayerOptions>): void;
  115764. /**
  115765. * Generates the index buffer of the full screen quad blending to the main canvas.
  115766. */
  115767. private _generateIndexBuffer;
  115768. /**
  115769. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  115770. */
  115771. private _generateVertexBuffer;
  115772. /**
  115773. * Sets the main texture desired size which is the closest power of two
  115774. * of the engine canvas size.
  115775. */
  115776. private _setMainTextureSize;
  115777. /**
  115778. * Creates the main texture for the effect layer.
  115779. */
  115780. protected _createMainTexture(): void;
  115781. /**
  115782. * Adds specific effects defines.
  115783. * @param defines The defines to add specifics to.
  115784. */
  115785. protected _addCustomEffectDefines(defines: string[]): void;
  115786. /**
  115787. * Checks for the readiness of the element composing the layer.
  115788. * @param subMesh the mesh to check for
  115789. * @param useInstances specify wether or not to use instances to render the mesh
  115790. * @param emissiveTexture the associated emissive texture used to generate the glow
  115791. * @return true if ready otherwise, false
  115792. */
  115793. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  115794. /**
  115795. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  115796. */
  115797. render(): void;
  115798. /**
  115799. * Determine if a given mesh will be used in the current effect.
  115800. * @param mesh mesh to test
  115801. * @returns true if the mesh will be used
  115802. */
  115803. hasMesh(mesh: AbstractMesh): boolean;
  115804. /**
  115805. * Returns true if the layer contains information to display, otherwise false.
  115806. * @returns true if the glow layer should be rendered
  115807. */
  115808. shouldRender(): boolean;
  115809. /**
  115810. * Returns true if the mesh should render, otherwise false.
  115811. * @param mesh The mesh to render
  115812. * @returns true if it should render otherwise false
  115813. */
  115814. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  115815. /**
  115816. * Returns true if the mesh can be rendered, otherwise false.
  115817. * @param mesh The mesh to render
  115818. * @param material The material used on the mesh
  115819. * @returns true if it can be rendered otherwise false
  115820. */
  115821. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115822. /**
  115823. * Returns true if the mesh should render, otherwise false.
  115824. * @param mesh The mesh to render
  115825. * @returns true if it should render otherwise false
  115826. */
  115827. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  115828. /**
  115829. * Renders the submesh passed in parameter to the generation map.
  115830. */
  115831. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  115832. /**
  115833. * Rebuild the required buffers.
  115834. * @hidden Internal use only.
  115835. */
  115836. _rebuild(): void;
  115837. /**
  115838. * Dispose only the render target textures and post process.
  115839. */
  115840. private _disposeTextureAndPostProcesses;
  115841. /**
  115842. * Dispose the highlight layer and free resources.
  115843. */
  115844. dispose(): void;
  115845. /**
  115846. * Gets the class name of the effect layer
  115847. * @returns the string with the class name of the effect layer
  115848. */
  115849. getClassName(): string;
  115850. /**
  115851. * Creates an effect layer from parsed effect layer data
  115852. * @param parsedEffectLayer defines effect layer data
  115853. * @param scene defines the current scene
  115854. * @param rootUrl defines the root URL containing the effect layer information
  115855. * @returns a parsed effect Layer
  115856. */
  115857. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  115858. }
  115859. }
  115860. declare module BABYLON {
  115861. interface AbstractScene {
  115862. /**
  115863. * The list of effect layers (highlights/glow) added to the scene
  115864. * @see http://doc.babylonjs.com/how_to/highlight_layer
  115865. * @see http://doc.babylonjs.com/how_to/glow_layer
  115866. */
  115867. effectLayers: Array<EffectLayer>;
  115868. /**
  115869. * Removes the given effect layer from this scene.
  115870. * @param toRemove defines the effect layer to remove
  115871. * @returns the index of the removed effect layer
  115872. */
  115873. removeEffectLayer(toRemove: EffectLayer): number;
  115874. /**
  115875. * Adds the given effect layer to this scene
  115876. * @param newEffectLayer defines the effect layer to add
  115877. */
  115878. addEffectLayer(newEffectLayer: EffectLayer): void;
  115879. }
  115880. /**
  115881. * Defines the layer scene component responsible to manage any effect layers
  115882. * in a given scene.
  115883. */
  115884. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  115885. /**
  115886. * The component name helpfull to identify the component in the list of scene components.
  115887. */
  115888. readonly name: string;
  115889. /**
  115890. * The scene the component belongs to.
  115891. */
  115892. scene: Scene;
  115893. private _engine;
  115894. private _renderEffects;
  115895. private _needStencil;
  115896. private _previousStencilState;
  115897. /**
  115898. * Creates a new instance of the component for the given scene
  115899. * @param scene Defines the scene to register the component in
  115900. */
  115901. constructor(scene: Scene);
  115902. /**
  115903. * Registers the component in a given scene
  115904. */
  115905. register(): void;
  115906. /**
  115907. * Rebuilds the elements related to this component in case of
  115908. * context lost for instance.
  115909. */
  115910. rebuild(): void;
  115911. /**
  115912. * Serializes the component data to the specified json object
  115913. * @param serializationObject The object to serialize to
  115914. */
  115915. serialize(serializationObject: any): void;
  115916. /**
  115917. * Adds all the elements from the container to the scene
  115918. * @param container the container holding the elements
  115919. */
  115920. addFromContainer(container: AbstractScene): void;
  115921. /**
  115922. * Removes all the elements in the container from the scene
  115923. * @param container contains the elements to remove
  115924. * @param dispose if the removed element should be disposed (default: false)
  115925. */
  115926. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115927. /**
  115928. * Disposes the component and the associated ressources.
  115929. */
  115930. dispose(): void;
  115931. private _isReadyForMesh;
  115932. private _renderMainTexture;
  115933. private _setStencil;
  115934. private _setStencilBack;
  115935. private _draw;
  115936. private _drawCamera;
  115937. private _drawRenderingGroup;
  115938. }
  115939. }
  115940. declare module BABYLON {
  115941. /** @hidden */
  115942. export var glowMapMergePixelShader: {
  115943. name: string;
  115944. shader: string;
  115945. };
  115946. }
  115947. declare module BABYLON {
  115948. /** @hidden */
  115949. export var glowMapMergeVertexShader: {
  115950. name: string;
  115951. shader: string;
  115952. };
  115953. }
  115954. declare module BABYLON {
  115955. interface AbstractScene {
  115956. /**
  115957. * Return a the first highlight layer of the scene with a given name.
  115958. * @param name The name of the highlight layer to look for.
  115959. * @return The highlight layer if found otherwise null.
  115960. */
  115961. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  115962. }
  115963. /**
  115964. * Glow layer options. This helps customizing the behaviour
  115965. * of the glow layer.
  115966. */
  115967. export interface IGlowLayerOptions {
  115968. /**
  115969. * Multiplication factor apply to the canvas size to compute the render target size
  115970. * used to generated the glowing objects (the smaller the faster).
  115971. */
  115972. mainTextureRatio: number;
  115973. /**
  115974. * Enforces a fixed size texture to ensure resize independant blur.
  115975. */
  115976. mainTextureFixedSize?: number;
  115977. /**
  115978. * How big is the kernel of the blur texture.
  115979. */
  115980. blurKernelSize: number;
  115981. /**
  115982. * The camera attached to the layer.
  115983. */
  115984. camera: Nullable<Camera>;
  115985. /**
  115986. * Enable MSAA by chosing the number of samples.
  115987. */
  115988. mainTextureSamples?: number;
  115989. /**
  115990. * The rendering group to draw the layer in.
  115991. */
  115992. renderingGroupId: number;
  115993. }
  115994. /**
  115995. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  115996. *
  115997. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115998. * glowy meshes to your scene.
  115999. *
  116000. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116001. */
  116002. export class GlowLayer extends EffectLayer {
  116003. /**
  116004. * Effect Name of the layer.
  116005. */
  116006. static readonly EffectName: string;
  116007. /**
  116008. * The default blur kernel size used for the glow.
  116009. */
  116010. static DefaultBlurKernelSize: number;
  116011. /**
  116012. * The default texture size ratio used for the glow.
  116013. */
  116014. static DefaultTextureRatio: number;
  116015. /**
  116016. * Sets the kernel size of the blur.
  116017. */
  116018. /**
  116019. * Gets the kernel size of the blur.
  116020. */
  116021. blurKernelSize: number;
  116022. /**
  116023. * Sets the glow intensity.
  116024. */
  116025. /**
  116026. * Gets the glow intensity.
  116027. */
  116028. intensity: number;
  116029. private _options;
  116030. private _intensity;
  116031. private _horizontalBlurPostprocess1;
  116032. private _verticalBlurPostprocess1;
  116033. private _horizontalBlurPostprocess2;
  116034. private _verticalBlurPostprocess2;
  116035. private _blurTexture1;
  116036. private _blurTexture2;
  116037. private _postProcesses1;
  116038. private _postProcesses2;
  116039. private _includedOnlyMeshes;
  116040. private _excludedMeshes;
  116041. /**
  116042. * Callback used to let the user override the color selection on a per mesh basis
  116043. */
  116044. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116045. /**
  116046. * Callback used to let the user override the texture selection on a per mesh basis
  116047. */
  116048. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116049. /**
  116050. * Instantiates a new glow Layer and references it to the scene.
  116051. * @param name The name of the layer
  116052. * @param scene The scene to use the layer in
  116053. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116054. */
  116055. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116056. /**
  116057. * Get the effect name of the layer.
  116058. * @return The effect name
  116059. */
  116060. getEffectName(): string;
  116061. /**
  116062. * Create the merge effect. This is the shader use to blit the information back
  116063. * to the main canvas at the end of the scene rendering.
  116064. */
  116065. protected _createMergeEffect(): Effect;
  116066. /**
  116067. * Creates the render target textures and post processes used in the glow layer.
  116068. */
  116069. protected _createTextureAndPostProcesses(): void;
  116070. /**
  116071. * Checks for the readiness of the element composing the layer.
  116072. * @param subMesh the mesh to check for
  116073. * @param useInstances specify wether or not to use instances to render the mesh
  116074. * @param emissiveTexture the associated emissive texture used to generate the glow
  116075. * @return true if ready otherwise, false
  116076. */
  116077. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116078. /**
  116079. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116080. */
  116081. needStencil(): boolean;
  116082. /**
  116083. * Returns true if the mesh can be rendered, otherwise false.
  116084. * @param mesh The mesh to render
  116085. * @param material The material used on the mesh
  116086. * @returns true if it can be rendered otherwise false
  116087. */
  116088. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116089. /**
  116090. * Implementation specific of rendering the generating effect on the main canvas.
  116091. * @param effect The effect used to render through
  116092. */
  116093. protected _internalRender(effect: Effect): void;
  116094. /**
  116095. * Sets the required values for both the emissive texture and and the main color.
  116096. */
  116097. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116098. /**
  116099. * Returns true if the mesh should render, otherwise false.
  116100. * @param mesh The mesh to render
  116101. * @returns true if it should render otherwise false
  116102. */
  116103. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116104. /**
  116105. * Adds specific effects defines.
  116106. * @param defines The defines to add specifics to.
  116107. */
  116108. protected _addCustomEffectDefines(defines: string[]): void;
  116109. /**
  116110. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116111. * @param mesh The mesh to exclude from the glow layer
  116112. */
  116113. addExcludedMesh(mesh: Mesh): void;
  116114. /**
  116115. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116116. * @param mesh The mesh to remove
  116117. */
  116118. removeExcludedMesh(mesh: Mesh): void;
  116119. /**
  116120. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116121. * @param mesh The mesh to include in the glow layer
  116122. */
  116123. addIncludedOnlyMesh(mesh: Mesh): void;
  116124. /**
  116125. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116126. * @param mesh The mesh to remove
  116127. */
  116128. removeIncludedOnlyMesh(mesh: Mesh): void;
  116129. /**
  116130. * Determine if a given mesh will be used in the glow layer
  116131. * @param mesh The mesh to test
  116132. * @returns true if the mesh will be highlighted by the current glow layer
  116133. */
  116134. hasMesh(mesh: AbstractMesh): boolean;
  116135. /**
  116136. * Free any resources and references associated to a mesh.
  116137. * Internal use
  116138. * @param mesh The mesh to free.
  116139. * @hidden
  116140. */
  116141. _disposeMesh(mesh: Mesh): void;
  116142. /**
  116143. * Gets the class name of the effect layer
  116144. * @returns the string with the class name of the effect layer
  116145. */
  116146. getClassName(): string;
  116147. /**
  116148. * Serializes this glow layer
  116149. * @returns a serialized glow layer object
  116150. */
  116151. serialize(): any;
  116152. /**
  116153. * Creates a Glow Layer from parsed glow layer data
  116154. * @param parsedGlowLayer defines glow layer data
  116155. * @param scene defines the current scene
  116156. * @param rootUrl defines the root URL containing the glow layer information
  116157. * @returns a parsed Glow Layer
  116158. */
  116159. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116160. }
  116161. }
  116162. declare module BABYLON {
  116163. /** @hidden */
  116164. export var glowBlurPostProcessPixelShader: {
  116165. name: string;
  116166. shader: string;
  116167. };
  116168. }
  116169. declare module BABYLON {
  116170. interface AbstractScene {
  116171. /**
  116172. * Return a the first highlight layer of the scene with a given name.
  116173. * @param name The name of the highlight layer to look for.
  116174. * @return The highlight layer if found otherwise null.
  116175. */
  116176. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116177. }
  116178. /**
  116179. * Highlight layer options. This helps customizing the behaviour
  116180. * of the highlight layer.
  116181. */
  116182. export interface IHighlightLayerOptions {
  116183. /**
  116184. * Multiplication factor apply to the canvas size to compute the render target size
  116185. * used to generated the glowing objects (the smaller the faster).
  116186. */
  116187. mainTextureRatio: number;
  116188. /**
  116189. * Enforces a fixed size texture to ensure resize independant blur.
  116190. */
  116191. mainTextureFixedSize?: number;
  116192. /**
  116193. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116194. * of the picture to blur (the smaller the faster).
  116195. */
  116196. blurTextureSizeRatio: number;
  116197. /**
  116198. * How big in texel of the blur texture is the vertical blur.
  116199. */
  116200. blurVerticalSize: number;
  116201. /**
  116202. * How big in texel of the blur texture is the horizontal blur.
  116203. */
  116204. blurHorizontalSize: number;
  116205. /**
  116206. * Alpha blending mode used to apply the blur. Default is combine.
  116207. */
  116208. alphaBlendingMode: number;
  116209. /**
  116210. * The camera attached to the layer.
  116211. */
  116212. camera: Nullable<Camera>;
  116213. /**
  116214. * Should we display highlight as a solid stroke?
  116215. */
  116216. isStroke?: boolean;
  116217. /**
  116218. * The rendering group to draw the layer in.
  116219. */
  116220. renderingGroupId: number;
  116221. }
  116222. /**
  116223. * The highlight layer Helps adding a glow effect around a mesh.
  116224. *
  116225. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116226. * glowy meshes to your scene.
  116227. *
  116228. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116229. */
  116230. export class HighlightLayer extends EffectLayer {
  116231. name: string;
  116232. /**
  116233. * Effect Name of the highlight layer.
  116234. */
  116235. static readonly EffectName: string;
  116236. /**
  116237. * The neutral color used during the preparation of the glow effect.
  116238. * This is black by default as the blend operation is a blend operation.
  116239. */
  116240. static NeutralColor: Color4;
  116241. /**
  116242. * Stencil value used for glowing meshes.
  116243. */
  116244. static GlowingMeshStencilReference: number;
  116245. /**
  116246. * Stencil value used for the other meshes in the scene.
  116247. */
  116248. static NormalMeshStencilReference: number;
  116249. /**
  116250. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116251. */
  116252. innerGlow: boolean;
  116253. /**
  116254. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116255. */
  116256. outerGlow: boolean;
  116257. /**
  116258. * Specifies the horizontal size of the blur.
  116259. */
  116260. /**
  116261. * Gets the horizontal size of the blur.
  116262. */
  116263. blurHorizontalSize: number;
  116264. /**
  116265. * Specifies the vertical size of the blur.
  116266. */
  116267. /**
  116268. * Gets the vertical size of the blur.
  116269. */
  116270. blurVerticalSize: number;
  116271. /**
  116272. * An event triggered when the highlight layer is being blurred.
  116273. */
  116274. onBeforeBlurObservable: Observable<HighlightLayer>;
  116275. /**
  116276. * An event triggered when the highlight layer has been blurred.
  116277. */
  116278. onAfterBlurObservable: Observable<HighlightLayer>;
  116279. private _instanceGlowingMeshStencilReference;
  116280. private _options;
  116281. private _downSamplePostprocess;
  116282. private _horizontalBlurPostprocess;
  116283. private _verticalBlurPostprocess;
  116284. private _blurTexture;
  116285. private _meshes;
  116286. private _excludedMeshes;
  116287. /**
  116288. * Instantiates a new highlight Layer and references it to the scene..
  116289. * @param name The name of the layer
  116290. * @param scene The scene to use the layer in
  116291. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116292. */
  116293. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116294. /**
  116295. * Get the effect name of the layer.
  116296. * @return The effect name
  116297. */
  116298. getEffectName(): string;
  116299. /**
  116300. * Create the merge effect. This is the shader use to blit the information back
  116301. * to the main canvas at the end of the scene rendering.
  116302. */
  116303. protected _createMergeEffect(): Effect;
  116304. /**
  116305. * Creates the render target textures and post processes used in the highlight layer.
  116306. */
  116307. protected _createTextureAndPostProcesses(): void;
  116308. /**
  116309. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116310. */
  116311. needStencil(): boolean;
  116312. /**
  116313. * Checks for the readiness of the element composing the layer.
  116314. * @param subMesh the mesh to check for
  116315. * @param useInstances specify wether or not to use instances to render the mesh
  116316. * @param emissiveTexture the associated emissive texture used to generate the glow
  116317. * @return true if ready otherwise, false
  116318. */
  116319. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116320. /**
  116321. * Implementation specific of rendering the generating effect on the main canvas.
  116322. * @param effect The effect used to render through
  116323. */
  116324. protected _internalRender(effect: Effect): void;
  116325. /**
  116326. * Returns true if the layer contains information to display, otherwise false.
  116327. */
  116328. shouldRender(): boolean;
  116329. /**
  116330. * Returns true if the mesh should render, otherwise false.
  116331. * @param mesh The mesh to render
  116332. * @returns true if it should render otherwise false
  116333. */
  116334. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116335. /**
  116336. * Sets the required values for both the emissive texture and and the main color.
  116337. */
  116338. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116339. /**
  116340. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116341. * @param mesh The mesh to exclude from the highlight layer
  116342. */
  116343. addExcludedMesh(mesh: Mesh): void;
  116344. /**
  116345. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116346. * @param mesh The mesh to highlight
  116347. */
  116348. removeExcludedMesh(mesh: Mesh): void;
  116349. /**
  116350. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116351. * @param mesh mesh to test
  116352. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116353. */
  116354. hasMesh(mesh: AbstractMesh): boolean;
  116355. /**
  116356. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116357. * @param mesh The mesh to highlight
  116358. * @param color The color of the highlight
  116359. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116360. */
  116361. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116362. /**
  116363. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116364. * @param mesh The mesh to highlight
  116365. */
  116366. removeMesh(mesh: Mesh): void;
  116367. /**
  116368. * Force the stencil to the normal expected value for none glowing parts
  116369. */
  116370. private _defaultStencilReference;
  116371. /**
  116372. * Free any resources and references associated to a mesh.
  116373. * Internal use
  116374. * @param mesh The mesh to free.
  116375. * @hidden
  116376. */
  116377. _disposeMesh(mesh: Mesh): void;
  116378. /**
  116379. * Dispose the highlight layer and free resources.
  116380. */
  116381. dispose(): void;
  116382. /**
  116383. * Gets the class name of the effect layer
  116384. * @returns the string with the class name of the effect layer
  116385. */
  116386. getClassName(): string;
  116387. /**
  116388. * Serializes this Highlight layer
  116389. * @returns a serialized Highlight layer object
  116390. */
  116391. serialize(): any;
  116392. /**
  116393. * Creates a Highlight layer from parsed Highlight layer data
  116394. * @param parsedHightlightLayer defines the Highlight layer data
  116395. * @param scene defines the current scene
  116396. * @param rootUrl defines the root URL containing the Highlight layer information
  116397. * @returns a parsed Highlight layer
  116398. */
  116399. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116400. }
  116401. }
  116402. declare module BABYLON {
  116403. interface AbstractScene {
  116404. /**
  116405. * The list of layers (background and foreground) of the scene
  116406. */
  116407. layers: Array<Layer>;
  116408. }
  116409. /**
  116410. * Defines the layer scene component responsible to manage any layers
  116411. * in a given scene.
  116412. */
  116413. export class LayerSceneComponent implements ISceneComponent {
  116414. /**
  116415. * The component name helpfull to identify the component in the list of scene components.
  116416. */
  116417. readonly name: string;
  116418. /**
  116419. * The scene the component belongs to.
  116420. */
  116421. scene: Scene;
  116422. private _engine;
  116423. /**
  116424. * Creates a new instance of the component for the given scene
  116425. * @param scene Defines the scene to register the component in
  116426. */
  116427. constructor(scene: Scene);
  116428. /**
  116429. * Registers the component in a given scene
  116430. */
  116431. register(): void;
  116432. /**
  116433. * Rebuilds the elements related to this component in case of
  116434. * context lost for instance.
  116435. */
  116436. rebuild(): void;
  116437. /**
  116438. * Disposes the component and the associated ressources.
  116439. */
  116440. dispose(): void;
  116441. private _draw;
  116442. private _drawCameraPredicate;
  116443. private _drawCameraBackground;
  116444. private _drawCameraForeground;
  116445. private _drawRenderTargetPredicate;
  116446. private _drawRenderTargetBackground;
  116447. private _drawRenderTargetForeground;
  116448. /**
  116449. * Adds all the elements from the container to the scene
  116450. * @param container the container holding the elements
  116451. */
  116452. addFromContainer(container: AbstractScene): void;
  116453. /**
  116454. * Removes all the elements in the container from the scene
  116455. * @param container contains the elements to remove
  116456. * @param dispose if the removed element should be disposed (default: false)
  116457. */
  116458. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116459. }
  116460. }
  116461. declare module BABYLON {
  116462. /** @hidden */
  116463. export var layerPixelShader: {
  116464. name: string;
  116465. shader: string;
  116466. };
  116467. }
  116468. declare module BABYLON {
  116469. /** @hidden */
  116470. export var layerVertexShader: {
  116471. name: string;
  116472. shader: string;
  116473. };
  116474. }
  116475. declare module BABYLON {
  116476. /**
  116477. * This represents a full screen 2d layer.
  116478. * This can be useful to display a picture in the background of your scene for instance.
  116479. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116480. */
  116481. export class Layer {
  116482. /**
  116483. * Define the name of the layer.
  116484. */
  116485. name: string;
  116486. /**
  116487. * Define the texture the layer should display.
  116488. */
  116489. texture: Nullable<Texture>;
  116490. /**
  116491. * Is the layer in background or foreground.
  116492. */
  116493. isBackground: boolean;
  116494. /**
  116495. * Define the color of the layer (instead of texture).
  116496. */
  116497. color: Color4;
  116498. /**
  116499. * Define the scale of the layer in order to zoom in out of the texture.
  116500. */
  116501. scale: Vector2;
  116502. /**
  116503. * Define an offset for the layer in order to shift the texture.
  116504. */
  116505. offset: Vector2;
  116506. /**
  116507. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116508. */
  116509. alphaBlendingMode: number;
  116510. /**
  116511. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116512. * Alpha test will not mix with the background color in case of transparency.
  116513. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116514. */
  116515. alphaTest: boolean;
  116516. /**
  116517. * Define a mask to restrict the layer to only some of the scene cameras.
  116518. */
  116519. layerMask: number;
  116520. /**
  116521. * Define the list of render target the layer is visible into.
  116522. */
  116523. renderTargetTextures: RenderTargetTexture[];
  116524. /**
  116525. * Define if the layer is only used in renderTarget or if it also
  116526. * renders in the main frame buffer of the canvas.
  116527. */
  116528. renderOnlyInRenderTargetTextures: boolean;
  116529. private _scene;
  116530. private _vertexBuffers;
  116531. private _indexBuffer;
  116532. private _effect;
  116533. private _alphaTestEffect;
  116534. /**
  116535. * An event triggered when the layer is disposed.
  116536. */
  116537. onDisposeObservable: Observable<Layer>;
  116538. private _onDisposeObserver;
  116539. /**
  116540. * Back compatibility with callback before the onDisposeObservable existed.
  116541. * The set callback will be triggered when the layer has been disposed.
  116542. */
  116543. onDispose: () => void;
  116544. /**
  116545. * An event triggered before rendering the scene
  116546. */
  116547. onBeforeRenderObservable: Observable<Layer>;
  116548. private _onBeforeRenderObserver;
  116549. /**
  116550. * Back compatibility with callback before the onBeforeRenderObservable existed.
  116551. * The set callback will be triggered just before rendering the layer.
  116552. */
  116553. onBeforeRender: () => void;
  116554. /**
  116555. * An event triggered after rendering the scene
  116556. */
  116557. onAfterRenderObservable: Observable<Layer>;
  116558. private _onAfterRenderObserver;
  116559. /**
  116560. * Back compatibility with callback before the onAfterRenderObservable existed.
  116561. * The set callback will be triggered just after rendering the layer.
  116562. */
  116563. onAfterRender: () => void;
  116564. /**
  116565. * Instantiates a new layer.
  116566. * This represents a full screen 2d layer.
  116567. * This can be useful to display a picture in the background of your scene for instance.
  116568. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116569. * @param name Define the name of the layer in the scene
  116570. * @param imgUrl Define the url of the texture to display in the layer
  116571. * @param scene Define the scene the layer belongs to
  116572. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  116573. * @param color Defines a color for the layer
  116574. */
  116575. constructor(
  116576. /**
  116577. * Define the name of the layer.
  116578. */
  116579. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  116580. private _createIndexBuffer;
  116581. /** @hidden */
  116582. _rebuild(): void;
  116583. /**
  116584. * Renders the layer in the scene.
  116585. */
  116586. render(): void;
  116587. /**
  116588. * Disposes and releases the associated ressources.
  116589. */
  116590. dispose(): void;
  116591. }
  116592. }
  116593. declare module BABYLON {
  116594. /** @hidden */
  116595. export var lensFlarePixelShader: {
  116596. name: string;
  116597. shader: string;
  116598. };
  116599. }
  116600. declare module BABYLON {
  116601. /** @hidden */
  116602. export var lensFlareVertexShader: {
  116603. name: string;
  116604. shader: string;
  116605. };
  116606. }
  116607. declare module BABYLON {
  116608. /**
  116609. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116610. * It is usually composed of several `lensFlare`.
  116611. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116612. */
  116613. export class LensFlareSystem {
  116614. /**
  116615. * Define the name of the lens flare system
  116616. */
  116617. name: string;
  116618. /**
  116619. * List of lens flares used in this system.
  116620. */
  116621. lensFlares: LensFlare[];
  116622. /**
  116623. * Define a limit from the border the lens flare can be visible.
  116624. */
  116625. borderLimit: number;
  116626. /**
  116627. * Define a viewport border we do not want to see the lens flare in.
  116628. */
  116629. viewportBorder: number;
  116630. /**
  116631. * Define a predicate which could limit the list of meshes able to occlude the effect.
  116632. */
  116633. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  116634. /**
  116635. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  116636. */
  116637. layerMask: number;
  116638. /**
  116639. * Define the id of the lens flare system in the scene.
  116640. * (equal to name by default)
  116641. */
  116642. id: string;
  116643. private _scene;
  116644. private _emitter;
  116645. private _vertexBuffers;
  116646. private _indexBuffer;
  116647. private _effect;
  116648. private _positionX;
  116649. private _positionY;
  116650. private _isEnabled;
  116651. /** @hidden */
  116652. static _SceneComponentInitialization: (scene: Scene) => void;
  116653. /**
  116654. * Instantiates a lens flare system.
  116655. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116656. * It is usually composed of several `lensFlare`.
  116657. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116658. * @param name Define the name of the lens flare system in the scene
  116659. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  116660. * @param scene Define the scene the lens flare system belongs to
  116661. */
  116662. constructor(
  116663. /**
  116664. * Define the name of the lens flare system
  116665. */
  116666. name: string, emitter: any, scene: Scene);
  116667. /**
  116668. * Define if the lens flare system is enabled.
  116669. */
  116670. isEnabled: boolean;
  116671. /**
  116672. * Get the scene the effects belongs to.
  116673. * @returns the scene holding the lens flare system
  116674. */
  116675. getScene(): Scene;
  116676. /**
  116677. * Get the emitter of the lens flare system.
  116678. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116679. * @returns the emitter of the lens flare system
  116680. */
  116681. getEmitter(): any;
  116682. /**
  116683. * Set the emitter of the lens flare system.
  116684. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116685. * @param newEmitter Define the new emitter of the system
  116686. */
  116687. setEmitter(newEmitter: any): void;
  116688. /**
  116689. * Get the lens flare system emitter position.
  116690. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  116691. * @returns the position
  116692. */
  116693. getEmitterPosition(): Vector3;
  116694. /**
  116695. * @hidden
  116696. */
  116697. computeEffectivePosition(globalViewport: Viewport): boolean;
  116698. /** @hidden */
  116699. _isVisible(): boolean;
  116700. /**
  116701. * @hidden
  116702. */
  116703. render(): boolean;
  116704. /**
  116705. * Dispose and release the lens flare with its associated resources.
  116706. */
  116707. dispose(): void;
  116708. /**
  116709. * Parse a lens flare system from a JSON repressentation
  116710. * @param parsedLensFlareSystem Define the JSON to parse
  116711. * @param scene Define the scene the parsed system should be instantiated in
  116712. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  116713. * @returns the parsed system
  116714. */
  116715. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  116716. /**
  116717. * Serialize the current Lens Flare System into a JSON representation.
  116718. * @returns the serialized JSON
  116719. */
  116720. serialize(): any;
  116721. }
  116722. }
  116723. declare module BABYLON {
  116724. /**
  116725. * This represents one of the lens effect in a `lensFlareSystem`.
  116726. * It controls one of the indiviual texture used in the effect.
  116727. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116728. */
  116729. export class LensFlare {
  116730. /**
  116731. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  116732. */
  116733. size: number;
  116734. /**
  116735. * 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.
  116736. */
  116737. position: number;
  116738. /**
  116739. * Define the lens color.
  116740. */
  116741. color: Color3;
  116742. /**
  116743. * Define the lens texture.
  116744. */
  116745. texture: Nullable<Texture>;
  116746. /**
  116747. * Define the alpha mode to render this particular lens.
  116748. */
  116749. alphaMode: number;
  116750. private _system;
  116751. /**
  116752. * Creates a new Lens Flare.
  116753. * This represents one of the lens effect in a `lensFlareSystem`.
  116754. * It controls one of the indiviual texture used in the effect.
  116755. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116756. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  116757. * @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.
  116758. * @param color Define the lens color
  116759. * @param imgUrl Define the lens texture url
  116760. * @param system Define the `lensFlareSystem` this flare is part of
  116761. * @returns The newly created Lens Flare
  116762. */
  116763. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  116764. /**
  116765. * Instantiates a new Lens Flare.
  116766. * This represents one of the lens effect in a `lensFlareSystem`.
  116767. * It controls one of the indiviual texture used in the effect.
  116768. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116769. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  116770. * @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.
  116771. * @param color Define the lens color
  116772. * @param imgUrl Define the lens texture url
  116773. * @param system Define the `lensFlareSystem` this flare is part of
  116774. */
  116775. constructor(
  116776. /**
  116777. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  116778. */
  116779. size: number,
  116780. /**
  116781. * 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.
  116782. */
  116783. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  116784. /**
  116785. * Dispose and release the lens flare with its associated resources.
  116786. */
  116787. dispose(): void;
  116788. }
  116789. }
  116790. declare module BABYLON {
  116791. interface AbstractScene {
  116792. /**
  116793. * The list of lens flare system added to the scene
  116794. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116795. */
  116796. lensFlareSystems: Array<LensFlareSystem>;
  116797. /**
  116798. * Removes the given lens flare system from this scene.
  116799. * @param toRemove The lens flare system to remove
  116800. * @returns The index of the removed lens flare system
  116801. */
  116802. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  116803. /**
  116804. * Adds the given lens flare system to this scene
  116805. * @param newLensFlareSystem The lens flare system to add
  116806. */
  116807. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  116808. /**
  116809. * Gets a lens flare system using its name
  116810. * @param name defines the name to look for
  116811. * @returns the lens flare system or null if not found
  116812. */
  116813. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  116814. /**
  116815. * Gets a lens flare system using its id
  116816. * @param id defines the id to look for
  116817. * @returns the lens flare system or null if not found
  116818. */
  116819. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  116820. }
  116821. /**
  116822. * Defines the lens flare scene component responsible to manage any lens flares
  116823. * in a given scene.
  116824. */
  116825. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  116826. /**
  116827. * The component name helpfull to identify the component in the list of scene components.
  116828. */
  116829. readonly name: string;
  116830. /**
  116831. * The scene the component belongs to.
  116832. */
  116833. scene: Scene;
  116834. /**
  116835. * Creates a new instance of the component for the given scene
  116836. * @param scene Defines the scene to register the component in
  116837. */
  116838. constructor(scene: Scene);
  116839. /**
  116840. * Registers the component in a given scene
  116841. */
  116842. register(): void;
  116843. /**
  116844. * Rebuilds the elements related to this component in case of
  116845. * context lost for instance.
  116846. */
  116847. rebuild(): void;
  116848. /**
  116849. * Adds all the elements from the container to the scene
  116850. * @param container the container holding the elements
  116851. */
  116852. addFromContainer(container: AbstractScene): void;
  116853. /**
  116854. * Removes all the elements in the container from the scene
  116855. * @param container contains the elements to remove
  116856. * @param dispose if the removed element should be disposed (default: false)
  116857. */
  116858. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116859. /**
  116860. * Serializes the component data to the specified json object
  116861. * @param serializationObject The object to serialize to
  116862. */
  116863. serialize(serializationObject: any): void;
  116864. /**
  116865. * Disposes the component and the associated ressources.
  116866. */
  116867. dispose(): void;
  116868. private _draw;
  116869. }
  116870. }
  116871. declare module BABYLON {
  116872. /**
  116873. * Defines the shadow generator component responsible to manage any shadow generators
  116874. * in a given scene.
  116875. */
  116876. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  116877. /**
  116878. * The component name helpfull to identify the component in the list of scene components.
  116879. */
  116880. readonly name: string;
  116881. /**
  116882. * The scene the component belongs to.
  116883. */
  116884. scene: Scene;
  116885. /**
  116886. * Creates a new instance of the component for the given scene
  116887. * @param scene Defines the scene to register the component in
  116888. */
  116889. constructor(scene: Scene);
  116890. /**
  116891. * Registers the component in a given scene
  116892. */
  116893. register(): void;
  116894. /**
  116895. * Rebuilds the elements related to this component in case of
  116896. * context lost for instance.
  116897. */
  116898. rebuild(): void;
  116899. /**
  116900. * Serializes the component data to the specified json object
  116901. * @param serializationObject The object to serialize to
  116902. */
  116903. serialize(serializationObject: any): void;
  116904. /**
  116905. * Adds all the elements from the container to the scene
  116906. * @param container the container holding the elements
  116907. */
  116908. addFromContainer(container: AbstractScene): void;
  116909. /**
  116910. * Removes all the elements in the container from the scene
  116911. * @param container contains the elements to remove
  116912. * @param dispose if the removed element should be disposed (default: false)
  116913. */
  116914. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116915. /**
  116916. * Rebuilds the elements related to this component in case of
  116917. * context lost for instance.
  116918. */
  116919. dispose(): void;
  116920. private _gatherRenderTargets;
  116921. }
  116922. }
  116923. declare module BABYLON {
  116924. /**
  116925. * A point light is a light defined by an unique point in world space.
  116926. * The light is emitted in every direction from this point.
  116927. * A good example of a point light is a standard light bulb.
  116928. * Documentation: https://doc.babylonjs.com/babylon101/lights
  116929. */
  116930. export class PointLight extends ShadowLight {
  116931. private _shadowAngle;
  116932. /**
  116933. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116934. * This specifies what angle the shadow will use to be created.
  116935. *
  116936. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116937. */
  116938. /**
  116939. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116940. * This specifies what angle the shadow will use to be created.
  116941. *
  116942. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116943. */
  116944. shadowAngle: number;
  116945. /**
  116946. * Gets the direction if it has been set.
  116947. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116948. */
  116949. /**
  116950. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116951. */
  116952. direction: Vector3;
  116953. /**
  116954. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  116955. * A PointLight emits the light in every direction.
  116956. * It can cast shadows.
  116957. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  116958. * ```javascript
  116959. * var pointLight = new PointLight("pl", camera.position, scene);
  116960. * ```
  116961. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116962. * @param name The light friendly name
  116963. * @param position The position of the point light in the scene
  116964. * @param scene The scene the lights belongs to
  116965. */
  116966. constructor(name: string, position: Vector3, scene: Scene);
  116967. /**
  116968. * Returns the string "PointLight"
  116969. * @returns the class name
  116970. */
  116971. getClassName(): string;
  116972. /**
  116973. * Returns the integer 0.
  116974. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116975. */
  116976. getTypeID(): number;
  116977. /**
  116978. * Specifies wether or not the shadowmap should be a cube texture.
  116979. * @returns true if the shadowmap needs to be a cube texture.
  116980. */
  116981. needCube(): boolean;
  116982. /**
  116983. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  116984. * @param faceIndex The index of the face we are computed the direction to generate shadow
  116985. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  116986. */
  116987. getShadowDirection(faceIndex?: number): Vector3;
  116988. /**
  116989. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  116990. * - fov = PI / 2
  116991. * - aspect ratio : 1.0
  116992. * - z-near and far equal to the active camera minZ and maxZ.
  116993. * Returns the PointLight.
  116994. */
  116995. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116996. protected _buildUniformLayout(): void;
  116997. /**
  116998. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  116999. * @param effect The effect to update
  117000. * @param lightIndex The index of the light in the effect to update
  117001. * @returns The point light
  117002. */
  117003. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117004. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117005. /**
  117006. * Prepares the list of defines specific to the light type.
  117007. * @param defines the list of defines
  117008. * @param lightIndex defines the index of the light for the effect
  117009. */
  117010. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117011. }
  117012. }
  117013. declare module BABYLON {
  117014. /**
  117015. * Header information of HDR texture files.
  117016. */
  117017. export interface HDRInfo {
  117018. /**
  117019. * The height of the texture in pixels.
  117020. */
  117021. height: number;
  117022. /**
  117023. * The width of the texture in pixels.
  117024. */
  117025. width: number;
  117026. /**
  117027. * The index of the beginning of the data in the binary file.
  117028. */
  117029. dataPosition: number;
  117030. }
  117031. /**
  117032. * This groups tools to convert HDR texture to native colors array.
  117033. */
  117034. export class HDRTools {
  117035. private static Ldexp;
  117036. private static Rgbe2float;
  117037. private static readStringLine;
  117038. /**
  117039. * Reads header information from an RGBE texture stored in a native array.
  117040. * More information on this format are available here:
  117041. * https://en.wikipedia.org/wiki/RGBE_image_format
  117042. *
  117043. * @param uint8array The binary file stored in native array.
  117044. * @return The header information.
  117045. */
  117046. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117047. /**
  117048. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117049. * This RGBE texture needs to store the information as a panorama.
  117050. *
  117051. * More information on this format are available here:
  117052. * https://en.wikipedia.org/wiki/RGBE_image_format
  117053. *
  117054. * @param buffer The binary file stored in an array buffer.
  117055. * @param size The expected size of the extracted cubemap.
  117056. * @return The Cube Map information.
  117057. */
  117058. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117059. /**
  117060. * Returns the pixels data extracted from an RGBE texture.
  117061. * This pixels will be stored left to right up to down in the R G B order in one array.
  117062. *
  117063. * More information on this format are available here:
  117064. * https://en.wikipedia.org/wiki/RGBE_image_format
  117065. *
  117066. * @param uint8array The binary file stored in an array buffer.
  117067. * @param hdrInfo The header information of the file.
  117068. * @return The pixels data in RGB right to left up to down order.
  117069. */
  117070. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117071. private static RGBE_ReadPixels_RLE;
  117072. }
  117073. }
  117074. declare module BABYLON {
  117075. /**
  117076. * This represents a texture coming from an HDR input.
  117077. *
  117078. * The only supported format is currently panorama picture stored in RGBE format.
  117079. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117080. */
  117081. export class HDRCubeTexture extends BaseTexture {
  117082. private static _facesMapping;
  117083. private _generateHarmonics;
  117084. private _noMipmap;
  117085. private _textureMatrix;
  117086. private _size;
  117087. private _onLoad;
  117088. private _onError;
  117089. /**
  117090. * The texture URL.
  117091. */
  117092. url: string;
  117093. /**
  117094. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117095. */
  117096. coordinatesMode: number;
  117097. protected _isBlocking: boolean;
  117098. /**
  117099. * Sets wether or not the texture is blocking during loading.
  117100. */
  117101. /**
  117102. * Gets wether or not the texture is blocking during loading.
  117103. */
  117104. isBlocking: boolean;
  117105. protected _rotationY: number;
  117106. /**
  117107. * Sets texture matrix rotation angle around Y axis in radians.
  117108. */
  117109. /**
  117110. * Gets texture matrix rotation angle around Y axis radians.
  117111. */
  117112. rotationY: number;
  117113. /**
  117114. * Gets or sets the center of the bounding box associated with the cube texture
  117115. * It must define where the camera used to render the texture was set
  117116. */
  117117. boundingBoxPosition: Vector3;
  117118. private _boundingBoxSize;
  117119. /**
  117120. * Gets or sets the size of the bounding box associated with the cube texture
  117121. * When defined, the cubemap will switch to local mode
  117122. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117123. * @example https://www.babylonjs-playground.com/#RNASML
  117124. */
  117125. boundingBoxSize: Vector3;
  117126. /**
  117127. * Instantiates an HDRTexture from the following parameters.
  117128. *
  117129. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117130. * @param scene The scene the texture will be used in
  117131. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117132. * @param noMipmap Forces to not generate the mipmap if true
  117133. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117134. * @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)
  117135. * @param reserved Reserved flag for internal use.
  117136. */
  117137. 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>);
  117138. /**
  117139. * Get the current class name of the texture useful for serialization or dynamic coding.
  117140. * @returns "HDRCubeTexture"
  117141. */
  117142. getClassName(): string;
  117143. /**
  117144. * Occurs when the file is raw .hdr file.
  117145. */
  117146. private loadTexture;
  117147. clone(): HDRCubeTexture;
  117148. delayLoad(): void;
  117149. /**
  117150. * Get the texture reflection matrix used to rotate/transform the reflection.
  117151. * @returns the reflection matrix
  117152. */
  117153. getReflectionTextureMatrix(): Matrix;
  117154. /**
  117155. * Set the texture reflection matrix used to rotate/transform the reflection.
  117156. * @param value Define the reflection matrix to set
  117157. */
  117158. setReflectionTextureMatrix(value: Matrix): void;
  117159. /**
  117160. * Parses a JSON representation of an HDR Texture in order to create the texture
  117161. * @param parsedTexture Define the JSON representation
  117162. * @param scene Define the scene the texture should be created in
  117163. * @param rootUrl Define the root url in case we need to load relative dependencies
  117164. * @returns the newly created texture after parsing
  117165. */
  117166. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117167. serialize(): any;
  117168. }
  117169. }
  117170. declare module BABYLON {
  117171. /**
  117172. * Class used to control physics engine
  117173. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117174. */
  117175. export class PhysicsEngine implements IPhysicsEngine {
  117176. private _physicsPlugin;
  117177. /**
  117178. * Global value used to control the smallest number supported by the simulation
  117179. */
  117180. static Epsilon: number;
  117181. private _impostors;
  117182. private _joints;
  117183. /**
  117184. * Gets the gravity vector used by the simulation
  117185. */
  117186. gravity: Vector3;
  117187. /**
  117188. * Factory used to create the default physics plugin.
  117189. * @returns The default physics plugin
  117190. */
  117191. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117192. /**
  117193. * Creates a new Physics Engine
  117194. * @param gravity defines the gravity vector used by the simulation
  117195. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117196. */
  117197. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117198. /**
  117199. * Sets the gravity vector used by the simulation
  117200. * @param gravity defines the gravity vector to use
  117201. */
  117202. setGravity(gravity: Vector3): void;
  117203. /**
  117204. * Set the time step of the physics engine.
  117205. * Default is 1/60.
  117206. * To slow it down, enter 1/600 for example.
  117207. * To speed it up, 1/30
  117208. * @param newTimeStep defines the new timestep to apply to this world.
  117209. */
  117210. setTimeStep(newTimeStep?: number): void;
  117211. /**
  117212. * Get the time step of the physics engine.
  117213. * @returns the current time step
  117214. */
  117215. getTimeStep(): number;
  117216. /**
  117217. * Release all resources
  117218. */
  117219. dispose(): void;
  117220. /**
  117221. * Gets the name of the current physics plugin
  117222. * @returns the name of the plugin
  117223. */
  117224. getPhysicsPluginName(): string;
  117225. /**
  117226. * Adding a new impostor for the impostor tracking.
  117227. * This will be done by the impostor itself.
  117228. * @param impostor the impostor to add
  117229. */
  117230. addImpostor(impostor: PhysicsImpostor): void;
  117231. /**
  117232. * Remove an impostor from the engine.
  117233. * This impostor and its mesh will not longer be updated by the physics engine.
  117234. * @param impostor the impostor to remove
  117235. */
  117236. removeImpostor(impostor: PhysicsImpostor): void;
  117237. /**
  117238. * Add a joint to the physics engine
  117239. * @param mainImpostor defines the main impostor to which the joint is added.
  117240. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117241. * @param joint defines the joint that will connect both impostors.
  117242. */
  117243. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117244. /**
  117245. * Removes a joint from the simulation
  117246. * @param mainImpostor defines the impostor used with the joint
  117247. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117248. * @param joint defines the joint to remove
  117249. */
  117250. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117251. /**
  117252. * Called by the scene. No need to call it.
  117253. * @param delta defines the timespam between frames
  117254. */
  117255. _step(delta: number): void;
  117256. /**
  117257. * Gets the current plugin used to run the simulation
  117258. * @returns current plugin
  117259. */
  117260. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117261. /**
  117262. * Gets the list of physic impostors
  117263. * @returns an array of PhysicsImpostor
  117264. */
  117265. getImpostors(): Array<PhysicsImpostor>;
  117266. /**
  117267. * Gets the impostor for a physics enabled object
  117268. * @param object defines the object impersonated by the impostor
  117269. * @returns the PhysicsImpostor or null if not found
  117270. */
  117271. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117272. /**
  117273. * Gets the impostor for a physics body object
  117274. * @param body defines physics body used by the impostor
  117275. * @returns the PhysicsImpostor or null if not found
  117276. */
  117277. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117278. /**
  117279. * Does a raycast in the physics world
  117280. * @param from when should the ray start?
  117281. * @param to when should the ray end?
  117282. * @returns PhysicsRaycastResult
  117283. */
  117284. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117285. }
  117286. }
  117287. declare module BABYLON {
  117288. /** @hidden */
  117289. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117290. private _useDeltaForWorldStep;
  117291. world: any;
  117292. name: string;
  117293. private _physicsMaterials;
  117294. private _fixedTimeStep;
  117295. private _cannonRaycastResult;
  117296. private _raycastResult;
  117297. private _physicsBodysToRemoveAfterStep;
  117298. BJSCANNON: any;
  117299. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117300. setGravity(gravity: Vector3): void;
  117301. setTimeStep(timeStep: number): void;
  117302. getTimeStep(): number;
  117303. executeStep(delta: number): void;
  117304. private _removeMarkedPhysicsBodiesFromWorld;
  117305. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117306. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117307. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117308. private _processChildMeshes;
  117309. removePhysicsBody(impostor: PhysicsImpostor): void;
  117310. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117311. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117312. private _addMaterial;
  117313. private _checkWithEpsilon;
  117314. private _createShape;
  117315. private _createHeightmap;
  117316. private _minus90X;
  117317. private _plus90X;
  117318. private _tmpPosition;
  117319. private _tmpDeltaPosition;
  117320. private _tmpUnityRotation;
  117321. private _updatePhysicsBodyTransformation;
  117322. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117323. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117324. isSupported(): boolean;
  117325. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117326. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117327. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117328. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117329. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117330. getBodyMass(impostor: PhysicsImpostor): number;
  117331. getBodyFriction(impostor: PhysicsImpostor): number;
  117332. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117333. getBodyRestitution(impostor: PhysicsImpostor): number;
  117334. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117335. sleepBody(impostor: PhysicsImpostor): void;
  117336. wakeUpBody(impostor: PhysicsImpostor): void;
  117337. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117338. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117339. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117340. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117341. getRadius(impostor: PhysicsImpostor): number;
  117342. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117343. dispose(): void;
  117344. private _extendNamespace;
  117345. /**
  117346. * Does a raycast in the physics world
  117347. * @param from when should the ray start?
  117348. * @param to when should the ray end?
  117349. * @returns PhysicsRaycastResult
  117350. */
  117351. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117352. }
  117353. }
  117354. declare module BABYLON {
  117355. /** @hidden */
  117356. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117357. world: any;
  117358. name: string;
  117359. BJSOIMO: any;
  117360. private _raycastResult;
  117361. constructor(iterations?: number, oimoInjection?: any);
  117362. setGravity(gravity: Vector3): void;
  117363. setTimeStep(timeStep: number): void;
  117364. getTimeStep(): number;
  117365. private _tmpImpostorsArray;
  117366. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117367. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117368. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117369. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117370. private _tmpPositionVector;
  117371. removePhysicsBody(impostor: PhysicsImpostor): void;
  117372. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117373. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117374. isSupported(): boolean;
  117375. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117376. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117377. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117378. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117379. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117380. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117381. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117382. getBodyMass(impostor: PhysicsImpostor): number;
  117383. getBodyFriction(impostor: PhysicsImpostor): number;
  117384. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117385. getBodyRestitution(impostor: PhysicsImpostor): number;
  117386. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117387. sleepBody(impostor: PhysicsImpostor): void;
  117388. wakeUpBody(impostor: PhysicsImpostor): void;
  117389. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117390. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117391. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117392. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117393. getRadius(impostor: PhysicsImpostor): number;
  117394. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117395. dispose(): void;
  117396. /**
  117397. * Does a raycast in the physics world
  117398. * @param from when should the ray start?
  117399. * @param to when should the ray end?
  117400. * @returns PhysicsRaycastResult
  117401. */
  117402. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117403. }
  117404. }
  117405. declare module BABYLON {
  117406. /**
  117407. * Class containing static functions to help procedurally build meshes
  117408. */
  117409. export class RibbonBuilder {
  117410. /**
  117411. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117412. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117413. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117414. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117415. * * 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
  117416. * * 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
  117417. * * 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
  117418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117421. * * 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
  117422. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117423. * * 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
  117424. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117426. * @param name defines the name of the mesh
  117427. * @param options defines the options used to create the mesh
  117428. * @param scene defines the hosting scene
  117429. * @returns the ribbon mesh
  117430. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117432. */
  117433. static CreateRibbon(name: string, options: {
  117434. pathArray: Vector3[][];
  117435. closeArray?: boolean;
  117436. closePath?: boolean;
  117437. offset?: number;
  117438. updatable?: boolean;
  117439. sideOrientation?: number;
  117440. frontUVs?: Vector4;
  117441. backUVs?: Vector4;
  117442. instance?: Mesh;
  117443. invertUV?: boolean;
  117444. uvs?: Vector2[];
  117445. colors?: Color4[];
  117446. }, scene?: Nullable<Scene>): Mesh;
  117447. }
  117448. }
  117449. declare module BABYLON {
  117450. /**
  117451. * Class containing static functions to help procedurally build meshes
  117452. */
  117453. export class ShapeBuilder {
  117454. /**
  117455. * 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.
  117456. * * 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.
  117457. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117458. * * 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.
  117459. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117460. * * 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
  117461. * * 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
  117462. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117465. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117467. * @param name defines the name of the mesh
  117468. * @param options defines the options used to create the mesh
  117469. * @param scene defines the hosting scene
  117470. * @returns the extruded shape mesh
  117471. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117473. */
  117474. static ExtrudeShape(name: string, options: {
  117475. shape: Vector3[];
  117476. path: Vector3[];
  117477. scale?: number;
  117478. rotation?: number;
  117479. cap?: number;
  117480. updatable?: boolean;
  117481. sideOrientation?: number;
  117482. frontUVs?: Vector4;
  117483. backUVs?: Vector4;
  117484. instance?: Mesh;
  117485. invertUV?: boolean;
  117486. }, scene?: Nullable<Scene>): Mesh;
  117487. /**
  117488. * Creates an custom extruded shape mesh.
  117489. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117490. * * 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.
  117491. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117492. * * 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
  117493. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117494. * * 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
  117495. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117496. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117497. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117498. * * 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
  117499. * * 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
  117500. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117505. * @param name defines the name of the mesh
  117506. * @param options defines the options used to create the mesh
  117507. * @param scene defines the hosting scene
  117508. * @returns the custom extruded shape mesh
  117509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117512. */
  117513. static ExtrudeShapeCustom(name: string, options: {
  117514. shape: Vector3[];
  117515. path: Vector3[];
  117516. scaleFunction?: any;
  117517. rotationFunction?: any;
  117518. ribbonCloseArray?: boolean;
  117519. ribbonClosePath?: boolean;
  117520. cap?: number;
  117521. updatable?: boolean;
  117522. sideOrientation?: number;
  117523. frontUVs?: Vector4;
  117524. backUVs?: Vector4;
  117525. instance?: Mesh;
  117526. invertUV?: boolean;
  117527. }, scene?: Nullable<Scene>): Mesh;
  117528. private static _ExtrudeShapeGeneric;
  117529. }
  117530. }
  117531. declare module BABYLON {
  117532. /**
  117533. * AmmoJS Physics plugin
  117534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117535. * @see https://github.com/kripken/ammo.js/
  117536. */
  117537. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  117538. private _useDeltaForWorldStep;
  117539. /**
  117540. * Reference to the Ammo library
  117541. */
  117542. bjsAMMO: any;
  117543. /**
  117544. * Created ammoJS world which physics bodies are added to
  117545. */
  117546. world: any;
  117547. /**
  117548. * Name of the plugin
  117549. */
  117550. name: string;
  117551. private _timeStep;
  117552. private _fixedTimeStep;
  117553. private _maxSteps;
  117554. private _tmpQuaternion;
  117555. private _tmpAmmoTransform;
  117556. private _tmpAmmoQuaternion;
  117557. private _tmpAmmoConcreteContactResultCallback;
  117558. private _collisionConfiguration;
  117559. private _dispatcher;
  117560. private _overlappingPairCache;
  117561. private _solver;
  117562. private _softBodySolver;
  117563. private _tmpAmmoVectorA;
  117564. private _tmpAmmoVectorB;
  117565. private _tmpAmmoVectorC;
  117566. private _tmpAmmoVectorD;
  117567. private _tmpContactCallbackResult;
  117568. private _tmpAmmoVectorRCA;
  117569. private _tmpAmmoVectorRCB;
  117570. private _raycastResult;
  117571. private static readonly DISABLE_COLLISION_FLAG;
  117572. private static readonly KINEMATIC_FLAG;
  117573. private static readonly DISABLE_DEACTIVATION_FLAG;
  117574. /**
  117575. * Initializes the ammoJS plugin
  117576. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  117577. * @param ammoInjection can be used to inject your own ammo reference
  117578. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  117579. */
  117580. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  117581. /**
  117582. * Sets the gravity of the physics world (m/(s^2))
  117583. * @param gravity Gravity to set
  117584. */
  117585. setGravity(gravity: Vector3): void;
  117586. /**
  117587. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  117588. * @param timeStep timestep to use in seconds
  117589. */
  117590. setTimeStep(timeStep: number): void;
  117591. /**
  117592. * 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)
  117593. * @param fixedTimeStep fixedTimeStep to use in seconds
  117594. */
  117595. setFixedTimeStep(fixedTimeStep: number): void;
  117596. /**
  117597. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  117598. * @param maxSteps the maximum number of steps by the physics engine per frame
  117599. */
  117600. setMaxSteps(maxSteps: number): void;
  117601. /**
  117602. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  117603. * @returns the current timestep in seconds
  117604. */
  117605. getTimeStep(): number;
  117606. private _isImpostorInContact;
  117607. private _isImpostorPairInContact;
  117608. private _stepSimulation;
  117609. /**
  117610. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  117611. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  117612. * After the step the babylon meshes are set to the position of the physics imposters
  117613. * @param delta amount of time to step forward
  117614. * @param impostors array of imposters to update before/after the step
  117615. */
  117616. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117617. /**
  117618. * Update babylon mesh to match physics world object
  117619. * @param impostor imposter to match
  117620. */
  117621. private _afterSoftStep;
  117622. /**
  117623. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117624. * @param impostor imposter to match
  117625. */
  117626. private _ropeStep;
  117627. /**
  117628. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117629. * @param impostor imposter to match
  117630. */
  117631. private _softbodyOrClothStep;
  117632. private _tmpVector;
  117633. private _tmpMatrix;
  117634. /**
  117635. * Applies an impulse on the imposter
  117636. * @param impostor imposter to apply impulse to
  117637. * @param force amount of force to be applied to the imposter
  117638. * @param contactPoint the location to apply the impulse on the imposter
  117639. */
  117640. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117641. /**
  117642. * Applies a force on the imposter
  117643. * @param impostor imposter to apply force
  117644. * @param force amount of force to be applied to the imposter
  117645. * @param contactPoint the location to apply the force on the imposter
  117646. */
  117647. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117648. /**
  117649. * Creates a physics body using the plugin
  117650. * @param impostor the imposter to create the physics body on
  117651. */
  117652. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117653. /**
  117654. * Removes the physics body from the imposter and disposes of the body's memory
  117655. * @param impostor imposter to remove the physics body from
  117656. */
  117657. removePhysicsBody(impostor: PhysicsImpostor): void;
  117658. /**
  117659. * Generates a joint
  117660. * @param impostorJoint the imposter joint to create the joint with
  117661. */
  117662. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117663. /**
  117664. * Removes a joint
  117665. * @param impostorJoint the imposter joint to remove the joint from
  117666. */
  117667. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117668. private _addMeshVerts;
  117669. /**
  117670. * Initialise the soft body vertices to match its object's (mesh) vertices
  117671. * Softbody vertices (nodes) are in world space and to match this
  117672. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  117673. * @param impostor to create the softbody for
  117674. */
  117675. private _softVertexData;
  117676. /**
  117677. * Create an impostor's soft body
  117678. * @param impostor to create the softbody for
  117679. */
  117680. private _createSoftbody;
  117681. /**
  117682. * Create cloth for an impostor
  117683. * @param impostor to create the softbody for
  117684. */
  117685. private _createCloth;
  117686. /**
  117687. * Create rope for an impostor
  117688. * @param impostor to create the softbody for
  117689. */
  117690. private _createRope;
  117691. private _addHullVerts;
  117692. private _createShape;
  117693. /**
  117694. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  117695. * @param impostor imposter containing the physics body and babylon object
  117696. */
  117697. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117698. /**
  117699. * Sets the babylon object's position/rotation from the physics body's position/rotation
  117700. * @param impostor imposter containing the physics body and babylon object
  117701. * @param newPosition new position
  117702. * @param newRotation new rotation
  117703. */
  117704. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117705. /**
  117706. * If this plugin is supported
  117707. * @returns true if its supported
  117708. */
  117709. isSupported(): boolean;
  117710. /**
  117711. * Sets the linear velocity of the physics body
  117712. * @param impostor imposter to set the velocity on
  117713. * @param velocity velocity to set
  117714. */
  117715. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117716. /**
  117717. * Sets the angular velocity of the physics body
  117718. * @param impostor imposter to set the velocity on
  117719. * @param velocity velocity to set
  117720. */
  117721. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117722. /**
  117723. * gets the linear velocity
  117724. * @param impostor imposter to get linear velocity from
  117725. * @returns linear velocity
  117726. */
  117727. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117728. /**
  117729. * gets the angular velocity
  117730. * @param impostor imposter to get angular velocity from
  117731. * @returns angular velocity
  117732. */
  117733. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117734. /**
  117735. * Sets the mass of physics body
  117736. * @param impostor imposter to set the mass on
  117737. * @param mass mass to set
  117738. */
  117739. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117740. /**
  117741. * Gets the mass of the physics body
  117742. * @param impostor imposter to get the mass from
  117743. * @returns mass
  117744. */
  117745. getBodyMass(impostor: PhysicsImpostor): number;
  117746. /**
  117747. * Gets friction of the impostor
  117748. * @param impostor impostor to get friction from
  117749. * @returns friction value
  117750. */
  117751. getBodyFriction(impostor: PhysicsImpostor): number;
  117752. /**
  117753. * Sets friction of the impostor
  117754. * @param impostor impostor to set friction on
  117755. * @param friction friction value
  117756. */
  117757. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117758. /**
  117759. * Gets restitution of the impostor
  117760. * @param impostor impostor to get restitution from
  117761. * @returns restitution value
  117762. */
  117763. getBodyRestitution(impostor: PhysicsImpostor): number;
  117764. /**
  117765. * Sets resitution of the impostor
  117766. * @param impostor impostor to set resitution on
  117767. * @param restitution resitution value
  117768. */
  117769. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117770. /**
  117771. * Gets pressure inside the impostor
  117772. * @param impostor impostor to get pressure from
  117773. * @returns pressure value
  117774. */
  117775. getBodyPressure(impostor: PhysicsImpostor): number;
  117776. /**
  117777. * Sets pressure inside a soft body impostor
  117778. * Cloth and rope must remain 0 pressure
  117779. * @param impostor impostor to set pressure on
  117780. * @param pressure pressure value
  117781. */
  117782. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  117783. /**
  117784. * Gets stiffness of the impostor
  117785. * @param impostor impostor to get stiffness from
  117786. * @returns pressure value
  117787. */
  117788. getBodyStiffness(impostor: PhysicsImpostor): number;
  117789. /**
  117790. * Sets stiffness of the impostor
  117791. * @param impostor impostor to set stiffness on
  117792. * @param stiffness stiffness value from 0 to 1
  117793. */
  117794. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  117795. /**
  117796. * Gets velocityIterations of the impostor
  117797. * @param impostor impostor to get velocity iterations from
  117798. * @returns velocityIterations value
  117799. */
  117800. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  117801. /**
  117802. * Sets velocityIterations of the impostor
  117803. * @param impostor impostor to set velocity iterations on
  117804. * @param velocityIterations velocityIterations value
  117805. */
  117806. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  117807. /**
  117808. * Gets positionIterations of the impostor
  117809. * @param impostor impostor to get position iterations from
  117810. * @returns positionIterations value
  117811. */
  117812. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  117813. /**
  117814. * Sets positionIterations of the impostor
  117815. * @param impostor impostor to set position on
  117816. * @param positionIterations positionIterations value
  117817. */
  117818. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  117819. /**
  117820. * Append an anchor to a cloth object
  117821. * @param impostor is the cloth impostor to add anchor to
  117822. * @param otherImpostor is the rigid impostor to anchor to
  117823. * @param width ratio across width from 0 to 1
  117824. * @param height ratio up height from 0 to 1
  117825. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117826. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117827. */
  117828. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  117829. /**
  117830. * Append an hook to a rope object
  117831. * @param impostor is the rope impostor to add hook to
  117832. * @param otherImpostor is the rigid impostor to hook to
  117833. * @param length ratio along the rope from 0 to 1
  117834. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  117835. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117836. */
  117837. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  117838. /**
  117839. * Sleeps the physics body and stops it from being active
  117840. * @param impostor impostor to sleep
  117841. */
  117842. sleepBody(impostor: PhysicsImpostor): void;
  117843. /**
  117844. * Activates the physics body
  117845. * @param impostor impostor to activate
  117846. */
  117847. wakeUpBody(impostor: PhysicsImpostor): void;
  117848. /**
  117849. * Updates the distance parameters of the joint
  117850. * @param joint joint to update
  117851. * @param maxDistance maximum distance of the joint
  117852. * @param minDistance minimum distance of the joint
  117853. */
  117854. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117855. /**
  117856. * Sets a motor on the joint
  117857. * @param joint joint to set motor on
  117858. * @param speed speed of the motor
  117859. * @param maxForce maximum force of the motor
  117860. * @param motorIndex index of the motor
  117861. */
  117862. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117863. /**
  117864. * Sets the motors limit
  117865. * @param joint joint to set limit on
  117866. * @param upperLimit upper limit
  117867. * @param lowerLimit lower limit
  117868. */
  117869. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117870. /**
  117871. * Syncs the position and rotation of a mesh with the impostor
  117872. * @param mesh mesh to sync
  117873. * @param impostor impostor to update the mesh with
  117874. */
  117875. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117876. /**
  117877. * Gets the radius of the impostor
  117878. * @param impostor impostor to get radius from
  117879. * @returns the radius
  117880. */
  117881. getRadius(impostor: PhysicsImpostor): number;
  117882. /**
  117883. * Gets the box size of the impostor
  117884. * @param impostor impostor to get box size from
  117885. * @param result the resulting box size
  117886. */
  117887. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117888. /**
  117889. * Disposes of the impostor
  117890. */
  117891. dispose(): void;
  117892. /**
  117893. * Does a raycast in the physics world
  117894. * @param from when should the ray start?
  117895. * @param to when should the ray end?
  117896. * @returns PhysicsRaycastResult
  117897. */
  117898. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117899. }
  117900. }
  117901. declare module BABYLON {
  117902. interface AbstractScene {
  117903. /**
  117904. * The list of reflection probes added to the scene
  117905. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  117906. */
  117907. reflectionProbes: Array<ReflectionProbe>;
  117908. /**
  117909. * Removes the given reflection probe from this scene.
  117910. * @param toRemove The reflection probe to remove
  117911. * @returns The index of the removed reflection probe
  117912. */
  117913. removeReflectionProbe(toRemove: ReflectionProbe): number;
  117914. /**
  117915. * Adds the given reflection probe to this scene.
  117916. * @param newReflectionProbe The reflection probe to add
  117917. */
  117918. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  117919. }
  117920. /**
  117921. * Class used to generate realtime reflection / refraction cube textures
  117922. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  117923. */
  117924. export class ReflectionProbe {
  117925. /** defines the name of the probe */
  117926. name: string;
  117927. private _scene;
  117928. private _renderTargetTexture;
  117929. private _projectionMatrix;
  117930. private _viewMatrix;
  117931. private _target;
  117932. private _add;
  117933. private _attachedMesh;
  117934. private _invertYAxis;
  117935. /** Gets or sets probe position (center of the cube map) */
  117936. position: Vector3;
  117937. /**
  117938. * Creates a new reflection probe
  117939. * @param name defines the name of the probe
  117940. * @param size defines the texture resolution (for each face)
  117941. * @param scene defines the hosting scene
  117942. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  117943. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  117944. */
  117945. constructor(
  117946. /** defines the name of the probe */
  117947. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  117948. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  117949. samples: number;
  117950. /** Gets or sets the refresh rate to use (on every frame by default) */
  117951. refreshRate: number;
  117952. /**
  117953. * Gets the hosting scene
  117954. * @returns a Scene
  117955. */
  117956. getScene(): Scene;
  117957. /** Gets the internal CubeTexture used to render to */
  117958. readonly cubeTexture: RenderTargetTexture;
  117959. /** Gets the list of meshes to render */
  117960. readonly renderList: Nullable<AbstractMesh[]>;
  117961. /**
  117962. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  117963. * @param mesh defines the mesh to attach to
  117964. */
  117965. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  117966. /**
  117967. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  117968. * @param renderingGroupId The rendering group id corresponding to its index
  117969. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117970. */
  117971. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  117972. /**
  117973. * Clean all associated resources
  117974. */
  117975. dispose(): void;
  117976. /**
  117977. * Converts the reflection probe information to a readable string for debug purpose.
  117978. * @param fullDetails Supports for multiple levels of logging within scene loading
  117979. * @returns the human readable reflection probe info
  117980. */
  117981. toString(fullDetails?: boolean): string;
  117982. /**
  117983. * Get the class name of the relfection probe.
  117984. * @returns "ReflectionProbe"
  117985. */
  117986. getClassName(): string;
  117987. /**
  117988. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  117989. * @returns The JSON representation of the texture
  117990. */
  117991. serialize(): any;
  117992. /**
  117993. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  117994. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  117995. * @param scene Define the scene the parsed reflection probe should be instantiated in
  117996. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  117997. * @returns The parsed reflection probe if successful
  117998. */
  117999. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118000. }
  118001. }
  118002. declare module BABYLON {
  118003. /** @hidden */
  118004. export var _BabylonLoaderRegistered: boolean;
  118005. }
  118006. declare module BABYLON {
  118007. /**
  118008. * The Physically based simple base material of BJS.
  118009. *
  118010. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118011. * It is used as the base class for both the specGloss and metalRough conventions.
  118012. */
  118013. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118014. /**
  118015. * Number of Simultaneous lights allowed on the material.
  118016. */
  118017. maxSimultaneousLights: number;
  118018. /**
  118019. * If sets to true, disables all the lights affecting the material.
  118020. */
  118021. disableLighting: boolean;
  118022. /**
  118023. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118024. */
  118025. environmentTexture: BaseTexture;
  118026. /**
  118027. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118028. */
  118029. invertNormalMapX: boolean;
  118030. /**
  118031. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118032. */
  118033. invertNormalMapY: boolean;
  118034. /**
  118035. * Normal map used in the model.
  118036. */
  118037. normalTexture: BaseTexture;
  118038. /**
  118039. * Emissivie color used to self-illuminate the model.
  118040. */
  118041. emissiveColor: Color3;
  118042. /**
  118043. * Emissivie texture used to self-illuminate the model.
  118044. */
  118045. emissiveTexture: BaseTexture;
  118046. /**
  118047. * Occlusion Channel Strenght.
  118048. */
  118049. occlusionStrength: number;
  118050. /**
  118051. * Occlusion Texture of the material (adding extra occlusion effects).
  118052. */
  118053. occlusionTexture: BaseTexture;
  118054. /**
  118055. * Defines the alpha limits in alpha test mode.
  118056. */
  118057. alphaCutOff: number;
  118058. /**
  118059. * Gets the current double sided mode.
  118060. */
  118061. /**
  118062. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118063. */
  118064. doubleSided: boolean;
  118065. /**
  118066. * Stores the pre-calculated light information of a mesh in a texture.
  118067. */
  118068. lightmapTexture: BaseTexture;
  118069. /**
  118070. * If true, the light map contains occlusion information instead of lighting info.
  118071. */
  118072. useLightmapAsShadowmap: boolean;
  118073. /**
  118074. * Instantiates a new PBRMaterial instance.
  118075. *
  118076. * @param name The material name
  118077. * @param scene The scene the material will be use in.
  118078. */
  118079. constructor(name: string, scene: Scene);
  118080. getClassName(): string;
  118081. }
  118082. }
  118083. declare module BABYLON {
  118084. /**
  118085. * The PBR material of BJS following the metal roughness convention.
  118086. *
  118087. * This fits to the PBR convention in the GLTF definition:
  118088. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118089. */
  118090. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118091. /**
  118092. * The base color has two different interpretations depending on the value of metalness.
  118093. * When the material is a metal, the base color is the specific measured reflectance value
  118094. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118095. * of the material.
  118096. */
  118097. baseColor: Color3;
  118098. /**
  118099. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118100. * well as opacity information in the alpha channel.
  118101. */
  118102. baseTexture: BaseTexture;
  118103. /**
  118104. * Specifies the metallic scalar value of the material.
  118105. * Can also be used to scale the metalness values of the metallic texture.
  118106. */
  118107. metallic: number;
  118108. /**
  118109. * Specifies the roughness scalar value of the material.
  118110. * Can also be used to scale the roughness values of the metallic texture.
  118111. */
  118112. roughness: number;
  118113. /**
  118114. * Texture containing both the metallic value in the B channel and the
  118115. * roughness value in the G channel to keep better precision.
  118116. */
  118117. metallicRoughnessTexture: BaseTexture;
  118118. /**
  118119. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118120. *
  118121. * @param name The material name
  118122. * @param scene The scene the material will be use in.
  118123. */
  118124. constructor(name: string, scene: Scene);
  118125. /**
  118126. * Return the currrent class name of the material.
  118127. */
  118128. getClassName(): string;
  118129. /**
  118130. * Makes a duplicate of the current material.
  118131. * @param name - name to use for the new material.
  118132. */
  118133. clone(name: string): PBRMetallicRoughnessMaterial;
  118134. /**
  118135. * Serialize the material to a parsable JSON object.
  118136. */
  118137. serialize(): any;
  118138. /**
  118139. * Parses a JSON object correponding to the serialize function.
  118140. */
  118141. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118142. }
  118143. }
  118144. declare module BABYLON {
  118145. /**
  118146. * The PBR material of BJS following the specular glossiness convention.
  118147. *
  118148. * This fits to the PBR convention in the GLTF definition:
  118149. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118150. */
  118151. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118152. /**
  118153. * Specifies the diffuse color of the material.
  118154. */
  118155. diffuseColor: Color3;
  118156. /**
  118157. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118158. * channel.
  118159. */
  118160. diffuseTexture: BaseTexture;
  118161. /**
  118162. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118163. */
  118164. specularColor: Color3;
  118165. /**
  118166. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118167. */
  118168. glossiness: number;
  118169. /**
  118170. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118171. */
  118172. specularGlossinessTexture: BaseTexture;
  118173. /**
  118174. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118175. *
  118176. * @param name The material name
  118177. * @param scene The scene the material will be use in.
  118178. */
  118179. constructor(name: string, scene: Scene);
  118180. /**
  118181. * Return the currrent class name of the material.
  118182. */
  118183. getClassName(): string;
  118184. /**
  118185. * Makes a duplicate of the current material.
  118186. * @param name - name to use for the new material.
  118187. */
  118188. clone(name: string): PBRSpecularGlossinessMaterial;
  118189. /**
  118190. * Serialize the material to a parsable JSON object.
  118191. */
  118192. serialize(): any;
  118193. /**
  118194. * Parses a JSON object correponding to the serialize function.
  118195. */
  118196. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118197. }
  118198. }
  118199. declare module BABYLON {
  118200. /**
  118201. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118202. * It can help converting any input color in a desired output one. This can then be used to create effects
  118203. * from sepia, black and white to sixties or futuristic rendering...
  118204. *
  118205. * The only supported format is currently 3dl.
  118206. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118207. */
  118208. export class ColorGradingTexture extends BaseTexture {
  118209. /**
  118210. * The current texture matrix. (will always be identity in color grading texture)
  118211. */
  118212. private _textureMatrix;
  118213. /**
  118214. * The texture URL.
  118215. */
  118216. url: string;
  118217. /**
  118218. * Empty line regex stored for GC.
  118219. */
  118220. private static _noneEmptyLineRegex;
  118221. private _engine;
  118222. /**
  118223. * Instantiates a ColorGradingTexture from the following parameters.
  118224. *
  118225. * @param url The location of the color gradind data (currently only supporting 3dl)
  118226. * @param scene The scene the texture will be used in
  118227. */
  118228. constructor(url: string, scene: Scene);
  118229. /**
  118230. * Returns the texture matrix used in most of the material.
  118231. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118232. */
  118233. getTextureMatrix(): Matrix;
  118234. /**
  118235. * Occurs when the file being loaded is a .3dl LUT file.
  118236. */
  118237. private load3dlTexture;
  118238. /**
  118239. * Starts the loading process of the texture.
  118240. */
  118241. private loadTexture;
  118242. /**
  118243. * Clones the color gradind texture.
  118244. */
  118245. clone(): ColorGradingTexture;
  118246. /**
  118247. * Called during delayed load for textures.
  118248. */
  118249. delayLoad(): void;
  118250. /**
  118251. * Parses a color grading texture serialized by Babylon.
  118252. * @param parsedTexture The texture information being parsedTexture
  118253. * @param scene The scene to load the texture in
  118254. * @param rootUrl The root url of the data assets to load
  118255. * @return A color gradind texture
  118256. */
  118257. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118258. /**
  118259. * Serializes the LUT texture to json format.
  118260. */
  118261. serialize(): any;
  118262. }
  118263. }
  118264. declare module BABYLON {
  118265. /**
  118266. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118267. */
  118268. export class EquiRectangularCubeTexture extends BaseTexture {
  118269. /** The six faces of the cube. */
  118270. private static _FacesMapping;
  118271. private _noMipmap;
  118272. private _onLoad;
  118273. private _onError;
  118274. /** The size of the cubemap. */
  118275. private _size;
  118276. /** The buffer of the image. */
  118277. private _buffer;
  118278. /** The width of the input image. */
  118279. private _width;
  118280. /** The height of the input image. */
  118281. private _height;
  118282. /** The URL to the image. */
  118283. url: string;
  118284. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118285. coordinatesMode: number;
  118286. /**
  118287. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118288. * @param url The location of the image
  118289. * @param scene The scene the texture will be used in
  118290. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118291. * @param noMipmap Forces to not generate the mipmap if true
  118292. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118293. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118294. * @param onLoad — defines a callback called when texture is loaded
  118295. * @param onError — defines a callback called if there is an error
  118296. */
  118297. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118298. /**
  118299. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118300. */
  118301. private loadImage;
  118302. /**
  118303. * Convert the image buffer into a cubemap and create a CubeTexture.
  118304. */
  118305. private loadTexture;
  118306. /**
  118307. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118308. * @param buffer The ArrayBuffer that should be converted.
  118309. * @returns The buffer as Float32Array.
  118310. */
  118311. private getFloat32ArrayFromArrayBuffer;
  118312. /**
  118313. * Get the current class name of the texture useful for serialization or dynamic coding.
  118314. * @returns "EquiRectangularCubeTexture"
  118315. */
  118316. getClassName(): string;
  118317. /**
  118318. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118319. * @returns A clone of the current EquiRectangularCubeTexture.
  118320. */
  118321. clone(): EquiRectangularCubeTexture;
  118322. }
  118323. }
  118324. declare module BABYLON {
  118325. /**
  118326. * Based on jsTGALoader - Javascript loader for TGA file
  118327. * By Vincent Thibault
  118328. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118329. */
  118330. export class TGATools {
  118331. private static _TYPE_INDEXED;
  118332. private static _TYPE_RGB;
  118333. private static _TYPE_GREY;
  118334. private static _TYPE_RLE_INDEXED;
  118335. private static _TYPE_RLE_RGB;
  118336. private static _TYPE_RLE_GREY;
  118337. private static _ORIGIN_MASK;
  118338. private static _ORIGIN_SHIFT;
  118339. private static _ORIGIN_BL;
  118340. private static _ORIGIN_BR;
  118341. private static _ORIGIN_UL;
  118342. private static _ORIGIN_UR;
  118343. /**
  118344. * Gets the header of a TGA file
  118345. * @param data defines the TGA data
  118346. * @returns the header
  118347. */
  118348. static GetTGAHeader(data: Uint8Array): any;
  118349. /**
  118350. * Uploads TGA content to a Babylon Texture
  118351. * @hidden
  118352. */
  118353. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118354. /** @hidden */
  118355. 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;
  118356. /** @hidden */
  118357. 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;
  118358. /** @hidden */
  118359. 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;
  118360. /** @hidden */
  118361. 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;
  118362. /** @hidden */
  118363. 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;
  118364. /** @hidden */
  118365. 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;
  118366. }
  118367. }
  118368. declare module BABYLON {
  118369. /**
  118370. * Implementation of the TGA Texture Loader.
  118371. * @hidden
  118372. */
  118373. export class _TGATextureLoader implements IInternalTextureLoader {
  118374. /**
  118375. * Defines wether the loader supports cascade loading the different faces.
  118376. */
  118377. readonly supportCascades: boolean;
  118378. /**
  118379. * This returns if the loader support the current file information.
  118380. * @param extension defines the file extension of the file being loaded
  118381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118382. * @param fallback defines the fallback internal texture if any
  118383. * @param isBase64 defines whether the texture is encoded as a base64
  118384. * @param isBuffer defines whether the texture data are stored as a buffer
  118385. * @returns true if the loader can load the specified file
  118386. */
  118387. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118388. /**
  118389. * Transform the url before loading if required.
  118390. * @param rootUrl the url of the texture
  118391. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118392. * @returns the transformed texture
  118393. */
  118394. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118395. /**
  118396. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118397. * @param rootUrl the url of the texture
  118398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118399. * @returns the fallback texture
  118400. */
  118401. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118402. /**
  118403. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118404. * @param data contains the texture data
  118405. * @param texture defines the BabylonJS internal texture
  118406. * @param createPolynomials will be true if polynomials have been requested
  118407. * @param onLoad defines the callback to trigger once the texture is ready
  118408. * @param onError defines the callback to trigger in case of error
  118409. */
  118410. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118411. /**
  118412. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118413. * @param data contains the texture data
  118414. * @param texture defines the BabylonJS internal texture
  118415. * @param callback defines the method to call once ready to upload
  118416. */
  118417. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118418. }
  118419. }
  118420. declare module BABYLON {
  118421. /**
  118422. * Info about the .basis files
  118423. */
  118424. class BasisFileInfo {
  118425. /**
  118426. * If the file has alpha
  118427. */
  118428. hasAlpha: boolean;
  118429. /**
  118430. * Info about each image of the basis file
  118431. */
  118432. images: Array<{
  118433. levels: Array<{
  118434. width: number;
  118435. height: number;
  118436. transcodedPixels: ArrayBufferView;
  118437. }>;
  118438. }>;
  118439. }
  118440. /**
  118441. * Result of transcoding a basis file
  118442. */
  118443. class TranscodeResult {
  118444. /**
  118445. * Info about the .basis file
  118446. */
  118447. fileInfo: BasisFileInfo;
  118448. /**
  118449. * Format to use when loading the file
  118450. */
  118451. format: number;
  118452. }
  118453. /**
  118454. * Configuration options for the Basis transcoder
  118455. */
  118456. export class BasisTranscodeConfiguration {
  118457. /**
  118458. * Supported compression formats used to determine the supported output format of the transcoder
  118459. */
  118460. supportedCompressionFormats?: {
  118461. /**
  118462. * etc1 compression format
  118463. */
  118464. etc1?: boolean;
  118465. /**
  118466. * s3tc compression format
  118467. */
  118468. s3tc?: boolean;
  118469. /**
  118470. * pvrtc compression format
  118471. */
  118472. pvrtc?: boolean;
  118473. /**
  118474. * etc2 compression format
  118475. */
  118476. etc2?: boolean;
  118477. };
  118478. /**
  118479. * If mipmap levels should be loaded for transcoded images (Default: true)
  118480. */
  118481. loadMipmapLevels?: boolean;
  118482. /**
  118483. * Index of a single image to load (Default: all images)
  118484. */
  118485. loadSingleImage?: number;
  118486. }
  118487. /**
  118488. * Used to load .Basis files
  118489. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118490. */
  118491. export class BasisTools {
  118492. private static _IgnoreSupportedFormats;
  118493. /**
  118494. * URL to use when loading the basis transcoder
  118495. */
  118496. static JSModuleURL: string;
  118497. /**
  118498. * URL to use when loading the wasm module for the transcoder
  118499. */
  118500. static WasmModuleURL: string;
  118501. /**
  118502. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118503. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118504. * @returns internal format corresponding to the Basis format
  118505. */
  118506. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118507. private static _WorkerPromise;
  118508. private static _Worker;
  118509. private static _actionId;
  118510. private static _CreateWorkerAsync;
  118511. /**
  118512. * Transcodes a loaded image file to compressed pixel data
  118513. * @param imageData image data to transcode
  118514. * @param config configuration options for the transcoding
  118515. * @returns a promise resulting in the transcoded image
  118516. */
  118517. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118518. /**
  118519. * Loads a texture from the transcode result
  118520. * @param texture texture load to
  118521. * @param transcodeResult the result of transcoding the basis file to load from
  118522. */
  118523. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  118524. }
  118525. }
  118526. declare module BABYLON {
  118527. /**
  118528. * Loader for .basis file format
  118529. */
  118530. export class _BasisTextureLoader implements IInternalTextureLoader {
  118531. /**
  118532. * Defines whether the loader supports cascade loading the different faces.
  118533. */
  118534. readonly supportCascades: boolean;
  118535. /**
  118536. * This returns if the loader support the current file information.
  118537. * @param extension defines the file extension of the file being loaded
  118538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118539. * @param fallback defines the fallback internal texture if any
  118540. * @param isBase64 defines whether the texture is encoded as a base64
  118541. * @param isBuffer defines whether the texture data are stored as a buffer
  118542. * @returns true if the loader can load the specified file
  118543. */
  118544. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118545. /**
  118546. * Transform the url before loading if required.
  118547. * @param rootUrl the url of the texture
  118548. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118549. * @returns the transformed texture
  118550. */
  118551. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118552. /**
  118553. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118554. * @param rootUrl the url of the texture
  118555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118556. * @returns the fallback texture
  118557. */
  118558. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118559. /**
  118560. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  118561. * @param data contains the texture data
  118562. * @param texture defines the BabylonJS internal texture
  118563. * @param createPolynomials will be true if polynomials have been requested
  118564. * @param onLoad defines the callback to trigger once the texture is ready
  118565. * @param onError defines the callback to trigger in case of error
  118566. */
  118567. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118568. /**
  118569. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118570. * @param data contains the texture data
  118571. * @param texture defines the BabylonJS internal texture
  118572. * @param callback defines the method to call once ready to upload
  118573. */
  118574. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118575. }
  118576. }
  118577. declare module BABYLON {
  118578. /**
  118579. * 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.
  118580. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118581. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118582. */
  118583. export class CustomProceduralTexture extends ProceduralTexture {
  118584. private _animate;
  118585. private _time;
  118586. private _config;
  118587. private _texturePath;
  118588. /**
  118589. * Instantiates a new Custom Procedural Texture.
  118590. * 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.
  118591. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118592. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118593. * @param name Define the name of the texture
  118594. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  118595. * @param size Define the size of the texture to create
  118596. * @param scene Define the scene the texture belongs to
  118597. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  118598. * @param generateMipMaps Define if the texture should creates mip maps or not
  118599. */
  118600. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118601. private _loadJson;
  118602. /**
  118603. * Is the texture ready to be used ? (rendered at least once)
  118604. * @returns true if ready, otherwise, false.
  118605. */
  118606. isReady(): boolean;
  118607. /**
  118608. * Render the texture to its associated render target.
  118609. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  118610. */
  118611. render(useCameraPostProcess?: boolean): void;
  118612. /**
  118613. * Update the list of dependant textures samplers in the shader.
  118614. */
  118615. updateTextures(): void;
  118616. /**
  118617. * Update the uniform values of the procedural texture in the shader.
  118618. */
  118619. updateShaderUniforms(): void;
  118620. /**
  118621. * Define if the texture animates or not.
  118622. */
  118623. animate: boolean;
  118624. }
  118625. }
  118626. declare module BABYLON {
  118627. /** @hidden */
  118628. export var noisePixelShader: {
  118629. name: string;
  118630. shader: string;
  118631. };
  118632. }
  118633. declare module BABYLON {
  118634. /**
  118635. * Class used to generate noise procedural textures
  118636. */
  118637. export class NoiseProceduralTexture extends ProceduralTexture {
  118638. private _time;
  118639. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  118640. brightness: number;
  118641. /** Defines the number of octaves to process */
  118642. octaves: number;
  118643. /** Defines the level of persistence (0.8 by default) */
  118644. persistence: number;
  118645. /** Gets or sets animation speed factor (default is 1) */
  118646. animationSpeedFactor: number;
  118647. /**
  118648. * Creates a new NoiseProceduralTexture
  118649. * @param name defines the name fo the texture
  118650. * @param size defines the size of the texture (default is 256)
  118651. * @param scene defines the hosting scene
  118652. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  118653. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  118654. */
  118655. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118656. private _updateShaderUniforms;
  118657. protected _getDefines(): string;
  118658. /** Generate the current state of the procedural texture */
  118659. render(useCameraPostProcess?: boolean): void;
  118660. /**
  118661. * Serializes this noise procedural texture
  118662. * @returns a serialized noise procedural texture object
  118663. */
  118664. serialize(): any;
  118665. /**
  118666. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  118667. * @param parsedTexture defines parsed texture data
  118668. * @param scene defines the current scene
  118669. * @param rootUrl defines the root URL containing noise procedural texture information
  118670. * @returns a parsed NoiseProceduralTexture
  118671. */
  118672. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  118673. }
  118674. }
  118675. declare module BABYLON {
  118676. /**
  118677. * Raw cube texture where the raw buffers are passed in
  118678. */
  118679. export class RawCubeTexture extends CubeTexture {
  118680. /**
  118681. * Creates a cube texture where the raw buffers are passed in.
  118682. * @param scene defines the scene the texture is attached to
  118683. * @param data defines the array of data to use to create each face
  118684. * @param size defines the size of the textures
  118685. * @param format defines the format of the data
  118686. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  118687. * @param generateMipMaps defines if the engine should generate the mip levels
  118688. * @param invertY defines if data must be stored with Y axis inverted
  118689. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  118690. * @param compression defines the compression used (null by default)
  118691. */
  118692. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  118693. /**
  118694. * Updates the raw cube texture.
  118695. * @param data defines the data to store
  118696. * @param format defines the data format
  118697. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118698. * @param invertY defines if data must be stored with Y axis inverted
  118699. * @param compression defines the compression used (null by default)
  118700. * @param level defines which level of the texture to update
  118701. */
  118702. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  118703. /**
  118704. * Updates a raw cube texture with RGBD encoded data.
  118705. * @param data defines the array of data [mipmap][face] to use to create each face
  118706. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  118707. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  118708. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  118709. * @returns a promsie that resolves when the operation is complete
  118710. */
  118711. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  118712. /**
  118713. * Clones the raw cube texture.
  118714. * @return a new cube texture
  118715. */
  118716. clone(): CubeTexture;
  118717. /** @hidden */
  118718. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  118719. }
  118720. }
  118721. declare module BABYLON {
  118722. /**
  118723. * Class used to store 3D textures containing user data
  118724. */
  118725. export class RawTexture3D extends Texture {
  118726. /** Gets or sets the texture format to use */
  118727. format: number;
  118728. private _engine;
  118729. /**
  118730. * Create a new RawTexture3D
  118731. * @param data defines the data of the texture
  118732. * @param width defines the width of the texture
  118733. * @param height defines the height of the texture
  118734. * @param depth defines the depth of the texture
  118735. * @param format defines the texture format to use
  118736. * @param scene defines the hosting scene
  118737. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  118738. * @param invertY defines if texture must be stored with Y axis inverted
  118739. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  118740. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  118741. */
  118742. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  118743. /** Gets or sets the texture format to use */
  118744. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  118745. /**
  118746. * Update the texture with new data
  118747. * @param data defines the data to store in the texture
  118748. */
  118749. update(data: ArrayBufferView): void;
  118750. }
  118751. }
  118752. declare module BABYLON {
  118753. /**
  118754. * Creates a refraction texture used by refraction channel of the standard material.
  118755. * It is like a mirror but to see through a material.
  118756. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118757. */
  118758. export class RefractionTexture extends RenderTargetTexture {
  118759. /**
  118760. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  118761. * 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.
  118762. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118763. */
  118764. refractionPlane: Plane;
  118765. /**
  118766. * Define how deep under the surface we should see.
  118767. */
  118768. depth: number;
  118769. /**
  118770. * Creates a refraction texture used by refraction channel of the standard material.
  118771. * It is like a mirror but to see through a material.
  118772. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118773. * @param name Define the texture name
  118774. * @param size Define the size of the underlying texture
  118775. * @param scene Define the scene the refraction belongs to
  118776. * @param generateMipMaps Define if we need to generate mips level for the refraction
  118777. */
  118778. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  118779. /**
  118780. * Clone the refraction texture.
  118781. * @returns the cloned texture
  118782. */
  118783. clone(): RefractionTexture;
  118784. /**
  118785. * Serialize the texture to a JSON representation you could use in Parse later on
  118786. * @returns the serialized JSON representation
  118787. */
  118788. serialize(): any;
  118789. }
  118790. }
  118791. declare module BABYLON {
  118792. /**
  118793. * Defines the options related to the creation of an HtmlElementTexture
  118794. */
  118795. export interface IHtmlElementTextureOptions {
  118796. /**
  118797. * Defines wether mip maps should be created or not.
  118798. */
  118799. generateMipMaps?: boolean;
  118800. /**
  118801. * Defines the sampling mode of the texture.
  118802. */
  118803. samplingMode?: number;
  118804. /**
  118805. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  118806. */
  118807. engine: Nullable<Engine>;
  118808. /**
  118809. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  118810. */
  118811. scene: Nullable<Scene>;
  118812. }
  118813. /**
  118814. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  118815. * To be as efficient as possible depending on your constraints nothing aside the first upload
  118816. * is automatically managed.
  118817. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  118818. * in your application.
  118819. *
  118820. * As the update is not automatic, you need to call them manually.
  118821. */
  118822. export class HtmlElementTexture extends BaseTexture {
  118823. /**
  118824. * The texture URL.
  118825. */
  118826. element: HTMLVideoElement | HTMLCanvasElement;
  118827. private static readonly DefaultOptions;
  118828. private _textureMatrix;
  118829. private _engine;
  118830. private _isVideo;
  118831. private _generateMipMaps;
  118832. private _samplingMode;
  118833. /**
  118834. * Instantiates a HtmlElementTexture from the following parameters.
  118835. *
  118836. * @param name Defines the name of the texture
  118837. * @param element Defines the video or canvas the texture is filled with
  118838. * @param options Defines the other none mandatory texture creation options
  118839. */
  118840. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  118841. private _createInternalTexture;
  118842. /**
  118843. * Returns the texture matrix used in most of the material.
  118844. */
  118845. getTextureMatrix(): Matrix;
  118846. /**
  118847. * Updates the content of the texture.
  118848. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  118849. */
  118850. update(invertY?: Nullable<boolean>): void;
  118851. }
  118852. }
  118853. declare module BABYLON {
  118854. /**
  118855. * Enum used to define the target of a block
  118856. */
  118857. export enum NodeMaterialBlockTargets {
  118858. /** Vertex shader */
  118859. Vertex = 1,
  118860. /** Fragment shader */
  118861. Fragment = 2,
  118862. /** Neutral */
  118863. Neutral = 4,
  118864. /** Vertex and Fragment */
  118865. VertexAndFragment = 3
  118866. }
  118867. }
  118868. declare module BABYLON {
  118869. /**
  118870. * Defines the kind of connection point for node based material
  118871. */
  118872. export enum NodeMaterialBlockConnectionPointTypes {
  118873. /** Float */
  118874. Float = 1,
  118875. /** Int */
  118876. Int = 2,
  118877. /** Vector2 */
  118878. Vector2 = 4,
  118879. /** Vector3 */
  118880. Vector3 = 8,
  118881. /** Vector4 */
  118882. Vector4 = 16,
  118883. /** Color3 */
  118884. Color3 = 32,
  118885. /** Color4 */
  118886. Color4 = 64,
  118887. /** Matrix */
  118888. Matrix = 128,
  118889. /** Detect type based on connection */
  118890. AutoDetect = 1024,
  118891. /** Output type that will be defined by input type */
  118892. BasedOnInput = 2048
  118893. }
  118894. }
  118895. declare module BABYLON {
  118896. /**
  118897. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118898. */
  118899. export enum NodeMaterialBlockConnectionPointMode {
  118900. /** Value is an uniform */
  118901. Uniform = 0,
  118902. /** Value is a mesh attribute */
  118903. Attribute = 1,
  118904. /** Value is a varying between vertex and fragment shaders */
  118905. Varying = 2,
  118906. /** Mode is undefined */
  118907. Undefined = 3
  118908. }
  118909. }
  118910. declare module BABYLON {
  118911. /**
  118912. * Enum used to define system values e.g. values automatically provided by the system
  118913. */
  118914. export enum NodeMaterialSystemValues {
  118915. /** World */
  118916. World = 1,
  118917. /** View */
  118918. View = 2,
  118919. /** Projection */
  118920. Projection = 3,
  118921. /** ViewProjection */
  118922. ViewProjection = 4,
  118923. /** WorldView */
  118924. WorldView = 5,
  118925. /** WorldViewProjection */
  118926. WorldViewProjection = 6,
  118927. /** CameraPosition */
  118928. CameraPosition = 7,
  118929. /** Fog Color */
  118930. FogColor = 8
  118931. }
  118932. }
  118933. declare module BABYLON {
  118934. /**
  118935. * Root class for all node material optimizers
  118936. */
  118937. export class NodeMaterialOptimizer {
  118938. /**
  118939. * Function used to optimize a NodeMaterial graph
  118940. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  118941. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  118942. */
  118943. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  118944. }
  118945. }
  118946. declare module BABYLON {
  118947. /**
  118948. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  118949. */
  118950. export class TransformBlock extends NodeMaterialBlock {
  118951. /**
  118952. * Defines the value to use to complement W value to transform it to a Vector4
  118953. */
  118954. complementW: number;
  118955. /**
  118956. * Defines the value to use to complement z value to transform it to a Vector4
  118957. */
  118958. complementZ: number;
  118959. /**
  118960. * Creates a new TransformBlock
  118961. * @param name defines the block name
  118962. */
  118963. constructor(name: string);
  118964. /**
  118965. * Gets the current class name
  118966. * @returns the class name
  118967. */
  118968. getClassName(): string;
  118969. /**
  118970. * Gets the vector input
  118971. */
  118972. readonly vector: NodeMaterialConnectionPoint;
  118973. /**
  118974. * Gets the output component
  118975. */
  118976. readonly output: NodeMaterialConnectionPoint;
  118977. /**
  118978. * Gets the matrix transform input
  118979. */
  118980. readonly transform: NodeMaterialConnectionPoint;
  118981. protected _buildBlock(state: NodeMaterialBuildState): this;
  118982. serialize(): any;
  118983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118984. protected _dumpPropertiesCode(): string;
  118985. }
  118986. }
  118987. declare module BABYLON {
  118988. /**
  118989. * Block used to output the vertex position
  118990. */
  118991. export class VertexOutputBlock extends NodeMaterialBlock {
  118992. /**
  118993. * Creates a new VertexOutputBlock
  118994. * @param name defines the block name
  118995. */
  118996. constructor(name: string);
  118997. /**
  118998. * Gets the current class name
  118999. * @returns the class name
  119000. */
  119001. getClassName(): string;
  119002. /**
  119003. * Gets the vector input component
  119004. */
  119005. readonly vector: NodeMaterialConnectionPoint;
  119006. protected _buildBlock(state: NodeMaterialBuildState): this;
  119007. }
  119008. }
  119009. declare module BABYLON {
  119010. /**
  119011. * Block used to output the final color
  119012. */
  119013. export class FragmentOutputBlock extends NodeMaterialBlock {
  119014. /**
  119015. * Create a new FragmentOutputBlock
  119016. * @param name defines the block name
  119017. */
  119018. constructor(name: string);
  119019. /**
  119020. * Gets the current class name
  119021. * @returns the class name
  119022. */
  119023. getClassName(): string;
  119024. /**
  119025. * Gets the rgba input component
  119026. */
  119027. readonly rgba: NodeMaterialConnectionPoint;
  119028. /**
  119029. * Gets the rgb input component
  119030. */
  119031. readonly rgb: NodeMaterialConnectionPoint;
  119032. /**
  119033. * Gets the a input component
  119034. */
  119035. readonly a: NodeMaterialConnectionPoint;
  119036. protected _buildBlock(state: NodeMaterialBuildState): this;
  119037. }
  119038. }
  119039. declare module BABYLON {
  119040. /**
  119041. * Block used to read a reflection texture from a sampler
  119042. */
  119043. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119044. private _define3DName;
  119045. private _defineCubicName;
  119046. private _defineExplicitName;
  119047. private _defineProjectionName;
  119048. private _defineLocalCubicName;
  119049. private _defineSphericalName;
  119050. private _definePlanarName;
  119051. private _defineEquirectangularName;
  119052. private _defineMirroredEquirectangularFixedName;
  119053. private _defineEquirectangularFixedName;
  119054. private _defineSkyboxName;
  119055. private _cubeSamplerName;
  119056. private _2DSamplerName;
  119057. private _positionUVWName;
  119058. private _directionWName;
  119059. private _reflectionCoordsName;
  119060. private _reflection2DCoordsName;
  119061. private _reflectionColorName;
  119062. private _reflectionMatrixName;
  119063. /**
  119064. * Gets or sets the texture associated with the node
  119065. */
  119066. texture: Nullable<BaseTexture>;
  119067. /**
  119068. * Create a new TextureBlock
  119069. * @param name defines the block name
  119070. */
  119071. constructor(name: string);
  119072. /**
  119073. * Gets the current class name
  119074. * @returns the class name
  119075. */
  119076. getClassName(): string;
  119077. /**
  119078. * Gets the world position input component
  119079. */
  119080. readonly position: NodeMaterialConnectionPoint;
  119081. /**
  119082. * Gets the world position input component
  119083. */
  119084. readonly worldPosition: NodeMaterialConnectionPoint;
  119085. /**
  119086. * Gets the world normal input component
  119087. */
  119088. readonly worldNormal: NodeMaterialConnectionPoint;
  119089. /**
  119090. * Gets the world input component
  119091. */
  119092. readonly world: NodeMaterialConnectionPoint;
  119093. /**
  119094. * Gets the camera (or eye) position component
  119095. */
  119096. readonly cameraPosition: NodeMaterialConnectionPoint;
  119097. /**
  119098. * Gets the view input component
  119099. */
  119100. readonly view: NodeMaterialConnectionPoint;
  119101. /**
  119102. * Gets the rgb output component
  119103. */
  119104. readonly rgb: NodeMaterialConnectionPoint;
  119105. /**
  119106. * Gets the r output component
  119107. */
  119108. readonly r: NodeMaterialConnectionPoint;
  119109. /**
  119110. * Gets the g output component
  119111. */
  119112. readonly g: NodeMaterialConnectionPoint;
  119113. /**
  119114. * Gets the b output component
  119115. */
  119116. readonly b: NodeMaterialConnectionPoint;
  119117. autoConfigure(material: NodeMaterial): void;
  119118. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119119. isReady(): boolean;
  119120. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119121. private _injectVertexCode;
  119122. private _writeOutput;
  119123. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119124. serialize(): any;
  119125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119126. }
  119127. }
  119128. declare module BABYLON {
  119129. /**
  119130. * Interface used to configure the node material editor
  119131. */
  119132. export interface INodeMaterialEditorOptions {
  119133. /** Define the URl to load node editor script */
  119134. editorURL?: string;
  119135. }
  119136. /** @hidden */
  119137. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119138. /** BONES */
  119139. NUM_BONE_INFLUENCERS: number;
  119140. BonesPerMesh: number;
  119141. BONETEXTURE: boolean;
  119142. /** MORPH TARGETS */
  119143. MORPHTARGETS: boolean;
  119144. MORPHTARGETS_NORMAL: boolean;
  119145. MORPHTARGETS_TANGENT: boolean;
  119146. MORPHTARGETS_UV: boolean;
  119147. NUM_MORPH_INFLUENCERS: number;
  119148. /** IMAGE PROCESSING */
  119149. IMAGEPROCESSING: boolean;
  119150. VIGNETTE: boolean;
  119151. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119152. VIGNETTEBLENDMODEOPAQUE: boolean;
  119153. TONEMAPPING: boolean;
  119154. TONEMAPPING_ACES: boolean;
  119155. CONTRAST: boolean;
  119156. EXPOSURE: boolean;
  119157. COLORCURVES: boolean;
  119158. COLORGRADING: boolean;
  119159. COLORGRADING3D: boolean;
  119160. SAMPLER3DGREENDEPTH: boolean;
  119161. SAMPLER3DBGRMAP: boolean;
  119162. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119163. /** MISC. */
  119164. BUMPDIRECTUV: number;
  119165. constructor();
  119166. setValue(name: string, value: boolean): void;
  119167. }
  119168. /**
  119169. * Class used to configure NodeMaterial
  119170. */
  119171. export interface INodeMaterialOptions {
  119172. /**
  119173. * Defines if blocks should emit comments
  119174. */
  119175. emitComments: boolean;
  119176. }
  119177. /**
  119178. * Class used to create a node based material built by assembling shader blocks
  119179. */
  119180. export class NodeMaterial extends PushMaterial {
  119181. private static _BuildIdGenerator;
  119182. private _options;
  119183. private _vertexCompilationState;
  119184. private _fragmentCompilationState;
  119185. private _sharedData;
  119186. private _buildId;
  119187. private _buildWasSuccessful;
  119188. private _cachedWorldViewMatrix;
  119189. private _cachedWorldViewProjectionMatrix;
  119190. private _optimizers;
  119191. private _animationFrame;
  119192. /** Define the URl to load node editor script */
  119193. static EditorURL: string;
  119194. private BJSNODEMATERIALEDITOR;
  119195. /** Get the inspector from bundle or global */
  119196. private _getGlobalNodeMaterialEditor;
  119197. /**
  119198. * 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)
  119199. */
  119200. ignoreAlpha: boolean;
  119201. /**
  119202. * Defines the maximum number of lights that can be used in the material
  119203. */
  119204. maxSimultaneousLights: number;
  119205. /**
  119206. * Observable raised when the material is built
  119207. */
  119208. onBuildObservable: Observable<NodeMaterial>;
  119209. /**
  119210. * Gets or sets the root nodes of the material vertex shader
  119211. */
  119212. _vertexOutputNodes: NodeMaterialBlock[];
  119213. /**
  119214. * Gets or sets the root nodes of the material fragment (pixel) shader
  119215. */
  119216. _fragmentOutputNodes: NodeMaterialBlock[];
  119217. /** Gets or sets options to control the node material overall behavior */
  119218. options: INodeMaterialOptions;
  119219. /**
  119220. * Default configuration related to image processing available in the standard Material.
  119221. */
  119222. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119223. /**
  119224. * Gets the image processing configuration used either in this material.
  119225. */
  119226. /**
  119227. * Sets the Default image processing configuration used either in the this material.
  119228. *
  119229. * If sets to null, the scene one is in use.
  119230. */
  119231. imageProcessingConfiguration: ImageProcessingConfiguration;
  119232. /**
  119233. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119234. */
  119235. attachedBlocks: NodeMaterialBlock[];
  119236. /**
  119237. * Create a new node based material
  119238. * @param name defines the material name
  119239. * @param scene defines the hosting scene
  119240. * @param options defines creation option
  119241. */
  119242. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119243. /**
  119244. * Gets the current class name of the material e.g. "NodeMaterial"
  119245. * @returns the class name
  119246. */
  119247. getClassName(): string;
  119248. /**
  119249. * Keep track of the image processing observer to allow dispose and replace.
  119250. */
  119251. private _imageProcessingObserver;
  119252. /**
  119253. * Attaches a new image processing configuration to the Standard Material.
  119254. * @param configuration
  119255. */
  119256. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119257. /**
  119258. * Get a block by its name
  119259. * @param name defines the name of the block to retrieve
  119260. * @returns the required block or null if not found
  119261. */
  119262. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119263. /**
  119264. * Get a block by its name
  119265. * @param predicate defines the predicate used to find the good candidate
  119266. * @returns the required block or null if not found
  119267. */
  119268. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119269. /**
  119270. * Get an input block by its name
  119271. * @param predicate defines the predicate used to find the good candidate
  119272. * @returns the required input block or null if not found
  119273. */
  119274. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119275. /**
  119276. * Gets the list of input blocks attached to this material
  119277. * @returns an array of InputBlocks
  119278. */
  119279. getInputBlocks(): InputBlock[];
  119280. /**
  119281. * Adds a new optimizer to the list of optimizers
  119282. * @param optimizer defines the optimizers to add
  119283. * @returns the current material
  119284. */
  119285. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119286. /**
  119287. * Remove an optimizer from the list of optimizers
  119288. * @param optimizer defines the optimizers to remove
  119289. * @returns the current material
  119290. */
  119291. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119292. /**
  119293. * Add a new block to the list of output nodes
  119294. * @param node defines the node to add
  119295. * @returns the current material
  119296. */
  119297. addOutputNode(node: NodeMaterialBlock): this;
  119298. /**
  119299. * Remove a block from the list of root nodes
  119300. * @param node defines the node to remove
  119301. * @returns the current material
  119302. */
  119303. removeOutputNode(node: NodeMaterialBlock): this;
  119304. private _addVertexOutputNode;
  119305. private _removeVertexOutputNode;
  119306. private _addFragmentOutputNode;
  119307. private _removeFragmentOutputNode;
  119308. /**
  119309. * Specifies if the material will require alpha blending
  119310. * @returns a boolean specifying if alpha blending is needed
  119311. */
  119312. needAlphaBlending(): boolean;
  119313. /**
  119314. * Specifies if this material should be rendered in alpha test mode
  119315. * @returns a boolean specifying if an alpha test is needed.
  119316. */
  119317. needAlphaTesting(): boolean;
  119318. private _initializeBlock;
  119319. private _resetDualBlocks;
  119320. /**
  119321. * Build the material and generates the inner effect
  119322. * @param verbose defines if the build should log activity
  119323. */
  119324. build(verbose?: boolean): void;
  119325. /**
  119326. * Runs an otpimization phase to try to improve the shader code
  119327. */
  119328. optimize(): void;
  119329. private _prepareDefinesForAttributes;
  119330. /**
  119331. * Get if the submesh is ready to be used and all its information available.
  119332. * Child classes can use it to update shaders
  119333. * @param mesh defines the mesh to check
  119334. * @param subMesh defines which submesh to check
  119335. * @param useInstances specifies that instances should be used
  119336. * @returns a boolean indicating that the submesh is ready or not
  119337. */
  119338. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119339. /**
  119340. * Get a string representing the shaders built by the current node graph
  119341. */
  119342. readonly compiledShaders: string;
  119343. /**
  119344. * Binds the world matrix to the material
  119345. * @param world defines the world transformation matrix
  119346. */
  119347. bindOnlyWorldMatrix(world: Matrix): void;
  119348. /**
  119349. * Binds the submesh to this material by preparing the effect and shader to draw
  119350. * @param world defines the world transformation matrix
  119351. * @param mesh defines the mesh containing the submesh
  119352. * @param subMesh defines the submesh to bind the material to
  119353. */
  119354. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119355. /**
  119356. * Gets the active textures from the material
  119357. * @returns an array of textures
  119358. */
  119359. getActiveTextures(): BaseTexture[];
  119360. /**
  119361. * Gets the list of texture blocks
  119362. * @returns an array of texture blocks
  119363. */
  119364. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119365. /**
  119366. * Specifies if the material uses a texture
  119367. * @param texture defines the texture to check against the material
  119368. * @returns a boolean specifying if the material uses the texture
  119369. */
  119370. hasTexture(texture: BaseTexture): boolean;
  119371. /**
  119372. * Disposes the material
  119373. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119374. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119375. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119376. */
  119377. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119378. /** Creates the node editor window. */
  119379. private _createNodeEditor;
  119380. /**
  119381. * Launch the node material editor
  119382. * @param config Define the configuration of the editor
  119383. * @return a promise fulfilled when the node editor is visible
  119384. */
  119385. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119386. /**
  119387. * Clear the current material
  119388. */
  119389. clear(): void;
  119390. /**
  119391. * Clear the current material and set it to a default state
  119392. */
  119393. setToDefault(): void;
  119394. /**
  119395. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119396. * @param url defines the url to load from
  119397. * @returns a promise that will fullfil when the material is fully loaded
  119398. */
  119399. loadAsync(url: string): Promise<unknown>;
  119400. private _gatherBlocks;
  119401. /**
  119402. * Generate a string containing the code declaration required to create an equivalent of this material
  119403. * @returns a string
  119404. */
  119405. generateCode(): string;
  119406. /**
  119407. * Serializes this material in a JSON representation
  119408. * @returns the serialized material object
  119409. */
  119410. serialize(): any;
  119411. private _restoreConnections;
  119412. /**
  119413. * Clear the current graph and load a new one from a serialization object
  119414. * @param source defines the JSON representation of the material
  119415. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119416. */
  119417. loadFromSerialization(source: any, rootUrl?: string): void;
  119418. /**
  119419. * Creates a node material from parsed material data
  119420. * @param source defines the JSON representation of the material
  119421. * @param scene defines the hosting scene
  119422. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119423. * @returns a new node material
  119424. */
  119425. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119426. /**
  119427. * Creates a new node material set to default basic configuration
  119428. * @param name defines the name of the material
  119429. * @param scene defines the hosting scene
  119430. * @returns a new NodeMaterial
  119431. */
  119432. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119433. }
  119434. }
  119435. declare module BABYLON {
  119436. /**
  119437. * Block used to read a texture from a sampler
  119438. */
  119439. export class TextureBlock extends NodeMaterialBlock {
  119440. private _defineName;
  119441. private _samplerName;
  119442. private _transformedUVName;
  119443. private _textureTransformName;
  119444. private _textureInfoName;
  119445. private _mainUVName;
  119446. private _mainUVDefineName;
  119447. /**
  119448. * Gets or sets the texture associated with the node
  119449. */
  119450. texture: Nullable<Texture>;
  119451. /**
  119452. * Create a new TextureBlock
  119453. * @param name defines the block name
  119454. */
  119455. constructor(name: string);
  119456. /**
  119457. * Gets the current class name
  119458. * @returns the class name
  119459. */
  119460. getClassName(): string;
  119461. /**
  119462. * Gets the uv input component
  119463. */
  119464. readonly uv: NodeMaterialConnectionPoint;
  119465. /**
  119466. * Gets the rgba output component
  119467. */
  119468. readonly rgba: NodeMaterialConnectionPoint;
  119469. /**
  119470. * Gets the rgb output component
  119471. */
  119472. readonly rgb: NodeMaterialConnectionPoint;
  119473. /**
  119474. * Gets the r output component
  119475. */
  119476. readonly r: NodeMaterialConnectionPoint;
  119477. /**
  119478. * Gets the g output component
  119479. */
  119480. readonly g: NodeMaterialConnectionPoint;
  119481. /**
  119482. * Gets the b output component
  119483. */
  119484. readonly b: NodeMaterialConnectionPoint;
  119485. /**
  119486. * Gets the a output component
  119487. */
  119488. readonly a: NodeMaterialConnectionPoint;
  119489. readonly target: NodeMaterialBlockTargets;
  119490. autoConfigure(material: NodeMaterial): void;
  119491. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119493. isReady(): boolean;
  119494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119495. private readonly _isMixed;
  119496. private _injectVertexCode;
  119497. private _writeOutput;
  119498. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119499. protected _dumpPropertiesCode(): string;
  119500. serialize(): any;
  119501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119502. }
  119503. }
  119504. declare module BABYLON {
  119505. /**
  119506. * Class used to store shared data between 2 NodeMaterialBuildState
  119507. */
  119508. export class NodeMaterialBuildStateSharedData {
  119509. /**
  119510. * Gets the list of emitted varyings
  119511. */
  119512. temps: string[];
  119513. /**
  119514. * Gets the list of emitted varyings
  119515. */
  119516. varyings: string[];
  119517. /**
  119518. * Gets the varying declaration string
  119519. */
  119520. varyingDeclaration: string;
  119521. /**
  119522. * Input blocks
  119523. */
  119524. inputBlocks: InputBlock[];
  119525. /**
  119526. * Input blocks
  119527. */
  119528. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  119529. /**
  119530. * Bindable blocks (Blocks that need to set data to the effect)
  119531. */
  119532. bindableBlocks: NodeMaterialBlock[];
  119533. /**
  119534. * List of blocks that can provide a compilation fallback
  119535. */
  119536. blocksWithFallbacks: NodeMaterialBlock[];
  119537. /**
  119538. * List of blocks that can provide a define update
  119539. */
  119540. blocksWithDefines: NodeMaterialBlock[];
  119541. /**
  119542. * List of blocks that can provide a repeatable content
  119543. */
  119544. repeatableContentBlocks: NodeMaterialBlock[];
  119545. /**
  119546. * List of blocks that can provide a dynamic list of uniforms
  119547. */
  119548. dynamicUniformBlocks: NodeMaterialBlock[];
  119549. /**
  119550. * List of blocks that can block the isReady function for the material
  119551. */
  119552. blockingBlocks: NodeMaterialBlock[];
  119553. /**
  119554. * Gets the list of animated inputs
  119555. */
  119556. animatedInputs: InputBlock[];
  119557. /**
  119558. * Build Id used to avoid multiple recompilations
  119559. */
  119560. buildId: number;
  119561. /** List of emitted variables */
  119562. variableNames: {
  119563. [key: string]: number;
  119564. };
  119565. /** List of emitted defines */
  119566. defineNames: {
  119567. [key: string]: number;
  119568. };
  119569. /** Should emit comments? */
  119570. emitComments: boolean;
  119571. /** Emit build activity */
  119572. verbose: boolean;
  119573. /** Gets or sets the hosting scene */
  119574. scene: Scene;
  119575. /**
  119576. * Gets the compilation hints emitted at compilation time
  119577. */
  119578. hints: {
  119579. needWorldViewMatrix: boolean;
  119580. needWorldViewProjectionMatrix: boolean;
  119581. needAlphaBlending: boolean;
  119582. needAlphaTesting: boolean;
  119583. };
  119584. /**
  119585. * List of compilation checks
  119586. */
  119587. checks: {
  119588. emitVertex: boolean;
  119589. emitFragment: boolean;
  119590. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  119591. };
  119592. /** Creates a new shared data */
  119593. constructor();
  119594. /**
  119595. * Emits console errors and exceptions if there is a failing check
  119596. */
  119597. emitErrors(): void;
  119598. }
  119599. }
  119600. declare module BABYLON {
  119601. /**
  119602. * Class used to store node based material build state
  119603. */
  119604. export class NodeMaterialBuildState {
  119605. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  119606. supportUniformBuffers: boolean;
  119607. /**
  119608. * Gets the list of emitted attributes
  119609. */
  119610. attributes: string[];
  119611. /**
  119612. * Gets the list of emitted uniforms
  119613. */
  119614. uniforms: string[];
  119615. /**
  119616. * Gets the list of emitted constants
  119617. */
  119618. constants: string[];
  119619. /**
  119620. * Gets the list of emitted uniform buffers
  119621. */
  119622. uniformBuffers: string[];
  119623. /**
  119624. * Gets the list of emitted samplers
  119625. */
  119626. samplers: string[];
  119627. /**
  119628. * Gets the list of emitted functions
  119629. */
  119630. functions: {
  119631. [key: string]: string;
  119632. };
  119633. /**
  119634. * Gets the list of emitted extensions
  119635. */
  119636. extensions: {
  119637. [key: string]: string;
  119638. };
  119639. /**
  119640. * Gets the target of the compilation state
  119641. */
  119642. target: NodeMaterialBlockTargets;
  119643. /**
  119644. * Gets the list of emitted counters
  119645. */
  119646. counters: {
  119647. [key: string]: number;
  119648. };
  119649. /**
  119650. * Shared data between multiple NodeMaterialBuildState instances
  119651. */
  119652. sharedData: NodeMaterialBuildStateSharedData;
  119653. /** @hidden */
  119654. _vertexState: NodeMaterialBuildState;
  119655. /** @hidden */
  119656. _attributeDeclaration: string;
  119657. /** @hidden */
  119658. _uniformDeclaration: string;
  119659. /** @hidden */
  119660. _constantDeclaration: string;
  119661. /** @hidden */
  119662. _samplerDeclaration: string;
  119663. /** @hidden */
  119664. _varyingTransfer: string;
  119665. private _repeatableContentAnchorIndex;
  119666. /** @hidden */
  119667. _builtCompilationString: string;
  119668. /**
  119669. * Gets the emitted compilation strings
  119670. */
  119671. compilationString: string;
  119672. /**
  119673. * Finalize the compilation strings
  119674. * @param state defines the current compilation state
  119675. */
  119676. finalize(state: NodeMaterialBuildState): void;
  119677. /** @hidden */
  119678. readonly _repeatableContentAnchor: string;
  119679. /** @hidden */
  119680. _getFreeVariableName(prefix: string): string;
  119681. /** @hidden */
  119682. _getFreeDefineName(prefix: string): string;
  119683. /** @hidden */
  119684. _excludeVariableName(name: string): void;
  119685. /** @hidden */
  119686. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  119687. /** @hidden */
  119688. _emitExtension(name: string, extension: string): void;
  119689. /** @hidden */
  119690. _emitFunction(name: string, code: string, comments: string): void;
  119691. /** @hidden */
  119692. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  119693. replaceStrings?: {
  119694. search: RegExp;
  119695. replace: string;
  119696. }[];
  119697. repeatKey?: string;
  119698. }): string;
  119699. /** @hidden */
  119700. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  119701. repeatKey?: string;
  119702. removeAttributes?: boolean;
  119703. removeUniforms?: boolean;
  119704. removeVaryings?: boolean;
  119705. removeIfDef?: boolean;
  119706. replaceStrings?: {
  119707. search: RegExp;
  119708. replace: string;
  119709. }[];
  119710. }, storeKey?: string): void;
  119711. /** @hidden */
  119712. _registerTempVariable(name: string): boolean;
  119713. /** @hidden */
  119714. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  119715. /** @hidden */
  119716. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  119717. }
  119718. }
  119719. declare module BABYLON {
  119720. /**
  119721. * Defines a block that can be used inside a node based material
  119722. */
  119723. export class NodeMaterialBlock {
  119724. private _buildId;
  119725. private _buildTarget;
  119726. private _target;
  119727. private _isFinalMerger;
  119728. private _isInput;
  119729. /** @hidden */
  119730. _codeVariableName: string;
  119731. /** @hidden */
  119732. _inputs: NodeMaterialConnectionPoint[];
  119733. /** @hidden */
  119734. _outputs: NodeMaterialConnectionPoint[];
  119735. /** @hidden */
  119736. _preparationId: number;
  119737. /**
  119738. * Gets or sets the name of the block
  119739. */
  119740. name: string;
  119741. /**
  119742. * Gets or sets the unique id of the node
  119743. */
  119744. uniqueId: number;
  119745. /**
  119746. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  119747. */
  119748. readonly isFinalMerger: boolean;
  119749. /**
  119750. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  119751. */
  119752. readonly isInput: boolean;
  119753. /**
  119754. * Gets or sets the build Id
  119755. */
  119756. buildId: number;
  119757. /**
  119758. * Gets or sets the target of the block
  119759. */
  119760. target: NodeMaterialBlockTargets;
  119761. /**
  119762. * Gets the list of input points
  119763. */
  119764. readonly inputs: NodeMaterialConnectionPoint[];
  119765. /** Gets the list of output points */
  119766. readonly outputs: NodeMaterialConnectionPoint[];
  119767. /**
  119768. * Find an input by its name
  119769. * @param name defines the name of the input to look for
  119770. * @returns the input or null if not found
  119771. */
  119772. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  119773. /**
  119774. * Find an output by its name
  119775. * @param name defines the name of the outputto look for
  119776. * @returns the output or null if not found
  119777. */
  119778. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  119779. /**
  119780. * Creates a new NodeMaterialBlock
  119781. * @param name defines the block name
  119782. * @param target defines the target of that block (Vertex by default)
  119783. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  119784. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  119785. */
  119786. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  119787. /**
  119788. * Initialize the block and prepare the context for build
  119789. * @param state defines the state that will be used for the build
  119790. */
  119791. initialize(state: NodeMaterialBuildState): void;
  119792. /**
  119793. * Bind data to effect. Will only be called for blocks with isBindable === true
  119794. * @param effect defines the effect to bind data to
  119795. * @param nodeMaterial defines the hosting NodeMaterial
  119796. * @param mesh defines the mesh that will be rendered
  119797. */
  119798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119799. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  119800. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  119801. protected _writeFloat(value: number): string;
  119802. /**
  119803. * Gets the current class name e.g. "NodeMaterialBlock"
  119804. * @returns the class name
  119805. */
  119806. getClassName(): string;
  119807. /**
  119808. * Register a new input. Must be called inside a block constructor
  119809. * @param name defines the connection point name
  119810. * @param type defines the connection point type
  119811. * @param isOptional defines a boolean indicating that this input can be omitted
  119812. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  119813. * @returns the current block
  119814. */
  119815. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  119816. /**
  119817. * Register a new output. Must be called inside a block constructor
  119818. * @param name defines the connection point name
  119819. * @param type defines the connection point type
  119820. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  119821. * @returns the current block
  119822. */
  119823. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  119824. /**
  119825. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  119826. * @param forOutput defines an optional connection point to check compatibility with
  119827. * @returns the first available input or null
  119828. */
  119829. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  119830. /**
  119831. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  119832. * @param forBlock defines an optional block to check compatibility with
  119833. * @returns the first available input or null
  119834. */
  119835. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  119836. /**
  119837. * Gets the sibling of the given output
  119838. * @param current defines the current output
  119839. * @returns the next output in the list or null
  119840. */
  119841. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  119842. /**
  119843. * Connect current block with another block
  119844. * @param other defines the block to connect with
  119845. * @param options define the various options to help pick the right connections
  119846. * @returns the current block
  119847. */
  119848. connectTo(other: NodeMaterialBlock, options?: {
  119849. input?: string;
  119850. output?: string;
  119851. outputSwizzle?: string;
  119852. }): this | undefined;
  119853. protected _buildBlock(state: NodeMaterialBuildState): void;
  119854. /**
  119855. * Add uniforms, samplers and uniform buffers at compilation time
  119856. * @param state defines the state to update
  119857. * @param nodeMaterial defines the node material requesting the update
  119858. * @param defines defines the material defines to update
  119859. */
  119860. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119861. /**
  119862. * Add potential fallbacks if shader compilation fails
  119863. * @param mesh defines the mesh to be rendered
  119864. * @param fallbacks defines the current prioritized list of fallbacks
  119865. */
  119866. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119867. /**
  119868. * Initialize defines for shader compilation
  119869. * @param mesh defines the mesh to be rendered
  119870. * @param nodeMaterial defines the node material requesting the update
  119871. * @param defines defines the material defines to update
  119872. * @param useInstances specifies that instances should be used
  119873. */
  119874. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119875. /**
  119876. * Update defines for shader compilation
  119877. * @param mesh defines the mesh to be rendered
  119878. * @param nodeMaterial defines the node material requesting the update
  119879. * @param defines defines the material defines to update
  119880. * @param useInstances specifies that instances should be used
  119881. */
  119882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119883. /**
  119884. * Lets the block try to connect some inputs automatically
  119885. * @param material defines the hosting NodeMaterial
  119886. */
  119887. autoConfigure(material: NodeMaterial): void;
  119888. /**
  119889. * Function called when a block is declared as repeatable content generator
  119890. * @param vertexShaderState defines the current compilation state for the vertex shader
  119891. * @param fragmentShaderState defines the current compilation state for the fragment shader
  119892. * @param mesh defines the mesh to be rendered
  119893. * @param defines defines the material defines to update
  119894. */
  119895. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119896. /**
  119897. * Checks if the block is ready
  119898. * @param mesh defines the mesh to be rendered
  119899. * @param nodeMaterial defines the node material requesting the update
  119900. * @param defines defines the material defines to update
  119901. * @param useInstances specifies that instances should be used
  119902. * @returns true if the block is ready
  119903. */
  119904. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  119905. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  119906. private _processBuild;
  119907. /**
  119908. * Compile the current node and generate the shader code
  119909. * @param state defines the current compilation state (uniforms, samplers, current string)
  119910. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  119911. * @returns true if already built
  119912. */
  119913. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  119914. protected _inputRename(name: string): string;
  119915. protected _outputRename(name: string): string;
  119916. protected _dumpPropertiesCode(): string;
  119917. /** @hidden */
  119918. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  119919. /**
  119920. * Clone the current block to a new identical block
  119921. * @param scene defines the hosting scene
  119922. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119923. * @returns a copy of the current block
  119924. */
  119925. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  119926. /**
  119927. * Serializes this block in a JSON representation
  119928. * @returns the serialized block object
  119929. */
  119930. serialize(): any;
  119931. /** @hidden */
  119932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119933. }
  119934. }
  119935. declare module BABYLON {
  119936. /**
  119937. * Enum defining the type of animations supported by InputBlock
  119938. */
  119939. export enum AnimatedInputBlockTypes {
  119940. /** No animation */
  119941. None = 0,
  119942. /** Time based animation. Will only work for floats */
  119943. Time = 1
  119944. }
  119945. }
  119946. declare module BABYLON {
  119947. /**
  119948. * Block used to expose an input value
  119949. */
  119950. export class InputBlock extends NodeMaterialBlock {
  119951. private _mode;
  119952. private _associatedVariableName;
  119953. private _storedValue;
  119954. private _valueCallback;
  119955. private _type;
  119956. private _animationType;
  119957. /** Gets or set a value used to limit the range of float values */
  119958. min: number;
  119959. /** Gets or set a value used to limit the range of float values */
  119960. max: number;
  119961. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  119962. matrixMode: number;
  119963. /** @hidden */
  119964. _systemValue: Nullable<NodeMaterialSystemValues>;
  119965. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  119966. visibleInInspector: boolean;
  119967. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  119968. isConstant: boolean;
  119969. /**
  119970. * Gets or sets the connection point type (default is float)
  119971. */
  119972. readonly type: NodeMaterialBlockConnectionPointTypes;
  119973. /**
  119974. * Creates a new InputBlock
  119975. * @param name defines the block name
  119976. * @param target defines the target of that block (Vertex by default)
  119977. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  119978. */
  119979. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  119980. /**
  119981. * Gets the output component
  119982. */
  119983. readonly output: NodeMaterialConnectionPoint;
  119984. /**
  119985. * Set the source of this connection point to a vertex attribute
  119986. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  119987. * @returns the current connection point
  119988. */
  119989. setAsAttribute(attributeName?: string): InputBlock;
  119990. /**
  119991. * Set the source of this connection point to a system value
  119992. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  119993. * @returns the current connection point
  119994. */
  119995. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  119996. /**
  119997. * Gets or sets the value of that point.
  119998. * Please note that this value will be ignored if valueCallback is defined
  119999. */
  120000. value: any;
  120001. /**
  120002. * Gets or sets a callback used to get the value of that point.
  120003. * Please note that setting this value will force the connection point to ignore the value property
  120004. */
  120005. valueCallback: () => any;
  120006. /**
  120007. * Gets or sets the associated variable name in the shader
  120008. */
  120009. associatedVariableName: string;
  120010. /** Gets or sets the type of animation applied to the input */
  120011. animationType: AnimatedInputBlockTypes;
  120012. /**
  120013. * Gets a boolean indicating that this connection point not defined yet
  120014. */
  120015. readonly isUndefined: boolean;
  120016. /**
  120017. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120018. * In this case the connection point name must be the name of the uniform to use.
  120019. * Can only be set on inputs
  120020. */
  120021. isUniform: boolean;
  120022. /**
  120023. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120024. * In this case the connection point name must be the name of the attribute to use
  120025. * Can only be set on inputs
  120026. */
  120027. isAttribute: boolean;
  120028. /**
  120029. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120030. * Can only be set on exit points
  120031. */
  120032. isVarying: boolean;
  120033. /**
  120034. * Gets a boolean indicating that the current connection point is a system value
  120035. */
  120036. readonly isSystemValue: boolean;
  120037. /**
  120038. * Gets or sets the current well known value or null if not defined as a system value
  120039. */
  120040. systemValue: Nullable<NodeMaterialSystemValues>;
  120041. /**
  120042. * Gets the current class name
  120043. * @returns the class name
  120044. */
  120045. getClassName(): string;
  120046. /**
  120047. * Animate the input if animationType !== None
  120048. * @param scene defines the rendering scene
  120049. */
  120050. animate(scene: Scene): void;
  120051. private _emitDefine;
  120052. initialize(state: NodeMaterialBuildState): void;
  120053. /**
  120054. * Set the input block to its default value (based on its type)
  120055. */
  120056. setDefaultValue(): void;
  120057. private _emitConstant;
  120058. private _emit;
  120059. /** @hidden */
  120060. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120061. /** @hidden */
  120062. _transmit(effect: Effect, scene: Scene): void;
  120063. protected _buildBlock(state: NodeMaterialBuildState): void;
  120064. protected _dumpPropertiesCode(): string;
  120065. serialize(): any;
  120066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120067. }
  120068. }
  120069. declare module BABYLON {
  120070. /**
  120071. * Defines a connection point for a block
  120072. */
  120073. export class NodeMaterialConnectionPoint {
  120074. /** @hidden */
  120075. _ownerBlock: NodeMaterialBlock;
  120076. /** @hidden */
  120077. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120078. private _endpoints;
  120079. private _associatedVariableName;
  120080. /** @hidden */
  120081. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120082. /** @hidden */
  120083. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120084. private _type;
  120085. /** @hidden */
  120086. _enforceAssociatedVariableName: boolean;
  120087. /**
  120088. * Gets or sets the additional types supported by this connection point
  120089. */
  120090. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120091. /**
  120092. * Gets or sets the additional types excluded by this connection point
  120093. */
  120094. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120095. /**
  120096. * Gets or sets the associated variable name in the shader
  120097. */
  120098. associatedVariableName: string;
  120099. /**
  120100. * Gets or sets the connection point type (default is float)
  120101. */
  120102. type: NodeMaterialBlockConnectionPointTypes;
  120103. /**
  120104. * Gets or sets the connection point name
  120105. */
  120106. name: string;
  120107. /**
  120108. * Gets or sets a boolean indicating that this connection point can be omitted
  120109. */
  120110. isOptional: boolean;
  120111. /**
  120112. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120113. */
  120114. define: string;
  120115. /** Gets or sets the target of that connection point */
  120116. target: NodeMaterialBlockTargets;
  120117. /**
  120118. * Gets a boolean indicating that the current point is connected
  120119. */
  120120. readonly isConnected: boolean;
  120121. /**
  120122. * Gets a boolean indicating that the current point is connected to an input block
  120123. */
  120124. readonly isConnectedToInputBlock: boolean;
  120125. /**
  120126. * Gets a the connected input block (if any)
  120127. */
  120128. readonly connectInputBlock: Nullable<InputBlock>;
  120129. /** Get the other side of the connection (if any) */
  120130. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120131. /** Get the block that owns this connection point */
  120132. readonly ownerBlock: NodeMaterialBlock;
  120133. /** Get the block connected on the other side of this connection (if any) */
  120134. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120135. /** Get the block connected on the endpoints of this connection (if any) */
  120136. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120137. /** Gets the list of connected endpoints */
  120138. readonly endpoints: NodeMaterialConnectionPoint[];
  120139. /** Gets a boolean indicating if that output point is connected to at least one input */
  120140. readonly hasEndpoints: boolean;
  120141. /**
  120142. * Creates a new connection point
  120143. * @param name defines the connection point name
  120144. * @param ownerBlock defines the block hosting this connection point
  120145. */
  120146. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120147. /**
  120148. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120149. * @returns the class name
  120150. */
  120151. getClassName(): string;
  120152. /**
  120153. * Gets an boolean indicating if the current point can be connected to another point
  120154. * @param connectionPoint defines the other connection point
  120155. * @returns true if the connection is possible
  120156. */
  120157. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120158. /**
  120159. * Connect this point to another connection point
  120160. * @param connectionPoint defines the other connection point
  120161. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120162. * @returns the current connection point
  120163. */
  120164. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120165. /**
  120166. * Disconnect this point from one of his endpoint
  120167. * @param endpoint defines the other connection point
  120168. * @returns the current connection point
  120169. */
  120170. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120171. /**
  120172. * Serializes this point in a JSON representation
  120173. * @returns the serialized point object
  120174. */
  120175. serialize(): any;
  120176. }
  120177. }
  120178. declare module BABYLON {
  120179. /**
  120180. * Block used to add support for vertex skinning (bones)
  120181. */
  120182. export class BonesBlock extends NodeMaterialBlock {
  120183. /**
  120184. * Creates a new BonesBlock
  120185. * @param name defines the block name
  120186. */
  120187. constructor(name: string);
  120188. /**
  120189. * Initialize the block and prepare the context for build
  120190. * @param state defines the state that will be used for the build
  120191. */
  120192. initialize(state: NodeMaterialBuildState): void;
  120193. /**
  120194. * Gets the current class name
  120195. * @returns the class name
  120196. */
  120197. getClassName(): string;
  120198. /**
  120199. * Gets the matrix indices input component
  120200. */
  120201. readonly matricesIndices: NodeMaterialConnectionPoint;
  120202. /**
  120203. * Gets the matrix weights input component
  120204. */
  120205. readonly matricesWeights: NodeMaterialConnectionPoint;
  120206. /**
  120207. * Gets the extra matrix indices input component
  120208. */
  120209. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120210. /**
  120211. * Gets the extra matrix weights input component
  120212. */
  120213. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120214. /**
  120215. * Gets the world input component
  120216. */
  120217. readonly world: NodeMaterialConnectionPoint;
  120218. /**
  120219. * Gets the output component
  120220. */
  120221. readonly output: NodeMaterialConnectionPoint;
  120222. autoConfigure(material: NodeMaterial): void;
  120223. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120226. protected _buildBlock(state: NodeMaterialBuildState): this;
  120227. }
  120228. }
  120229. declare module BABYLON {
  120230. /**
  120231. * Block used to add support for instances
  120232. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120233. */
  120234. export class InstancesBlock extends NodeMaterialBlock {
  120235. /**
  120236. * Creates a new InstancesBlock
  120237. * @param name defines the block name
  120238. */
  120239. constructor(name: string);
  120240. /**
  120241. * Gets the current class name
  120242. * @returns the class name
  120243. */
  120244. getClassName(): string;
  120245. /**
  120246. * Gets the first world row input component
  120247. */
  120248. readonly world0: NodeMaterialConnectionPoint;
  120249. /**
  120250. * Gets the second world row input component
  120251. */
  120252. readonly world1: NodeMaterialConnectionPoint;
  120253. /**
  120254. * Gets the third world row input component
  120255. */
  120256. readonly world2: NodeMaterialConnectionPoint;
  120257. /**
  120258. * Gets the forth world row input component
  120259. */
  120260. readonly world3: NodeMaterialConnectionPoint;
  120261. /**
  120262. * Gets the world input component
  120263. */
  120264. readonly world: NodeMaterialConnectionPoint;
  120265. /**
  120266. * Gets the output component
  120267. */
  120268. readonly output: NodeMaterialConnectionPoint;
  120269. autoConfigure(material: NodeMaterial): void;
  120270. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120271. protected _buildBlock(state: NodeMaterialBuildState): this;
  120272. }
  120273. }
  120274. declare module BABYLON {
  120275. /**
  120276. * Block used to add morph targets support to vertex shader
  120277. */
  120278. export class MorphTargetsBlock extends NodeMaterialBlock {
  120279. private _repeatableContentAnchor;
  120280. private _repeatebleContentGenerated;
  120281. /**
  120282. * Create a new MorphTargetsBlock
  120283. * @param name defines the block name
  120284. */
  120285. constructor(name: string);
  120286. /**
  120287. * Gets the current class name
  120288. * @returns the class name
  120289. */
  120290. getClassName(): string;
  120291. /**
  120292. * Gets the position input component
  120293. */
  120294. readonly position: NodeMaterialConnectionPoint;
  120295. /**
  120296. * Gets the normal input component
  120297. */
  120298. readonly normal: NodeMaterialConnectionPoint;
  120299. /**
  120300. * Gets the tangent input component
  120301. */
  120302. readonly tangent: NodeMaterialConnectionPoint;
  120303. /**
  120304. * Gets the tangent input component
  120305. */
  120306. readonly uv: NodeMaterialConnectionPoint;
  120307. /**
  120308. * Gets the position output component
  120309. */
  120310. readonly positionOutput: NodeMaterialConnectionPoint;
  120311. /**
  120312. * Gets the normal output component
  120313. */
  120314. readonly normalOutput: NodeMaterialConnectionPoint;
  120315. /**
  120316. * Gets the tangent output component
  120317. */
  120318. readonly tangentOutput: NodeMaterialConnectionPoint;
  120319. /**
  120320. * Gets the tangent output component
  120321. */
  120322. readonly uvOutput: NodeMaterialConnectionPoint;
  120323. initialize(state: NodeMaterialBuildState): void;
  120324. autoConfigure(material: NodeMaterial): void;
  120325. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120327. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120328. protected _buildBlock(state: NodeMaterialBuildState): this;
  120329. }
  120330. }
  120331. declare module BABYLON {
  120332. /**
  120333. * Block used to get data information from a light
  120334. */
  120335. export class LightInformationBlock extends NodeMaterialBlock {
  120336. private _lightDataUniformName;
  120337. private _lightColorUniformName;
  120338. private _lightTypeDefineName;
  120339. /**
  120340. * Gets or sets the light associated with this block
  120341. */
  120342. light: Nullable<Light>;
  120343. /**
  120344. * Creates a new LightInformationBlock
  120345. * @param name defines the block name
  120346. */
  120347. constructor(name: string);
  120348. /**
  120349. * Gets the current class name
  120350. * @returns the class name
  120351. */
  120352. getClassName(): string;
  120353. /**
  120354. * Gets the world position input component
  120355. */
  120356. readonly worldPosition: NodeMaterialConnectionPoint;
  120357. /**
  120358. * Gets the direction output component
  120359. */
  120360. readonly direction: NodeMaterialConnectionPoint;
  120361. /**
  120362. * Gets the direction output component
  120363. */
  120364. readonly color: NodeMaterialConnectionPoint;
  120365. /**
  120366. * Gets the direction output component
  120367. */
  120368. readonly intensity: NodeMaterialConnectionPoint;
  120369. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120370. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120371. protected _buildBlock(state: NodeMaterialBuildState): this;
  120372. serialize(): any;
  120373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120374. }
  120375. }
  120376. declare module BABYLON {
  120377. /**
  120378. * Block used to add image processing support to fragment shader
  120379. */
  120380. export class ImageProcessingBlock extends NodeMaterialBlock {
  120381. /**
  120382. * Create a new ImageProcessingBlock
  120383. * @param name defines the block name
  120384. */
  120385. constructor(name: string);
  120386. /**
  120387. * Gets the current class name
  120388. * @returns the class name
  120389. */
  120390. getClassName(): string;
  120391. /**
  120392. * Gets the color input component
  120393. */
  120394. readonly color: NodeMaterialConnectionPoint;
  120395. /**
  120396. * Gets the output component
  120397. */
  120398. readonly output: NodeMaterialConnectionPoint;
  120399. /**
  120400. * Initialize the block and prepare the context for build
  120401. * @param state defines the state that will be used for the build
  120402. */
  120403. initialize(state: NodeMaterialBuildState): void;
  120404. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120406. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120407. protected _buildBlock(state: NodeMaterialBuildState): this;
  120408. }
  120409. }
  120410. declare module BABYLON {
  120411. /**
  120412. * Block used to pertub normals based on a normal map
  120413. */
  120414. export class PerturbNormalBlock extends NodeMaterialBlock {
  120415. private _tangentSpaceParameterName;
  120416. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120417. invertX: boolean;
  120418. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120419. invertY: boolean;
  120420. /**
  120421. * Create a new PerturbNormalBlock
  120422. * @param name defines the block name
  120423. */
  120424. constructor(name: string);
  120425. /**
  120426. * Gets the current class name
  120427. * @returns the class name
  120428. */
  120429. getClassName(): string;
  120430. /**
  120431. * Gets the world position input component
  120432. */
  120433. readonly worldPosition: NodeMaterialConnectionPoint;
  120434. /**
  120435. * Gets the world normal input component
  120436. */
  120437. readonly worldNormal: NodeMaterialConnectionPoint;
  120438. /**
  120439. * Gets the uv input component
  120440. */
  120441. readonly uv: NodeMaterialConnectionPoint;
  120442. /**
  120443. * Gets the normal map color input component
  120444. */
  120445. readonly normalMapColor: NodeMaterialConnectionPoint;
  120446. /**
  120447. * Gets the strength input component
  120448. */
  120449. readonly strength: NodeMaterialConnectionPoint;
  120450. /**
  120451. * Gets the output component
  120452. */
  120453. readonly output: NodeMaterialConnectionPoint;
  120454. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120456. autoConfigure(material: NodeMaterial): void;
  120457. protected _buildBlock(state: NodeMaterialBuildState): this;
  120458. protected _dumpPropertiesCode(): string;
  120459. serialize(): any;
  120460. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120461. }
  120462. }
  120463. declare module BABYLON {
  120464. /**
  120465. * Block used to discard a pixel if a value is smaller than a cutoff
  120466. */
  120467. export class DiscardBlock extends NodeMaterialBlock {
  120468. /**
  120469. * Create a new DiscardBlock
  120470. * @param name defines the block name
  120471. */
  120472. constructor(name: string);
  120473. /**
  120474. * Gets the current class name
  120475. * @returns the class name
  120476. */
  120477. getClassName(): string;
  120478. /**
  120479. * Gets the color input component
  120480. */
  120481. readonly value: NodeMaterialConnectionPoint;
  120482. /**
  120483. * Gets the cutoff input component
  120484. */
  120485. readonly cutoff: NodeMaterialConnectionPoint;
  120486. protected _buildBlock(state: NodeMaterialBuildState): this;
  120487. }
  120488. }
  120489. declare module BABYLON {
  120490. /**
  120491. * Block used to add support for scene fog
  120492. */
  120493. export class FogBlock extends NodeMaterialBlock {
  120494. private _fogDistanceName;
  120495. private _fogParameters;
  120496. /**
  120497. * Create a new FogBlock
  120498. * @param name defines the block name
  120499. */
  120500. constructor(name: string);
  120501. /**
  120502. * Gets the current class name
  120503. * @returns the class name
  120504. */
  120505. getClassName(): string;
  120506. /**
  120507. * Gets the world position input component
  120508. */
  120509. readonly worldPosition: NodeMaterialConnectionPoint;
  120510. /**
  120511. * Gets the view input component
  120512. */
  120513. readonly view: NodeMaterialConnectionPoint;
  120514. /**
  120515. * Gets the color input component
  120516. */
  120517. readonly input: NodeMaterialConnectionPoint;
  120518. /**
  120519. * Gets the fog color input component
  120520. */
  120521. readonly fogColor: NodeMaterialConnectionPoint;
  120522. /**
  120523. * Gets the output component
  120524. */
  120525. readonly output: NodeMaterialConnectionPoint;
  120526. autoConfigure(material: NodeMaterial): void;
  120527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120528. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120529. protected _buildBlock(state: NodeMaterialBuildState): this;
  120530. }
  120531. }
  120532. declare module BABYLON {
  120533. /**
  120534. * Block used to add light in the fragment shader
  120535. */
  120536. export class LightBlock extends NodeMaterialBlock {
  120537. private _lightId;
  120538. /**
  120539. * Gets or sets the light associated with this block
  120540. */
  120541. light: Nullable<Light>;
  120542. /**
  120543. * Create a new LightBlock
  120544. * @param name defines the block name
  120545. */
  120546. constructor(name: string);
  120547. /**
  120548. * Gets the current class name
  120549. * @returns the class name
  120550. */
  120551. getClassName(): string;
  120552. /**
  120553. * Gets the world position input component
  120554. */
  120555. readonly worldPosition: NodeMaterialConnectionPoint;
  120556. /**
  120557. * Gets the world normal input component
  120558. */
  120559. readonly worldNormal: NodeMaterialConnectionPoint;
  120560. /**
  120561. * Gets the camera (or eye) position component
  120562. */
  120563. readonly cameraPosition: NodeMaterialConnectionPoint;
  120564. /**
  120565. * Gets the glossiness component
  120566. */
  120567. readonly glossiness: NodeMaterialConnectionPoint;
  120568. /**
  120569. * Gets the diffuse color component
  120570. */
  120571. readonly diffuseColor: NodeMaterialConnectionPoint;
  120572. /**
  120573. * Gets the specular color component
  120574. */
  120575. readonly specularColor: NodeMaterialConnectionPoint;
  120576. /**
  120577. * Gets the diffuse output component
  120578. */
  120579. readonly diffuseOutput: NodeMaterialConnectionPoint;
  120580. /**
  120581. * Gets the specular output component
  120582. */
  120583. readonly specularOutput: NodeMaterialConnectionPoint;
  120584. autoConfigure(material: NodeMaterial): void;
  120585. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120586. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120588. private _injectVertexCode;
  120589. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120590. serialize(): any;
  120591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120592. }
  120593. }
  120594. declare module BABYLON {
  120595. /**
  120596. * Block used to multiply 2 values
  120597. */
  120598. export class MultiplyBlock extends NodeMaterialBlock {
  120599. /**
  120600. * Creates a new MultiplyBlock
  120601. * @param name defines the block name
  120602. */
  120603. constructor(name: string);
  120604. /**
  120605. * Gets the current class name
  120606. * @returns the class name
  120607. */
  120608. getClassName(): string;
  120609. /**
  120610. * Gets the left operand input component
  120611. */
  120612. readonly left: NodeMaterialConnectionPoint;
  120613. /**
  120614. * Gets the right operand input component
  120615. */
  120616. readonly right: NodeMaterialConnectionPoint;
  120617. /**
  120618. * Gets the output component
  120619. */
  120620. readonly output: NodeMaterialConnectionPoint;
  120621. protected _buildBlock(state: NodeMaterialBuildState): this;
  120622. }
  120623. }
  120624. declare module BABYLON {
  120625. /**
  120626. * Block used to add 2 vectors
  120627. */
  120628. export class AddBlock extends NodeMaterialBlock {
  120629. /**
  120630. * Creates a new AddBlock
  120631. * @param name defines the block name
  120632. */
  120633. constructor(name: string);
  120634. /**
  120635. * Gets the current class name
  120636. * @returns the class name
  120637. */
  120638. getClassName(): string;
  120639. /**
  120640. * Gets the left operand input component
  120641. */
  120642. readonly left: NodeMaterialConnectionPoint;
  120643. /**
  120644. * Gets the right operand input component
  120645. */
  120646. readonly right: NodeMaterialConnectionPoint;
  120647. /**
  120648. * Gets the output component
  120649. */
  120650. readonly output: NodeMaterialConnectionPoint;
  120651. protected _buildBlock(state: NodeMaterialBuildState): this;
  120652. }
  120653. }
  120654. declare module BABYLON {
  120655. /**
  120656. * Block used to scale a vector by a float
  120657. */
  120658. export class ScaleBlock extends NodeMaterialBlock {
  120659. /**
  120660. * Creates a new ScaleBlock
  120661. * @param name defines the block name
  120662. */
  120663. constructor(name: string);
  120664. /**
  120665. * Gets the current class name
  120666. * @returns the class name
  120667. */
  120668. getClassName(): string;
  120669. /**
  120670. * Gets the input component
  120671. */
  120672. readonly input: NodeMaterialConnectionPoint;
  120673. /**
  120674. * Gets the factor input component
  120675. */
  120676. readonly factor: NodeMaterialConnectionPoint;
  120677. /**
  120678. * Gets the output component
  120679. */
  120680. readonly output: NodeMaterialConnectionPoint;
  120681. protected _buildBlock(state: NodeMaterialBuildState): this;
  120682. }
  120683. }
  120684. declare module BABYLON {
  120685. /**
  120686. * Block used to clamp a float
  120687. */
  120688. export class ClampBlock extends NodeMaterialBlock {
  120689. /** Gets or sets the minimum range */
  120690. minimum: number;
  120691. /** Gets or sets the maximum range */
  120692. maximum: number;
  120693. /**
  120694. * Creates a new ClampBlock
  120695. * @param name defines the block name
  120696. */
  120697. constructor(name: string);
  120698. /**
  120699. * Gets the current class name
  120700. * @returns the class name
  120701. */
  120702. getClassName(): string;
  120703. /**
  120704. * Gets the value input component
  120705. */
  120706. readonly value: NodeMaterialConnectionPoint;
  120707. /**
  120708. * Gets the output component
  120709. */
  120710. readonly output: NodeMaterialConnectionPoint;
  120711. protected _buildBlock(state: NodeMaterialBuildState): this;
  120712. protected _dumpPropertiesCode(): string;
  120713. serialize(): any;
  120714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120715. }
  120716. }
  120717. declare module BABYLON {
  120718. /**
  120719. * Block used to apply a cross product between 2 vectors
  120720. */
  120721. export class CrossBlock extends NodeMaterialBlock {
  120722. /**
  120723. * Creates a new CrossBlock
  120724. * @param name defines the block name
  120725. */
  120726. constructor(name: string);
  120727. /**
  120728. * Gets the current class name
  120729. * @returns the class name
  120730. */
  120731. getClassName(): string;
  120732. /**
  120733. * Gets the left operand input component
  120734. */
  120735. readonly left: NodeMaterialConnectionPoint;
  120736. /**
  120737. * Gets the right operand input component
  120738. */
  120739. readonly right: NodeMaterialConnectionPoint;
  120740. /**
  120741. * Gets the output component
  120742. */
  120743. readonly output: NodeMaterialConnectionPoint;
  120744. protected _buildBlock(state: NodeMaterialBuildState): this;
  120745. }
  120746. }
  120747. declare module BABYLON {
  120748. /**
  120749. * Block used to apply a dot product between 2 vectors
  120750. */
  120751. export class DotBlock extends NodeMaterialBlock {
  120752. /**
  120753. * Creates a new DotBlock
  120754. * @param name defines the block name
  120755. */
  120756. constructor(name: string);
  120757. /**
  120758. * Gets the current class name
  120759. * @returns the class name
  120760. */
  120761. getClassName(): string;
  120762. /**
  120763. * Gets the left operand input component
  120764. */
  120765. readonly left: NodeMaterialConnectionPoint;
  120766. /**
  120767. * Gets the right operand input component
  120768. */
  120769. readonly right: NodeMaterialConnectionPoint;
  120770. /**
  120771. * Gets the output component
  120772. */
  120773. readonly output: NodeMaterialConnectionPoint;
  120774. protected _buildBlock(state: NodeMaterialBuildState): this;
  120775. }
  120776. }
  120777. declare module BABYLON {
  120778. /**
  120779. * Block used to remap a float from a range to a new one
  120780. */
  120781. export class RemapBlock extends NodeMaterialBlock {
  120782. /**
  120783. * Gets or sets the source range
  120784. */
  120785. sourceRange: Vector2;
  120786. /**
  120787. * Gets or sets the target range
  120788. */
  120789. targetRange: Vector2;
  120790. /**
  120791. * Creates a new RemapBlock
  120792. * @param name defines the block name
  120793. */
  120794. constructor(name: string);
  120795. /**
  120796. * Gets the current class name
  120797. * @returns the class name
  120798. */
  120799. getClassName(): string;
  120800. /**
  120801. * Gets the input component
  120802. */
  120803. readonly input: NodeMaterialConnectionPoint;
  120804. /**
  120805. * Gets the source min input component
  120806. */
  120807. readonly sourceMin: NodeMaterialConnectionPoint;
  120808. /**
  120809. * Gets the source max input component
  120810. */
  120811. readonly sourceMax: NodeMaterialConnectionPoint;
  120812. /**
  120813. * Gets the target min input component
  120814. */
  120815. readonly targetMin: NodeMaterialConnectionPoint;
  120816. /**
  120817. * Gets the target max input component
  120818. */
  120819. readonly targetMax: NodeMaterialConnectionPoint;
  120820. /**
  120821. * Gets the output component
  120822. */
  120823. readonly output: NodeMaterialConnectionPoint;
  120824. protected _buildBlock(state: NodeMaterialBuildState): this;
  120825. protected _dumpPropertiesCode(): string;
  120826. serialize(): any;
  120827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120828. }
  120829. }
  120830. declare module BABYLON {
  120831. /**
  120832. * Block used to normalize a vector
  120833. */
  120834. export class NormalizeBlock extends NodeMaterialBlock {
  120835. /**
  120836. * Creates a new NormalizeBlock
  120837. * @param name defines the block name
  120838. */
  120839. constructor(name: string);
  120840. /**
  120841. * Gets the current class name
  120842. * @returns the class name
  120843. */
  120844. getClassName(): string;
  120845. /**
  120846. * Gets the input component
  120847. */
  120848. readonly input: NodeMaterialConnectionPoint;
  120849. /**
  120850. * Gets the output component
  120851. */
  120852. readonly output: NodeMaterialConnectionPoint;
  120853. protected _buildBlock(state: NodeMaterialBuildState): this;
  120854. }
  120855. }
  120856. declare module BABYLON {
  120857. /**
  120858. * Operations supported by the Trigonometry block
  120859. */
  120860. export enum TrigonometryBlockOperations {
  120861. /** Cos */
  120862. Cos = 0,
  120863. /** Sin */
  120864. Sin = 1,
  120865. /** Abs */
  120866. Abs = 2,
  120867. /** Exp */
  120868. Exp = 3,
  120869. /** Exp2 */
  120870. Exp2 = 4,
  120871. /** Round */
  120872. Round = 5,
  120873. /** Floor */
  120874. Floor = 6,
  120875. /** Ceiling */
  120876. Ceiling = 7,
  120877. /** Square root */
  120878. Sqrt = 8,
  120879. /** Log */
  120880. Log = 9,
  120881. /** Tangent */
  120882. Tan = 10,
  120883. /** Arc tangent */
  120884. ATan = 11,
  120885. /** Arc cosinus */
  120886. ACos = 12,
  120887. /** Arc sinus */
  120888. ASin = 13,
  120889. /** Fraction */
  120890. Fract = 14,
  120891. /** Sign */
  120892. Sign = 15
  120893. }
  120894. /**
  120895. * Block used to apply trigonometry operation to floats
  120896. */
  120897. export class TrigonometryBlock extends NodeMaterialBlock {
  120898. /**
  120899. * Gets or sets the operation applied by the block
  120900. */
  120901. operation: TrigonometryBlockOperations;
  120902. /**
  120903. * Creates a new TrigonometryBlock
  120904. * @param name defines the block name
  120905. */
  120906. constructor(name: string);
  120907. /**
  120908. * Gets the current class name
  120909. * @returns the class name
  120910. */
  120911. getClassName(): string;
  120912. /**
  120913. * Gets the input component
  120914. */
  120915. readonly input: NodeMaterialConnectionPoint;
  120916. /**
  120917. * Gets the output component
  120918. */
  120919. readonly output: NodeMaterialConnectionPoint;
  120920. protected _buildBlock(state: NodeMaterialBuildState): this;
  120921. serialize(): any;
  120922. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120923. }
  120924. }
  120925. declare module BABYLON {
  120926. /**
  120927. * Block used to create a Color3/4 out of individual inputs (one for each component)
  120928. */
  120929. export class ColorMergerBlock extends NodeMaterialBlock {
  120930. /**
  120931. * Create a new ColorMergerBlock
  120932. * @param name defines the block name
  120933. */
  120934. constructor(name: string);
  120935. /**
  120936. * Gets the current class name
  120937. * @returns the class name
  120938. */
  120939. getClassName(): string;
  120940. /**
  120941. * Gets the r component (input)
  120942. */
  120943. readonly r: NodeMaterialConnectionPoint;
  120944. /**
  120945. * Gets the g component (input)
  120946. */
  120947. readonly g: NodeMaterialConnectionPoint;
  120948. /**
  120949. * Gets the b component (input)
  120950. */
  120951. readonly b: NodeMaterialConnectionPoint;
  120952. /**
  120953. * Gets the a component (input)
  120954. */
  120955. readonly a: NodeMaterialConnectionPoint;
  120956. /**
  120957. * Gets the rgba component (output)
  120958. */
  120959. readonly rgba: NodeMaterialConnectionPoint;
  120960. /**
  120961. * Gets the rgb component (output)
  120962. */
  120963. readonly rgb: NodeMaterialConnectionPoint;
  120964. protected _buildBlock(state: NodeMaterialBuildState): this;
  120965. }
  120966. }
  120967. declare module BABYLON {
  120968. /**
  120969. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  120970. */
  120971. export class VectorMergerBlock extends NodeMaterialBlock {
  120972. /**
  120973. * Create a new VectorMergerBlock
  120974. * @param name defines the block name
  120975. */
  120976. constructor(name: string);
  120977. /**
  120978. * Gets the current class name
  120979. * @returns the class name
  120980. */
  120981. getClassName(): string;
  120982. /**
  120983. * Gets the x component (input)
  120984. */
  120985. readonly x: NodeMaterialConnectionPoint;
  120986. /**
  120987. * Gets the y component (input)
  120988. */
  120989. readonly y: NodeMaterialConnectionPoint;
  120990. /**
  120991. * Gets the z component (input)
  120992. */
  120993. readonly z: NodeMaterialConnectionPoint;
  120994. /**
  120995. * Gets the w component (input)
  120996. */
  120997. readonly w: NodeMaterialConnectionPoint;
  120998. /**
  120999. * Gets the xyzw component (output)
  121000. */
  121001. readonly xyzw: NodeMaterialConnectionPoint;
  121002. /**
  121003. * Gets the xyz component (output)
  121004. */
  121005. readonly xyz: NodeMaterialConnectionPoint;
  121006. /**
  121007. * Gets the xy component (output)
  121008. */
  121009. readonly xy: NodeMaterialConnectionPoint;
  121010. protected _buildBlock(state: NodeMaterialBuildState): this;
  121011. }
  121012. }
  121013. declare module BABYLON {
  121014. /**
  121015. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121016. */
  121017. export class ColorSplitterBlock extends NodeMaterialBlock {
  121018. /**
  121019. * Create a new ColorSplitterBlock
  121020. * @param name defines the block name
  121021. */
  121022. constructor(name: string);
  121023. /**
  121024. * Gets the current class name
  121025. * @returns the class name
  121026. */
  121027. getClassName(): string;
  121028. /**
  121029. * Gets the rgba component (input)
  121030. */
  121031. readonly rgba: NodeMaterialConnectionPoint;
  121032. /**
  121033. * Gets the rgb component (input)
  121034. */
  121035. readonly rgbIn: NodeMaterialConnectionPoint;
  121036. /**
  121037. * Gets the rgb component (output)
  121038. */
  121039. readonly rgbOut: NodeMaterialConnectionPoint;
  121040. /**
  121041. * Gets the r component (output)
  121042. */
  121043. readonly r: NodeMaterialConnectionPoint;
  121044. /**
  121045. * Gets the g component (output)
  121046. */
  121047. readonly g: NodeMaterialConnectionPoint;
  121048. /**
  121049. * Gets the b component (output)
  121050. */
  121051. readonly b: NodeMaterialConnectionPoint;
  121052. /**
  121053. * Gets the a component (output)
  121054. */
  121055. readonly a: NodeMaterialConnectionPoint;
  121056. protected _inputRename(name: string): string;
  121057. protected _outputRename(name: string): string;
  121058. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121059. }
  121060. }
  121061. declare module BABYLON {
  121062. /**
  121063. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121064. */
  121065. export class VectorSplitterBlock extends NodeMaterialBlock {
  121066. /**
  121067. * Create a new VectorSplitterBlock
  121068. * @param name defines the block name
  121069. */
  121070. constructor(name: string);
  121071. /**
  121072. * Gets the current class name
  121073. * @returns the class name
  121074. */
  121075. getClassName(): string;
  121076. /**
  121077. * Gets the xyzw component (input)
  121078. */
  121079. readonly xyzw: NodeMaterialConnectionPoint;
  121080. /**
  121081. * Gets the xyz component (input)
  121082. */
  121083. readonly xyzIn: NodeMaterialConnectionPoint;
  121084. /**
  121085. * Gets the xy component (input)
  121086. */
  121087. readonly xyIn: NodeMaterialConnectionPoint;
  121088. /**
  121089. * Gets the xyz component (output)
  121090. */
  121091. readonly xyzOut: NodeMaterialConnectionPoint;
  121092. /**
  121093. * Gets the xy component (output)
  121094. */
  121095. readonly xyOut: NodeMaterialConnectionPoint;
  121096. /**
  121097. * Gets the x component (output)
  121098. */
  121099. readonly x: NodeMaterialConnectionPoint;
  121100. /**
  121101. * Gets the y component (output)
  121102. */
  121103. readonly y: NodeMaterialConnectionPoint;
  121104. /**
  121105. * Gets the z component (output)
  121106. */
  121107. readonly z: NodeMaterialConnectionPoint;
  121108. /**
  121109. * Gets the w component (output)
  121110. */
  121111. readonly w: NodeMaterialConnectionPoint;
  121112. protected _inputRename(name: string): string;
  121113. protected _outputRename(name: string): string;
  121114. protected _buildBlock(state: NodeMaterialBuildState): this;
  121115. }
  121116. }
  121117. declare module BABYLON {
  121118. /**
  121119. * Block used to lerp 2 values
  121120. */
  121121. export class LerpBlock extends NodeMaterialBlock {
  121122. /**
  121123. * Creates a new LerpBlock
  121124. * @param name defines the block name
  121125. */
  121126. constructor(name: string);
  121127. /**
  121128. * Gets the current class name
  121129. * @returns the class name
  121130. */
  121131. getClassName(): string;
  121132. /**
  121133. * Gets the left operand input component
  121134. */
  121135. readonly left: NodeMaterialConnectionPoint;
  121136. /**
  121137. * Gets the right operand input component
  121138. */
  121139. readonly right: NodeMaterialConnectionPoint;
  121140. /**
  121141. * Gets the gradient operand input component
  121142. */
  121143. readonly gradient: NodeMaterialConnectionPoint;
  121144. /**
  121145. * Gets the output component
  121146. */
  121147. readonly output: NodeMaterialConnectionPoint;
  121148. protected _buildBlock(state: NodeMaterialBuildState): this;
  121149. }
  121150. }
  121151. declare module BABYLON {
  121152. /**
  121153. * Block used to divide 2 vectors
  121154. */
  121155. export class DivideBlock extends NodeMaterialBlock {
  121156. /**
  121157. * Creates a new DivideBlock
  121158. * @param name defines the block name
  121159. */
  121160. constructor(name: string);
  121161. /**
  121162. * Gets the current class name
  121163. * @returns the class name
  121164. */
  121165. getClassName(): string;
  121166. /**
  121167. * Gets the left operand input component
  121168. */
  121169. readonly left: NodeMaterialConnectionPoint;
  121170. /**
  121171. * Gets the right operand input component
  121172. */
  121173. readonly right: NodeMaterialConnectionPoint;
  121174. /**
  121175. * Gets the output component
  121176. */
  121177. readonly output: NodeMaterialConnectionPoint;
  121178. protected _buildBlock(state: NodeMaterialBuildState): this;
  121179. }
  121180. }
  121181. declare module BABYLON {
  121182. /**
  121183. * Block used to subtract 2 vectors
  121184. */
  121185. export class SubtractBlock extends NodeMaterialBlock {
  121186. /**
  121187. * Creates a new SubtractBlock
  121188. * @param name defines the block name
  121189. */
  121190. constructor(name: string);
  121191. /**
  121192. * Gets the current class name
  121193. * @returns the class name
  121194. */
  121195. getClassName(): string;
  121196. /**
  121197. * Gets the left operand input component
  121198. */
  121199. readonly left: NodeMaterialConnectionPoint;
  121200. /**
  121201. * Gets the right operand input component
  121202. */
  121203. readonly right: NodeMaterialConnectionPoint;
  121204. /**
  121205. * Gets the output component
  121206. */
  121207. readonly output: NodeMaterialConnectionPoint;
  121208. protected _buildBlock(state: NodeMaterialBuildState): this;
  121209. }
  121210. }
  121211. declare module BABYLON {
  121212. /**
  121213. * Block used to step a value
  121214. */
  121215. export class StepBlock extends NodeMaterialBlock {
  121216. /**
  121217. * Creates a new AddBlock
  121218. * @param name defines the block name
  121219. */
  121220. constructor(name: string);
  121221. /**
  121222. * Gets the current class name
  121223. * @returns the class name
  121224. */
  121225. getClassName(): string;
  121226. /**
  121227. * Gets the value operand input component
  121228. */
  121229. readonly value: NodeMaterialConnectionPoint;
  121230. /**
  121231. * Gets the edge operand input component
  121232. */
  121233. readonly edge: NodeMaterialConnectionPoint;
  121234. /**
  121235. * Gets the output component
  121236. */
  121237. readonly output: NodeMaterialConnectionPoint;
  121238. protected _buildBlock(state: NodeMaterialBuildState): this;
  121239. }
  121240. }
  121241. declare module BABYLON {
  121242. /**
  121243. * Block used to get the opposite (1 - x) of a value
  121244. */
  121245. export class OneMinusBlock extends NodeMaterialBlock {
  121246. /**
  121247. * Creates a new OneMinusBlock
  121248. * @param name defines the block name
  121249. */
  121250. constructor(name: string);
  121251. /**
  121252. * Gets the current class name
  121253. * @returns the class name
  121254. */
  121255. getClassName(): string;
  121256. /**
  121257. * Gets the input component
  121258. */
  121259. readonly input: NodeMaterialConnectionPoint;
  121260. /**
  121261. * Gets the output component
  121262. */
  121263. readonly output: NodeMaterialConnectionPoint;
  121264. protected _buildBlock(state: NodeMaterialBuildState): this;
  121265. }
  121266. }
  121267. declare module BABYLON {
  121268. /**
  121269. * Block used to get the view direction
  121270. */
  121271. export class ViewDirectionBlock extends NodeMaterialBlock {
  121272. /**
  121273. * Creates a new ViewDirectionBlock
  121274. * @param name defines the block name
  121275. */
  121276. constructor(name: string);
  121277. /**
  121278. * Gets the current class name
  121279. * @returns the class name
  121280. */
  121281. getClassName(): string;
  121282. /**
  121283. * Gets the world position component
  121284. */
  121285. readonly worldPosition: NodeMaterialConnectionPoint;
  121286. /**
  121287. * Gets the camera position component
  121288. */
  121289. readonly cameraPosition: NodeMaterialConnectionPoint;
  121290. /**
  121291. * Gets the output component
  121292. */
  121293. readonly output: NodeMaterialConnectionPoint;
  121294. autoConfigure(material: NodeMaterial): void;
  121295. protected _buildBlock(state: NodeMaterialBuildState): this;
  121296. }
  121297. }
  121298. declare module BABYLON {
  121299. /**
  121300. * Block used to compute fresnel value
  121301. */
  121302. export class FresnelBlock extends NodeMaterialBlock {
  121303. /**
  121304. * Create a new FresnelBlock
  121305. * @param name defines the block name
  121306. */
  121307. constructor(name: string);
  121308. /**
  121309. * Gets the current class name
  121310. * @returns the class name
  121311. */
  121312. getClassName(): string;
  121313. /**
  121314. * Gets the world normal input component
  121315. */
  121316. readonly worldNormal: NodeMaterialConnectionPoint;
  121317. /**
  121318. * Gets the view direction input component
  121319. */
  121320. readonly viewDirection: NodeMaterialConnectionPoint;
  121321. /**
  121322. * Gets the bias input component
  121323. */
  121324. readonly bias: NodeMaterialConnectionPoint;
  121325. /**
  121326. * Gets the camera (or eye) position component
  121327. */
  121328. readonly power: NodeMaterialConnectionPoint;
  121329. /**
  121330. * Gets the fresnel output component
  121331. */
  121332. readonly fresnel: NodeMaterialConnectionPoint;
  121333. autoConfigure(material: NodeMaterial): void;
  121334. protected _buildBlock(state: NodeMaterialBuildState): this;
  121335. }
  121336. }
  121337. declare module BABYLON {
  121338. /**
  121339. * Block used to get the max of 2 values
  121340. */
  121341. export class MaxBlock extends NodeMaterialBlock {
  121342. /**
  121343. * Creates a new MaxBlock
  121344. * @param name defines the block name
  121345. */
  121346. constructor(name: string);
  121347. /**
  121348. * Gets the current class name
  121349. * @returns the class name
  121350. */
  121351. getClassName(): string;
  121352. /**
  121353. * Gets the left operand input component
  121354. */
  121355. readonly left: NodeMaterialConnectionPoint;
  121356. /**
  121357. * Gets the right operand input component
  121358. */
  121359. readonly right: NodeMaterialConnectionPoint;
  121360. /**
  121361. * Gets the output component
  121362. */
  121363. readonly output: NodeMaterialConnectionPoint;
  121364. protected _buildBlock(state: NodeMaterialBuildState): this;
  121365. }
  121366. }
  121367. declare module BABYLON {
  121368. /**
  121369. * Block used to get the min of 2 values
  121370. */
  121371. export class MinBlock extends NodeMaterialBlock {
  121372. /**
  121373. * Creates a new MinBlock
  121374. * @param name defines the block name
  121375. */
  121376. constructor(name: string);
  121377. /**
  121378. * Gets the current class name
  121379. * @returns the class name
  121380. */
  121381. getClassName(): string;
  121382. /**
  121383. * Gets the left operand input component
  121384. */
  121385. readonly left: NodeMaterialConnectionPoint;
  121386. /**
  121387. * Gets the right operand input component
  121388. */
  121389. readonly right: NodeMaterialConnectionPoint;
  121390. /**
  121391. * Gets the output component
  121392. */
  121393. readonly output: NodeMaterialConnectionPoint;
  121394. protected _buildBlock(state: NodeMaterialBuildState): this;
  121395. }
  121396. }
  121397. declare module BABYLON {
  121398. /**
  121399. * Block used to get the distance between 2 values
  121400. */
  121401. export class DistanceBlock extends NodeMaterialBlock {
  121402. /**
  121403. * Creates a new DistanceBlock
  121404. * @param name defines the block name
  121405. */
  121406. constructor(name: string);
  121407. /**
  121408. * Gets the current class name
  121409. * @returns the class name
  121410. */
  121411. getClassName(): string;
  121412. /**
  121413. * Gets the left operand input component
  121414. */
  121415. readonly left: NodeMaterialConnectionPoint;
  121416. /**
  121417. * Gets the right operand input component
  121418. */
  121419. readonly right: NodeMaterialConnectionPoint;
  121420. /**
  121421. * Gets the output component
  121422. */
  121423. readonly output: NodeMaterialConnectionPoint;
  121424. protected _buildBlock(state: NodeMaterialBuildState): this;
  121425. }
  121426. }
  121427. declare module BABYLON {
  121428. /**
  121429. * Block used to get the length of a vector
  121430. */
  121431. export class LengthBlock extends NodeMaterialBlock {
  121432. /**
  121433. * Creates a new LengthBlock
  121434. * @param name defines the block name
  121435. */
  121436. constructor(name: string);
  121437. /**
  121438. * Gets the current class name
  121439. * @returns the class name
  121440. */
  121441. getClassName(): string;
  121442. /**
  121443. * Gets the value input component
  121444. */
  121445. readonly value: NodeMaterialConnectionPoint;
  121446. /**
  121447. * Gets the output component
  121448. */
  121449. readonly output: NodeMaterialConnectionPoint;
  121450. protected _buildBlock(state: NodeMaterialBuildState): this;
  121451. }
  121452. }
  121453. declare module BABYLON {
  121454. /**
  121455. * Block used to get negative version of a value (i.e. x * -1)
  121456. */
  121457. export class NegateBlock extends NodeMaterialBlock {
  121458. /**
  121459. * Creates a new NegateBlock
  121460. * @param name defines the block name
  121461. */
  121462. constructor(name: string);
  121463. /**
  121464. * Gets the current class name
  121465. * @returns the class name
  121466. */
  121467. getClassName(): string;
  121468. /**
  121469. * Gets the value input component
  121470. */
  121471. readonly value: NodeMaterialConnectionPoint;
  121472. /**
  121473. * Gets the output component
  121474. */
  121475. readonly output: NodeMaterialConnectionPoint;
  121476. protected _buildBlock(state: NodeMaterialBuildState): this;
  121477. }
  121478. }
  121479. declare module BABYLON {
  121480. /**
  121481. * Block used to get the value of the first parameter raised to the power of the second
  121482. */
  121483. export class PowBlock extends NodeMaterialBlock {
  121484. /**
  121485. * Creates a new PowBlock
  121486. * @param name defines the block name
  121487. */
  121488. constructor(name: string);
  121489. /**
  121490. * Gets the current class name
  121491. * @returns the class name
  121492. */
  121493. getClassName(): string;
  121494. /**
  121495. * Gets the value operand input component
  121496. */
  121497. readonly value: NodeMaterialConnectionPoint;
  121498. /**
  121499. * Gets the power operand input component
  121500. */
  121501. readonly power: NodeMaterialConnectionPoint;
  121502. /**
  121503. * Gets the output component
  121504. */
  121505. readonly output: NodeMaterialConnectionPoint;
  121506. protected _buildBlock(state: NodeMaterialBuildState): this;
  121507. }
  121508. }
  121509. declare module BABYLON {
  121510. /**
  121511. * Block used to get a random number
  121512. */
  121513. export class RandomNumberBlock extends NodeMaterialBlock {
  121514. /**
  121515. * Creates a new RandomNumberBlock
  121516. * @param name defines the block name
  121517. */
  121518. constructor(name: string);
  121519. /**
  121520. * Gets the current class name
  121521. * @returns the class name
  121522. */
  121523. getClassName(): string;
  121524. /**
  121525. * Gets the seed input component
  121526. */
  121527. readonly seed: NodeMaterialConnectionPoint;
  121528. /**
  121529. * Gets the output component
  121530. */
  121531. readonly output: NodeMaterialConnectionPoint;
  121532. protected _buildBlock(state: NodeMaterialBuildState): this;
  121533. }
  121534. }
  121535. declare module BABYLON {
  121536. /**
  121537. * Effect Render Options
  121538. */
  121539. export interface IEffectRendererOptions {
  121540. /**
  121541. * Defines the vertices positions.
  121542. */
  121543. positions?: number[];
  121544. /**
  121545. * Defines the indices.
  121546. */
  121547. indices?: number[];
  121548. }
  121549. /**
  121550. * Helper class to render one or more effects
  121551. */
  121552. export class EffectRenderer {
  121553. private engine;
  121554. private static _DefaultOptions;
  121555. private _vertexBuffers;
  121556. private _indexBuffer;
  121557. private _ringBufferIndex;
  121558. private _ringScreenBuffer;
  121559. private _fullscreenViewport;
  121560. private _getNextFrameBuffer;
  121561. /**
  121562. * Creates an effect renderer
  121563. * @param engine the engine to use for rendering
  121564. * @param options defines the options of the effect renderer
  121565. */
  121566. constructor(engine: Engine, options?: IEffectRendererOptions);
  121567. /**
  121568. * Sets the current viewport in normalized coordinates 0-1
  121569. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  121570. */
  121571. setViewport(viewport?: Viewport): void;
  121572. /**
  121573. * Binds the embedded attributes buffer to the effect.
  121574. * @param effect Defines the effect to bind the attributes for
  121575. */
  121576. bindBuffers(effect: Effect): void;
  121577. /**
  121578. * Sets the current effect wrapper to use during draw.
  121579. * The effect needs to be ready before calling this api.
  121580. * This also sets the default full screen position attribute.
  121581. * @param effectWrapper Defines the effect to draw with
  121582. */
  121583. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  121584. /**
  121585. * Draws a full screen quad.
  121586. */
  121587. draw(): void;
  121588. /**
  121589. * renders one or more effects to a specified texture
  121590. * @param effectWrappers list of effects to renderer
  121591. * @param outputTexture texture to draw to, if null it will render to the screen
  121592. */
  121593. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  121594. /**
  121595. * Disposes of the effect renderer
  121596. */
  121597. dispose(): void;
  121598. }
  121599. /**
  121600. * Options to create an EffectWrapper
  121601. */
  121602. interface EffectWrapperCreationOptions {
  121603. /**
  121604. * Engine to use to create the effect
  121605. */
  121606. engine: Engine;
  121607. /**
  121608. * Fragment shader for the effect
  121609. */
  121610. fragmentShader: string;
  121611. /**
  121612. * Vertex shader for the effect
  121613. */
  121614. vertexShader?: string;
  121615. /**
  121616. * Attributes to use in the shader
  121617. */
  121618. attributeNames?: Array<string>;
  121619. /**
  121620. * Uniforms to use in the shader
  121621. */
  121622. uniformNames?: Array<string>;
  121623. /**
  121624. * Texture sampler names to use in the shader
  121625. */
  121626. samplerNames?: Array<string>;
  121627. /**
  121628. * The friendly name of the effect displayed in Spector.
  121629. */
  121630. name?: string;
  121631. }
  121632. /**
  121633. * Wraps an effect to be used for rendering
  121634. */
  121635. export class EffectWrapper {
  121636. /**
  121637. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  121638. */
  121639. onApplyObservable: Observable<{}>;
  121640. /**
  121641. * The underlying effect
  121642. */
  121643. effect: Effect;
  121644. /**
  121645. * Creates an effect to be renderer
  121646. * @param creationOptions options to create the effect
  121647. */
  121648. constructor(creationOptions: EffectWrapperCreationOptions);
  121649. /**
  121650. * Disposes of the effect wrapper
  121651. */
  121652. dispose(): void;
  121653. }
  121654. }
  121655. declare module BABYLON {
  121656. /**
  121657. * Helper class to push actions to a pool of workers.
  121658. */
  121659. export class WorkerPool implements IDisposable {
  121660. private _workerInfos;
  121661. private _pendingActions;
  121662. /**
  121663. * Constructor
  121664. * @param workers Array of workers to use for actions
  121665. */
  121666. constructor(workers: Array<Worker>);
  121667. /**
  121668. * Terminates all workers and clears any pending actions.
  121669. */
  121670. dispose(): void;
  121671. /**
  121672. * Pushes an action to the worker pool. If all the workers are active, the action will be
  121673. * pended until a worker has completed its action.
  121674. * @param action The action to perform. Call onComplete when the action is complete.
  121675. */
  121676. push(action: (worker: Worker, onComplete: () => void) => void): void;
  121677. private _execute;
  121678. }
  121679. }
  121680. declare module BABYLON {
  121681. /**
  121682. * Configuration for Draco compression
  121683. */
  121684. export interface IDracoCompressionConfiguration {
  121685. /**
  121686. * Configuration for the decoder.
  121687. */
  121688. decoder: {
  121689. /**
  121690. * The url to the WebAssembly module.
  121691. */
  121692. wasmUrl?: string;
  121693. /**
  121694. * The url to the WebAssembly binary.
  121695. */
  121696. wasmBinaryUrl?: string;
  121697. /**
  121698. * The url to the fallback JavaScript module.
  121699. */
  121700. fallbackUrl?: string;
  121701. };
  121702. }
  121703. /**
  121704. * Draco compression (https://google.github.io/draco/)
  121705. *
  121706. * This class wraps the Draco module.
  121707. *
  121708. * **Encoder**
  121709. *
  121710. * The encoder is not currently implemented.
  121711. *
  121712. * **Decoder**
  121713. *
  121714. * 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.
  121715. *
  121716. * To update the configuration, use the following code:
  121717. * ```javascript
  121718. * DracoCompression.Configuration = {
  121719. * decoder: {
  121720. * wasmUrl: "<url to the WebAssembly library>",
  121721. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  121722. * fallbackUrl: "<url to the fallback JavaScript library>",
  121723. * }
  121724. * };
  121725. * ```
  121726. *
  121727. * 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.
  121728. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  121729. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  121730. *
  121731. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  121732. * ```javascript
  121733. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  121734. * ```
  121735. *
  121736. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  121737. */
  121738. export class DracoCompression implements IDisposable {
  121739. private _workerPoolPromise?;
  121740. private _decoderModulePromise?;
  121741. /**
  121742. * The configuration. Defaults to the following urls:
  121743. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  121744. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  121745. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  121746. */
  121747. static Configuration: IDracoCompressionConfiguration;
  121748. /**
  121749. * Returns true if the decoder configuration is available.
  121750. */
  121751. static readonly DecoderAvailable: boolean;
  121752. /**
  121753. * Default number of workers to create when creating the draco compression object.
  121754. */
  121755. static DefaultNumWorkers: number;
  121756. private static GetDefaultNumWorkers;
  121757. private static _Default;
  121758. /**
  121759. * Default instance for the draco compression object.
  121760. */
  121761. static readonly Default: DracoCompression;
  121762. /**
  121763. * Constructor
  121764. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  121765. */
  121766. constructor(numWorkers?: number);
  121767. /**
  121768. * Stop all async operations and release resources.
  121769. */
  121770. dispose(): void;
  121771. /**
  121772. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  121773. * @returns a promise that resolves when ready
  121774. */
  121775. whenReadyAsync(): Promise<void>;
  121776. /**
  121777. * Decode Draco compressed mesh data to vertex data.
  121778. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  121779. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  121780. * @returns A promise that resolves with the decoded vertex data
  121781. */
  121782. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  121783. [kind: string]: number;
  121784. }): Promise<VertexData>;
  121785. }
  121786. }
  121787. declare module BABYLON {
  121788. /**
  121789. * Class for building Constructive Solid Geometry
  121790. */
  121791. export class CSG {
  121792. private polygons;
  121793. /**
  121794. * The world matrix
  121795. */
  121796. matrix: Matrix;
  121797. /**
  121798. * Stores the position
  121799. */
  121800. position: Vector3;
  121801. /**
  121802. * Stores the rotation
  121803. */
  121804. rotation: Vector3;
  121805. /**
  121806. * Stores the rotation quaternion
  121807. */
  121808. rotationQuaternion: Nullable<Quaternion>;
  121809. /**
  121810. * Stores the scaling vector
  121811. */
  121812. scaling: Vector3;
  121813. /**
  121814. * Convert the Mesh to CSG
  121815. * @param mesh The Mesh to convert to CSG
  121816. * @returns A new CSG from the Mesh
  121817. */
  121818. static FromMesh(mesh: Mesh): CSG;
  121819. /**
  121820. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  121821. * @param polygons Polygons used to construct a CSG solid
  121822. */
  121823. private static FromPolygons;
  121824. /**
  121825. * Clones, or makes a deep copy, of the CSG
  121826. * @returns A new CSG
  121827. */
  121828. clone(): CSG;
  121829. /**
  121830. * Unions this CSG with another CSG
  121831. * @param csg The CSG to union against this CSG
  121832. * @returns The unioned CSG
  121833. */
  121834. union(csg: CSG): CSG;
  121835. /**
  121836. * Unions this CSG with another CSG in place
  121837. * @param csg The CSG to union against this CSG
  121838. */
  121839. unionInPlace(csg: CSG): void;
  121840. /**
  121841. * Subtracts this CSG with another CSG
  121842. * @param csg The CSG to subtract against this CSG
  121843. * @returns A new CSG
  121844. */
  121845. subtract(csg: CSG): CSG;
  121846. /**
  121847. * Subtracts this CSG with another CSG in place
  121848. * @param csg The CSG to subtact against this CSG
  121849. */
  121850. subtractInPlace(csg: CSG): void;
  121851. /**
  121852. * Intersect this CSG with another CSG
  121853. * @param csg The CSG to intersect against this CSG
  121854. * @returns A new CSG
  121855. */
  121856. intersect(csg: CSG): CSG;
  121857. /**
  121858. * Intersects this CSG with another CSG in place
  121859. * @param csg The CSG to intersect against this CSG
  121860. */
  121861. intersectInPlace(csg: CSG): void;
  121862. /**
  121863. * Return a new CSG solid with solid and empty space switched. This solid is
  121864. * not modified.
  121865. * @returns A new CSG solid with solid and empty space switched
  121866. */
  121867. inverse(): CSG;
  121868. /**
  121869. * Inverses the CSG in place
  121870. */
  121871. inverseInPlace(): void;
  121872. /**
  121873. * This is used to keep meshes transformations so they can be restored
  121874. * when we build back a Babylon Mesh
  121875. * NB : All CSG operations are performed in world coordinates
  121876. * @param csg The CSG to copy the transform attributes from
  121877. * @returns This CSG
  121878. */
  121879. copyTransformAttributes(csg: CSG): CSG;
  121880. /**
  121881. * Build Raw mesh from CSG
  121882. * Coordinates here are in world space
  121883. * @param name The name of the mesh geometry
  121884. * @param scene The Scene
  121885. * @param keepSubMeshes Specifies if the submeshes should be kept
  121886. * @returns A new Mesh
  121887. */
  121888. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  121889. /**
  121890. * Build Mesh from CSG taking material and transforms into account
  121891. * @param name The name of the Mesh
  121892. * @param material The material of the Mesh
  121893. * @param scene The Scene
  121894. * @param keepSubMeshes Specifies if submeshes should be kept
  121895. * @returns The new Mesh
  121896. */
  121897. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  121898. }
  121899. }
  121900. declare module BABYLON {
  121901. /**
  121902. * Class used to create a trail following a mesh
  121903. */
  121904. export class TrailMesh extends Mesh {
  121905. private _generator;
  121906. private _autoStart;
  121907. private _running;
  121908. private _diameter;
  121909. private _length;
  121910. private _sectionPolygonPointsCount;
  121911. private _sectionVectors;
  121912. private _sectionNormalVectors;
  121913. private _beforeRenderObserver;
  121914. /**
  121915. * @constructor
  121916. * @param name The value used by scene.getMeshByName() to do a lookup.
  121917. * @param generator The mesh to generate a trail.
  121918. * @param scene The scene to add this mesh to.
  121919. * @param diameter Diameter of trailing mesh. Default is 1.
  121920. * @param length Length of trailing mesh. Default is 60.
  121921. * @param autoStart Automatically start trailing mesh. Default true.
  121922. */
  121923. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  121924. /**
  121925. * "TrailMesh"
  121926. * @returns "TrailMesh"
  121927. */
  121928. getClassName(): string;
  121929. private _createMesh;
  121930. /**
  121931. * Start trailing mesh.
  121932. */
  121933. start(): void;
  121934. /**
  121935. * Stop trailing mesh.
  121936. */
  121937. stop(): void;
  121938. /**
  121939. * Update trailing mesh geometry.
  121940. */
  121941. update(): void;
  121942. /**
  121943. * Returns a new TrailMesh object.
  121944. * @param name is a string, the name given to the new mesh
  121945. * @param newGenerator use new generator object for cloned trail mesh
  121946. * @returns a new mesh
  121947. */
  121948. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  121949. /**
  121950. * Serializes this trail mesh
  121951. * @param serializationObject object to write serialization to
  121952. */
  121953. serialize(serializationObject: any): void;
  121954. /**
  121955. * Parses a serialized trail mesh
  121956. * @param parsedMesh the serialized mesh
  121957. * @param scene the scene to create the trail mesh in
  121958. * @returns the created trail mesh
  121959. */
  121960. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  121961. }
  121962. }
  121963. declare module BABYLON {
  121964. /**
  121965. * Class containing static functions to help procedurally build meshes
  121966. */
  121967. export class TiledBoxBuilder {
  121968. /**
  121969. * Creates a box mesh
  121970. * 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)
  121971. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121975. * @param name defines the name of the mesh
  121976. * @param options defines the options used to create the mesh
  121977. * @param scene defines the hosting scene
  121978. * @returns the box mesh
  121979. */
  121980. static CreateTiledBox(name: string, options: {
  121981. pattern?: number;
  121982. width?: number;
  121983. height?: number;
  121984. depth?: number;
  121985. tileSize?: number;
  121986. tileWidth?: number;
  121987. tileHeight?: number;
  121988. alignHorizontal?: number;
  121989. alignVertical?: number;
  121990. faceUV?: Vector4[];
  121991. faceColors?: Color4[];
  121992. sideOrientation?: number;
  121993. updatable?: boolean;
  121994. }, scene?: Nullable<Scene>): Mesh;
  121995. }
  121996. }
  121997. declare module BABYLON {
  121998. /**
  121999. * Class containing static functions to help procedurally build meshes
  122000. */
  122001. export class TorusKnotBuilder {
  122002. /**
  122003. * Creates a torus knot mesh
  122004. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122005. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122006. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122007. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122011. * @param name defines the name of the mesh
  122012. * @param options defines the options used to create the mesh
  122013. * @param scene defines the hosting scene
  122014. * @returns the torus knot mesh
  122015. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122016. */
  122017. static CreateTorusKnot(name: string, options: {
  122018. radius?: number;
  122019. tube?: number;
  122020. radialSegments?: number;
  122021. tubularSegments?: number;
  122022. p?: number;
  122023. q?: number;
  122024. updatable?: boolean;
  122025. sideOrientation?: number;
  122026. frontUVs?: Vector4;
  122027. backUVs?: Vector4;
  122028. }, scene: any): Mesh;
  122029. }
  122030. }
  122031. declare module BABYLON {
  122032. /**
  122033. * Polygon
  122034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122035. */
  122036. export class Polygon {
  122037. /**
  122038. * Creates a rectangle
  122039. * @param xmin bottom X coord
  122040. * @param ymin bottom Y coord
  122041. * @param xmax top X coord
  122042. * @param ymax top Y coord
  122043. * @returns points that make the resulting rectation
  122044. */
  122045. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122046. /**
  122047. * Creates a circle
  122048. * @param radius radius of circle
  122049. * @param cx scale in x
  122050. * @param cy scale in y
  122051. * @param numberOfSides number of sides that make up the circle
  122052. * @returns points that make the resulting circle
  122053. */
  122054. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122055. /**
  122056. * Creates a polygon from input string
  122057. * @param input Input polygon data
  122058. * @returns the parsed points
  122059. */
  122060. static Parse(input: string): Vector2[];
  122061. /**
  122062. * Starts building a polygon from x and y coordinates
  122063. * @param x x coordinate
  122064. * @param y y coordinate
  122065. * @returns the started path2
  122066. */
  122067. static StartingAt(x: number, y: number): Path2;
  122068. }
  122069. /**
  122070. * Builds a polygon
  122071. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122072. */
  122073. export class PolygonMeshBuilder {
  122074. private _points;
  122075. private _outlinepoints;
  122076. private _holes;
  122077. private _name;
  122078. private _scene;
  122079. private _epoints;
  122080. private _eholes;
  122081. private _addToepoint;
  122082. /**
  122083. * Babylon reference to the earcut plugin.
  122084. */
  122085. bjsEarcut: any;
  122086. /**
  122087. * Creates a PolygonMeshBuilder
  122088. * @param name name of the builder
  122089. * @param contours Path of the polygon
  122090. * @param scene scene to add to when creating the mesh
  122091. * @param earcutInjection can be used to inject your own earcut reference
  122092. */
  122093. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122094. /**
  122095. * Adds a whole within the polygon
  122096. * @param hole Array of points defining the hole
  122097. * @returns this
  122098. */
  122099. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122100. /**
  122101. * Creates the polygon
  122102. * @param updatable If the mesh should be updatable
  122103. * @param depth The depth of the mesh created
  122104. * @returns the created mesh
  122105. */
  122106. build(updatable?: boolean, depth?: number): Mesh;
  122107. /**
  122108. * Creates the polygon
  122109. * @param depth The depth of the mesh created
  122110. * @returns the created VertexData
  122111. */
  122112. buildVertexData(depth?: number): VertexData;
  122113. /**
  122114. * Adds a side to the polygon
  122115. * @param positions points that make the polygon
  122116. * @param normals normals of the polygon
  122117. * @param uvs uvs of the polygon
  122118. * @param indices indices of the polygon
  122119. * @param bounds bounds of the polygon
  122120. * @param points points of the polygon
  122121. * @param depth depth of the polygon
  122122. * @param flip flip of the polygon
  122123. */
  122124. private addSide;
  122125. }
  122126. }
  122127. declare module BABYLON {
  122128. /**
  122129. * Class containing static functions to help procedurally build meshes
  122130. */
  122131. export class PolygonBuilder {
  122132. /**
  122133. * Creates a polygon mesh
  122134. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122135. * * 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
  122136. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122139. * * Remember you can only change the shape positions, not their number when updating a polygon
  122140. * @param name defines the name of the mesh
  122141. * @param options defines the options used to create the mesh
  122142. * @param scene defines the hosting scene
  122143. * @param earcutInjection can be used to inject your own earcut reference
  122144. * @returns the polygon mesh
  122145. */
  122146. static CreatePolygon(name: string, options: {
  122147. shape: Vector3[];
  122148. holes?: Vector3[][];
  122149. depth?: number;
  122150. faceUV?: Vector4[];
  122151. faceColors?: Color4[];
  122152. updatable?: boolean;
  122153. sideOrientation?: number;
  122154. frontUVs?: Vector4;
  122155. backUVs?: Vector4;
  122156. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122157. /**
  122158. * Creates an extruded polygon mesh, with depth in the Y direction.
  122159. * * 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)
  122160. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122161. * @param name defines the name of the mesh
  122162. * @param options defines the options used to create the mesh
  122163. * @param scene defines the hosting scene
  122164. * @param earcutInjection can be used to inject your own earcut reference
  122165. * @returns the polygon mesh
  122166. */
  122167. static ExtrudePolygon(name: string, options: {
  122168. shape: Vector3[];
  122169. holes?: Vector3[][];
  122170. depth?: number;
  122171. faceUV?: Vector4[];
  122172. faceColors?: Color4[];
  122173. updatable?: boolean;
  122174. sideOrientation?: number;
  122175. frontUVs?: Vector4;
  122176. backUVs?: Vector4;
  122177. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122178. }
  122179. }
  122180. declare module BABYLON {
  122181. /**
  122182. * Class containing static functions to help procedurally build meshes
  122183. */
  122184. export class LatheBuilder {
  122185. /**
  122186. * Creates lathe mesh.
  122187. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122188. * * 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
  122189. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122190. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122191. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122192. * * 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
  122193. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122194. * * 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
  122195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122199. * @param name defines the name of the mesh
  122200. * @param options defines the options used to create the mesh
  122201. * @param scene defines the hosting scene
  122202. * @returns the lathe mesh
  122203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122204. */
  122205. static CreateLathe(name: string, options: {
  122206. shape: Vector3[];
  122207. radius?: number;
  122208. tessellation?: number;
  122209. clip?: number;
  122210. arc?: number;
  122211. closed?: boolean;
  122212. updatable?: boolean;
  122213. sideOrientation?: number;
  122214. frontUVs?: Vector4;
  122215. backUVs?: Vector4;
  122216. cap?: number;
  122217. invertUV?: boolean;
  122218. }, scene?: Nullable<Scene>): Mesh;
  122219. }
  122220. }
  122221. declare module BABYLON {
  122222. /**
  122223. * Class containing static functions to help procedurally build meshes
  122224. */
  122225. export class TiledPlaneBuilder {
  122226. /**
  122227. * Creates a tiled plane mesh
  122228. * * The parameter `pattern` will, depending on value, do nothing or
  122229. * * * flip (reflect about central vertical) alternate tiles across and up
  122230. * * * flip every tile on alternate rows
  122231. * * * rotate (180 degs) alternate tiles across and up
  122232. * * * rotate every tile on alternate rows
  122233. * * * flip and rotate alternate tiles across and up
  122234. * * * flip and rotate every tile on alternate rows
  122235. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  122236. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  122237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122239. * * 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)
  122240. * * 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)
  122241. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122242. * @param name defines the name of the mesh
  122243. * @param options defines the options used to create the mesh
  122244. * @param scene defines the hosting scene
  122245. * @returns the box mesh
  122246. */
  122247. static CreateTiledPlane(name: string, options: {
  122248. pattern?: number;
  122249. tileSize?: number;
  122250. tileWidth?: number;
  122251. tileHeight?: number;
  122252. size?: number;
  122253. width?: number;
  122254. height?: number;
  122255. alignHorizontal?: number;
  122256. alignVertical?: number;
  122257. sideOrientation?: number;
  122258. frontUVs?: Vector4;
  122259. backUVs?: Vector4;
  122260. updatable?: boolean;
  122261. }, scene?: Nullable<Scene>): Mesh;
  122262. }
  122263. }
  122264. declare module BABYLON {
  122265. /**
  122266. * Class containing static functions to help procedurally build meshes
  122267. */
  122268. export class TubeBuilder {
  122269. /**
  122270. * Creates a tube mesh.
  122271. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122272. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122273. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122274. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122275. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122276. * * 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)
  122277. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122278. * * 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
  122279. * * 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
  122280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122282. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122284. * @param name defines the name of the mesh
  122285. * @param options defines the options used to create the mesh
  122286. * @param scene defines the hosting scene
  122287. * @returns the tube mesh
  122288. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122289. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122290. */
  122291. static CreateTube(name: string, options: {
  122292. path: Vector3[];
  122293. radius?: number;
  122294. tessellation?: number;
  122295. radiusFunction?: {
  122296. (i: number, distance: number): number;
  122297. };
  122298. cap?: number;
  122299. arc?: number;
  122300. updatable?: boolean;
  122301. sideOrientation?: number;
  122302. frontUVs?: Vector4;
  122303. backUVs?: Vector4;
  122304. instance?: Mesh;
  122305. invertUV?: boolean;
  122306. }, scene?: Nullable<Scene>): Mesh;
  122307. }
  122308. }
  122309. declare module BABYLON {
  122310. /**
  122311. * Class containing static functions to help procedurally build meshes
  122312. */
  122313. export class IcoSphereBuilder {
  122314. /**
  122315. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122316. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122317. * * 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`)
  122318. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122319. * * 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
  122320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122321. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122323. * @param name defines the name of the mesh
  122324. * @param options defines the options used to create the mesh
  122325. * @param scene defines the hosting scene
  122326. * @returns the icosahedron mesh
  122327. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122328. */
  122329. static CreateIcoSphere(name: string, options: {
  122330. radius?: number;
  122331. radiusX?: number;
  122332. radiusY?: number;
  122333. radiusZ?: number;
  122334. flat?: boolean;
  122335. subdivisions?: number;
  122336. sideOrientation?: number;
  122337. frontUVs?: Vector4;
  122338. backUVs?: Vector4;
  122339. updatable?: boolean;
  122340. }, scene?: Nullable<Scene>): Mesh;
  122341. }
  122342. }
  122343. declare module BABYLON {
  122344. /**
  122345. * Class containing static functions to help procedurally build meshes
  122346. */
  122347. export class DecalBuilder {
  122348. /**
  122349. * Creates a decal mesh.
  122350. * 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
  122351. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122352. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122353. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122354. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122355. * @param name defines the name of the mesh
  122356. * @param sourceMesh defines the mesh where the decal must be applied
  122357. * @param options defines the options used to create the mesh
  122358. * @param scene defines the hosting scene
  122359. * @returns the decal mesh
  122360. * @see https://doc.babylonjs.com/how_to/decals
  122361. */
  122362. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122363. position?: Vector3;
  122364. normal?: Vector3;
  122365. size?: Vector3;
  122366. angle?: number;
  122367. }): Mesh;
  122368. }
  122369. }
  122370. declare module BABYLON {
  122371. /**
  122372. * Class containing static functions to help procedurally build meshes
  122373. */
  122374. export class MeshBuilder {
  122375. /**
  122376. * Creates a box mesh
  122377. * * The parameter `size` sets the size (float) of each box side (default 1)
  122378. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122379. * * 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)
  122380. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122384. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122385. * @param name defines the name of the mesh
  122386. * @param options defines the options used to create the mesh
  122387. * @param scene defines the hosting scene
  122388. * @returns the box mesh
  122389. */
  122390. static CreateBox(name: string, options: {
  122391. size?: number;
  122392. width?: number;
  122393. height?: number;
  122394. depth?: number;
  122395. faceUV?: Vector4[];
  122396. faceColors?: Color4[];
  122397. sideOrientation?: number;
  122398. frontUVs?: Vector4;
  122399. backUVs?: Vector4;
  122400. updatable?: boolean;
  122401. }, scene?: Nullable<Scene>): Mesh;
  122402. /**
  122403. * Creates a tiled box mesh
  122404. * * faceTiles sets the pattern, tile size and number of tiles for a face
  122405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122406. * @param name defines the name of the mesh
  122407. * @param options defines the options used to create the mesh
  122408. * @param scene defines the hosting scene
  122409. * @returns the tiled box mesh
  122410. */
  122411. static CreateTiledBox(name: string, options: {
  122412. pattern?: number;
  122413. size?: number;
  122414. width?: number;
  122415. height?: number;
  122416. depth: number;
  122417. tileSize?: number;
  122418. tileWidth?: number;
  122419. tileHeight?: number;
  122420. faceUV?: Vector4[];
  122421. faceColors?: Color4[];
  122422. alignHorizontal?: number;
  122423. alignVertical?: number;
  122424. sideOrientation?: number;
  122425. updatable?: boolean;
  122426. }, scene?: Nullable<Scene>): Mesh;
  122427. /**
  122428. * Creates a sphere mesh
  122429. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  122430. * * 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`)
  122431. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  122432. * * 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
  122433. * * 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)
  122434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122437. * @param name defines the name of the mesh
  122438. * @param options defines the options used to create the mesh
  122439. * @param scene defines the hosting scene
  122440. * @returns the sphere mesh
  122441. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  122442. */
  122443. static CreateSphere(name: string, options: {
  122444. segments?: number;
  122445. diameter?: number;
  122446. diameterX?: number;
  122447. diameterY?: number;
  122448. diameterZ?: number;
  122449. arc?: number;
  122450. slice?: number;
  122451. sideOrientation?: number;
  122452. frontUVs?: Vector4;
  122453. backUVs?: Vector4;
  122454. updatable?: boolean;
  122455. }, scene?: Nullable<Scene>): Mesh;
  122456. /**
  122457. * Creates a plane polygonal mesh. By default, this is a disc
  122458. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  122459. * * 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
  122460. * * 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
  122461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122464. * @param name defines the name of the mesh
  122465. * @param options defines the options used to create the mesh
  122466. * @param scene defines the hosting scene
  122467. * @returns the plane polygonal mesh
  122468. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  122469. */
  122470. static CreateDisc(name: string, options: {
  122471. radius?: number;
  122472. tessellation?: number;
  122473. arc?: number;
  122474. updatable?: boolean;
  122475. sideOrientation?: number;
  122476. frontUVs?: Vector4;
  122477. backUVs?: Vector4;
  122478. }, scene?: Nullable<Scene>): Mesh;
  122479. /**
  122480. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122481. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122482. * * 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`)
  122483. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122484. * * 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
  122485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122488. * @param name defines the name of the mesh
  122489. * @param options defines the options used to create the mesh
  122490. * @param scene defines the hosting scene
  122491. * @returns the icosahedron mesh
  122492. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122493. */
  122494. static CreateIcoSphere(name: string, options: {
  122495. radius?: number;
  122496. radiusX?: number;
  122497. radiusY?: number;
  122498. radiusZ?: number;
  122499. flat?: boolean;
  122500. subdivisions?: number;
  122501. sideOrientation?: number;
  122502. frontUVs?: Vector4;
  122503. backUVs?: Vector4;
  122504. updatable?: boolean;
  122505. }, scene?: Nullable<Scene>): Mesh;
  122506. /**
  122507. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122508. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  122509. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  122510. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  122511. * * 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
  122512. * * 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
  122513. * * 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
  122514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122517. * * 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
  122518. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  122519. * * 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
  122520. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  122521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122522. * @param name defines the name of the mesh
  122523. * @param options defines the options used to create the mesh
  122524. * @param scene defines the hosting scene
  122525. * @returns the ribbon mesh
  122526. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  122527. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122528. */
  122529. static CreateRibbon(name: string, options: {
  122530. pathArray: Vector3[][];
  122531. closeArray?: boolean;
  122532. closePath?: boolean;
  122533. offset?: number;
  122534. updatable?: boolean;
  122535. sideOrientation?: number;
  122536. frontUVs?: Vector4;
  122537. backUVs?: Vector4;
  122538. instance?: Mesh;
  122539. invertUV?: boolean;
  122540. uvs?: Vector2[];
  122541. colors?: Color4[];
  122542. }, scene?: Nullable<Scene>): Mesh;
  122543. /**
  122544. * Creates a cylinder or a cone mesh
  122545. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  122546. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  122547. * * 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.
  122548. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  122549. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  122550. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  122551. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  122552. * * 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).
  122553. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  122554. * * 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).
  122555. * * 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
  122556. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  122557. * * 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
  122558. * * 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.
  122559. * * If `enclose` is false, a ring surface is one element.
  122560. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  122561. * * 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
  122562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122565. * @param name defines the name of the mesh
  122566. * @param options defines the options used to create the mesh
  122567. * @param scene defines the hosting scene
  122568. * @returns the cylinder mesh
  122569. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  122570. */
  122571. static CreateCylinder(name: string, options: {
  122572. height?: number;
  122573. diameterTop?: number;
  122574. diameterBottom?: number;
  122575. diameter?: number;
  122576. tessellation?: number;
  122577. subdivisions?: number;
  122578. arc?: number;
  122579. faceColors?: Color4[];
  122580. faceUV?: Vector4[];
  122581. updatable?: boolean;
  122582. hasRings?: boolean;
  122583. enclose?: boolean;
  122584. cap?: number;
  122585. sideOrientation?: number;
  122586. frontUVs?: Vector4;
  122587. backUVs?: Vector4;
  122588. }, scene?: Nullable<Scene>): Mesh;
  122589. /**
  122590. * Creates a torus mesh
  122591. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  122592. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  122593. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  122594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122597. * @param name defines the name of the mesh
  122598. * @param options defines the options used to create the mesh
  122599. * @param scene defines the hosting scene
  122600. * @returns the torus mesh
  122601. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  122602. */
  122603. static CreateTorus(name: string, options: {
  122604. diameter?: number;
  122605. thickness?: number;
  122606. tessellation?: number;
  122607. updatable?: boolean;
  122608. sideOrientation?: number;
  122609. frontUVs?: Vector4;
  122610. backUVs?: Vector4;
  122611. }, scene?: Nullable<Scene>): Mesh;
  122612. /**
  122613. * Creates a torus knot mesh
  122614. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122615. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122616. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122617. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122621. * @param name defines the name of the mesh
  122622. * @param options defines the options used to create the mesh
  122623. * @param scene defines the hosting scene
  122624. * @returns the torus knot mesh
  122625. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122626. */
  122627. static CreateTorusKnot(name: string, options: {
  122628. radius?: number;
  122629. tube?: number;
  122630. radialSegments?: number;
  122631. tubularSegments?: number;
  122632. p?: number;
  122633. q?: number;
  122634. updatable?: boolean;
  122635. sideOrientation?: number;
  122636. frontUVs?: Vector4;
  122637. backUVs?: Vector4;
  122638. }, scene?: Nullable<Scene>): Mesh;
  122639. /**
  122640. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  122641. * * 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
  122642. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  122643. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  122644. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  122645. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  122646. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  122647. * * 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
  122648. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  122649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  122651. * @param name defines the name of the new line system
  122652. * @param options defines the options used to create the line system
  122653. * @param scene defines the hosting scene
  122654. * @returns a new line system mesh
  122655. */
  122656. static CreateLineSystem(name: string, options: {
  122657. lines: Vector3[][];
  122658. updatable?: boolean;
  122659. instance?: Nullable<LinesMesh>;
  122660. colors?: Nullable<Color4[][]>;
  122661. useVertexAlpha?: boolean;
  122662. }, scene: Nullable<Scene>): LinesMesh;
  122663. /**
  122664. * Creates a line mesh
  122665. * 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
  122666. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  122667. * * The parameter `points` is an array successive Vector3
  122668. * * 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
  122669. * * The optional parameter `colors` is an array of successive Color4, one per line point
  122670. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  122671. * * When updating an instance, remember that only point positions can change, not the number of points
  122672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  122674. * @param name defines the name of the new line system
  122675. * @param options defines the options used to create the line system
  122676. * @param scene defines the hosting scene
  122677. * @returns a new line mesh
  122678. */
  122679. static CreateLines(name: string, options: {
  122680. points: Vector3[];
  122681. updatable?: boolean;
  122682. instance?: Nullable<LinesMesh>;
  122683. colors?: Color4[];
  122684. useVertexAlpha?: boolean;
  122685. }, scene?: Nullable<Scene>): LinesMesh;
  122686. /**
  122687. * Creates a dashed line mesh
  122688. * * 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
  122689. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  122690. * * The parameter `points` is an array successive Vector3
  122691. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  122692. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  122693. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  122694. * * 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
  122695. * * When updating an instance, remember that only point positions can change, not the number of points
  122696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122697. * @param name defines the name of the mesh
  122698. * @param options defines the options used to create the mesh
  122699. * @param scene defines the hosting scene
  122700. * @returns the dashed line mesh
  122701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  122702. */
  122703. static CreateDashedLines(name: string, options: {
  122704. points: Vector3[];
  122705. dashSize?: number;
  122706. gapSize?: number;
  122707. dashNb?: number;
  122708. updatable?: boolean;
  122709. instance?: LinesMesh;
  122710. }, scene?: Nullable<Scene>): LinesMesh;
  122711. /**
  122712. * 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.
  122713. * * 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.
  122714. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  122715. * * 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.
  122716. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  122717. * * 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
  122718. * * 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
  122719. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  122720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122722. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  122723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122724. * @param name defines the name of the mesh
  122725. * @param options defines the options used to create the mesh
  122726. * @param scene defines the hosting scene
  122727. * @returns the extruded shape mesh
  122728. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  122730. */
  122731. static ExtrudeShape(name: string, options: {
  122732. shape: Vector3[];
  122733. path: Vector3[];
  122734. scale?: number;
  122735. rotation?: number;
  122736. cap?: number;
  122737. updatable?: boolean;
  122738. sideOrientation?: number;
  122739. frontUVs?: Vector4;
  122740. backUVs?: Vector4;
  122741. instance?: Mesh;
  122742. invertUV?: boolean;
  122743. }, scene?: Nullable<Scene>): Mesh;
  122744. /**
  122745. * Creates an custom extruded shape mesh.
  122746. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  122747. * * 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.
  122748. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  122749. * * 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
  122750. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  122751. * * 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
  122752. * * It must returns a float value that will be the scale value applied to the shape on each path point
  122753. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  122754. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  122755. * * 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
  122756. * * 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
  122757. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  122758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122759. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122762. * @param name defines the name of the mesh
  122763. * @param options defines the options used to create the mesh
  122764. * @param scene defines the hosting scene
  122765. * @returns the custom extruded shape mesh
  122766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  122767. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  122769. */
  122770. static ExtrudeShapeCustom(name: string, options: {
  122771. shape: Vector3[];
  122772. path: Vector3[];
  122773. scaleFunction?: any;
  122774. rotationFunction?: any;
  122775. ribbonCloseArray?: boolean;
  122776. ribbonClosePath?: boolean;
  122777. cap?: number;
  122778. updatable?: boolean;
  122779. sideOrientation?: number;
  122780. frontUVs?: Vector4;
  122781. backUVs?: Vector4;
  122782. instance?: Mesh;
  122783. invertUV?: boolean;
  122784. }, scene?: Nullable<Scene>): Mesh;
  122785. /**
  122786. * Creates lathe mesh.
  122787. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122788. * * 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
  122789. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122790. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122791. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122792. * * 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
  122793. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122794. * * 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
  122795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122797. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122799. * @param name defines the name of the mesh
  122800. * @param options defines the options used to create the mesh
  122801. * @param scene defines the hosting scene
  122802. * @returns the lathe mesh
  122803. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122804. */
  122805. static CreateLathe(name: string, options: {
  122806. shape: Vector3[];
  122807. radius?: number;
  122808. tessellation?: number;
  122809. clip?: number;
  122810. arc?: number;
  122811. closed?: boolean;
  122812. updatable?: boolean;
  122813. sideOrientation?: number;
  122814. frontUVs?: Vector4;
  122815. backUVs?: Vector4;
  122816. cap?: number;
  122817. invertUV?: boolean;
  122818. }, scene?: Nullable<Scene>): Mesh;
  122819. /**
  122820. * Creates a tiled plane mesh
  122821. * * You can set a limited pattern arrangement with the tiles
  122822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122825. * @param name defines the name of the mesh
  122826. * @param options defines the options used to create the mesh
  122827. * @param scene defines the hosting scene
  122828. * @returns the plane mesh
  122829. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122830. */
  122831. static CreateTiledPlane(name: string, options: {
  122832. pattern?: number;
  122833. tileSize?: number;
  122834. tileWidth?: number;
  122835. tileHeight?: number;
  122836. size?: number;
  122837. width?: number;
  122838. height?: number;
  122839. alignHorizontal?: number;
  122840. alignVertical?: number;
  122841. sideOrientation?: number;
  122842. frontUVs?: Vector4;
  122843. backUVs?: Vector4;
  122844. updatable?: boolean;
  122845. }, scene?: Nullable<Scene>): Mesh;
  122846. /**
  122847. * Creates a plane mesh
  122848. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122849. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122850. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122854. * @param name defines the name of the mesh
  122855. * @param options defines the options used to create the mesh
  122856. * @param scene defines the hosting scene
  122857. * @returns the plane mesh
  122858. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122859. */
  122860. static CreatePlane(name: string, options: {
  122861. size?: number;
  122862. width?: number;
  122863. height?: number;
  122864. sideOrientation?: number;
  122865. frontUVs?: Vector4;
  122866. backUVs?: Vector4;
  122867. updatable?: boolean;
  122868. sourcePlane?: Plane;
  122869. }, scene?: Nullable<Scene>): Mesh;
  122870. /**
  122871. * Creates a ground mesh
  122872. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  122873. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  122874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122875. * @param name defines the name of the mesh
  122876. * @param options defines the options used to create the mesh
  122877. * @param scene defines the hosting scene
  122878. * @returns the ground mesh
  122879. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  122880. */
  122881. static CreateGround(name: string, options: {
  122882. width?: number;
  122883. height?: number;
  122884. subdivisions?: number;
  122885. subdivisionsX?: number;
  122886. subdivisionsY?: number;
  122887. updatable?: boolean;
  122888. }, scene?: Nullable<Scene>): Mesh;
  122889. /**
  122890. * Creates a tiled ground mesh
  122891. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  122892. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  122893. * * 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
  122894. * * 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
  122895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122896. * @param name defines the name of the mesh
  122897. * @param options defines the options used to create the mesh
  122898. * @param scene defines the hosting scene
  122899. * @returns the tiled ground mesh
  122900. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  122901. */
  122902. static CreateTiledGround(name: string, options: {
  122903. xmin: number;
  122904. zmin: number;
  122905. xmax: number;
  122906. zmax: number;
  122907. subdivisions?: {
  122908. w: number;
  122909. h: number;
  122910. };
  122911. precision?: {
  122912. w: number;
  122913. h: number;
  122914. };
  122915. updatable?: boolean;
  122916. }, scene?: Nullable<Scene>): Mesh;
  122917. /**
  122918. * Creates a ground mesh from a height map
  122919. * * The parameter `url` sets the URL of the height map image resource.
  122920. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  122921. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  122922. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  122923. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  122924. * * 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.
  122925. * * 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).
  122926. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  122927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122928. * @param name defines the name of the mesh
  122929. * @param url defines the url to the height map
  122930. * @param options defines the options used to create the mesh
  122931. * @param scene defines the hosting scene
  122932. * @returns the ground mesh
  122933. * @see https://doc.babylonjs.com/babylon101/height_map
  122934. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  122935. */
  122936. static CreateGroundFromHeightMap(name: string, url: string, options: {
  122937. width?: number;
  122938. height?: number;
  122939. subdivisions?: number;
  122940. minHeight?: number;
  122941. maxHeight?: number;
  122942. colorFilter?: Color3;
  122943. alphaFilter?: number;
  122944. updatable?: boolean;
  122945. onReady?: (mesh: GroundMesh) => void;
  122946. }, scene?: Nullable<Scene>): GroundMesh;
  122947. /**
  122948. * Creates a polygon mesh
  122949. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122950. * * 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
  122951. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122954. * * Remember you can only change the shape positions, not their number when updating a polygon
  122955. * @param name defines the name of the mesh
  122956. * @param options defines the options used to create the mesh
  122957. * @param scene defines the hosting scene
  122958. * @param earcutInjection can be used to inject your own earcut reference
  122959. * @returns the polygon mesh
  122960. */
  122961. static CreatePolygon(name: string, options: {
  122962. shape: Vector3[];
  122963. holes?: Vector3[][];
  122964. depth?: number;
  122965. faceUV?: Vector4[];
  122966. faceColors?: Color4[];
  122967. updatable?: boolean;
  122968. sideOrientation?: number;
  122969. frontUVs?: Vector4;
  122970. backUVs?: Vector4;
  122971. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122972. /**
  122973. * Creates an extruded polygon mesh, with depth in the Y direction.
  122974. * * 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)
  122975. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122976. * @param name defines the name of the mesh
  122977. * @param options defines the options used to create the mesh
  122978. * @param scene defines the hosting scene
  122979. * @param earcutInjection can be used to inject your own earcut reference
  122980. * @returns the polygon mesh
  122981. */
  122982. static ExtrudePolygon(name: string, options: {
  122983. shape: Vector3[];
  122984. holes?: Vector3[][];
  122985. depth?: number;
  122986. faceUV?: Vector4[];
  122987. faceColors?: Color4[];
  122988. updatable?: boolean;
  122989. sideOrientation?: number;
  122990. frontUVs?: Vector4;
  122991. backUVs?: Vector4;
  122992. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122993. /**
  122994. * Creates a tube mesh.
  122995. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122996. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122997. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122998. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122999. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123000. * * 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)
  123001. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123002. * * 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
  123003. * * 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
  123004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123008. * @param name defines the name of the mesh
  123009. * @param options defines the options used to create the mesh
  123010. * @param scene defines the hosting scene
  123011. * @returns the tube mesh
  123012. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123013. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123014. */
  123015. static CreateTube(name: string, options: {
  123016. path: Vector3[];
  123017. radius?: number;
  123018. tessellation?: number;
  123019. radiusFunction?: {
  123020. (i: number, distance: number): number;
  123021. };
  123022. cap?: number;
  123023. arc?: number;
  123024. updatable?: boolean;
  123025. sideOrientation?: number;
  123026. frontUVs?: Vector4;
  123027. backUVs?: Vector4;
  123028. instance?: Mesh;
  123029. invertUV?: boolean;
  123030. }, scene?: Nullable<Scene>): Mesh;
  123031. /**
  123032. * Creates a polyhedron mesh
  123033. * * 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
  123034. * * The parameter `size` (positive float, default 1) sets the polygon size
  123035. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123036. * * 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`
  123037. * * 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
  123038. * * 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)`)
  123039. * * 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
  123040. * * 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
  123041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123044. * @param name defines the name of the mesh
  123045. * @param options defines the options used to create the mesh
  123046. * @param scene defines the hosting scene
  123047. * @returns the polyhedron mesh
  123048. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123049. */
  123050. static CreatePolyhedron(name: string, options: {
  123051. type?: number;
  123052. size?: number;
  123053. sizeX?: number;
  123054. sizeY?: number;
  123055. sizeZ?: number;
  123056. custom?: any;
  123057. faceUV?: Vector4[];
  123058. faceColors?: Color4[];
  123059. flat?: boolean;
  123060. updatable?: boolean;
  123061. sideOrientation?: number;
  123062. frontUVs?: Vector4;
  123063. backUVs?: Vector4;
  123064. }, scene?: Nullable<Scene>): Mesh;
  123065. /**
  123066. * Creates a decal mesh.
  123067. * 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
  123068. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123069. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123070. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123071. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123072. * @param name defines the name of the mesh
  123073. * @param sourceMesh defines the mesh where the decal must be applied
  123074. * @param options defines the options used to create the mesh
  123075. * @param scene defines the hosting scene
  123076. * @returns the decal mesh
  123077. * @see https://doc.babylonjs.com/how_to/decals
  123078. */
  123079. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123080. position?: Vector3;
  123081. normal?: Vector3;
  123082. size?: Vector3;
  123083. angle?: number;
  123084. }): Mesh;
  123085. }
  123086. }
  123087. declare module BABYLON {
  123088. /**
  123089. * A simplifier interface for future simplification implementations
  123090. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123091. */
  123092. export interface ISimplifier {
  123093. /**
  123094. * Simplification of a given mesh according to the given settings.
  123095. * Since this requires computation, it is assumed that the function runs async.
  123096. * @param settings The settings of the simplification, including quality and distance
  123097. * @param successCallback A callback that will be called after the mesh was simplified.
  123098. * @param errorCallback in case of an error, this callback will be called. optional.
  123099. */
  123100. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123101. }
  123102. /**
  123103. * Expected simplification settings.
  123104. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123105. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123106. */
  123107. export interface ISimplificationSettings {
  123108. /**
  123109. * Gets or sets the expected quality
  123110. */
  123111. quality: number;
  123112. /**
  123113. * Gets or sets the distance when this optimized version should be used
  123114. */
  123115. distance: number;
  123116. /**
  123117. * Gets an already optimized mesh
  123118. */
  123119. optimizeMesh?: boolean;
  123120. }
  123121. /**
  123122. * Class used to specify simplification options
  123123. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123124. */
  123125. export class SimplificationSettings implements ISimplificationSettings {
  123126. /** expected quality */
  123127. quality: number;
  123128. /** distance when this optimized version should be used */
  123129. distance: number;
  123130. /** already optimized mesh */
  123131. optimizeMesh?: boolean | undefined;
  123132. /**
  123133. * Creates a SimplificationSettings
  123134. * @param quality expected quality
  123135. * @param distance distance when this optimized version should be used
  123136. * @param optimizeMesh already optimized mesh
  123137. */
  123138. constructor(
  123139. /** expected quality */
  123140. quality: number,
  123141. /** distance when this optimized version should be used */
  123142. distance: number,
  123143. /** already optimized mesh */
  123144. optimizeMesh?: boolean | undefined);
  123145. }
  123146. /**
  123147. * Interface used to define a simplification task
  123148. */
  123149. export interface ISimplificationTask {
  123150. /**
  123151. * Array of settings
  123152. */
  123153. settings: Array<ISimplificationSettings>;
  123154. /**
  123155. * Simplification type
  123156. */
  123157. simplificationType: SimplificationType;
  123158. /**
  123159. * Mesh to simplify
  123160. */
  123161. mesh: Mesh;
  123162. /**
  123163. * Callback called on success
  123164. */
  123165. successCallback?: () => void;
  123166. /**
  123167. * Defines if parallel processing can be used
  123168. */
  123169. parallelProcessing: boolean;
  123170. }
  123171. /**
  123172. * Queue used to order the simplification tasks
  123173. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123174. */
  123175. export class SimplificationQueue {
  123176. private _simplificationArray;
  123177. /**
  123178. * Gets a boolean indicating that the process is still running
  123179. */
  123180. running: boolean;
  123181. /**
  123182. * Creates a new queue
  123183. */
  123184. constructor();
  123185. /**
  123186. * Adds a new simplification task
  123187. * @param task defines a task to add
  123188. */
  123189. addTask(task: ISimplificationTask): void;
  123190. /**
  123191. * Execute next task
  123192. */
  123193. executeNext(): void;
  123194. /**
  123195. * Execute a simplification task
  123196. * @param task defines the task to run
  123197. */
  123198. runSimplification(task: ISimplificationTask): void;
  123199. private getSimplifier;
  123200. }
  123201. /**
  123202. * The implemented types of simplification
  123203. * At the moment only Quadratic Error Decimation is implemented
  123204. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123205. */
  123206. export enum SimplificationType {
  123207. /** Quadratic error decimation */
  123208. QUADRATIC = 0
  123209. }
  123210. }
  123211. declare module BABYLON {
  123212. interface Scene {
  123213. /** @hidden (Backing field) */
  123214. _simplificationQueue: SimplificationQueue;
  123215. /**
  123216. * Gets or sets the simplification queue attached to the scene
  123217. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123218. */
  123219. simplificationQueue: SimplificationQueue;
  123220. }
  123221. interface Mesh {
  123222. /**
  123223. * Simplify the mesh according to the given array of settings.
  123224. * Function will return immediately and will simplify async
  123225. * @param settings a collection of simplification settings
  123226. * @param parallelProcessing should all levels calculate parallel or one after the other
  123227. * @param simplificationType the type of simplification to run
  123228. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  123229. * @returns the current mesh
  123230. */
  123231. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  123232. }
  123233. /**
  123234. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  123235. * created in a scene
  123236. */
  123237. export class SimplicationQueueSceneComponent implements ISceneComponent {
  123238. /**
  123239. * The component name helpfull to identify the component in the list of scene components.
  123240. */
  123241. readonly name: string;
  123242. /**
  123243. * The scene the component belongs to.
  123244. */
  123245. scene: Scene;
  123246. /**
  123247. * Creates a new instance of the component for the given scene
  123248. * @param scene Defines the scene to register the component in
  123249. */
  123250. constructor(scene: Scene);
  123251. /**
  123252. * Registers the component in a given scene
  123253. */
  123254. register(): void;
  123255. /**
  123256. * Rebuilds the elements related to this component in case of
  123257. * context lost for instance.
  123258. */
  123259. rebuild(): void;
  123260. /**
  123261. * Disposes the component and the associated ressources
  123262. */
  123263. dispose(): void;
  123264. private _beforeCameraUpdate;
  123265. }
  123266. }
  123267. declare module BABYLON {
  123268. /**
  123269. * Navigation plugin interface to add navigation constrained by a navigation mesh
  123270. */
  123271. export interface INavigationEnginePlugin {
  123272. /**
  123273. * plugin name
  123274. */
  123275. name: string;
  123276. /**
  123277. * Creates a navigation mesh
  123278. * @param meshes array of all the geometry used to compute the navigatio mesh
  123279. * @param parameters bunch of parameters used to filter geometry
  123280. */
  123281. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123282. /**
  123283. * Create a navigation mesh debug mesh
  123284. * @param scene is where the mesh will be added
  123285. * @returns debug display mesh
  123286. */
  123287. createDebugNavMesh(scene: Scene): Mesh;
  123288. /**
  123289. * Get a navigation mesh constrained position, closest to the parameter position
  123290. * @param position world position
  123291. * @returns the closest point to position constrained by the navigation mesh
  123292. */
  123293. getClosestPoint(position: Vector3): Vector3;
  123294. /**
  123295. * Get a navigation mesh constrained position, within a particular radius
  123296. * @param position world position
  123297. * @param maxRadius the maximum distance to the constrained world position
  123298. * @returns the closest point to position constrained by the navigation mesh
  123299. */
  123300. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123301. /**
  123302. * Compute the final position from a segment made of destination-position
  123303. * @param position world position
  123304. * @param destination world position
  123305. * @returns the resulting point along the navmesh
  123306. */
  123307. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123308. /**
  123309. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123310. * @param start world position
  123311. * @param end world position
  123312. * @returns array containing world position composing the path
  123313. */
  123314. computePath(start: Vector3, end: Vector3): Vector3[];
  123315. /**
  123316. * If this plugin is supported
  123317. * @returns true if plugin is supported
  123318. */
  123319. isSupported(): boolean;
  123320. /**
  123321. * Create a new Crowd so you can add agents
  123322. * @param maxAgents the maximum agent count in the crowd
  123323. * @param maxAgentRadius the maximum radius an agent can have
  123324. * @param scene to attach the crowd to
  123325. * @returns the crowd you can add agents to
  123326. */
  123327. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  123328. /**
  123329. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123330. * The queries will try to find a solution within those bounds
  123331. * default is (1,1,1)
  123332. * @param extent x,y,z value that define the extent around the queries point of reference
  123333. */
  123334. setDefaultQueryExtent(extent: Vector3): void;
  123335. /**
  123336. * Get the Bounding box extent specified by setDefaultQueryExtent
  123337. * @returns the box extent values
  123338. */
  123339. getDefaultQueryExtent(): Vector3;
  123340. /**
  123341. * Release all resources
  123342. */
  123343. dispose(): void;
  123344. }
  123345. /**
  123346. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  123347. */
  123348. export interface ICrowd {
  123349. /**
  123350. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  123351. * You can attach anything to that node. The node position is updated in the scene update tick.
  123352. * @param pos world position that will be constrained by the navigation mesh
  123353. * @param parameters agent parameters
  123354. * @param transform hooked to the agent that will be update by the scene
  123355. * @returns agent index
  123356. */
  123357. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  123358. /**
  123359. * Returns the agent position in world space
  123360. * @param index agent index returned by addAgent
  123361. * @returns world space position
  123362. */
  123363. getAgentPosition(index: number): Vector3;
  123364. /**
  123365. * Gets the agent velocity in world space
  123366. * @param index agent index returned by addAgent
  123367. * @returns world space velocity
  123368. */
  123369. getAgentVelocity(index: number): Vector3;
  123370. /**
  123371. * remove a particular agent previously created
  123372. * @param index agent index returned by addAgent
  123373. */
  123374. removeAgent(index: number): void;
  123375. /**
  123376. * get the list of all agents attached to this crowd
  123377. * @returns list of agent indices
  123378. */
  123379. getAgents(): number[];
  123380. /**
  123381. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123382. * @param deltaTime in seconds
  123383. */
  123384. update(deltaTime: number): void;
  123385. /**
  123386. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  123387. * @param index agent index returned by addAgent
  123388. * @param destination targeted world position
  123389. */
  123390. agentGoto(index: number, destination: Vector3): void;
  123391. /**
  123392. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123393. * The queries will try to find a solution within those bounds
  123394. * default is (1,1,1)
  123395. * @param extent x,y,z value that define the extent around the queries point of reference
  123396. */
  123397. setDefaultQueryExtent(extent: Vector3): void;
  123398. /**
  123399. * Get the Bounding box extent specified by setDefaultQueryExtent
  123400. * @returns the box extent values
  123401. */
  123402. getDefaultQueryExtent(): Vector3;
  123403. /**
  123404. * Release all resources
  123405. */
  123406. dispose(): void;
  123407. }
  123408. /**
  123409. * Configures an agent
  123410. */
  123411. export interface IAgentParameters {
  123412. /**
  123413. * Agent radius. [Limit: >= 0]
  123414. */
  123415. radius: number;
  123416. /**
  123417. * Agent height. [Limit: > 0]
  123418. */
  123419. height: number;
  123420. /**
  123421. * Maximum allowed acceleration. [Limit: >= 0]
  123422. */
  123423. maxAcceleration: number;
  123424. /**
  123425. * Maximum allowed speed. [Limit: >= 0]
  123426. */
  123427. maxSpeed: number;
  123428. /**
  123429. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  123430. */
  123431. collisionQueryRange: number;
  123432. /**
  123433. * The path visibility optimization range. [Limit: > 0]
  123434. */
  123435. pathOptimizationRange: number;
  123436. /**
  123437. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  123438. */
  123439. separationWeight: number;
  123440. }
  123441. /**
  123442. * Configures the navigation mesh creation
  123443. */
  123444. export interface INavMeshParameters {
  123445. /**
  123446. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  123447. */
  123448. cs: number;
  123449. /**
  123450. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  123451. */
  123452. ch: number;
  123453. /**
  123454. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  123455. */
  123456. walkableSlopeAngle: number;
  123457. /**
  123458. * Minimum floor to 'ceiling' height that will still allow the floor area to
  123459. * be considered walkable. [Limit: >= 3] [Units: vx]
  123460. */
  123461. walkableHeight: number;
  123462. /**
  123463. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  123464. */
  123465. walkableClimb: number;
  123466. /**
  123467. * The distance to erode/shrink the walkable area of the heightfield away from
  123468. * obstructions. [Limit: >=0] [Units: vx]
  123469. */
  123470. walkableRadius: number;
  123471. /**
  123472. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  123473. */
  123474. maxEdgeLen: number;
  123475. /**
  123476. * The maximum distance a simplfied contour's border edges should deviate
  123477. * the original raw contour. [Limit: >=0] [Units: vx]
  123478. */
  123479. maxSimplificationError: number;
  123480. /**
  123481. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  123482. */
  123483. minRegionArea: number;
  123484. /**
  123485. * Any regions with a span count smaller than this value will, if possible,
  123486. * be merged with larger regions. [Limit: >=0] [Units: vx]
  123487. */
  123488. mergeRegionArea: number;
  123489. /**
  123490. * The maximum number of vertices allowed for polygons generated during the
  123491. * contour to polygon conversion process. [Limit: >= 3]
  123492. */
  123493. maxVertsPerPoly: number;
  123494. /**
  123495. * Sets the sampling distance to use when generating the detail mesh.
  123496. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  123497. */
  123498. detailSampleDist: number;
  123499. /**
  123500. * The maximum distance the detail mesh surface should deviate from heightfield
  123501. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  123502. */
  123503. detailSampleMaxError: number;
  123504. }
  123505. }
  123506. declare module BABYLON {
  123507. /**
  123508. * RecastJS navigation plugin
  123509. */
  123510. export class RecastJSPlugin implements INavigationEnginePlugin {
  123511. /**
  123512. * Reference to the Recast library
  123513. */
  123514. bjsRECAST: any;
  123515. /**
  123516. * plugin name
  123517. */
  123518. name: string;
  123519. /**
  123520. * the first navmesh created. We might extend this to support multiple navmeshes
  123521. */
  123522. navMesh: any;
  123523. /**
  123524. * Initializes the recastJS plugin
  123525. * @param recastInjection can be used to inject your own recast reference
  123526. */
  123527. constructor(recastInjection?: any);
  123528. /**
  123529. * Creates a navigation mesh
  123530. * @param meshes array of all the geometry used to compute the navigatio mesh
  123531. * @param parameters bunch of parameters used to filter geometry
  123532. */
  123533. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123534. /**
  123535. * Create a navigation mesh debug mesh
  123536. * @param scene is where the mesh will be added
  123537. * @returns debug display mesh
  123538. */
  123539. createDebugNavMesh(scene: Scene): Mesh;
  123540. /**
  123541. * Get a navigation mesh constrained position, closest to the parameter position
  123542. * @param position world position
  123543. * @returns the closest point to position constrained by the navigation mesh
  123544. */
  123545. getClosestPoint(position: Vector3): Vector3;
  123546. /**
  123547. * Get a navigation mesh constrained position, within a particular radius
  123548. * @param position world position
  123549. * @param maxRadius the maximum distance to the constrained world position
  123550. * @returns the closest point to position constrained by the navigation mesh
  123551. */
  123552. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123553. /**
  123554. * Compute the final position from a segment made of destination-position
  123555. * @param position world position
  123556. * @param destination world position
  123557. * @returns the resulting point along the navmesh
  123558. */
  123559. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123560. /**
  123561. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123562. * @param start world position
  123563. * @param end world position
  123564. * @returns array containing world position composing the path
  123565. */
  123566. computePath(start: Vector3, end: Vector3): Vector3[];
  123567. /**
  123568. * Create a new Crowd so you can add agents
  123569. * @param maxAgents the maximum agent count in the crowd
  123570. * @param maxAgentRadius the maximum radius an agent can have
  123571. * @param scene to attach the crowd to
  123572. * @returns the crowd you can add agents to
  123573. */
  123574. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  123575. /**
  123576. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123577. * The queries will try to find a solution within those bounds
  123578. * default is (1,1,1)
  123579. * @param extent x,y,z value that define the extent around the queries point of reference
  123580. */
  123581. setDefaultQueryExtent(extent: Vector3): void;
  123582. /**
  123583. * Get the Bounding box extent specified by setDefaultQueryExtent
  123584. * @returns the box extent values
  123585. */
  123586. getDefaultQueryExtent(): Vector3;
  123587. /**
  123588. * Disposes
  123589. */
  123590. dispose(): void;
  123591. /**
  123592. * If this plugin is supported
  123593. * @returns true if plugin is supported
  123594. */
  123595. isSupported(): boolean;
  123596. }
  123597. /**
  123598. * Recast detour crowd implementation
  123599. */
  123600. export class RecastJSCrowd implements ICrowd {
  123601. /**
  123602. * Recast/detour plugin
  123603. */
  123604. bjsRECASTPlugin: RecastJSPlugin;
  123605. /**
  123606. * Link to the detour crowd
  123607. */
  123608. recastCrowd: any;
  123609. /**
  123610. * One transform per agent
  123611. */
  123612. transforms: TransformNode[];
  123613. /**
  123614. * All agents created
  123615. */
  123616. agents: number[];
  123617. /**
  123618. * Link to the scene is kept to unregister the crowd from the scene
  123619. */
  123620. private _scene;
  123621. /**
  123622. * Observer for crowd updates
  123623. */
  123624. private _onBeforeAnimationsObserver;
  123625. /**
  123626. * Constructor
  123627. * @param plugin recastJS plugin
  123628. * @param maxAgents the maximum agent count in the crowd
  123629. * @param maxAgentRadius the maximum radius an agent can have
  123630. * @param scene to attach the crowd to
  123631. * @returns the crowd you can add agents to
  123632. */
  123633. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  123634. /**
  123635. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  123636. * You can attach anything to that node. The node position is updated in the scene update tick.
  123637. * @param pos world position that will be constrained by the navigation mesh
  123638. * @param parameters agent parameters
  123639. * @param transform hooked to the agent that will be update by the scene
  123640. * @returns agent index
  123641. */
  123642. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  123643. /**
  123644. * Returns the agent position in world space
  123645. * @param index agent index returned by addAgent
  123646. * @returns world space position
  123647. */
  123648. getAgentPosition(index: number): Vector3;
  123649. /**
  123650. * Returns the agent velocity in world space
  123651. * @param index agent index returned by addAgent
  123652. * @returns world space velocity
  123653. */
  123654. getAgentVelocity(index: number): Vector3;
  123655. /**
  123656. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  123657. * @param index agent index returned by addAgent
  123658. * @param destination targeted world position
  123659. */
  123660. agentGoto(index: number, destination: Vector3): void;
  123661. /**
  123662. * remove a particular agent previously created
  123663. * @param index agent index returned by addAgent
  123664. */
  123665. removeAgent(index: number): void;
  123666. /**
  123667. * get the list of all agents attached to this crowd
  123668. * @returns list of agent indices
  123669. */
  123670. getAgents(): number[];
  123671. /**
  123672. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123673. * @param deltaTime in seconds
  123674. */
  123675. update(deltaTime: number): void;
  123676. /**
  123677. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123678. * The queries will try to find a solution within those bounds
  123679. * default is (1,1,1)
  123680. * @param extent x,y,z value that define the extent around the queries point of reference
  123681. */
  123682. setDefaultQueryExtent(extent: Vector3): void;
  123683. /**
  123684. * Get the Bounding box extent specified by setDefaultQueryExtent
  123685. * @returns the box extent values
  123686. */
  123687. getDefaultQueryExtent(): Vector3;
  123688. /**
  123689. * Release all resources
  123690. */
  123691. dispose(): void;
  123692. }
  123693. }
  123694. declare module BABYLON {
  123695. /**
  123696. * Class used to enable access to IndexedDB
  123697. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123698. */
  123699. export class Database implements IOfflineProvider {
  123700. private _callbackManifestChecked;
  123701. private _currentSceneUrl;
  123702. private _db;
  123703. private _enableSceneOffline;
  123704. private _enableTexturesOffline;
  123705. private _manifestVersionFound;
  123706. private _mustUpdateRessources;
  123707. private _hasReachedQuota;
  123708. private _isSupported;
  123709. private _idbFactory;
  123710. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  123711. private static IsUASupportingBlobStorage;
  123712. /**
  123713. * Gets a boolean indicating if Database storate is enabled (off by default)
  123714. */
  123715. static IDBStorageEnabled: boolean;
  123716. /**
  123717. * Gets a boolean indicating if scene must be saved in the database
  123718. */
  123719. readonly enableSceneOffline: boolean;
  123720. /**
  123721. * Gets a boolean indicating if textures must be saved in the database
  123722. */
  123723. readonly enableTexturesOffline: boolean;
  123724. /**
  123725. * Creates a new Database
  123726. * @param urlToScene defines the url to load the scene
  123727. * @param callbackManifestChecked defines the callback to use when manifest is checked
  123728. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  123729. */
  123730. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  123731. private static _ParseURL;
  123732. private static _ReturnFullUrlLocation;
  123733. private _checkManifestFile;
  123734. /**
  123735. * Open the database and make it available
  123736. * @param successCallback defines the callback to call on success
  123737. * @param errorCallback defines the callback to call on error
  123738. */
  123739. open(successCallback: () => void, errorCallback: () => void): void;
  123740. /**
  123741. * Loads an image from the database
  123742. * @param url defines the url to load from
  123743. * @param image defines the target DOM image
  123744. */
  123745. loadImage(url: string, image: HTMLImageElement): void;
  123746. private _loadImageFromDBAsync;
  123747. private _saveImageIntoDBAsync;
  123748. private _checkVersionFromDB;
  123749. private _loadVersionFromDBAsync;
  123750. private _saveVersionIntoDBAsync;
  123751. /**
  123752. * Loads a file from database
  123753. * @param url defines the URL to load from
  123754. * @param sceneLoaded defines a callback to call on success
  123755. * @param progressCallBack defines a callback to call when progress changed
  123756. * @param errorCallback defines a callback to call on error
  123757. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  123758. */
  123759. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  123760. private _loadFileAsync;
  123761. private _saveFileAsync;
  123762. /**
  123763. * Validates if xhr data is correct
  123764. * @param xhr defines the request to validate
  123765. * @param dataType defines the expected data type
  123766. * @returns true if data is correct
  123767. */
  123768. private static _ValidateXHRData;
  123769. }
  123770. }
  123771. declare module BABYLON {
  123772. /** @hidden */
  123773. export var gpuUpdateParticlesPixelShader: {
  123774. name: string;
  123775. shader: string;
  123776. };
  123777. }
  123778. declare module BABYLON {
  123779. /** @hidden */
  123780. export var gpuUpdateParticlesVertexShader: {
  123781. name: string;
  123782. shader: string;
  123783. };
  123784. }
  123785. declare module BABYLON {
  123786. /** @hidden */
  123787. export var clipPlaneFragmentDeclaration2: {
  123788. name: string;
  123789. shader: string;
  123790. };
  123791. }
  123792. declare module BABYLON {
  123793. /** @hidden */
  123794. export var gpuRenderParticlesPixelShader: {
  123795. name: string;
  123796. shader: string;
  123797. };
  123798. }
  123799. declare module BABYLON {
  123800. /** @hidden */
  123801. export var clipPlaneVertexDeclaration2: {
  123802. name: string;
  123803. shader: string;
  123804. };
  123805. }
  123806. declare module BABYLON {
  123807. /** @hidden */
  123808. export var gpuRenderParticlesVertexShader: {
  123809. name: string;
  123810. shader: string;
  123811. };
  123812. }
  123813. declare module BABYLON {
  123814. /**
  123815. * This represents a GPU particle system in Babylon
  123816. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  123817. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  123818. */
  123819. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  123820. /**
  123821. * The layer mask we are rendering the particles through.
  123822. */
  123823. layerMask: number;
  123824. private _capacity;
  123825. private _activeCount;
  123826. private _currentActiveCount;
  123827. private _accumulatedCount;
  123828. private _renderEffect;
  123829. private _updateEffect;
  123830. private _buffer0;
  123831. private _buffer1;
  123832. private _spriteBuffer;
  123833. private _updateVAO;
  123834. private _renderVAO;
  123835. private _targetIndex;
  123836. private _sourceBuffer;
  123837. private _targetBuffer;
  123838. private _engine;
  123839. private _currentRenderId;
  123840. private _started;
  123841. private _stopped;
  123842. private _timeDelta;
  123843. private _randomTexture;
  123844. private _randomTexture2;
  123845. private _attributesStrideSize;
  123846. private _updateEffectOptions;
  123847. private _randomTextureSize;
  123848. private _actualFrame;
  123849. private readonly _rawTextureWidth;
  123850. /**
  123851. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  123852. */
  123853. static readonly IsSupported: boolean;
  123854. /**
  123855. * An event triggered when the system is disposed.
  123856. */
  123857. onDisposeObservable: Observable<GPUParticleSystem>;
  123858. /**
  123859. * Gets the maximum number of particles active at the same time.
  123860. * @returns The max number of active particles.
  123861. */
  123862. getCapacity(): number;
  123863. /**
  123864. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  123865. * to override the particles.
  123866. */
  123867. forceDepthWrite: boolean;
  123868. /**
  123869. * Gets or set the number of active particles
  123870. */
  123871. activeParticleCount: number;
  123872. private _preWarmDone;
  123873. /**
  123874. * Is this system ready to be used/rendered
  123875. * @return true if the system is ready
  123876. */
  123877. isReady(): boolean;
  123878. /**
  123879. * Gets if the system has been started. (Note: this will still be true after stop is called)
  123880. * @returns True if it has been started, otherwise false.
  123881. */
  123882. isStarted(): boolean;
  123883. /**
  123884. * Starts the particle system and begins to emit
  123885. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  123886. */
  123887. start(delay?: number): void;
  123888. /**
  123889. * Stops the particle system.
  123890. */
  123891. stop(): void;
  123892. /**
  123893. * Remove all active particles
  123894. */
  123895. reset(): void;
  123896. /**
  123897. * Returns the string "GPUParticleSystem"
  123898. * @returns a string containing the class name
  123899. */
  123900. getClassName(): string;
  123901. private _colorGradientsTexture;
  123902. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  123903. /**
  123904. * Adds a new color gradient
  123905. * @param gradient defines the gradient to use (between 0 and 1)
  123906. * @param color1 defines the color to affect to the specified gradient
  123907. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  123908. * @returns the current particle system
  123909. */
  123910. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  123911. /**
  123912. * Remove a specific color gradient
  123913. * @param gradient defines the gradient to remove
  123914. * @returns the current particle system
  123915. */
  123916. removeColorGradient(gradient: number): GPUParticleSystem;
  123917. private _angularSpeedGradientsTexture;
  123918. private _sizeGradientsTexture;
  123919. private _velocityGradientsTexture;
  123920. private _limitVelocityGradientsTexture;
  123921. private _dragGradientsTexture;
  123922. private _addFactorGradient;
  123923. /**
  123924. * Adds a new size gradient
  123925. * @param gradient defines the gradient to use (between 0 and 1)
  123926. * @param factor defines the size factor to affect to the specified gradient
  123927. * @returns the current particle system
  123928. */
  123929. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  123930. /**
  123931. * Remove a specific size gradient
  123932. * @param gradient defines the gradient to remove
  123933. * @returns the current particle system
  123934. */
  123935. removeSizeGradient(gradient: number): GPUParticleSystem;
  123936. /**
  123937. * Adds a new angular speed gradient
  123938. * @param gradient defines the gradient to use (between 0 and 1)
  123939. * @param factor defines the angular speed to affect to the specified gradient
  123940. * @returns the current particle system
  123941. */
  123942. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  123943. /**
  123944. * Remove a specific angular speed gradient
  123945. * @param gradient defines the gradient to remove
  123946. * @returns the current particle system
  123947. */
  123948. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  123949. /**
  123950. * Adds a new velocity gradient
  123951. * @param gradient defines the gradient to use (between 0 and 1)
  123952. * @param factor defines the velocity to affect to the specified gradient
  123953. * @returns the current particle system
  123954. */
  123955. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123956. /**
  123957. * Remove a specific velocity gradient
  123958. * @param gradient defines the gradient to remove
  123959. * @returns the current particle system
  123960. */
  123961. removeVelocityGradient(gradient: number): GPUParticleSystem;
  123962. /**
  123963. * Adds a new limit velocity gradient
  123964. * @param gradient defines the gradient to use (between 0 and 1)
  123965. * @param factor defines the limit velocity value to affect to the specified gradient
  123966. * @returns the current particle system
  123967. */
  123968. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123969. /**
  123970. * Remove a specific limit velocity gradient
  123971. * @param gradient defines the gradient to remove
  123972. * @returns the current particle system
  123973. */
  123974. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  123975. /**
  123976. * Adds a new drag gradient
  123977. * @param gradient defines the gradient to use (between 0 and 1)
  123978. * @param factor defines the drag value to affect to the specified gradient
  123979. * @returns the current particle system
  123980. */
  123981. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  123982. /**
  123983. * Remove a specific drag gradient
  123984. * @param gradient defines the gradient to remove
  123985. * @returns the current particle system
  123986. */
  123987. removeDragGradient(gradient: number): GPUParticleSystem;
  123988. /**
  123989. * Not supported by GPUParticleSystem
  123990. * @param gradient defines the gradient to use (between 0 and 1)
  123991. * @param factor defines the emit rate value to affect to the specified gradient
  123992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123993. * @returns the current particle system
  123994. */
  123995. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123996. /**
  123997. * Not supported by GPUParticleSystem
  123998. * @param gradient defines the gradient to remove
  123999. * @returns the current particle system
  124000. */
  124001. removeEmitRateGradient(gradient: number): IParticleSystem;
  124002. /**
  124003. * Not supported by GPUParticleSystem
  124004. * @param gradient defines the gradient to use (between 0 and 1)
  124005. * @param factor defines the start size value to affect to the specified gradient
  124006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124007. * @returns the current particle system
  124008. */
  124009. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124010. /**
  124011. * Not supported by GPUParticleSystem
  124012. * @param gradient defines the gradient to remove
  124013. * @returns the current particle system
  124014. */
  124015. removeStartSizeGradient(gradient: number): IParticleSystem;
  124016. /**
  124017. * Not supported by GPUParticleSystem
  124018. * @param gradient defines the gradient to use (between 0 and 1)
  124019. * @param min defines the color remap minimal range
  124020. * @param max defines the color remap maximal range
  124021. * @returns the current particle system
  124022. */
  124023. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124024. /**
  124025. * Not supported by GPUParticleSystem
  124026. * @param gradient defines the gradient to remove
  124027. * @returns the current particle system
  124028. */
  124029. removeColorRemapGradient(): IParticleSystem;
  124030. /**
  124031. * Not supported by GPUParticleSystem
  124032. * @param gradient defines the gradient to use (between 0 and 1)
  124033. * @param min defines the alpha remap minimal range
  124034. * @param max defines the alpha remap maximal range
  124035. * @returns the current particle system
  124036. */
  124037. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124038. /**
  124039. * Not supported by GPUParticleSystem
  124040. * @param gradient defines the gradient to remove
  124041. * @returns the current particle system
  124042. */
  124043. removeAlphaRemapGradient(): IParticleSystem;
  124044. /**
  124045. * Not supported by GPUParticleSystem
  124046. * @param gradient defines the gradient to use (between 0 and 1)
  124047. * @param color defines the color to affect to the specified gradient
  124048. * @returns the current particle system
  124049. */
  124050. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124051. /**
  124052. * Not supported by GPUParticleSystem
  124053. * @param gradient defines the gradient to remove
  124054. * @returns the current particle system
  124055. */
  124056. removeRampGradient(): IParticleSystem;
  124057. /**
  124058. * Not supported by GPUParticleSystem
  124059. * @returns the list of ramp gradients
  124060. */
  124061. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124062. /**
  124063. * Not supported by GPUParticleSystem
  124064. * Gets or sets a boolean indicating that ramp gradients must be used
  124065. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124066. */
  124067. useRampGradients: boolean;
  124068. /**
  124069. * Not supported by GPUParticleSystem
  124070. * @param gradient defines the gradient to use (between 0 and 1)
  124071. * @param factor defines the life time factor to affect to the specified gradient
  124072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124073. * @returns the current particle system
  124074. */
  124075. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124076. /**
  124077. * Not supported by GPUParticleSystem
  124078. * @param gradient defines the gradient to remove
  124079. * @returns the current particle system
  124080. */
  124081. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124082. /**
  124083. * Instantiates a GPU particle system.
  124084. * 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.
  124085. * @param name The name of the particle system
  124086. * @param options The options used to create the system
  124087. * @param scene The scene the particle system belongs to
  124088. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124089. */
  124090. constructor(name: string, options: Partial<{
  124091. capacity: number;
  124092. randomTextureSize: number;
  124093. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124094. protected _reset(): void;
  124095. private _createUpdateVAO;
  124096. private _createRenderVAO;
  124097. private _initialize;
  124098. /** @hidden */
  124099. _recreateUpdateEffect(): void;
  124100. /** @hidden */
  124101. _recreateRenderEffect(): void;
  124102. /**
  124103. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124104. * @param preWarm defines if we are in the pre-warmimg phase
  124105. */
  124106. animate(preWarm?: boolean): void;
  124107. private _createFactorGradientTexture;
  124108. private _createSizeGradientTexture;
  124109. private _createAngularSpeedGradientTexture;
  124110. private _createVelocityGradientTexture;
  124111. private _createLimitVelocityGradientTexture;
  124112. private _createDragGradientTexture;
  124113. private _createColorGradientTexture;
  124114. /**
  124115. * Renders the particle system in its current state
  124116. * @param preWarm defines if the system should only update the particles but not render them
  124117. * @returns the current number of particles
  124118. */
  124119. render(preWarm?: boolean): number;
  124120. /**
  124121. * Rebuilds the particle system
  124122. */
  124123. rebuild(): void;
  124124. private _releaseBuffers;
  124125. private _releaseVAOs;
  124126. /**
  124127. * Disposes the particle system and free the associated resources
  124128. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124129. */
  124130. dispose(disposeTexture?: boolean): void;
  124131. /**
  124132. * Clones the particle system.
  124133. * @param name The name of the cloned object
  124134. * @param newEmitter The new emitter to use
  124135. * @returns the cloned particle system
  124136. */
  124137. clone(name: string, newEmitter: any): GPUParticleSystem;
  124138. /**
  124139. * Serializes the particle system to a JSON object.
  124140. * @returns the JSON object
  124141. */
  124142. serialize(): any;
  124143. /**
  124144. * Parses a JSON object to create a GPU particle system.
  124145. * @param parsedParticleSystem The JSON object to parse
  124146. * @param scene The scene to create the particle system in
  124147. * @param rootUrl The root url to use to load external dependencies like texture
  124148. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124149. * @returns the parsed GPU particle system
  124150. */
  124151. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124152. }
  124153. }
  124154. declare module BABYLON {
  124155. /**
  124156. * Represents a set of particle systems working together to create a specific effect
  124157. */
  124158. export class ParticleSystemSet implements IDisposable {
  124159. private _emitterCreationOptions;
  124160. private _emitterNode;
  124161. /**
  124162. * Gets the particle system list
  124163. */
  124164. systems: IParticleSystem[];
  124165. /**
  124166. * Gets the emitter node used with this set
  124167. */
  124168. readonly emitterNode: Nullable<TransformNode>;
  124169. /**
  124170. * Creates a new emitter mesh as a sphere
  124171. * @param options defines the options used to create the sphere
  124172. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124173. * @param scene defines the hosting scene
  124174. */
  124175. setEmitterAsSphere(options: {
  124176. diameter: number;
  124177. segments: number;
  124178. color: Color3;
  124179. }, renderingGroupId: number, scene: Scene): void;
  124180. /**
  124181. * Starts all particle systems of the set
  124182. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124183. */
  124184. start(emitter?: AbstractMesh): void;
  124185. /**
  124186. * Release all associated resources
  124187. */
  124188. dispose(): void;
  124189. /**
  124190. * Serialize the set into a JSON compatible object
  124191. * @returns a JSON compatible representation of the set
  124192. */
  124193. serialize(): any;
  124194. /**
  124195. * Parse a new ParticleSystemSet from a serialized source
  124196. * @param data defines a JSON compatible representation of the set
  124197. * @param scene defines the hosting scene
  124198. * @param gpu defines if we want GPU particles or CPU particles
  124199. * @returns a new ParticleSystemSet
  124200. */
  124201. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124202. }
  124203. }
  124204. declare module BABYLON {
  124205. /**
  124206. * This class is made for on one-liner static method to help creating particle system set.
  124207. */
  124208. export class ParticleHelper {
  124209. /**
  124210. * Gets or sets base Assets URL
  124211. */
  124212. static BaseAssetsUrl: string;
  124213. /**
  124214. * Create a default particle system that you can tweak
  124215. * @param emitter defines the emitter to use
  124216. * @param capacity defines the system capacity (default is 500 particles)
  124217. * @param scene defines the hosting scene
  124218. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  124219. * @returns the new Particle system
  124220. */
  124221. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  124222. /**
  124223. * This is the main static method (one-liner) of this helper to create different particle systems
  124224. * @param type This string represents the type to the particle system to create
  124225. * @param scene The scene where the particle system should live
  124226. * @param gpu If the system will use gpu
  124227. * @returns the ParticleSystemSet created
  124228. */
  124229. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  124230. /**
  124231. * Static function used to export a particle system to a ParticleSystemSet variable.
  124232. * Please note that the emitter shape is not exported
  124233. * @param systems defines the particle systems to export
  124234. * @returns the created particle system set
  124235. */
  124236. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  124237. }
  124238. }
  124239. declare module BABYLON {
  124240. interface Engine {
  124241. /**
  124242. * Create an effect to use with particle systems.
  124243. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  124244. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  124245. * @param uniformsNames defines a list of attribute names
  124246. * @param samplers defines an array of string used to represent textures
  124247. * @param defines defines the string containing the defines to use to compile the shaders
  124248. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  124249. * @param onCompiled defines a function to call when the effect creation is successful
  124250. * @param onError defines a function to call when the effect creation has failed
  124251. * @returns the new Effect
  124252. */
  124253. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  124254. }
  124255. interface Mesh {
  124256. /**
  124257. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  124258. * @returns an array of IParticleSystem
  124259. */
  124260. getEmittedParticleSystems(): IParticleSystem[];
  124261. /**
  124262. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  124263. * @returns an array of IParticleSystem
  124264. */
  124265. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  124266. }
  124267. /**
  124268. * @hidden
  124269. */
  124270. export var _IDoNeedToBeInTheBuild: number;
  124271. }
  124272. declare module BABYLON {
  124273. interface Scene {
  124274. /** @hidden (Backing field) */
  124275. _physicsEngine: Nullable<IPhysicsEngine>;
  124276. /**
  124277. * Gets the current physics engine
  124278. * @returns a IPhysicsEngine or null if none attached
  124279. */
  124280. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  124281. /**
  124282. * Enables physics to the current scene
  124283. * @param gravity defines the scene's gravity for the physics engine
  124284. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  124285. * @return a boolean indicating if the physics engine was initialized
  124286. */
  124287. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  124288. /**
  124289. * Disables and disposes the physics engine associated with the scene
  124290. */
  124291. disablePhysicsEngine(): void;
  124292. /**
  124293. * Gets a boolean indicating if there is an active physics engine
  124294. * @returns a boolean indicating if there is an active physics engine
  124295. */
  124296. isPhysicsEnabled(): boolean;
  124297. /**
  124298. * Deletes a physics compound impostor
  124299. * @param compound defines the compound to delete
  124300. */
  124301. deleteCompoundImpostor(compound: any): void;
  124302. /**
  124303. * An event triggered when physic simulation is about to be run
  124304. */
  124305. onBeforePhysicsObservable: Observable<Scene>;
  124306. /**
  124307. * An event triggered when physic simulation has been done
  124308. */
  124309. onAfterPhysicsObservable: Observable<Scene>;
  124310. }
  124311. interface AbstractMesh {
  124312. /** @hidden */
  124313. _physicsImpostor: Nullable<PhysicsImpostor>;
  124314. /**
  124315. * Gets or sets impostor used for physic simulation
  124316. * @see http://doc.babylonjs.com/features/physics_engine
  124317. */
  124318. physicsImpostor: Nullable<PhysicsImpostor>;
  124319. /**
  124320. * Gets the current physics impostor
  124321. * @see http://doc.babylonjs.com/features/physics_engine
  124322. * @returns a physics impostor or null
  124323. */
  124324. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  124325. /** Apply a physic impulse to the mesh
  124326. * @param force defines the force to apply
  124327. * @param contactPoint defines where to apply the force
  124328. * @returns the current mesh
  124329. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  124330. */
  124331. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  124332. /**
  124333. * Creates a physic joint between two meshes
  124334. * @param otherMesh defines the other mesh to use
  124335. * @param pivot1 defines the pivot to use on this mesh
  124336. * @param pivot2 defines the pivot to use on the other mesh
  124337. * @param options defines additional options (can be plugin dependent)
  124338. * @returns the current mesh
  124339. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  124340. */
  124341. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  124342. /** @hidden */
  124343. _disposePhysicsObserver: Nullable<Observer<Node>>;
  124344. }
  124345. /**
  124346. * Defines the physics engine scene component responsible to manage a physics engine
  124347. */
  124348. export class PhysicsEngineSceneComponent implements ISceneComponent {
  124349. /**
  124350. * The component name helpful to identify the component in the list of scene components.
  124351. */
  124352. readonly name: string;
  124353. /**
  124354. * The scene the component belongs to.
  124355. */
  124356. scene: Scene;
  124357. /**
  124358. * Creates a new instance of the component for the given scene
  124359. * @param scene Defines the scene to register the component in
  124360. */
  124361. constructor(scene: Scene);
  124362. /**
  124363. * Registers the component in a given scene
  124364. */
  124365. register(): void;
  124366. /**
  124367. * Rebuilds the elements related to this component in case of
  124368. * context lost for instance.
  124369. */
  124370. rebuild(): void;
  124371. /**
  124372. * Disposes the component and the associated ressources
  124373. */
  124374. dispose(): void;
  124375. }
  124376. }
  124377. declare module BABYLON {
  124378. /**
  124379. * A helper for physics simulations
  124380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124381. */
  124382. export class PhysicsHelper {
  124383. private _scene;
  124384. private _physicsEngine;
  124385. /**
  124386. * Initializes the Physics helper
  124387. * @param scene Babylon.js scene
  124388. */
  124389. constructor(scene: Scene);
  124390. /**
  124391. * Applies a radial explosion impulse
  124392. * @param origin the origin of the explosion
  124393. * @param radiusOrEventOptions the radius or the options of radial explosion
  124394. * @param strength the explosion strength
  124395. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124396. * @returns A physics radial explosion event, or null
  124397. */
  124398. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  124399. /**
  124400. * Applies a radial explosion force
  124401. * @param origin the origin of the explosion
  124402. * @param radiusOrEventOptions the radius or the options of radial explosion
  124403. * @param strength the explosion strength
  124404. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124405. * @returns A physics radial explosion event, or null
  124406. */
  124407. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  124408. /**
  124409. * Creates a gravitational field
  124410. * @param origin the origin of the explosion
  124411. * @param radiusOrEventOptions the radius or the options of radial explosion
  124412. * @param strength the explosion strength
  124413. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124414. * @returns A physics gravitational field event, or null
  124415. */
  124416. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  124417. /**
  124418. * Creates a physics updraft event
  124419. * @param origin the origin of the updraft
  124420. * @param radiusOrEventOptions the radius or the options of the updraft
  124421. * @param strength the strength of the updraft
  124422. * @param height the height of the updraft
  124423. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  124424. * @returns A physics updraft event, or null
  124425. */
  124426. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  124427. /**
  124428. * Creates a physics vortex event
  124429. * @param origin the of the vortex
  124430. * @param radiusOrEventOptions the radius or the options of the vortex
  124431. * @param strength the strength of the vortex
  124432. * @param height the height of the vortex
  124433. * @returns a Physics vortex event, or null
  124434. * A physics vortex event or null
  124435. */
  124436. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  124437. }
  124438. /**
  124439. * Represents a physics radial explosion event
  124440. */
  124441. class PhysicsRadialExplosionEvent {
  124442. private _scene;
  124443. private _options;
  124444. private _sphere;
  124445. private _dataFetched;
  124446. /**
  124447. * Initializes a radial explosioin event
  124448. * @param _scene BabylonJS scene
  124449. * @param _options The options for the vortex event
  124450. */
  124451. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  124452. /**
  124453. * Returns the data related to the radial explosion event (sphere).
  124454. * @returns The radial explosion event data
  124455. */
  124456. getData(): PhysicsRadialExplosionEventData;
  124457. /**
  124458. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  124459. * @param impostor A physics imposter
  124460. * @param origin the origin of the explosion
  124461. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  124462. */
  124463. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  124464. /**
  124465. * Triggers affecterd impostors callbacks
  124466. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  124467. */
  124468. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  124469. /**
  124470. * Disposes the sphere.
  124471. * @param force Specifies if the sphere should be disposed by force
  124472. */
  124473. dispose(force?: boolean): void;
  124474. /*** Helpers ***/
  124475. private _prepareSphere;
  124476. private _intersectsWithSphere;
  124477. }
  124478. /**
  124479. * Represents a gravitational field event
  124480. */
  124481. class PhysicsGravitationalFieldEvent {
  124482. private _physicsHelper;
  124483. private _scene;
  124484. private _origin;
  124485. private _options;
  124486. private _tickCallback;
  124487. private _sphere;
  124488. private _dataFetched;
  124489. /**
  124490. * Initializes the physics gravitational field event
  124491. * @param _physicsHelper A physics helper
  124492. * @param _scene BabylonJS scene
  124493. * @param _origin The origin position of the gravitational field event
  124494. * @param _options The options for the vortex event
  124495. */
  124496. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  124497. /**
  124498. * Returns the data related to the gravitational field event (sphere).
  124499. * @returns A gravitational field event
  124500. */
  124501. getData(): PhysicsGravitationalFieldEventData;
  124502. /**
  124503. * Enables the gravitational field.
  124504. */
  124505. enable(): void;
  124506. /**
  124507. * Disables the gravitational field.
  124508. */
  124509. disable(): void;
  124510. /**
  124511. * Disposes the sphere.
  124512. * @param force The force to dispose from the gravitational field event
  124513. */
  124514. dispose(force?: boolean): void;
  124515. private _tick;
  124516. }
  124517. /**
  124518. * Represents a physics updraft event
  124519. */
  124520. class PhysicsUpdraftEvent {
  124521. private _scene;
  124522. private _origin;
  124523. private _options;
  124524. private _physicsEngine;
  124525. private _originTop;
  124526. private _originDirection;
  124527. private _tickCallback;
  124528. private _cylinder;
  124529. private _cylinderPosition;
  124530. private _dataFetched;
  124531. /**
  124532. * Initializes the physics updraft event
  124533. * @param _scene BabylonJS scene
  124534. * @param _origin The origin position of the updraft
  124535. * @param _options The options for the updraft event
  124536. */
  124537. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  124538. /**
  124539. * Returns the data related to the updraft event (cylinder).
  124540. * @returns A physics updraft event
  124541. */
  124542. getData(): PhysicsUpdraftEventData;
  124543. /**
  124544. * Enables the updraft.
  124545. */
  124546. enable(): void;
  124547. /**
  124548. * Disables the updraft.
  124549. */
  124550. disable(): void;
  124551. /**
  124552. * Disposes the cylinder.
  124553. * @param force Specifies if the updraft should be disposed by force
  124554. */
  124555. dispose(force?: boolean): void;
  124556. private getImpostorHitData;
  124557. private _tick;
  124558. /*** Helpers ***/
  124559. private _prepareCylinder;
  124560. private _intersectsWithCylinder;
  124561. }
  124562. /**
  124563. * Represents a physics vortex event
  124564. */
  124565. class PhysicsVortexEvent {
  124566. private _scene;
  124567. private _origin;
  124568. private _options;
  124569. private _physicsEngine;
  124570. private _originTop;
  124571. private _tickCallback;
  124572. private _cylinder;
  124573. private _cylinderPosition;
  124574. private _dataFetched;
  124575. /**
  124576. * Initializes the physics vortex event
  124577. * @param _scene The BabylonJS scene
  124578. * @param _origin The origin position of the vortex
  124579. * @param _options The options for the vortex event
  124580. */
  124581. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  124582. /**
  124583. * Returns the data related to the vortex event (cylinder).
  124584. * @returns The physics vortex event data
  124585. */
  124586. getData(): PhysicsVortexEventData;
  124587. /**
  124588. * Enables the vortex.
  124589. */
  124590. enable(): void;
  124591. /**
  124592. * Disables the cortex.
  124593. */
  124594. disable(): void;
  124595. /**
  124596. * Disposes the sphere.
  124597. * @param force
  124598. */
  124599. dispose(force?: boolean): void;
  124600. private getImpostorHitData;
  124601. private _tick;
  124602. /*** Helpers ***/
  124603. private _prepareCylinder;
  124604. private _intersectsWithCylinder;
  124605. }
  124606. /**
  124607. * Options fot the radial explosion event
  124608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124609. */
  124610. export class PhysicsRadialExplosionEventOptions {
  124611. /**
  124612. * The radius of the sphere for the radial explosion.
  124613. */
  124614. radius: number;
  124615. /**
  124616. * The strenth of the explosion.
  124617. */
  124618. strength: number;
  124619. /**
  124620. * The strenght of the force in correspondence to the distance of the affected object
  124621. */
  124622. falloff: PhysicsRadialImpulseFalloff;
  124623. /**
  124624. * Sphere options for the radial explosion.
  124625. */
  124626. sphere: {
  124627. segments: number;
  124628. diameter: number;
  124629. };
  124630. /**
  124631. * Sphere options for the radial explosion.
  124632. */
  124633. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  124634. }
  124635. /**
  124636. * Options fot the updraft event
  124637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124638. */
  124639. export class PhysicsUpdraftEventOptions {
  124640. /**
  124641. * The radius of the cylinder for the vortex
  124642. */
  124643. radius: number;
  124644. /**
  124645. * The strenth of the updraft.
  124646. */
  124647. strength: number;
  124648. /**
  124649. * The height of the cylinder for the updraft.
  124650. */
  124651. height: number;
  124652. /**
  124653. * The mode for the the updraft.
  124654. */
  124655. updraftMode: PhysicsUpdraftMode;
  124656. }
  124657. /**
  124658. * Options fot the vortex event
  124659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124660. */
  124661. export class PhysicsVortexEventOptions {
  124662. /**
  124663. * The radius of the cylinder for the vortex
  124664. */
  124665. radius: number;
  124666. /**
  124667. * The strenth of the vortex.
  124668. */
  124669. strength: number;
  124670. /**
  124671. * The height of the cylinder for the vortex.
  124672. */
  124673. height: number;
  124674. /**
  124675. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  124676. */
  124677. centripetalForceThreshold: number;
  124678. /**
  124679. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  124680. */
  124681. centripetalForceMultiplier: number;
  124682. /**
  124683. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  124684. */
  124685. centrifugalForceMultiplier: number;
  124686. /**
  124687. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  124688. */
  124689. updraftForceMultiplier: number;
  124690. }
  124691. /**
  124692. * The strenght of the force in correspondence to the distance of the affected object
  124693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124694. */
  124695. export enum PhysicsRadialImpulseFalloff {
  124696. /** Defines that impulse is constant in strength across it's whole radius */
  124697. Constant = 0,
  124698. /** Defines that impulse gets weaker if it's further from the origin */
  124699. Linear = 1
  124700. }
  124701. /**
  124702. * The strength of the force in correspondence to the distance of the affected object
  124703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124704. */
  124705. export enum PhysicsUpdraftMode {
  124706. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  124707. Center = 0,
  124708. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  124709. Perpendicular = 1
  124710. }
  124711. /**
  124712. * Interface for a physics hit data
  124713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124714. */
  124715. export interface PhysicsHitData {
  124716. /**
  124717. * The force applied at the contact point
  124718. */
  124719. force: Vector3;
  124720. /**
  124721. * The contact point
  124722. */
  124723. contactPoint: Vector3;
  124724. /**
  124725. * The distance from the origin to the contact point
  124726. */
  124727. distanceFromOrigin: number;
  124728. }
  124729. /**
  124730. * Interface for radial explosion event data
  124731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124732. */
  124733. export interface PhysicsRadialExplosionEventData {
  124734. /**
  124735. * A sphere used for the radial explosion event
  124736. */
  124737. sphere: Mesh;
  124738. }
  124739. /**
  124740. * Interface for gravitational field event data
  124741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124742. */
  124743. export interface PhysicsGravitationalFieldEventData {
  124744. /**
  124745. * A sphere mesh used for the gravitational field event
  124746. */
  124747. sphere: Mesh;
  124748. }
  124749. /**
  124750. * Interface for updraft event data
  124751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124752. */
  124753. export interface PhysicsUpdraftEventData {
  124754. /**
  124755. * A cylinder used for the updraft event
  124756. */
  124757. cylinder: Mesh;
  124758. }
  124759. /**
  124760. * Interface for vortex event data
  124761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124762. */
  124763. export interface PhysicsVortexEventData {
  124764. /**
  124765. * A cylinder used for the vortex event
  124766. */
  124767. cylinder: Mesh;
  124768. }
  124769. /**
  124770. * Interface for an affected physics impostor
  124771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124772. */
  124773. export interface PhysicsAffectedImpostorWithData {
  124774. /**
  124775. * The impostor affected by the effect
  124776. */
  124777. impostor: PhysicsImpostor;
  124778. /**
  124779. * The data about the hit/horce from the explosion
  124780. */
  124781. hitData: PhysicsHitData;
  124782. }
  124783. }
  124784. declare module BABYLON {
  124785. /** @hidden */
  124786. export var blackAndWhitePixelShader: {
  124787. name: string;
  124788. shader: string;
  124789. };
  124790. }
  124791. declare module BABYLON {
  124792. /**
  124793. * Post process used to render in black and white
  124794. */
  124795. export class BlackAndWhitePostProcess extends PostProcess {
  124796. /**
  124797. * Linear about to convert he result to black and white (default: 1)
  124798. */
  124799. degree: number;
  124800. /**
  124801. * Creates a black and white post process
  124802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  124803. * @param name The name of the effect.
  124804. * @param options The required width/height ratio to downsize to before computing the render pass.
  124805. * @param camera The camera to apply the render pass to.
  124806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124807. * @param engine The engine which the post process will be applied. (default: current engine)
  124808. * @param reusable If the post process can be reused on the same frame. (default: false)
  124809. */
  124810. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124811. }
  124812. }
  124813. declare module BABYLON {
  124814. /**
  124815. * This represents a set of one or more post processes in Babylon.
  124816. * A post process can be used to apply a shader to a texture after it is rendered.
  124817. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124818. */
  124819. export class PostProcessRenderEffect {
  124820. private _postProcesses;
  124821. private _getPostProcesses;
  124822. private _singleInstance;
  124823. private _cameras;
  124824. private _indicesForCamera;
  124825. /**
  124826. * Name of the effect
  124827. * @hidden
  124828. */
  124829. _name: string;
  124830. /**
  124831. * Instantiates a post process render effect.
  124832. * A post process can be used to apply a shader to a texture after it is rendered.
  124833. * @param engine The engine the effect is tied to
  124834. * @param name The name of the effect
  124835. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  124836. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  124837. */
  124838. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  124839. /**
  124840. * Checks if all the post processes in the effect are supported.
  124841. */
  124842. readonly isSupported: boolean;
  124843. /**
  124844. * Updates the current state of the effect
  124845. * @hidden
  124846. */
  124847. _update(): void;
  124848. /**
  124849. * Attaches the effect on cameras
  124850. * @param cameras The camera to attach to.
  124851. * @hidden
  124852. */
  124853. _attachCameras(cameras: Camera): void;
  124854. /**
  124855. * Attaches the effect on cameras
  124856. * @param cameras The camera to attach to.
  124857. * @hidden
  124858. */
  124859. _attachCameras(cameras: Camera[]): void;
  124860. /**
  124861. * Detaches the effect on cameras
  124862. * @param cameras The camera to detatch from.
  124863. * @hidden
  124864. */
  124865. _detachCameras(cameras: Camera): void;
  124866. /**
  124867. * Detatches the effect on cameras
  124868. * @param cameras The camera to detatch from.
  124869. * @hidden
  124870. */
  124871. _detachCameras(cameras: Camera[]): void;
  124872. /**
  124873. * Enables the effect on given cameras
  124874. * @param cameras The camera to enable.
  124875. * @hidden
  124876. */
  124877. _enable(cameras: Camera): void;
  124878. /**
  124879. * Enables the effect on given cameras
  124880. * @param cameras The camera to enable.
  124881. * @hidden
  124882. */
  124883. _enable(cameras: Nullable<Camera[]>): void;
  124884. /**
  124885. * Disables the effect on the given cameras
  124886. * @param cameras The camera to disable.
  124887. * @hidden
  124888. */
  124889. _disable(cameras: Camera): void;
  124890. /**
  124891. * Disables the effect on the given cameras
  124892. * @param cameras The camera to disable.
  124893. * @hidden
  124894. */
  124895. _disable(cameras: Nullable<Camera[]>): void;
  124896. /**
  124897. * Gets a list of the post processes contained in the effect.
  124898. * @param camera The camera to get the post processes on.
  124899. * @returns The list of the post processes in the effect.
  124900. */
  124901. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  124902. }
  124903. }
  124904. declare module BABYLON {
  124905. /** @hidden */
  124906. export var extractHighlightsPixelShader: {
  124907. name: string;
  124908. shader: string;
  124909. };
  124910. }
  124911. declare module BABYLON {
  124912. /**
  124913. * 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.
  124914. */
  124915. export class ExtractHighlightsPostProcess extends PostProcess {
  124916. /**
  124917. * The luminance threshold, pixels below this value will be set to black.
  124918. */
  124919. threshold: number;
  124920. /** @hidden */
  124921. _exposure: number;
  124922. /**
  124923. * Post process which has the input texture to be used when performing highlight extraction
  124924. * @hidden
  124925. */
  124926. _inputPostProcess: Nullable<PostProcess>;
  124927. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124928. }
  124929. }
  124930. declare module BABYLON {
  124931. /** @hidden */
  124932. export var bloomMergePixelShader: {
  124933. name: string;
  124934. shader: string;
  124935. };
  124936. }
  124937. declare module BABYLON {
  124938. /**
  124939. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124940. */
  124941. export class BloomMergePostProcess extends PostProcess {
  124942. /** Weight of the bloom to be added to the original input. */
  124943. weight: number;
  124944. /**
  124945. * Creates a new instance of @see BloomMergePostProcess
  124946. * @param name The name of the effect.
  124947. * @param originalFromInput Post process which's input will be used for the merge.
  124948. * @param blurred Blurred highlights post process which's output will be used.
  124949. * @param weight Weight of the bloom to be added to the original input.
  124950. * @param options The required width/height ratio to downsize to before computing the render pass.
  124951. * @param camera The camera to apply the render pass to.
  124952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124953. * @param engine The engine which the post process will be applied. (default: current engine)
  124954. * @param reusable If the post process can be reused on the same frame. (default: false)
  124955. * @param textureType Type of textures used when performing the post process. (default: 0)
  124956. * @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)
  124957. */
  124958. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  124959. /** Weight of the bloom to be added to the original input. */
  124960. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124961. }
  124962. }
  124963. declare module BABYLON {
  124964. /**
  124965. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  124966. */
  124967. export class BloomEffect extends PostProcessRenderEffect {
  124968. private bloomScale;
  124969. /**
  124970. * @hidden Internal
  124971. */
  124972. _effects: Array<PostProcess>;
  124973. /**
  124974. * @hidden Internal
  124975. */
  124976. _downscale: ExtractHighlightsPostProcess;
  124977. private _blurX;
  124978. private _blurY;
  124979. private _merge;
  124980. /**
  124981. * The luminance threshold to find bright areas of the image to bloom.
  124982. */
  124983. threshold: number;
  124984. /**
  124985. * The strength of the bloom.
  124986. */
  124987. weight: number;
  124988. /**
  124989. * Specifies the size of the bloom blur kernel, relative to the final output size
  124990. */
  124991. kernel: number;
  124992. /**
  124993. * Creates a new instance of @see BloomEffect
  124994. * @param scene The scene the effect belongs to.
  124995. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  124996. * @param bloomKernel The size of the kernel to be used when applying the blur.
  124997. * @param bloomWeight The the strength of bloom.
  124998. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124999. * @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)
  125000. */
  125001. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125002. /**
  125003. * Disposes each of the internal effects for a given camera.
  125004. * @param camera The camera to dispose the effect on.
  125005. */
  125006. disposeEffects(camera: Camera): void;
  125007. /**
  125008. * @hidden Internal
  125009. */
  125010. _updateEffects(): void;
  125011. /**
  125012. * Internal
  125013. * @returns if all the contained post processes are ready.
  125014. * @hidden
  125015. */
  125016. _isReady(): boolean;
  125017. }
  125018. }
  125019. declare module BABYLON {
  125020. /** @hidden */
  125021. export var chromaticAberrationPixelShader: {
  125022. name: string;
  125023. shader: string;
  125024. };
  125025. }
  125026. declare module BABYLON {
  125027. /**
  125028. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125029. */
  125030. export class ChromaticAberrationPostProcess extends PostProcess {
  125031. /**
  125032. * The amount of seperation of rgb channels (default: 30)
  125033. */
  125034. aberrationAmount: number;
  125035. /**
  125036. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125037. */
  125038. radialIntensity: number;
  125039. /**
  125040. * 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))
  125041. */
  125042. direction: Vector2;
  125043. /**
  125044. * 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))
  125045. */
  125046. centerPosition: Vector2;
  125047. /**
  125048. * Creates a new instance ChromaticAberrationPostProcess
  125049. * @param name The name of the effect.
  125050. * @param screenWidth The width of the screen to apply the effect on.
  125051. * @param screenHeight The height of the screen to apply the effect on.
  125052. * @param options The required width/height ratio to downsize to before computing the render pass.
  125053. * @param camera The camera to apply the render pass to.
  125054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125055. * @param engine The engine which the post process will be applied. (default: current engine)
  125056. * @param reusable If the post process can be reused on the same frame. (default: false)
  125057. * @param textureType Type of textures used when performing the post process. (default: 0)
  125058. * @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)
  125059. */
  125060. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125061. }
  125062. }
  125063. declare module BABYLON {
  125064. /** @hidden */
  125065. export var circleOfConfusionPixelShader: {
  125066. name: string;
  125067. shader: string;
  125068. };
  125069. }
  125070. declare module BABYLON {
  125071. /**
  125072. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125073. */
  125074. export class CircleOfConfusionPostProcess extends PostProcess {
  125075. /**
  125076. * 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.
  125077. */
  125078. lensSize: number;
  125079. /**
  125080. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125081. */
  125082. fStop: number;
  125083. /**
  125084. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125085. */
  125086. focusDistance: number;
  125087. /**
  125088. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125089. */
  125090. focalLength: number;
  125091. private _depthTexture;
  125092. /**
  125093. * Creates a new instance CircleOfConfusionPostProcess
  125094. * @param name The name of the effect.
  125095. * @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.
  125096. * @param options The required width/height ratio to downsize to before computing the render pass.
  125097. * @param camera The camera to apply the render pass to.
  125098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125099. * @param engine The engine which the post process will be applied. (default: current engine)
  125100. * @param reusable If the post process can be reused on the same frame. (default: false)
  125101. * @param textureType Type of textures used when performing the post process. (default: 0)
  125102. * @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)
  125103. */
  125104. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125105. /**
  125106. * 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.
  125107. */
  125108. depthTexture: RenderTargetTexture;
  125109. }
  125110. }
  125111. declare module BABYLON {
  125112. /** @hidden */
  125113. export var colorCorrectionPixelShader: {
  125114. name: string;
  125115. shader: string;
  125116. };
  125117. }
  125118. declare module BABYLON {
  125119. /**
  125120. *
  125121. * This post-process allows the modification of rendered colors by using
  125122. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125123. *
  125124. * The object needs to be provided an url to a texture containing the color
  125125. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125126. * Use an image editing software to tweak the LUT to match your needs.
  125127. *
  125128. * For an example of a color LUT, see here:
  125129. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125130. * For explanations on color grading, see here:
  125131. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125132. *
  125133. */
  125134. export class ColorCorrectionPostProcess extends PostProcess {
  125135. private _colorTableTexture;
  125136. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125137. }
  125138. }
  125139. declare module BABYLON {
  125140. /** @hidden */
  125141. export var convolutionPixelShader: {
  125142. name: string;
  125143. shader: string;
  125144. };
  125145. }
  125146. declare module BABYLON {
  125147. /**
  125148. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125149. * input texture to perform effects such as edge detection or sharpening
  125150. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125151. */
  125152. export class ConvolutionPostProcess extends PostProcess {
  125153. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125154. kernel: number[];
  125155. /**
  125156. * Creates a new instance ConvolutionPostProcess
  125157. * @param name The name of the effect.
  125158. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125159. * @param options The required width/height ratio to downsize to before computing the render pass.
  125160. * @param camera The camera to apply the render pass to.
  125161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125162. * @param engine The engine which the post process will be applied. (default: current engine)
  125163. * @param reusable If the post process can be reused on the same frame. (default: false)
  125164. * @param textureType Type of textures used when performing the post process. (default: 0)
  125165. */
  125166. constructor(name: string,
  125167. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125168. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125169. /**
  125170. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125171. */
  125172. static EdgeDetect0Kernel: number[];
  125173. /**
  125174. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125175. */
  125176. static EdgeDetect1Kernel: number[];
  125177. /**
  125178. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125179. */
  125180. static EdgeDetect2Kernel: number[];
  125181. /**
  125182. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125183. */
  125184. static SharpenKernel: number[];
  125185. /**
  125186. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125187. */
  125188. static EmbossKernel: number[];
  125189. /**
  125190. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125191. */
  125192. static GaussianKernel: number[];
  125193. }
  125194. }
  125195. declare module BABYLON {
  125196. /**
  125197. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125198. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125199. * based on samples that have a large difference in distance than the center pixel.
  125200. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125201. */
  125202. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125203. direction: Vector2;
  125204. /**
  125205. * Creates a new instance CircleOfConfusionPostProcess
  125206. * @param name The name of the effect.
  125207. * @param scene The scene the effect belongs to.
  125208. * @param direction The direction the blur should be applied.
  125209. * @param kernel The size of the kernel used to blur.
  125210. * @param options The required width/height ratio to downsize to before computing the render pass.
  125211. * @param camera The camera to apply the render pass to.
  125212. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125213. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125215. * @param engine The engine which the post process will be applied. (default: current engine)
  125216. * @param reusable If the post process can be reused on the same frame. (default: false)
  125217. * @param textureType Type of textures used when performing the post process. (default: 0)
  125218. * @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)
  125219. */
  125220. 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);
  125221. }
  125222. }
  125223. declare module BABYLON {
  125224. /** @hidden */
  125225. export var depthOfFieldMergePixelShader: {
  125226. name: string;
  125227. shader: string;
  125228. };
  125229. }
  125230. declare module BABYLON {
  125231. /**
  125232. * Options to be set when merging outputs from the default pipeline.
  125233. */
  125234. export class DepthOfFieldMergePostProcessOptions {
  125235. /**
  125236. * The original image to merge on top of
  125237. */
  125238. originalFromInput: PostProcess;
  125239. /**
  125240. * Parameters to perform the merge of the depth of field effect
  125241. */
  125242. depthOfField?: {
  125243. circleOfConfusion: PostProcess;
  125244. blurSteps: Array<PostProcess>;
  125245. };
  125246. /**
  125247. * Parameters to perform the merge of bloom effect
  125248. */
  125249. bloom?: {
  125250. blurred: PostProcess;
  125251. weight: number;
  125252. };
  125253. }
  125254. /**
  125255. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125256. */
  125257. export class DepthOfFieldMergePostProcess extends PostProcess {
  125258. private blurSteps;
  125259. /**
  125260. * Creates a new instance of DepthOfFieldMergePostProcess
  125261. * @param name The name of the effect.
  125262. * @param originalFromInput Post process which's input will be used for the merge.
  125263. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  125264. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  125265. * @param options The required width/height ratio to downsize to before computing the render pass.
  125266. * @param camera The camera to apply the render pass to.
  125267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125268. * @param engine The engine which the post process will be applied. (default: current engine)
  125269. * @param reusable If the post process can be reused on the same frame. (default: false)
  125270. * @param textureType Type of textures used when performing the post process. (default: 0)
  125271. * @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)
  125272. */
  125273. 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);
  125274. /**
  125275. * Updates the effect with the current post process compile time values and recompiles the shader.
  125276. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  125277. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  125278. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  125279. * @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
  125280. * @param onCompiled Called when the shader has been compiled.
  125281. * @param onError Called if there is an error when compiling a shader.
  125282. */
  125283. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  125284. }
  125285. }
  125286. declare module BABYLON {
  125287. /**
  125288. * Specifies the level of max blur that should be applied when using the depth of field effect
  125289. */
  125290. export enum DepthOfFieldEffectBlurLevel {
  125291. /**
  125292. * Subtle blur
  125293. */
  125294. Low = 0,
  125295. /**
  125296. * Medium blur
  125297. */
  125298. Medium = 1,
  125299. /**
  125300. * Large blur
  125301. */
  125302. High = 2
  125303. }
  125304. /**
  125305. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  125306. */
  125307. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  125308. private _circleOfConfusion;
  125309. /**
  125310. * @hidden Internal, blurs from high to low
  125311. */
  125312. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  125313. private _depthOfFieldBlurY;
  125314. private _dofMerge;
  125315. /**
  125316. * @hidden Internal post processes in depth of field effect
  125317. */
  125318. _effects: Array<PostProcess>;
  125319. /**
  125320. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  125321. */
  125322. focalLength: number;
  125323. /**
  125324. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125325. */
  125326. fStop: number;
  125327. /**
  125328. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125329. */
  125330. focusDistance: number;
  125331. /**
  125332. * 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.
  125333. */
  125334. lensSize: number;
  125335. /**
  125336. * Creates a new instance DepthOfFieldEffect
  125337. * @param scene The scene the effect belongs to.
  125338. * @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.
  125339. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125340. * @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)
  125341. */
  125342. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  125343. /**
  125344. * Get the current class name of the current effet
  125345. * @returns "DepthOfFieldEffect"
  125346. */
  125347. getClassName(): string;
  125348. /**
  125349. * 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.
  125350. */
  125351. depthTexture: RenderTargetTexture;
  125352. /**
  125353. * Disposes each of the internal effects for a given camera.
  125354. * @param camera The camera to dispose the effect on.
  125355. */
  125356. disposeEffects(camera: Camera): void;
  125357. /**
  125358. * @hidden Internal
  125359. */
  125360. _updateEffects(): void;
  125361. /**
  125362. * Internal
  125363. * @returns if all the contained post processes are ready.
  125364. * @hidden
  125365. */
  125366. _isReady(): boolean;
  125367. }
  125368. }
  125369. declare module BABYLON {
  125370. /** @hidden */
  125371. export var displayPassPixelShader: {
  125372. name: string;
  125373. shader: string;
  125374. };
  125375. }
  125376. declare module BABYLON {
  125377. /**
  125378. * DisplayPassPostProcess which produces an output the same as it's input
  125379. */
  125380. export class DisplayPassPostProcess extends PostProcess {
  125381. /**
  125382. * Creates the DisplayPassPostProcess
  125383. * @param name The name of the effect.
  125384. * @param options The required width/height ratio to downsize to before computing the render pass.
  125385. * @param camera The camera to apply the render pass to.
  125386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125387. * @param engine The engine which the post process will be applied. (default: current engine)
  125388. * @param reusable If the post process can be reused on the same frame. (default: false)
  125389. */
  125390. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125391. }
  125392. }
  125393. declare module BABYLON {
  125394. /** @hidden */
  125395. export var filterPixelShader: {
  125396. name: string;
  125397. shader: string;
  125398. };
  125399. }
  125400. declare module BABYLON {
  125401. /**
  125402. * Applies a kernel filter to the image
  125403. */
  125404. export class FilterPostProcess extends PostProcess {
  125405. /** The matrix to be applied to the image */
  125406. kernelMatrix: Matrix;
  125407. /**
  125408. *
  125409. * @param name The name of the effect.
  125410. * @param kernelMatrix The matrix to be applied to the image
  125411. * @param options The required width/height ratio to downsize to before computing the render pass.
  125412. * @param camera The camera to apply the render pass to.
  125413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125414. * @param engine The engine which the post process will be applied. (default: current engine)
  125415. * @param reusable If the post process can be reused on the same frame. (default: false)
  125416. */
  125417. constructor(name: string,
  125418. /** The matrix to be applied to the image */
  125419. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125420. }
  125421. }
  125422. declare module BABYLON {
  125423. /** @hidden */
  125424. export var fxaaPixelShader: {
  125425. name: string;
  125426. shader: string;
  125427. };
  125428. }
  125429. declare module BABYLON {
  125430. /** @hidden */
  125431. export var fxaaVertexShader: {
  125432. name: string;
  125433. shader: string;
  125434. };
  125435. }
  125436. declare module BABYLON {
  125437. /**
  125438. * Fxaa post process
  125439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  125440. */
  125441. export class FxaaPostProcess extends PostProcess {
  125442. /** @hidden */
  125443. texelWidth: number;
  125444. /** @hidden */
  125445. texelHeight: number;
  125446. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125447. private _getDefines;
  125448. }
  125449. }
  125450. declare module BABYLON {
  125451. /** @hidden */
  125452. export var grainPixelShader: {
  125453. name: string;
  125454. shader: string;
  125455. };
  125456. }
  125457. declare module BABYLON {
  125458. /**
  125459. * The GrainPostProcess adds noise to the image at mid luminance levels
  125460. */
  125461. export class GrainPostProcess extends PostProcess {
  125462. /**
  125463. * The intensity of the grain added (default: 30)
  125464. */
  125465. intensity: number;
  125466. /**
  125467. * If the grain should be randomized on every frame
  125468. */
  125469. animated: boolean;
  125470. /**
  125471. * Creates a new instance of @see GrainPostProcess
  125472. * @param name The name of the effect.
  125473. * @param options The required width/height ratio to downsize to before computing the render pass.
  125474. * @param camera The camera to apply the render pass to.
  125475. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125476. * @param engine The engine which the post process will be applied. (default: current engine)
  125477. * @param reusable If the post process can be reused on the same frame. (default: false)
  125478. * @param textureType Type of textures used when performing the post process. (default: 0)
  125479. * @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)
  125480. */
  125481. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125482. }
  125483. }
  125484. declare module BABYLON {
  125485. /** @hidden */
  125486. export var highlightsPixelShader: {
  125487. name: string;
  125488. shader: string;
  125489. };
  125490. }
  125491. declare module BABYLON {
  125492. /**
  125493. * Extracts highlights from the image
  125494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125495. */
  125496. export class HighlightsPostProcess extends PostProcess {
  125497. /**
  125498. * Extracts highlights from the image
  125499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125500. * @param name The name of the effect.
  125501. * @param options The required width/height ratio to downsize to before computing the render pass.
  125502. * @param camera The camera to apply the render pass to.
  125503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125504. * @param engine The engine which the post process will be applied. (default: current engine)
  125505. * @param reusable If the post process can be reused on the same frame. (default: false)
  125506. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  125507. */
  125508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125509. }
  125510. }
  125511. declare module BABYLON {
  125512. /** @hidden */
  125513. export var mrtFragmentDeclaration: {
  125514. name: string;
  125515. shader: string;
  125516. };
  125517. }
  125518. declare module BABYLON {
  125519. /** @hidden */
  125520. export var geometryPixelShader: {
  125521. name: string;
  125522. shader: string;
  125523. };
  125524. }
  125525. declare module BABYLON {
  125526. /** @hidden */
  125527. export var geometryVertexShader: {
  125528. name: string;
  125529. shader: string;
  125530. };
  125531. }
  125532. declare module BABYLON {
  125533. /** @hidden */
  125534. interface ISavedTransformationMatrix {
  125535. world: Matrix;
  125536. viewProjection: Matrix;
  125537. }
  125538. /**
  125539. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  125540. */
  125541. export class GeometryBufferRenderer {
  125542. /**
  125543. * Constant used to retrieve the position texture index in the G-Buffer textures array
  125544. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  125545. */
  125546. static readonly POSITION_TEXTURE_TYPE: number;
  125547. /**
  125548. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  125549. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  125550. */
  125551. static readonly VELOCITY_TEXTURE_TYPE: number;
  125552. /**
  125553. * Dictionary used to store the previous transformation matrices of each rendered mesh
  125554. * in order to compute objects velocities when enableVelocity is set to "true"
  125555. * @hidden
  125556. */
  125557. _previousTransformationMatrices: {
  125558. [index: number]: ISavedTransformationMatrix;
  125559. };
  125560. /**
  125561. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  125562. * in order to compute objects velocities when enableVelocity is set to "true"
  125563. * @hidden
  125564. */
  125565. _previousBonesTransformationMatrices: {
  125566. [index: number]: Float32Array;
  125567. };
  125568. /**
  125569. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  125570. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  125571. */
  125572. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  125573. private _scene;
  125574. private _multiRenderTarget;
  125575. private _ratio;
  125576. private _enablePosition;
  125577. private _enableVelocity;
  125578. private _positionIndex;
  125579. private _velocityIndex;
  125580. protected _effect: Effect;
  125581. protected _cachedDefines: string;
  125582. /**
  125583. * Set the render list (meshes to be rendered) used in the G buffer.
  125584. */
  125585. renderList: Mesh[];
  125586. /**
  125587. * Gets wether or not G buffer are supported by the running hardware.
  125588. * This requires draw buffer supports
  125589. */
  125590. readonly isSupported: boolean;
  125591. /**
  125592. * Returns the index of the given texture type in the G-Buffer textures array
  125593. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  125594. * @returns the index of the given texture type in the G-Buffer textures array
  125595. */
  125596. getTextureIndex(textureType: number): number;
  125597. /**
  125598. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  125599. */
  125600. /**
  125601. * Sets whether or not objects positions are enabled for the G buffer.
  125602. */
  125603. enablePosition: boolean;
  125604. /**
  125605. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  125606. */
  125607. /**
  125608. * Sets wether or not objects velocities are enabled for the G buffer.
  125609. */
  125610. enableVelocity: boolean;
  125611. /**
  125612. * Gets the scene associated with the buffer.
  125613. */
  125614. readonly scene: Scene;
  125615. /**
  125616. * Gets the ratio used by the buffer during its creation.
  125617. * How big is the buffer related to the main canvas.
  125618. */
  125619. readonly ratio: number;
  125620. /** @hidden */
  125621. static _SceneComponentInitialization: (scene: Scene) => void;
  125622. /**
  125623. * Creates a new G Buffer for the scene
  125624. * @param scene The scene the buffer belongs to
  125625. * @param ratio How big is the buffer related to the main canvas.
  125626. */
  125627. constructor(scene: Scene, ratio?: number);
  125628. /**
  125629. * Checks wether everything is ready to render a submesh to the G buffer.
  125630. * @param subMesh the submesh to check readiness for
  125631. * @param useInstances is the mesh drawn using instance or not
  125632. * @returns true if ready otherwise false
  125633. */
  125634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125635. /**
  125636. * Gets the current underlying G Buffer.
  125637. * @returns the buffer
  125638. */
  125639. getGBuffer(): MultiRenderTarget;
  125640. /**
  125641. * Gets the number of samples used to render the buffer (anti aliasing).
  125642. */
  125643. /**
  125644. * Sets the number of samples used to render the buffer (anti aliasing).
  125645. */
  125646. samples: number;
  125647. /**
  125648. * Disposes the renderer and frees up associated resources.
  125649. */
  125650. dispose(): void;
  125651. protected _createRenderTargets(): void;
  125652. private _copyBonesTransformationMatrices;
  125653. }
  125654. }
  125655. declare module BABYLON {
  125656. interface Scene {
  125657. /** @hidden (Backing field) */
  125658. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  125659. /**
  125660. * Gets or Sets the current geometry buffer associated to the scene.
  125661. */
  125662. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  125663. /**
  125664. * Enables a GeometryBufferRender and associates it with the scene
  125665. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  125666. * @returns the GeometryBufferRenderer
  125667. */
  125668. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  125669. /**
  125670. * Disables the GeometryBufferRender associated with the scene
  125671. */
  125672. disableGeometryBufferRenderer(): void;
  125673. }
  125674. /**
  125675. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  125676. * in several rendering techniques.
  125677. */
  125678. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  125679. /**
  125680. * The component name helpful to identify the component in the list of scene components.
  125681. */
  125682. readonly name: string;
  125683. /**
  125684. * The scene the component belongs to.
  125685. */
  125686. scene: Scene;
  125687. /**
  125688. * Creates a new instance of the component for the given scene
  125689. * @param scene Defines the scene to register the component in
  125690. */
  125691. constructor(scene: Scene);
  125692. /**
  125693. * Registers the component in a given scene
  125694. */
  125695. register(): void;
  125696. /**
  125697. * Rebuilds the elements related to this component in case of
  125698. * context lost for instance.
  125699. */
  125700. rebuild(): void;
  125701. /**
  125702. * Disposes the component and the associated ressources
  125703. */
  125704. dispose(): void;
  125705. private _gatherRenderTargets;
  125706. }
  125707. }
  125708. declare module BABYLON {
  125709. /** @hidden */
  125710. export var motionBlurPixelShader: {
  125711. name: string;
  125712. shader: string;
  125713. };
  125714. }
  125715. declare module BABYLON {
  125716. /**
  125717. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  125718. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  125719. * As an example, all you have to do is to create the post-process:
  125720. * var mb = new BABYLON.MotionBlurPostProcess(
  125721. * 'mb', // The name of the effect.
  125722. * scene, // The scene containing the objects to blur according to their velocity.
  125723. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  125724. * camera // The camera to apply the render pass to.
  125725. * );
  125726. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  125727. */
  125728. export class MotionBlurPostProcess extends PostProcess {
  125729. /**
  125730. * Defines how much the image is blurred by the movement. Default value is equal to 1
  125731. */
  125732. motionStrength: number;
  125733. /**
  125734. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  125735. */
  125736. /**
  125737. * Sets the number of iterations to be used for motion blur quality
  125738. */
  125739. motionBlurSamples: number;
  125740. private _motionBlurSamples;
  125741. private _geometryBufferRenderer;
  125742. /**
  125743. * Creates a new instance MotionBlurPostProcess
  125744. * @param name The name of the effect.
  125745. * @param scene The scene containing the objects to blur according to their velocity.
  125746. * @param options The required width/height ratio to downsize to before computing the render pass.
  125747. * @param camera The camera to apply the render pass to.
  125748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125749. * @param engine The engine which the post process will be applied. (default: current engine)
  125750. * @param reusable If the post process can be reused on the same frame. (default: false)
  125751. * @param textureType Type of textures used when performing the post process. (default: 0)
  125752. * @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)
  125753. */
  125754. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125755. /**
  125756. * Excludes the given skinned mesh from computing bones velocities.
  125757. * 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.
  125758. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  125759. */
  125760. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  125761. /**
  125762. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  125763. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  125764. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  125765. */
  125766. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  125767. /**
  125768. * Disposes the post process.
  125769. * @param camera The camera to dispose the post process on.
  125770. */
  125771. dispose(camera?: Camera): void;
  125772. }
  125773. }
  125774. declare module BABYLON {
  125775. /** @hidden */
  125776. export var refractionPixelShader: {
  125777. name: string;
  125778. shader: string;
  125779. };
  125780. }
  125781. declare module BABYLON {
  125782. /**
  125783. * Post process which applies a refractin texture
  125784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125785. */
  125786. export class RefractionPostProcess extends PostProcess {
  125787. /** the base color of the refraction (used to taint the rendering) */
  125788. color: Color3;
  125789. /** simulated refraction depth */
  125790. depth: number;
  125791. /** the coefficient of the base color (0 to remove base color tainting) */
  125792. colorLevel: number;
  125793. private _refTexture;
  125794. private _ownRefractionTexture;
  125795. /**
  125796. * Gets or sets the refraction texture
  125797. * Please note that you are responsible for disposing the texture if you set it manually
  125798. */
  125799. refractionTexture: Texture;
  125800. /**
  125801. * Initializes the RefractionPostProcess
  125802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125803. * @param name The name of the effect.
  125804. * @param refractionTextureUrl Url of the refraction texture to use
  125805. * @param color the base color of the refraction (used to taint the rendering)
  125806. * @param depth simulated refraction depth
  125807. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  125808. * @param camera The camera to apply the render pass to.
  125809. * @param options The required width/height ratio to downsize to before computing the render pass.
  125810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125811. * @param engine The engine which the post process will be applied. (default: current engine)
  125812. * @param reusable If the post process can be reused on the same frame. (default: false)
  125813. */
  125814. constructor(name: string, refractionTextureUrl: string,
  125815. /** the base color of the refraction (used to taint the rendering) */
  125816. color: Color3,
  125817. /** simulated refraction depth */
  125818. depth: number,
  125819. /** the coefficient of the base color (0 to remove base color tainting) */
  125820. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125821. /**
  125822. * Disposes of the post process
  125823. * @param camera Camera to dispose post process on
  125824. */
  125825. dispose(camera: Camera): void;
  125826. }
  125827. }
  125828. declare module BABYLON {
  125829. /** @hidden */
  125830. export var sharpenPixelShader: {
  125831. name: string;
  125832. shader: string;
  125833. };
  125834. }
  125835. declare module BABYLON {
  125836. /**
  125837. * The SharpenPostProcess applies a sharpen kernel to every pixel
  125838. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125839. */
  125840. export class SharpenPostProcess extends PostProcess {
  125841. /**
  125842. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  125843. */
  125844. colorAmount: number;
  125845. /**
  125846. * How much sharpness should be applied (default: 0.3)
  125847. */
  125848. edgeAmount: number;
  125849. /**
  125850. * Creates a new instance ConvolutionPostProcess
  125851. * @param name The name of the effect.
  125852. * @param options The required width/height ratio to downsize to before computing the render pass.
  125853. * @param camera The camera to apply the render pass to.
  125854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125855. * @param engine The engine which the post process will be applied. (default: current engine)
  125856. * @param reusable If the post process can be reused on the same frame. (default: false)
  125857. * @param textureType Type of textures used when performing the post process. (default: 0)
  125858. * @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)
  125859. */
  125860. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125861. }
  125862. }
  125863. declare module BABYLON {
  125864. /**
  125865. * PostProcessRenderPipeline
  125866. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125867. */
  125868. export class PostProcessRenderPipeline {
  125869. private engine;
  125870. private _renderEffects;
  125871. private _renderEffectsForIsolatedPass;
  125872. /**
  125873. * List of inspectable custom properties (used by the Inspector)
  125874. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  125875. */
  125876. inspectableCustomProperties: IInspectable[];
  125877. /**
  125878. * @hidden
  125879. */
  125880. protected _cameras: Camera[];
  125881. /** @hidden */
  125882. _name: string;
  125883. /**
  125884. * Gets pipeline name
  125885. */
  125886. readonly name: string;
  125887. /**
  125888. * Initializes a PostProcessRenderPipeline
  125889. * @param engine engine to add the pipeline to
  125890. * @param name name of the pipeline
  125891. */
  125892. constructor(engine: Engine, name: string);
  125893. /**
  125894. * Gets the class name
  125895. * @returns "PostProcessRenderPipeline"
  125896. */
  125897. getClassName(): string;
  125898. /**
  125899. * If all the render effects in the pipeline are supported
  125900. */
  125901. readonly isSupported: boolean;
  125902. /**
  125903. * Adds an effect to the pipeline
  125904. * @param renderEffect the effect to add
  125905. */
  125906. addEffect(renderEffect: PostProcessRenderEffect): void;
  125907. /** @hidden */
  125908. _rebuild(): void;
  125909. /** @hidden */
  125910. _enableEffect(renderEffectName: string, cameras: Camera): void;
  125911. /** @hidden */
  125912. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  125913. /** @hidden */
  125914. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  125915. /** @hidden */
  125916. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  125917. /** @hidden */
  125918. _attachCameras(cameras: Camera, unique: boolean): void;
  125919. /** @hidden */
  125920. _attachCameras(cameras: Camera[], unique: boolean): void;
  125921. /** @hidden */
  125922. _detachCameras(cameras: Camera): void;
  125923. /** @hidden */
  125924. _detachCameras(cameras: Nullable<Camera[]>): void;
  125925. /** @hidden */
  125926. _update(): void;
  125927. /** @hidden */
  125928. _reset(): void;
  125929. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  125930. /**
  125931. * Disposes of the pipeline
  125932. */
  125933. dispose(): void;
  125934. }
  125935. }
  125936. declare module BABYLON {
  125937. /**
  125938. * PostProcessRenderPipelineManager class
  125939. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125940. */
  125941. export class PostProcessRenderPipelineManager {
  125942. private _renderPipelines;
  125943. /**
  125944. * Initializes a PostProcessRenderPipelineManager
  125945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125946. */
  125947. constructor();
  125948. /**
  125949. * Gets the list of supported render pipelines
  125950. */
  125951. readonly supportedPipelines: PostProcessRenderPipeline[];
  125952. /**
  125953. * Adds a pipeline to the manager
  125954. * @param renderPipeline The pipeline to add
  125955. */
  125956. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  125957. /**
  125958. * Attaches a camera to the pipeline
  125959. * @param renderPipelineName The name of the pipeline to attach to
  125960. * @param cameras the camera to attach
  125961. * @param unique if the camera can be attached multiple times to the pipeline
  125962. */
  125963. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  125964. /**
  125965. * Detaches a camera from the pipeline
  125966. * @param renderPipelineName The name of the pipeline to detach from
  125967. * @param cameras the camera to detach
  125968. */
  125969. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  125970. /**
  125971. * Enables an effect by name on a pipeline
  125972. * @param renderPipelineName the name of the pipeline to enable the effect in
  125973. * @param renderEffectName the name of the effect to enable
  125974. * @param cameras the cameras that the effect should be enabled on
  125975. */
  125976. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125977. /**
  125978. * Disables an effect by name on a pipeline
  125979. * @param renderPipelineName the name of the pipeline to disable the effect in
  125980. * @param renderEffectName the name of the effect to disable
  125981. * @param cameras the cameras that the effect should be disabled on
  125982. */
  125983. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125984. /**
  125985. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  125986. */
  125987. update(): void;
  125988. /** @hidden */
  125989. _rebuild(): void;
  125990. /**
  125991. * Disposes of the manager and pipelines
  125992. */
  125993. dispose(): void;
  125994. }
  125995. }
  125996. declare module BABYLON {
  125997. interface Scene {
  125998. /** @hidden (Backing field) */
  125999. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126000. /**
  126001. * Gets the postprocess render pipeline manager
  126002. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126003. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126004. */
  126005. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126006. }
  126007. /**
  126008. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126009. */
  126010. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126011. /**
  126012. * The component name helpfull to identify the component in the list of scene components.
  126013. */
  126014. readonly name: string;
  126015. /**
  126016. * The scene the component belongs to.
  126017. */
  126018. scene: Scene;
  126019. /**
  126020. * Creates a new instance of the component for the given scene
  126021. * @param scene Defines the scene to register the component in
  126022. */
  126023. constructor(scene: Scene);
  126024. /**
  126025. * Registers the component in a given scene
  126026. */
  126027. register(): void;
  126028. /**
  126029. * Rebuilds the elements related to this component in case of
  126030. * context lost for instance.
  126031. */
  126032. rebuild(): void;
  126033. /**
  126034. * Disposes the component and the associated ressources
  126035. */
  126036. dispose(): void;
  126037. private _gatherRenderTargets;
  126038. }
  126039. }
  126040. declare module BABYLON {
  126041. /**
  126042. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126043. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126044. */
  126045. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126046. private _scene;
  126047. private _camerasToBeAttached;
  126048. /**
  126049. * ID of the sharpen post process,
  126050. */
  126051. private readonly SharpenPostProcessId;
  126052. /**
  126053. * @ignore
  126054. * ID of the image processing post process;
  126055. */
  126056. readonly ImageProcessingPostProcessId: string;
  126057. /**
  126058. * @ignore
  126059. * ID of the Fast Approximate Anti-Aliasing post process;
  126060. */
  126061. readonly FxaaPostProcessId: string;
  126062. /**
  126063. * ID of the chromatic aberration post process,
  126064. */
  126065. private readonly ChromaticAberrationPostProcessId;
  126066. /**
  126067. * ID of the grain post process
  126068. */
  126069. private readonly GrainPostProcessId;
  126070. /**
  126071. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126072. */
  126073. sharpen: SharpenPostProcess;
  126074. private _sharpenEffect;
  126075. private bloom;
  126076. /**
  126077. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126078. */
  126079. depthOfField: DepthOfFieldEffect;
  126080. /**
  126081. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126082. */
  126083. fxaa: FxaaPostProcess;
  126084. /**
  126085. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126086. */
  126087. imageProcessing: ImageProcessingPostProcess;
  126088. /**
  126089. * Chromatic aberration post process which will shift rgb colors in the image
  126090. */
  126091. chromaticAberration: ChromaticAberrationPostProcess;
  126092. private _chromaticAberrationEffect;
  126093. /**
  126094. * Grain post process which add noise to the image
  126095. */
  126096. grain: GrainPostProcess;
  126097. private _grainEffect;
  126098. /**
  126099. * Glow post process which adds a glow to emissive areas of the image
  126100. */
  126101. private _glowLayer;
  126102. /**
  126103. * Animations which can be used to tweak settings over a period of time
  126104. */
  126105. animations: Animation[];
  126106. private _imageProcessingConfigurationObserver;
  126107. private _sharpenEnabled;
  126108. private _bloomEnabled;
  126109. private _depthOfFieldEnabled;
  126110. private _depthOfFieldBlurLevel;
  126111. private _fxaaEnabled;
  126112. private _imageProcessingEnabled;
  126113. private _defaultPipelineTextureType;
  126114. private _bloomScale;
  126115. private _chromaticAberrationEnabled;
  126116. private _grainEnabled;
  126117. private _buildAllowed;
  126118. /**
  126119. * Gets active scene
  126120. */
  126121. readonly scene: Scene;
  126122. /**
  126123. * Enable or disable the sharpen process from the pipeline
  126124. */
  126125. sharpenEnabled: boolean;
  126126. private _resizeObserver;
  126127. private _hardwareScaleLevel;
  126128. private _bloomKernel;
  126129. /**
  126130. * Specifies the size of the bloom blur kernel, relative to the final output size
  126131. */
  126132. bloomKernel: number;
  126133. /**
  126134. * Specifies the weight of the bloom in the final rendering
  126135. */
  126136. private _bloomWeight;
  126137. /**
  126138. * Specifies the luma threshold for the area that will be blurred by the bloom
  126139. */
  126140. private _bloomThreshold;
  126141. private _hdr;
  126142. /**
  126143. * The strength of the bloom.
  126144. */
  126145. bloomWeight: number;
  126146. /**
  126147. * The strength of the bloom.
  126148. */
  126149. bloomThreshold: number;
  126150. /**
  126151. * The scale of the bloom, lower value will provide better performance.
  126152. */
  126153. bloomScale: number;
  126154. /**
  126155. * Enable or disable the bloom from the pipeline
  126156. */
  126157. bloomEnabled: boolean;
  126158. private _rebuildBloom;
  126159. /**
  126160. * If the depth of field is enabled.
  126161. */
  126162. depthOfFieldEnabled: boolean;
  126163. /**
  126164. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126165. */
  126166. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126167. /**
  126168. * If the anti aliasing is enabled.
  126169. */
  126170. fxaaEnabled: boolean;
  126171. private _samples;
  126172. /**
  126173. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126174. */
  126175. samples: number;
  126176. /**
  126177. * If image processing is enabled.
  126178. */
  126179. imageProcessingEnabled: boolean;
  126180. /**
  126181. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126182. */
  126183. glowLayerEnabled: boolean;
  126184. /**
  126185. * Gets the glow layer (or null if not defined)
  126186. */
  126187. readonly glowLayer: Nullable<GlowLayer>;
  126188. /**
  126189. * Enable or disable the chromaticAberration process from the pipeline
  126190. */
  126191. chromaticAberrationEnabled: boolean;
  126192. /**
  126193. * Enable or disable the grain process from the pipeline
  126194. */
  126195. grainEnabled: boolean;
  126196. /**
  126197. * @constructor
  126198. * @param name - The rendering pipeline name (default: "")
  126199. * @param hdr - If high dynamic range textures should be used (default: true)
  126200. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126201. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126202. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126203. */
  126204. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126205. /**
  126206. * Get the class name
  126207. * @returns "DefaultRenderingPipeline"
  126208. */
  126209. getClassName(): string;
  126210. /**
  126211. * Force the compilation of the entire pipeline.
  126212. */
  126213. prepare(): void;
  126214. private _hasCleared;
  126215. private _prevPostProcess;
  126216. private _prevPrevPostProcess;
  126217. private _setAutoClearAndTextureSharing;
  126218. private _depthOfFieldSceneObserver;
  126219. private _buildPipeline;
  126220. private _disposePostProcesses;
  126221. /**
  126222. * Adds a camera to the pipeline
  126223. * @param camera the camera to be added
  126224. */
  126225. addCamera(camera: Camera): void;
  126226. /**
  126227. * Removes a camera from the pipeline
  126228. * @param camera the camera to remove
  126229. */
  126230. removeCamera(camera: Camera): void;
  126231. /**
  126232. * Dispose of the pipeline and stop all post processes
  126233. */
  126234. dispose(): void;
  126235. /**
  126236. * Serialize the rendering pipeline (Used when exporting)
  126237. * @returns the serialized object
  126238. */
  126239. serialize(): any;
  126240. /**
  126241. * Parse the serialized pipeline
  126242. * @param source Source pipeline.
  126243. * @param scene The scene to load the pipeline to.
  126244. * @param rootUrl The URL of the serialized pipeline.
  126245. * @returns An instantiated pipeline from the serialized object.
  126246. */
  126247. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  126248. }
  126249. }
  126250. declare module BABYLON {
  126251. /** @hidden */
  126252. export var lensHighlightsPixelShader: {
  126253. name: string;
  126254. shader: string;
  126255. };
  126256. }
  126257. declare module BABYLON {
  126258. /** @hidden */
  126259. export var depthOfFieldPixelShader: {
  126260. name: string;
  126261. shader: string;
  126262. };
  126263. }
  126264. declare module BABYLON {
  126265. /**
  126266. * BABYLON.JS Chromatic Aberration GLSL Shader
  126267. * Author: Olivier Guyot
  126268. * Separates very slightly R, G and B colors on the edges of the screen
  126269. * Inspired by Francois Tarlier & Martins Upitis
  126270. */
  126271. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  126272. /**
  126273. * @ignore
  126274. * The chromatic aberration PostProcess id in the pipeline
  126275. */
  126276. LensChromaticAberrationEffect: string;
  126277. /**
  126278. * @ignore
  126279. * The highlights enhancing PostProcess id in the pipeline
  126280. */
  126281. HighlightsEnhancingEffect: string;
  126282. /**
  126283. * @ignore
  126284. * The depth-of-field PostProcess id in the pipeline
  126285. */
  126286. LensDepthOfFieldEffect: string;
  126287. private _scene;
  126288. private _depthTexture;
  126289. private _grainTexture;
  126290. private _chromaticAberrationPostProcess;
  126291. private _highlightsPostProcess;
  126292. private _depthOfFieldPostProcess;
  126293. private _edgeBlur;
  126294. private _grainAmount;
  126295. private _chromaticAberration;
  126296. private _distortion;
  126297. private _highlightsGain;
  126298. private _highlightsThreshold;
  126299. private _dofDistance;
  126300. private _dofAperture;
  126301. private _dofDarken;
  126302. private _dofPentagon;
  126303. private _blurNoise;
  126304. /**
  126305. * @constructor
  126306. *
  126307. * Effect parameters are as follow:
  126308. * {
  126309. * chromatic_aberration: number; // from 0 to x (1 for realism)
  126310. * edge_blur: number; // from 0 to x (1 for realism)
  126311. * distortion: number; // from 0 to x (1 for realism)
  126312. * grain_amount: number; // from 0 to 1
  126313. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  126314. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  126315. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  126316. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  126317. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  126318. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  126319. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  126320. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  126321. * }
  126322. * Note: if an effect parameter is unset, effect is disabled
  126323. *
  126324. * @param name The rendering pipeline name
  126325. * @param parameters - An object containing all parameters (see above)
  126326. * @param scene The scene linked to this pipeline
  126327. * @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)
  126328. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126329. */
  126330. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  126331. /**
  126332. * Get the class name
  126333. * @returns "LensRenderingPipeline"
  126334. */
  126335. getClassName(): string;
  126336. /**
  126337. * Gets associated scene
  126338. */
  126339. readonly scene: Scene;
  126340. /**
  126341. * Gets or sets the edge blur
  126342. */
  126343. edgeBlur: number;
  126344. /**
  126345. * Gets or sets the grain amount
  126346. */
  126347. grainAmount: number;
  126348. /**
  126349. * Gets or sets the chromatic aberration amount
  126350. */
  126351. chromaticAberration: number;
  126352. /**
  126353. * Gets or sets the depth of field aperture
  126354. */
  126355. dofAperture: number;
  126356. /**
  126357. * Gets or sets the edge distortion
  126358. */
  126359. edgeDistortion: number;
  126360. /**
  126361. * Gets or sets the depth of field distortion
  126362. */
  126363. dofDistortion: number;
  126364. /**
  126365. * Gets or sets the darken out of focus amount
  126366. */
  126367. darkenOutOfFocus: number;
  126368. /**
  126369. * Gets or sets a boolean indicating if blur noise is enabled
  126370. */
  126371. blurNoise: boolean;
  126372. /**
  126373. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  126374. */
  126375. pentagonBokeh: boolean;
  126376. /**
  126377. * Gets or sets the highlight grain amount
  126378. */
  126379. highlightsGain: number;
  126380. /**
  126381. * Gets or sets the highlight threshold
  126382. */
  126383. highlightsThreshold: number;
  126384. /**
  126385. * Sets the amount of blur at the edges
  126386. * @param amount blur amount
  126387. */
  126388. setEdgeBlur(amount: number): void;
  126389. /**
  126390. * Sets edge blur to 0
  126391. */
  126392. disableEdgeBlur(): void;
  126393. /**
  126394. * Sets the amout of grain
  126395. * @param amount Amount of grain
  126396. */
  126397. setGrainAmount(amount: number): void;
  126398. /**
  126399. * Set grain amount to 0
  126400. */
  126401. disableGrain(): void;
  126402. /**
  126403. * Sets the chromatic aberration amount
  126404. * @param amount amount of chromatic aberration
  126405. */
  126406. setChromaticAberration(amount: number): void;
  126407. /**
  126408. * Sets chromatic aberration amount to 0
  126409. */
  126410. disableChromaticAberration(): void;
  126411. /**
  126412. * Sets the EdgeDistortion amount
  126413. * @param amount amount of EdgeDistortion
  126414. */
  126415. setEdgeDistortion(amount: number): void;
  126416. /**
  126417. * Sets edge distortion to 0
  126418. */
  126419. disableEdgeDistortion(): void;
  126420. /**
  126421. * Sets the FocusDistance amount
  126422. * @param amount amount of FocusDistance
  126423. */
  126424. setFocusDistance(amount: number): void;
  126425. /**
  126426. * Disables depth of field
  126427. */
  126428. disableDepthOfField(): void;
  126429. /**
  126430. * Sets the Aperture amount
  126431. * @param amount amount of Aperture
  126432. */
  126433. setAperture(amount: number): void;
  126434. /**
  126435. * Sets the DarkenOutOfFocus amount
  126436. * @param amount amount of DarkenOutOfFocus
  126437. */
  126438. setDarkenOutOfFocus(amount: number): void;
  126439. private _pentagonBokehIsEnabled;
  126440. /**
  126441. * Creates a pentagon bokeh effect
  126442. */
  126443. enablePentagonBokeh(): void;
  126444. /**
  126445. * Disables the pentagon bokeh effect
  126446. */
  126447. disablePentagonBokeh(): void;
  126448. /**
  126449. * Enables noise blur
  126450. */
  126451. enableNoiseBlur(): void;
  126452. /**
  126453. * Disables noise blur
  126454. */
  126455. disableNoiseBlur(): void;
  126456. /**
  126457. * Sets the HighlightsGain amount
  126458. * @param amount amount of HighlightsGain
  126459. */
  126460. setHighlightsGain(amount: number): void;
  126461. /**
  126462. * Sets the HighlightsThreshold amount
  126463. * @param amount amount of HighlightsThreshold
  126464. */
  126465. setHighlightsThreshold(amount: number): void;
  126466. /**
  126467. * Disables highlights
  126468. */
  126469. disableHighlights(): void;
  126470. /**
  126471. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  126472. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  126473. */
  126474. dispose(disableDepthRender?: boolean): void;
  126475. private _createChromaticAberrationPostProcess;
  126476. private _createHighlightsPostProcess;
  126477. private _createDepthOfFieldPostProcess;
  126478. private _createGrainTexture;
  126479. }
  126480. }
  126481. declare module BABYLON {
  126482. /** @hidden */
  126483. export var ssao2PixelShader: {
  126484. name: string;
  126485. shader: string;
  126486. };
  126487. }
  126488. declare module BABYLON {
  126489. /** @hidden */
  126490. export var ssaoCombinePixelShader: {
  126491. name: string;
  126492. shader: string;
  126493. };
  126494. }
  126495. declare module BABYLON {
  126496. /**
  126497. * Render pipeline to produce ssao effect
  126498. */
  126499. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  126500. /**
  126501. * @ignore
  126502. * The PassPostProcess id in the pipeline that contains the original scene color
  126503. */
  126504. SSAOOriginalSceneColorEffect: string;
  126505. /**
  126506. * @ignore
  126507. * The SSAO PostProcess id in the pipeline
  126508. */
  126509. SSAORenderEffect: string;
  126510. /**
  126511. * @ignore
  126512. * The horizontal blur PostProcess id in the pipeline
  126513. */
  126514. SSAOBlurHRenderEffect: string;
  126515. /**
  126516. * @ignore
  126517. * The vertical blur PostProcess id in the pipeline
  126518. */
  126519. SSAOBlurVRenderEffect: string;
  126520. /**
  126521. * @ignore
  126522. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  126523. */
  126524. SSAOCombineRenderEffect: string;
  126525. /**
  126526. * The output strength of the SSAO post-process. Default value is 1.0.
  126527. */
  126528. totalStrength: number;
  126529. /**
  126530. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  126531. */
  126532. maxZ: number;
  126533. /**
  126534. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  126535. */
  126536. minZAspect: number;
  126537. private _samples;
  126538. /**
  126539. * Number of samples used for the SSAO calculations. Default value is 8
  126540. */
  126541. samples: number;
  126542. private _textureSamples;
  126543. /**
  126544. * Number of samples to use for antialiasing
  126545. */
  126546. textureSamples: number;
  126547. /**
  126548. * Ratio object used for SSAO ratio and blur ratio
  126549. */
  126550. private _ratio;
  126551. /**
  126552. * Dynamically generated sphere sampler.
  126553. */
  126554. private _sampleSphere;
  126555. /**
  126556. * Blur filter offsets
  126557. */
  126558. private _samplerOffsets;
  126559. private _expensiveBlur;
  126560. /**
  126561. * If bilateral blur should be used
  126562. */
  126563. expensiveBlur: boolean;
  126564. /**
  126565. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  126566. */
  126567. radius: number;
  126568. /**
  126569. * The base color of the SSAO post-process
  126570. * The final result is "base + ssao" between [0, 1]
  126571. */
  126572. base: number;
  126573. /**
  126574. * Support test.
  126575. */
  126576. static readonly IsSupported: boolean;
  126577. private _scene;
  126578. private _depthTexture;
  126579. private _normalTexture;
  126580. private _randomTexture;
  126581. private _originalColorPostProcess;
  126582. private _ssaoPostProcess;
  126583. private _blurHPostProcess;
  126584. private _blurVPostProcess;
  126585. private _ssaoCombinePostProcess;
  126586. private _firstUpdate;
  126587. /**
  126588. * Gets active scene
  126589. */
  126590. readonly scene: Scene;
  126591. /**
  126592. * @constructor
  126593. * @param name The rendering pipeline name
  126594. * @param scene The scene linked to this pipeline
  126595. * @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 }
  126596. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126597. */
  126598. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  126599. /**
  126600. * Get the class name
  126601. * @returns "SSAO2RenderingPipeline"
  126602. */
  126603. getClassName(): string;
  126604. /**
  126605. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  126606. */
  126607. dispose(disableGeometryBufferRenderer?: boolean): void;
  126608. private _createBlurPostProcess;
  126609. /** @hidden */
  126610. _rebuild(): void;
  126611. private _bits;
  126612. private _radicalInverse_VdC;
  126613. private _hammersley;
  126614. private _hemisphereSample_uniform;
  126615. private _generateHemisphere;
  126616. private _createSSAOPostProcess;
  126617. private _createSSAOCombinePostProcess;
  126618. private _createRandomTexture;
  126619. /**
  126620. * Serialize the rendering pipeline (Used when exporting)
  126621. * @returns the serialized object
  126622. */
  126623. serialize(): any;
  126624. /**
  126625. * Parse the serialized pipeline
  126626. * @param source Source pipeline.
  126627. * @param scene The scene to load the pipeline to.
  126628. * @param rootUrl The URL of the serialized pipeline.
  126629. * @returns An instantiated pipeline from the serialized object.
  126630. */
  126631. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  126632. }
  126633. }
  126634. declare module BABYLON {
  126635. /** @hidden */
  126636. export var ssaoPixelShader: {
  126637. name: string;
  126638. shader: string;
  126639. };
  126640. }
  126641. declare module BABYLON {
  126642. /**
  126643. * Render pipeline to produce ssao effect
  126644. */
  126645. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  126646. /**
  126647. * @ignore
  126648. * The PassPostProcess id in the pipeline that contains the original scene color
  126649. */
  126650. SSAOOriginalSceneColorEffect: string;
  126651. /**
  126652. * @ignore
  126653. * The SSAO PostProcess id in the pipeline
  126654. */
  126655. SSAORenderEffect: string;
  126656. /**
  126657. * @ignore
  126658. * The horizontal blur PostProcess id in the pipeline
  126659. */
  126660. SSAOBlurHRenderEffect: string;
  126661. /**
  126662. * @ignore
  126663. * The vertical blur PostProcess id in the pipeline
  126664. */
  126665. SSAOBlurVRenderEffect: string;
  126666. /**
  126667. * @ignore
  126668. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  126669. */
  126670. SSAOCombineRenderEffect: string;
  126671. /**
  126672. * The output strength of the SSAO post-process. Default value is 1.0.
  126673. */
  126674. totalStrength: number;
  126675. /**
  126676. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  126677. */
  126678. radius: number;
  126679. /**
  126680. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  126681. * Must not be equal to fallOff and superior to fallOff.
  126682. * Default value is 0.0075
  126683. */
  126684. area: number;
  126685. /**
  126686. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  126687. * Must not be equal to area and inferior to area.
  126688. * Default value is 0.000001
  126689. */
  126690. fallOff: number;
  126691. /**
  126692. * The base color of the SSAO post-process
  126693. * The final result is "base + ssao" between [0, 1]
  126694. */
  126695. base: number;
  126696. private _scene;
  126697. private _depthTexture;
  126698. private _randomTexture;
  126699. private _originalColorPostProcess;
  126700. private _ssaoPostProcess;
  126701. private _blurHPostProcess;
  126702. private _blurVPostProcess;
  126703. private _ssaoCombinePostProcess;
  126704. private _firstUpdate;
  126705. /**
  126706. * Gets active scene
  126707. */
  126708. readonly scene: Scene;
  126709. /**
  126710. * @constructor
  126711. * @param name - The rendering pipeline name
  126712. * @param scene - The scene linked to this pipeline
  126713. * @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 }
  126714. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  126715. */
  126716. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  126717. /**
  126718. * Get the class name
  126719. * @returns "SSAORenderingPipeline"
  126720. */
  126721. getClassName(): string;
  126722. /**
  126723. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  126724. */
  126725. dispose(disableDepthRender?: boolean): void;
  126726. private _createBlurPostProcess;
  126727. /** @hidden */
  126728. _rebuild(): void;
  126729. private _createSSAOPostProcess;
  126730. private _createSSAOCombinePostProcess;
  126731. private _createRandomTexture;
  126732. }
  126733. }
  126734. declare module BABYLON {
  126735. /** @hidden */
  126736. export var standardPixelShader: {
  126737. name: string;
  126738. shader: string;
  126739. };
  126740. }
  126741. declare module BABYLON {
  126742. /**
  126743. * Standard rendering pipeline
  126744. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  126745. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  126746. */
  126747. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126748. /**
  126749. * Public members
  126750. */
  126751. /**
  126752. * Post-process which contains the original scene color before the pipeline applies all the effects
  126753. */
  126754. originalPostProcess: Nullable<PostProcess>;
  126755. /**
  126756. * Post-process used to down scale an image x4
  126757. */
  126758. downSampleX4PostProcess: Nullable<PostProcess>;
  126759. /**
  126760. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  126761. */
  126762. brightPassPostProcess: Nullable<PostProcess>;
  126763. /**
  126764. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  126765. */
  126766. blurHPostProcesses: PostProcess[];
  126767. /**
  126768. * Post-process array storing all the vertical blur post-processes used by the pipeline
  126769. */
  126770. blurVPostProcesses: PostProcess[];
  126771. /**
  126772. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  126773. */
  126774. textureAdderPostProcess: Nullable<PostProcess>;
  126775. /**
  126776. * Post-process used to create volumetric lighting effect
  126777. */
  126778. volumetricLightPostProcess: Nullable<PostProcess>;
  126779. /**
  126780. * Post-process used to smooth the previous volumetric light post-process on the X axis
  126781. */
  126782. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  126783. /**
  126784. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  126785. */
  126786. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  126787. /**
  126788. * Post-process used to merge the volumetric light effect and the real scene color
  126789. */
  126790. volumetricLightMergePostProces: Nullable<PostProcess>;
  126791. /**
  126792. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  126793. */
  126794. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  126795. /**
  126796. * Base post-process used to calculate the average luminance of the final image for HDR
  126797. */
  126798. luminancePostProcess: Nullable<PostProcess>;
  126799. /**
  126800. * Post-processes used to create down sample post-processes in order to get
  126801. * the average luminance of the final image for HDR
  126802. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  126803. */
  126804. luminanceDownSamplePostProcesses: PostProcess[];
  126805. /**
  126806. * Post-process used to create a HDR effect (light adaptation)
  126807. */
  126808. hdrPostProcess: Nullable<PostProcess>;
  126809. /**
  126810. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  126811. */
  126812. textureAdderFinalPostProcess: Nullable<PostProcess>;
  126813. /**
  126814. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  126815. */
  126816. lensFlareFinalPostProcess: Nullable<PostProcess>;
  126817. /**
  126818. * Post-process used to merge the final HDR post-process and the real scene color
  126819. */
  126820. hdrFinalPostProcess: Nullable<PostProcess>;
  126821. /**
  126822. * Post-process used to create a lens flare effect
  126823. */
  126824. lensFlarePostProcess: Nullable<PostProcess>;
  126825. /**
  126826. * Post-process that merges the result of the lens flare post-process and the real scene color
  126827. */
  126828. lensFlareComposePostProcess: Nullable<PostProcess>;
  126829. /**
  126830. * Post-process used to create a motion blur effect
  126831. */
  126832. motionBlurPostProcess: Nullable<PostProcess>;
  126833. /**
  126834. * Post-process used to create a depth of field effect
  126835. */
  126836. depthOfFieldPostProcess: Nullable<PostProcess>;
  126837. /**
  126838. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126839. */
  126840. fxaaPostProcess: Nullable<FxaaPostProcess>;
  126841. /**
  126842. * Represents the brightness threshold in order to configure the illuminated surfaces
  126843. */
  126844. brightThreshold: number;
  126845. /**
  126846. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  126847. */
  126848. blurWidth: number;
  126849. /**
  126850. * Sets if the blur for highlighted surfaces must be only horizontal
  126851. */
  126852. horizontalBlur: boolean;
  126853. /**
  126854. * Gets the overall exposure used by the pipeline
  126855. */
  126856. /**
  126857. * Sets the overall exposure used by the pipeline
  126858. */
  126859. exposure: number;
  126860. /**
  126861. * Texture used typically to simulate "dirty" on camera lens
  126862. */
  126863. lensTexture: Nullable<Texture>;
  126864. /**
  126865. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  126866. */
  126867. volumetricLightCoefficient: number;
  126868. /**
  126869. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  126870. */
  126871. volumetricLightPower: number;
  126872. /**
  126873. * Used the set the blur intensity to smooth the volumetric lights
  126874. */
  126875. volumetricLightBlurScale: number;
  126876. /**
  126877. * Light (spot or directional) used to generate the volumetric lights rays
  126878. * The source light must have a shadow generate so the pipeline can get its
  126879. * depth map
  126880. */
  126881. sourceLight: Nullable<SpotLight | DirectionalLight>;
  126882. /**
  126883. * For eye adaptation, represents the minimum luminance the eye can see
  126884. */
  126885. hdrMinimumLuminance: number;
  126886. /**
  126887. * For eye adaptation, represents the decrease luminance speed
  126888. */
  126889. hdrDecreaseRate: number;
  126890. /**
  126891. * For eye adaptation, represents the increase luminance speed
  126892. */
  126893. hdrIncreaseRate: number;
  126894. /**
  126895. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  126896. */
  126897. /**
  126898. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  126899. */
  126900. hdrAutoExposure: boolean;
  126901. /**
  126902. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  126903. */
  126904. lensColorTexture: Nullable<Texture>;
  126905. /**
  126906. * The overall strengh for the lens flare effect
  126907. */
  126908. lensFlareStrength: number;
  126909. /**
  126910. * Dispersion coefficient for lens flare ghosts
  126911. */
  126912. lensFlareGhostDispersal: number;
  126913. /**
  126914. * Main lens flare halo width
  126915. */
  126916. lensFlareHaloWidth: number;
  126917. /**
  126918. * Based on the lens distortion effect, defines how much the lens flare result
  126919. * is distorted
  126920. */
  126921. lensFlareDistortionStrength: number;
  126922. /**
  126923. * Configures the blur intensity used for for lens flare (halo)
  126924. */
  126925. lensFlareBlurWidth: number;
  126926. /**
  126927. * Lens star texture must be used to simulate rays on the flares and is available
  126928. * in the documentation
  126929. */
  126930. lensStarTexture: Nullable<Texture>;
  126931. /**
  126932. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  126933. * flare effect by taking account of the dirt texture
  126934. */
  126935. lensFlareDirtTexture: Nullable<Texture>;
  126936. /**
  126937. * Represents the focal length for the depth of field effect
  126938. */
  126939. depthOfFieldDistance: number;
  126940. /**
  126941. * Represents the blur intensity for the blurred part of the depth of field effect
  126942. */
  126943. depthOfFieldBlurWidth: number;
  126944. /**
  126945. * Gets how much the image is blurred by the movement while using the motion blur post-process
  126946. */
  126947. /**
  126948. * Sets how much the image is blurred by the movement while using the motion blur post-process
  126949. */
  126950. motionStrength: number;
  126951. /**
  126952. * Gets wether or not the motion blur post-process is object based or screen based.
  126953. */
  126954. /**
  126955. * Sets wether or not the motion blur post-process should be object based or screen based
  126956. */
  126957. objectBasedMotionBlur: boolean;
  126958. /**
  126959. * List of animations for the pipeline (IAnimatable implementation)
  126960. */
  126961. animations: Animation[];
  126962. /**
  126963. * Private members
  126964. */
  126965. private _scene;
  126966. private _currentDepthOfFieldSource;
  126967. private _basePostProcess;
  126968. private _fixedExposure;
  126969. private _currentExposure;
  126970. private _hdrAutoExposure;
  126971. private _hdrCurrentLuminance;
  126972. private _motionStrength;
  126973. private _isObjectBasedMotionBlur;
  126974. private _floatTextureType;
  126975. private _camerasToBeAttached;
  126976. private _ratio;
  126977. private _bloomEnabled;
  126978. private _depthOfFieldEnabled;
  126979. private _vlsEnabled;
  126980. private _lensFlareEnabled;
  126981. private _hdrEnabled;
  126982. private _motionBlurEnabled;
  126983. private _fxaaEnabled;
  126984. private _motionBlurSamples;
  126985. private _volumetricLightStepsCount;
  126986. private _samples;
  126987. /**
  126988. * @ignore
  126989. * Specifies if the bloom pipeline is enabled
  126990. */
  126991. BloomEnabled: boolean;
  126992. /**
  126993. * @ignore
  126994. * Specifies if the depth of field pipeline is enabed
  126995. */
  126996. DepthOfFieldEnabled: boolean;
  126997. /**
  126998. * @ignore
  126999. * Specifies if the lens flare pipeline is enabed
  127000. */
  127001. LensFlareEnabled: boolean;
  127002. /**
  127003. * @ignore
  127004. * Specifies if the HDR pipeline is enabled
  127005. */
  127006. HDREnabled: boolean;
  127007. /**
  127008. * @ignore
  127009. * Specifies if the volumetric lights scattering effect is enabled
  127010. */
  127011. VLSEnabled: boolean;
  127012. /**
  127013. * @ignore
  127014. * Specifies if the motion blur effect is enabled
  127015. */
  127016. MotionBlurEnabled: boolean;
  127017. /**
  127018. * Specifies if anti-aliasing is enabled
  127019. */
  127020. fxaaEnabled: boolean;
  127021. /**
  127022. * Specifies the number of steps used to calculate the volumetric lights
  127023. * Typically in interval [50, 200]
  127024. */
  127025. volumetricLightStepsCount: number;
  127026. /**
  127027. * Specifies the number of samples used for the motion blur effect
  127028. * Typically in interval [16, 64]
  127029. */
  127030. motionBlurSamples: number;
  127031. /**
  127032. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127033. */
  127034. samples: number;
  127035. /**
  127036. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127037. * @constructor
  127038. * @param name The rendering pipeline name
  127039. * @param scene The scene linked to this pipeline
  127040. * @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)
  127041. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127042. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127043. */
  127044. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127045. private _buildPipeline;
  127046. private _createDownSampleX4PostProcess;
  127047. private _createBrightPassPostProcess;
  127048. private _createBlurPostProcesses;
  127049. private _createTextureAdderPostProcess;
  127050. private _createVolumetricLightPostProcess;
  127051. private _createLuminancePostProcesses;
  127052. private _createHdrPostProcess;
  127053. private _createLensFlarePostProcess;
  127054. private _createDepthOfFieldPostProcess;
  127055. private _createMotionBlurPostProcess;
  127056. private _getDepthTexture;
  127057. private _disposePostProcesses;
  127058. /**
  127059. * Dispose of the pipeline and stop all post processes
  127060. */
  127061. dispose(): void;
  127062. /**
  127063. * Serialize the rendering pipeline (Used when exporting)
  127064. * @returns the serialized object
  127065. */
  127066. serialize(): any;
  127067. /**
  127068. * Parse the serialized pipeline
  127069. * @param source Source pipeline.
  127070. * @param scene The scene to load the pipeline to.
  127071. * @param rootUrl The URL of the serialized pipeline.
  127072. * @returns An instantiated pipeline from the serialized object.
  127073. */
  127074. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127075. /**
  127076. * Luminance steps
  127077. */
  127078. static LuminanceSteps: number;
  127079. }
  127080. }
  127081. declare module BABYLON {
  127082. /** @hidden */
  127083. export var tonemapPixelShader: {
  127084. name: string;
  127085. shader: string;
  127086. };
  127087. }
  127088. declare module BABYLON {
  127089. /** Defines operator used for tonemapping */
  127090. export enum TonemappingOperator {
  127091. /** Hable */
  127092. Hable = 0,
  127093. /** Reinhard */
  127094. Reinhard = 1,
  127095. /** HejiDawson */
  127096. HejiDawson = 2,
  127097. /** Photographic */
  127098. Photographic = 3
  127099. }
  127100. /**
  127101. * Defines a post process to apply tone mapping
  127102. */
  127103. export class TonemapPostProcess extends PostProcess {
  127104. private _operator;
  127105. /** Defines the required exposure adjustement */
  127106. exposureAdjustment: number;
  127107. /**
  127108. * Creates a new TonemapPostProcess
  127109. * @param name defines the name of the postprocess
  127110. * @param _operator defines the operator to use
  127111. * @param exposureAdjustment defines the required exposure adjustement
  127112. * @param camera defines the camera to use (can be null)
  127113. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127114. * @param engine defines the hosting engine (can be ignore if camera is set)
  127115. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127116. */
  127117. constructor(name: string, _operator: TonemappingOperator,
  127118. /** Defines the required exposure adjustement */
  127119. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127120. }
  127121. }
  127122. declare module BABYLON {
  127123. /** @hidden */
  127124. export var depthVertexShader: {
  127125. name: string;
  127126. shader: string;
  127127. };
  127128. }
  127129. declare module BABYLON {
  127130. /** @hidden */
  127131. export var volumetricLightScatteringPixelShader: {
  127132. name: string;
  127133. shader: string;
  127134. };
  127135. }
  127136. declare module BABYLON {
  127137. /** @hidden */
  127138. export var volumetricLightScatteringPassVertexShader: {
  127139. name: string;
  127140. shader: string;
  127141. };
  127142. }
  127143. declare module BABYLON {
  127144. /** @hidden */
  127145. export var volumetricLightScatteringPassPixelShader: {
  127146. name: string;
  127147. shader: string;
  127148. };
  127149. }
  127150. declare module BABYLON {
  127151. /**
  127152. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127153. */
  127154. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127155. private _volumetricLightScatteringPass;
  127156. private _volumetricLightScatteringRTT;
  127157. private _viewPort;
  127158. private _screenCoordinates;
  127159. private _cachedDefines;
  127160. /**
  127161. * If not undefined, the mesh position is computed from the attached node position
  127162. */
  127163. attachedNode: {
  127164. position: Vector3;
  127165. };
  127166. /**
  127167. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127168. */
  127169. customMeshPosition: Vector3;
  127170. /**
  127171. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127172. */
  127173. useCustomMeshPosition: boolean;
  127174. /**
  127175. * If the post-process should inverse the light scattering direction
  127176. */
  127177. invert: boolean;
  127178. /**
  127179. * The internal mesh used by the post-process
  127180. */
  127181. mesh: Mesh;
  127182. /**
  127183. * @hidden
  127184. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127185. */
  127186. useDiffuseColor: boolean;
  127187. /**
  127188. * Array containing the excluded meshes not rendered in the internal pass
  127189. */
  127190. excludedMeshes: AbstractMesh[];
  127191. /**
  127192. * Controls the overall intensity of the post-process
  127193. */
  127194. exposure: number;
  127195. /**
  127196. * Dissipates each sample's contribution in range [0, 1]
  127197. */
  127198. decay: number;
  127199. /**
  127200. * Controls the overall intensity of each sample
  127201. */
  127202. weight: number;
  127203. /**
  127204. * Controls the density of each sample
  127205. */
  127206. density: number;
  127207. /**
  127208. * @constructor
  127209. * @param name The post-process name
  127210. * @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)
  127211. * @param camera The camera that the post-process will be attached to
  127212. * @param mesh The mesh used to create the light scattering
  127213. * @param samples The post-process quality, default 100
  127214. * @param samplingModeThe post-process filtering mode
  127215. * @param engine The babylon engine
  127216. * @param reusable If the post-process is reusable
  127217. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127218. */
  127219. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  127220. /**
  127221. * Returns the string "VolumetricLightScatteringPostProcess"
  127222. * @returns "VolumetricLightScatteringPostProcess"
  127223. */
  127224. getClassName(): string;
  127225. private _isReady;
  127226. /**
  127227. * Sets the new light position for light scattering effect
  127228. * @param position The new custom light position
  127229. */
  127230. setCustomMeshPosition(position: Vector3): void;
  127231. /**
  127232. * Returns the light position for light scattering effect
  127233. * @return Vector3 The custom light position
  127234. */
  127235. getCustomMeshPosition(): Vector3;
  127236. /**
  127237. * Disposes the internal assets and detaches the post-process from the camera
  127238. */
  127239. dispose(camera: Camera): void;
  127240. /**
  127241. * Returns the render target texture used by the post-process
  127242. * @return the render target texture used by the post-process
  127243. */
  127244. getPass(): RenderTargetTexture;
  127245. private _meshExcluded;
  127246. private _createPass;
  127247. private _updateMeshScreenCoordinates;
  127248. /**
  127249. * Creates a default mesh for the Volumeric Light Scattering post-process
  127250. * @param name The mesh name
  127251. * @param scene The scene where to create the mesh
  127252. * @return the default mesh
  127253. */
  127254. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  127255. }
  127256. }
  127257. declare module BABYLON {
  127258. interface Scene {
  127259. /** @hidden (Backing field) */
  127260. _boundingBoxRenderer: BoundingBoxRenderer;
  127261. /** @hidden (Backing field) */
  127262. _forceShowBoundingBoxes: boolean;
  127263. /**
  127264. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  127265. */
  127266. forceShowBoundingBoxes: boolean;
  127267. /**
  127268. * Gets the bounding box renderer associated with the scene
  127269. * @returns a BoundingBoxRenderer
  127270. */
  127271. getBoundingBoxRenderer(): BoundingBoxRenderer;
  127272. }
  127273. interface AbstractMesh {
  127274. /** @hidden (Backing field) */
  127275. _showBoundingBox: boolean;
  127276. /**
  127277. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  127278. */
  127279. showBoundingBox: boolean;
  127280. }
  127281. /**
  127282. * Component responsible of rendering the bounding box of the meshes in a scene.
  127283. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  127284. */
  127285. export class BoundingBoxRenderer implements ISceneComponent {
  127286. /**
  127287. * The component name helpfull to identify the component in the list of scene components.
  127288. */
  127289. readonly name: string;
  127290. /**
  127291. * The scene the component belongs to.
  127292. */
  127293. scene: Scene;
  127294. /**
  127295. * Color of the bounding box lines placed in front of an object
  127296. */
  127297. frontColor: Color3;
  127298. /**
  127299. * Color of the bounding box lines placed behind an object
  127300. */
  127301. backColor: Color3;
  127302. /**
  127303. * Defines if the renderer should show the back lines or not
  127304. */
  127305. showBackLines: boolean;
  127306. /**
  127307. * @hidden
  127308. */
  127309. renderList: SmartArray<BoundingBox>;
  127310. private _colorShader;
  127311. private _vertexBuffers;
  127312. private _indexBuffer;
  127313. private _fillIndexBuffer;
  127314. private _fillIndexData;
  127315. /**
  127316. * Instantiates a new bounding box renderer in a scene.
  127317. * @param scene the scene the renderer renders in
  127318. */
  127319. constructor(scene: Scene);
  127320. /**
  127321. * Registers the component in a given scene
  127322. */
  127323. register(): void;
  127324. private _evaluateSubMesh;
  127325. private _activeMesh;
  127326. private _prepareRessources;
  127327. private _createIndexBuffer;
  127328. /**
  127329. * Rebuilds the elements related to this component in case of
  127330. * context lost for instance.
  127331. */
  127332. rebuild(): void;
  127333. /**
  127334. * @hidden
  127335. */
  127336. reset(): void;
  127337. /**
  127338. * Render the bounding boxes of a specific rendering group
  127339. * @param renderingGroupId defines the rendering group to render
  127340. */
  127341. render(renderingGroupId: number): void;
  127342. /**
  127343. * In case of occlusion queries, we can render the occlusion bounding box through this method
  127344. * @param mesh Define the mesh to render the occlusion bounding box for
  127345. */
  127346. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  127347. /**
  127348. * Dispose and release the resources attached to this renderer.
  127349. */
  127350. dispose(): void;
  127351. }
  127352. }
  127353. declare module BABYLON {
  127354. /** @hidden */
  127355. export var depthPixelShader: {
  127356. name: string;
  127357. shader: string;
  127358. };
  127359. }
  127360. declare module BABYLON {
  127361. /**
  127362. * This represents a depth renderer in Babylon.
  127363. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127364. */
  127365. export class DepthRenderer {
  127366. private _scene;
  127367. private _depthMap;
  127368. private _effect;
  127369. private readonly _storeNonLinearDepth;
  127370. private readonly _clearColor;
  127371. /** Get if the depth renderer is using packed depth or not */
  127372. readonly isPacked: boolean;
  127373. private _cachedDefines;
  127374. private _camera;
  127375. /**
  127376. * Specifiess that the depth renderer will only be used within
  127377. * the camera it is created for.
  127378. * This can help forcing its rendering during the camera processing.
  127379. */
  127380. useOnlyInActiveCamera: boolean;
  127381. /** @hidden */
  127382. static _SceneComponentInitialization: (scene: Scene) => void;
  127383. /**
  127384. * Instantiates a depth renderer
  127385. * @param scene The scene the renderer belongs to
  127386. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127387. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127388. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127389. */
  127390. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127391. /**
  127392. * Creates the depth rendering effect and checks if the effect is ready.
  127393. * @param subMesh The submesh to be used to render the depth map of
  127394. * @param useInstances If multiple world instances should be used
  127395. * @returns if the depth renderer is ready to render the depth map
  127396. */
  127397. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127398. /**
  127399. * Gets the texture which the depth map will be written to.
  127400. * @returns The depth map texture
  127401. */
  127402. getDepthMap(): RenderTargetTexture;
  127403. /**
  127404. * Disposes of the depth renderer.
  127405. */
  127406. dispose(): void;
  127407. }
  127408. }
  127409. declare module BABYLON {
  127410. interface Scene {
  127411. /** @hidden (Backing field) */
  127412. _depthRenderer: {
  127413. [id: string]: DepthRenderer;
  127414. };
  127415. /**
  127416. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  127417. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  127418. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127419. * @returns the created depth renderer
  127420. */
  127421. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  127422. /**
  127423. * Disables a depth renderer for a given camera
  127424. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  127425. */
  127426. disableDepthRenderer(camera?: Nullable<Camera>): void;
  127427. }
  127428. /**
  127429. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  127430. * in several rendering techniques.
  127431. */
  127432. export class DepthRendererSceneComponent implements ISceneComponent {
  127433. /**
  127434. * The component name helpfull to identify the component in the list of scene components.
  127435. */
  127436. readonly name: string;
  127437. /**
  127438. * The scene the component belongs to.
  127439. */
  127440. scene: Scene;
  127441. /**
  127442. * Creates a new instance of the component for the given scene
  127443. * @param scene Defines the scene to register the component in
  127444. */
  127445. constructor(scene: Scene);
  127446. /**
  127447. * Registers the component in a given scene
  127448. */
  127449. register(): void;
  127450. /**
  127451. * Rebuilds the elements related to this component in case of
  127452. * context lost for instance.
  127453. */
  127454. rebuild(): void;
  127455. /**
  127456. * Disposes the component and the associated ressources
  127457. */
  127458. dispose(): void;
  127459. private _gatherRenderTargets;
  127460. private _gatherActiveCameraRenderTargets;
  127461. }
  127462. }
  127463. declare module BABYLON {
  127464. /** @hidden */
  127465. export var outlinePixelShader: {
  127466. name: string;
  127467. shader: string;
  127468. };
  127469. }
  127470. declare module BABYLON {
  127471. /** @hidden */
  127472. export var outlineVertexShader: {
  127473. name: string;
  127474. shader: string;
  127475. };
  127476. }
  127477. declare module BABYLON {
  127478. interface Scene {
  127479. /** @hidden */
  127480. _outlineRenderer: OutlineRenderer;
  127481. /**
  127482. * Gets the outline renderer associated with the scene
  127483. * @returns a OutlineRenderer
  127484. */
  127485. getOutlineRenderer(): OutlineRenderer;
  127486. }
  127487. interface AbstractMesh {
  127488. /** @hidden (Backing field) */
  127489. _renderOutline: boolean;
  127490. /**
  127491. * Gets or sets a boolean indicating if the outline must be rendered as well
  127492. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  127493. */
  127494. renderOutline: boolean;
  127495. /** @hidden (Backing field) */
  127496. _renderOverlay: boolean;
  127497. /**
  127498. * Gets or sets a boolean indicating if the overlay must be rendered as well
  127499. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  127500. */
  127501. renderOverlay: boolean;
  127502. }
  127503. /**
  127504. * This class is responsible to draw bothe outline/overlay of meshes.
  127505. * It should not be used directly but through the available method on mesh.
  127506. */
  127507. export class OutlineRenderer implements ISceneComponent {
  127508. /**
  127509. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  127510. */
  127511. private static _StencilReference;
  127512. /**
  127513. * The name of the component. Each component must have a unique name.
  127514. */
  127515. name: string;
  127516. /**
  127517. * The scene the component belongs to.
  127518. */
  127519. scene: Scene;
  127520. /**
  127521. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  127522. */
  127523. zOffset: number;
  127524. private _engine;
  127525. private _effect;
  127526. private _cachedDefines;
  127527. private _savedDepthWrite;
  127528. /**
  127529. * Instantiates a new outline renderer. (There could be only one per scene).
  127530. * @param scene Defines the scene it belongs to
  127531. */
  127532. constructor(scene: Scene);
  127533. /**
  127534. * Register the component to one instance of a scene.
  127535. */
  127536. register(): void;
  127537. /**
  127538. * Rebuilds the elements related to this component in case of
  127539. * context lost for instance.
  127540. */
  127541. rebuild(): void;
  127542. /**
  127543. * Disposes the component and the associated ressources.
  127544. */
  127545. dispose(): void;
  127546. /**
  127547. * Renders the outline in the canvas.
  127548. * @param subMesh Defines the sumesh to render
  127549. * @param batch Defines the batch of meshes in case of instances
  127550. * @param useOverlay Defines if the rendering is for the overlay or the outline
  127551. */
  127552. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  127553. /**
  127554. * Returns whether or not the outline renderer is ready for a given submesh.
  127555. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  127556. * @param subMesh Defines the submesh to check readyness for
  127557. * @param useInstances Defines wheter wee are trying to render instances or not
  127558. * @returns true if ready otherwise false
  127559. */
  127560. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127561. private _beforeRenderingMesh;
  127562. private _afterRenderingMesh;
  127563. }
  127564. }
  127565. declare module BABYLON {
  127566. /**
  127567. * Class used to manage multiple sprites of different sizes on the same spritesheet
  127568. * @see http://doc.babylonjs.com/babylon101/sprites
  127569. */
  127570. export class SpritePackedManager extends SpriteManager {
  127571. /** defines the packed manager's name */
  127572. name: string;
  127573. /**
  127574. * Creates a new sprite manager from a packed sprite sheet
  127575. * @param name defines the manager's name
  127576. * @param imgUrl defines the sprite sheet url
  127577. * @param capacity defines the maximum allowed number of sprites
  127578. * @param scene defines the hosting scene
  127579. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  127580. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  127581. * @param samplingMode defines the smapling mode to use with spritesheet
  127582. * @param fromPacked set to true; do not alter
  127583. */
  127584. constructor(
  127585. /** defines the packed manager's name */
  127586. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  127587. }
  127588. }
  127589. declare module BABYLON {
  127590. /**
  127591. * Defines the list of states available for a task inside a AssetsManager
  127592. */
  127593. export enum AssetTaskState {
  127594. /**
  127595. * Initialization
  127596. */
  127597. INIT = 0,
  127598. /**
  127599. * Running
  127600. */
  127601. RUNNING = 1,
  127602. /**
  127603. * Done
  127604. */
  127605. DONE = 2,
  127606. /**
  127607. * Error
  127608. */
  127609. ERROR = 3
  127610. }
  127611. /**
  127612. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  127613. */
  127614. export abstract class AbstractAssetTask {
  127615. /**
  127616. * Task name
  127617. */ name: string;
  127618. /**
  127619. * Callback called when the task is successful
  127620. */
  127621. onSuccess: (task: any) => void;
  127622. /**
  127623. * Callback called when the task is not successful
  127624. */
  127625. onError: (task: any, message?: string, exception?: any) => void;
  127626. /**
  127627. * Creates a new AssetsManager
  127628. * @param name defines the name of the task
  127629. */
  127630. constructor(
  127631. /**
  127632. * Task name
  127633. */ name: string);
  127634. private _isCompleted;
  127635. private _taskState;
  127636. private _errorObject;
  127637. /**
  127638. * Get if the task is completed
  127639. */
  127640. readonly isCompleted: boolean;
  127641. /**
  127642. * Gets the current state of the task
  127643. */
  127644. readonly taskState: AssetTaskState;
  127645. /**
  127646. * Gets the current error object (if task is in error)
  127647. */
  127648. readonly errorObject: {
  127649. message?: string;
  127650. exception?: any;
  127651. };
  127652. /**
  127653. * Internal only
  127654. * @hidden
  127655. */
  127656. _setErrorObject(message?: string, exception?: any): void;
  127657. /**
  127658. * Execute the current task
  127659. * @param scene defines the scene where you want your assets to be loaded
  127660. * @param onSuccess is a callback called when the task is successfully executed
  127661. * @param onError is a callback called if an error occurs
  127662. */
  127663. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127664. /**
  127665. * Execute the current task
  127666. * @param scene defines the scene where you want your assets to be loaded
  127667. * @param onSuccess is a callback called when the task is successfully executed
  127668. * @param onError is a callback called if an error occurs
  127669. */
  127670. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127671. /**
  127672. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  127673. * This can be used with failed tasks that have the reason for failure fixed.
  127674. */
  127675. reset(): void;
  127676. private onErrorCallback;
  127677. private onDoneCallback;
  127678. }
  127679. /**
  127680. * Define the interface used by progress events raised during assets loading
  127681. */
  127682. export interface IAssetsProgressEvent {
  127683. /**
  127684. * Defines the number of remaining tasks to process
  127685. */
  127686. remainingCount: number;
  127687. /**
  127688. * Defines the total number of tasks
  127689. */
  127690. totalCount: number;
  127691. /**
  127692. * Defines the task that was just processed
  127693. */
  127694. task: AbstractAssetTask;
  127695. }
  127696. /**
  127697. * Class used to share progress information about assets loading
  127698. */
  127699. export class AssetsProgressEvent implements IAssetsProgressEvent {
  127700. /**
  127701. * Defines the number of remaining tasks to process
  127702. */
  127703. remainingCount: number;
  127704. /**
  127705. * Defines the total number of tasks
  127706. */
  127707. totalCount: number;
  127708. /**
  127709. * Defines the task that was just processed
  127710. */
  127711. task: AbstractAssetTask;
  127712. /**
  127713. * Creates a AssetsProgressEvent
  127714. * @param remainingCount defines the number of remaining tasks to process
  127715. * @param totalCount defines the total number of tasks
  127716. * @param task defines the task that was just processed
  127717. */
  127718. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  127719. }
  127720. /**
  127721. * Define a task used by AssetsManager to load meshes
  127722. */
  127723. export class MeshAssetTask extends AbstractAssetTask {
  127724. /**
  127725. * Defines the name of the task
  127726. */
  127727. name: string;
  127728. /**
  127729. * Defines the list of mesh's names you want to load
  127730. */
  127731. meshesNames: any;
  127732. /**
  127733. * Defines the root url to use as a base to load your meshes and associated resources
  127734. */
  127735. rootUrl: string;
  127736. /**
  127737. * Defines the filename of the scene to load from
  127738. */
  127739. sceneFilename: string;
  127740. /**
  127741. * Gets the list of loaded meshes
  127742. */
  127743. loadedMeshes: Array<AbstractMesh>;
  127744. /**
  127745. * Gets the list of loaded particle systems
  127746. */
  127747. loadedParticleSystems: Array<IParticleSystem>;
  127748. /**
  127749. * Gets the list of loaded skeletons
  127750. */
  127751. loadedSkeletons: Array<Skeleton>;
  127752. /**
  127753. * Gets the list of loaded animation groups
  127754. */
  127755. loadedAnimationGroups: Array<AnimationGroup>;
  127756. /**
  127757. * Callback called when the task is successful
  127758. */
  127759. onSuccess: (task: MeshAssetTask) => void;
  127760. /**
  127761. * Callback called when the task is successful
  127762. */
  127763. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  127764. /**
  127765. * Creates a new MeshAssetTask
  127766. * @param name defines the name of the task
  127767. * @param meshesNames defines the list of mesh's names you want to load
  127768. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  127769. * @param sceneFilename defines the filename of the scene to load from
  127770. */
  127771. constructor(
  127772. /**
  127773. * Defines the name of the task
  127774. */
  127775. name: string,
  127776. /**
  127777. * Defines the list of mesh's names you want to load
  127778. */
  127779. meshesNames: any,
  127780. /**
  127781. * Defines the root url to use as a base to load your meshes and associated resources
  127782. */
  127783. rootUrl: string,
  127784. /**
  127785. * Defines the filename of the scene to load from
  127786. */
  127787. sceneFilename: string);
  127788. /**
  127789. * Execute the current task
  127790. * @param scene defines the scene where you want your assets to be loaded
  127791. * @param onSuccess is a callback called when the task is successfully executed
  127792. * @param onError is a callback called if an error occurs
  127793. */
  127794. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127795. }
  127796. /**
  127797. * Define a task used by AssetsManager to load text content
  127798. */
  127799. export class TextFileAssetTask extends AbstractAssetTask {
  127800. /**
  127801. * Defines the name of the task
  127802. */
  127803. name: string;
  127804. /**
  127805. * Defines the location of the file to load
  127806. */
  127807. url: string;
  127808. /**
  127809. * Gets the loaded text string
  127810. */
  127811. text: string;
  127812. /**
  127813. * Callback called when the task is successful
  127814. */
  127815. onSuccess: (task: TextFileAssetTask) => void;
  127816. /**
  127817. * Callback called when the task is successful
  127818. */
  127819. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  127820. /**
  127821. * Creates a new TextFileAssetTask object
  127822. * @param name defines the name of the task
  127823. * @param url defines the location of the file to load
  127824. */
  127825. constructor(
  127826. /**
  127827. * Defines the name of the task
  127828. */
  127829. name: string,
  127830. /**
  127831. * Defines the location of the file to load
  127832. */
  127833. url: string);
  127834. /**
  127835. * Execute the current task
  127836. * @param scene defines the scene where you want your assets to be loaded
  127837. * @param onSuccess is a callback called when the task is successfully executed
  127838. * @param onError is a callback called if an error occurs
  127839. */
  127840. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127841. }
  127842. /**
  127843. * Define a task used by AssetsManager to load binary data
  127844. */
  127845. export class BinaryFileAssetTask extends AbstractAssetTask {
  127846. /**
  127847. * Defines the name of the task
  127848. */
  127849. name: string;
  127850. /**
  127851. * Defines the location of the file to load
  127852. */
  127853. url: string;
  127854. /**
  127855. * Gets the lodaded data (as an array buffer)
  127856. */
  127857. data: ArrayBuffer;
  127858. /**
  127859. * Callback called when the task is successful
  127860. */
  127861. onSuccess: (task: BinaryFileAssetTask) => void;
  127862. /**
  127863. * Callback called when the task is successful
  127864. */
  127865. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  127866. /**
  127867. * Creates a new BinaryFileAssetTask object
  127868. * @param name defines the name of the new task
  127869. * @param url defines the location of the file to load
  127870. */
  127871. constructor(
  127872. /**
  127873. * Defines the name of the task
  127874. */
  127875. name: string,
  127876. /**
  127877. * Defines the location of the file to load
  127878. */
  127879. url: string);
  127880. /**
  127881. * Execute the current task
  127882. * @param scene defines the scene where you want your assets to be loaded
  127883. * @param onSuccess is a callback called when the task is successfully executed
  127884. * @param onError is a callback called if an error occurs
  127885. */
  127886. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127887. }
  127888. /**
  127889. * Define a task used by AssetsManager to load images
  127890. */
  127891. export class ImageAssetTask extends AbstractAssetTask {
  127892. /**
  127893. * Defines the name of the task
  127894. */
  127895. name: string;
  127896. /**
  127897. * Defines the location of the image to load
  127898. */
  127899. url: string;
  127900. /**
  127901. * Gets the loaded images
  127902. */
  127903. image: HTMLImageElement;
  127904. /**
  127905. * Callback called when the task is successful
  127906. */
  127907. onSuccess: (task: ImageAssetTask) => void;
  127908. /**
  127909. * Callback called when the task is successful
  127910. */
  127911. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  127912. /**
  127913. * Creates a new ImageAssetTask
  127914. * @param name defines the name of the task
  127915. * @param url defines the location of the image to load
  127916. */
  127917. constructor(
  127918. /**
  127919. * Defines the name of the task
  127920. */
  127921. name: string,
  127922. /**
  127923. * Defines the location of the image to load
  127924. */
  127925. url: string);
  127926. /**
  127927. * Execute the current task
  127928. * @param scene defines the scene where you want your assets to be loaded
  127929. * @param onSuccess is a callback called when the task is successfully executed
  127930. * @param onError is a callback called if an error occurs
  127931. */
  127932. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127933. }
  127934. /**
  127935. * Defines the interface used by texture loading tasks
  127936. */
  127937. export interface ITextureAssetTask<TEX extends BaseTexture> {
  127938. /**
  127939. * Gets the loaded texture
  127940. */
  127941. texture: TEX;
  127942. }
  127943. /**
  127944. * Define a task used by AssetsManager to load 2D textures
  127945. */
  127946. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  127947. /**
  127948. * Defines the name of the task
  127949. */
  127950. name: string;
  127951. /**
  127952. * Defines the location of the file to load
  127953. */
  127954. url: string;
  127955. /**
  127956. * Defines if mipmap should not be generated (default is false)
  127957. */
  127958. noMipmap?: boolean | undefined;
  127959. /**
  127960. * Defines if texture must be inverted on Y axis (default is false)
  127961. */
  127962. invertY?: boolean | undefined;
  127963. /**
  127964. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127965. */
  127966. samplingMode: number;
  127967. /**
  127968. * Gets the loaded texture
  127969. */
  127970. texture: Texture;
  127971. /**
  127972. * Callback called when the task is successful
  127973. */
  127974. onSuccess: (task: TextureAssetTask) => void;
  127975. /**
  127976. * Callback called when the task is successful
  127977. */
  127978. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  127979. /**
  127980. * Creates a new TextureAssetTask object
  127981. * @param name defines the name of the task
  127982. * @param url defines the location of the file to load
  127983. * @param noMipmap defines if mipmap should not be generated (default is false)
  127984. * @param invertY defines if texture must be inverted on Y axis (default is false)
  127985. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127986. */
  127987. constructor(
  127988. /**
  127989. * Defines the name of the task
  127990. */
  127991. name: string,
  127992. /**
  127993. * Defines the location of the file to load
  127994. */
  127995. url: string,
  127996. /**
  127997. * Defines if mipmap should not be generated (default is false)
  127998. */
  127999. noMipmap?: boolean | undefined,
  128000. /**
  128001. * Defines if texture must be inverted on Y axis (default is false)
  128002. */
  128003. invertY?: boolean | undefined,
  128004. /**
  128005. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128006. */
  128007. samplingMode?: number);
  128008. /**
  128009. * Execute the current task
  128010. * @param scene defines the scene where you want your assets to be loaded
  128011. * @param onSuccess is a callback called when the task is successfully executed
  128012. * @param onError is a callback called if an error occurs
  128013. */
  128014. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128015. }
  128016. /**
  128017. * Define a task used by AssetsManager to load cube textures
  128018. */
  128019. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128020. /**
  128021. * Defines the name of the task
  128022. */
  128023. name: string;
  128024. /**
  128025. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128026. */
  128027. url: string;
  128028. /**
  128029. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128030. */
  128031. extensions?: string[] | undefined;
  128032. /**
  128033. * Defines if mipmaps should not be generated (default is false)
  128034. */
  128035. noMipmap?: boolean | undefined;
  128036. /**
  128037. * Defines the explicit list of files (undefined by default)
  128038. */
  128039. files?: string[] | undefined;
  128040. /**
  128041. * Gets the loaded texture
  128042. */
  128043. texture: CubeTexture;
  128044. /**
  128045. * Callback called when the task is successful
  128046. */
  128047. onSuccess: (task: CubeTextureAssetTask) => void;
  128048. /**
  128049. * Callback called when the task is successful
  128050. */
  128051. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128052. /**
  128053. * Creates a new CubeTextureAssetTask
  128054. * @param name defines the name of the task
  128055. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128056. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128057. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128058. * @param files defines the explicit list of files (undefined by default)
  128059. */
  128060. constructor(
  128061. /**
  128062. * Defines the name of the task
  128063. */
  128064. name: string,
  128065. /**
  128066. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128067. */
  128068. url: string,
  128069. /**
  128070. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128071. */
  128072. extensions?: string[] | undefined,
  128073. /**
  128074. * Defines if mipmaps should not be generated (default is false)
  128075. */
  128076. noMipmap?: boolean | undefined,
  128077. /**
  128078. * Defines the explicit list of files (undefined by default)
  128079. */
  128080. files?: string[] | undefined);
  128081. /**
  128082. * Execute the current task
  128083. * @param scene defines the scene where you want your assets to be loaded
  128084. * @param onSuccess is a callback called when the task is successfully executed
  128085. * @param onError is a callback called if an error occurs
  128086. */
  128087. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128088. }
  128089. /**
  128090. * Define a task used by AssetsManager to load HDR cube textures
  128091. */
  128092. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128093. /**
  128094. * Defines the name of the task
  128095. */
  128096. name: string;
  128097. /**
  128098. * Defines the location of the file to load
  128099. */
  128100. url: string;
  128101. /**
  128102. * Defines the desired size (the more it increases the longer the generation will be)
  128103. */
  128104. size: number;
  128105. /**
  128106. * Defines if mipmaps should not be generated (default is false)
  128107. */
  128108. noMipmap: boolean;
  128109. /**
  128110. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128111. */
  128112. generateHarmonics: boolean;
  128113. /**
  128114. * 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)
  128115. */
  128116. gammaSpace: boolean;
  128117. /**
  128118. * Internal Use Only
  128119. */
  128120. reserved: boolean;
  128121. /**
  128122. * Gets the loaded texture
  128123. */
  128124. texture: HDRCubeTexture;
  128125. /**
  128126. * Callback called when the task is successful
  128127. */
  128128. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128129. /**
  128130. * Callback called when the task is successful
  128131. */
  128132. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128133. /**
  128134. * Creates a new HDRCubeTextureAssetTask object
  128135. * @param name defines the name of the task
  128136. * @param url defines the location of the file to load
  128137. * @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.
  128138. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128139. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128140. * @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)
  128141. * @param reserved Internal use only
  128142. */
  128143. constructor(
  128144. /**
  128145. * Defines the name of the task
  128146. */
  128147. name: string,
  128148. /**
  128149. * Defines the location of the file to load
  128150. */
  128151. url: string,
  128152. /**
  128153. * Defines the desired size (the more it increases the longer the generation will be)
  128154. */
  128155. size: number,
  128156. /**
  128157. * Defines if mipmaps should not be generated (default is false)
  128158. */
  128159. noMipmap?: boolean,
  128160. /**
  128161. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128162. */
  128163. generateHarmonics?: boolean,
  128164. /**
  128165. * 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)
  128166. */
  128167. gammaSpace?: boolean,
  128168. /**
  128169. * Internal Use Only
  128170. */
  128171. reserved?: boolean);
  128172. /**
  128173. * Execute the current task
  128174. * @param scene defines the scene where you want your assets to be loaded
  128175. * @param onSuccess is a callback called when the task is successfully executed
  128176. * @param onError is a callback called if an error occurs
  128177. */
  128178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128179. }
  128180. /**
  128181. * Define a task used by AssetsManager to load Equirectangular cube textures
  128182. */
  128183. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128184. /**
  128185. * Defines the name of the task
  128186. */
  128187. name: string;
  128188. /**
  128189. * Defines the location of the file to load
  128190. */
  128191. url: string;
  128192. /**
  128193. * Defines the desired size (the more it increases the longer the generation will be)
  128194. */
  128195. size: number;
  128196. /**
  128197. * Defines if mipmaps should not be generated (default is false)
  128198. */
  128199. noMipmap: boolean;
  128200. /**
  128201. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128202. * but the standard material would require them in Gamma space) (default is true)
  128203. */
  128204. gammaSpace: boolean;
  128205. /**
  128206. * Gets the loaded texture
  128207. */
  128208. texture: EquiRectangularCubeTexture;
  128209. /**
  128210. * Callback called when the task is successful
  128211. */
  128212. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  128213. /**
  128214. * Callback called when the task is successful
  128215. */
  128216. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  128217. /**
  128218. * Creates a new EquiRectangularCubeTextureAssetTask object
  128219. * @param name defines the name of the task
  128220. * @param url defines the location of the file to load
  128221. * @param size defines the desired size (the more it increases the longer the generation will be)
  128222. * If the size is omitted this implies you are using a preprocessed cubemap.
  128223. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128224. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  128225. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  128226. * (default is true)
  128227. */
  128228. constructor(
  128229. /**
  128230. * Defines the name of the task
  128231. */
  128232. name: string,
  128233. /**
  128234. * Defines the location of the file to load
  128235. */
  128236. url: string,
  128237. /**
  128238. * Defines the desired size (the more it increases the longer the generation will be)
  128239. */
  128240. size: number,
  128241. /**
  128242. * Defines if mipmaps should not be generated (default is false)
  128243. */
  128244. noMipmap?: boolean,
  128245. /**
  128246. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128247. * but the standard material would require them in Gamma space) (default is true)
  128248. */
  128249. gammaSpace?: boolean);
  128250. /**
  128251. * Execute the current task
  128252. * @param scene defines the scene where you want your assets to be loaded
  128253. * @param onSuccess is a callback called when the task is successfully executed
  128254. * @param onError is a callback called if an error occurs
  128255. */
  128256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128257. }
  128258. /**
  128259. * This class can be used to easily import assets into a scene
  128260. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  128261. */
  128262. export class AssetsManager {
  128263. private _scene;
  128264. private _isLoading;
  128265. protected _tasks: AbstractAssetTask[];
  128266. protected _waitingTasksCount: number;
  128267. protected _totalTasksCount: number;
  128268. /**
  128269. * Callback called when all tasks are processed
  128270. */
  128271. onFinish: (tasks: AbstractAssetTask[]) => void;
  128272. /**
  128273. * Callback called when a task is successful
  128274. */
  128275. onTaskSuccess: (task: AbstractAssetTask) => void;
  128276. /**
  128277. * Callback called when a task had an error
  128278. */
  128279. onTaskError: (task: AbstractAssetTask) => void;
  128280. /**
  128281. * Callback called when a task is done (whatever the result is)
  128282. */
  128283. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  128284. /**
  128285. * Observable called when all tasks are processed
  128286. */
  128287. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  128288. /**
  128289. * Observable called when a task had an error
  128290. */
  128291. onTaskErrorObservable: Observable<AbstractAssetTask>;
  128292. /**
  128293. * Observable called when all tasks were executed
  128294. */
  128295. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  128296. /**
  128297. * Observable called when a task is done (whatever the result is)
  128298. */
  128299. onProgressObservable: Observable<IAssetsProgressEvent>;
  128300. /**
  128301. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  128302. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128303. */
  128304. useDefaultLoadingScreen: boolean;
  128305. /**
  128306. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  128307. * when all assets have been downloaded.
  128308. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  128309. */
  128310. autoHideLoadingUI: boolean;
  128311. /**
  128312. * Creates a new AssetsManager
  128313. * @param scene defines the scene to work on
  128314. */
  128315. constructor(scene: Scene);
  128316. /**
  128317. * Add a MeshAssetTask to the list of active tasks
  128318. * @param taskName defines the name of the new task
  128319. * @param meshesNames defines the name of meshes to load
  128320. * @param rootUrl defines the root url to use to locate files
  128321. * @param sceneFilename defines the filename of the scene file
  128322. * @returns a new MeshAssetTask object
  128323. */
  128324. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  128325. /**
  128326. * Add a TextFileAssetTask to the list of active tasks
  128327. * @param taskName defines the name of the new task
  128328. * @param url defines the url of the file to load
  128329. * @returns a new TextFileAssetTask object
  128330. */
  128331. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  128332. /**
  128333. * Add a BinaryFileAssetTask to the list of active tasks
  128334. * @param taskName defines the name of the new task
  128335. * @param url defines the url of the file to load
  128336. * @returns a new BinaryFileAssetTask object
  128337. */
  128338. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  128339. /**
  128340. * Add a ImageAssetTask to the list of active tasks
  128341. * @param taskName defines the name of the new task
  128342. * @param url defines the url of the file to load
  128343. * @returns a new ImageAssetTask object
  128344. */
  128345. addImageTask(taskName: string, url: string): ImageAssetTask;
  128346. /**
  128347. * Add a TextureAssetTask to the list of active tasks
  128348. * @param taskName defines the name of the new task
  128349. * @param url defines the url of the file to load
  128350. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128351. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  128352. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  128353. * @returns a new TextureAssetTask object
  128354. */
  128355. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  128356. /**
  128357. * Add a CubeTextureAssetTask to the list of active tasks
  128358. * @param taskName defines the name of the new task
  128359. * @param url defines the url of the file to load
  128360. * @param extensions defines the extension to use to load the cube map (can be null)
  128361. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128362. * @param files defines the list of files to load (can be null)
  128363. * @returns a new CubeTextureAssetTask object
  128364. */
  128365. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  128366. /**
  128367. *
  128368. * Add a HDRCubeTextureAssetTask to the list of active tasks
  128369. * @param taskName defines the name of the new task
  128370. * @param url defines the url of the file to load
  128371. * @param size defines the size you want for the cubemap (can be null)
  128372. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128373. * @param generateHarmonics defines if you want to automatically generate (true by default)
  128374. * @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)
  128375. * @param reserved Internal use only
  128376. * @returns a new HDRCubeTextureAssetTask object
  128377. */
  128378. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  128379. /**
  128380. *
  128381. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  128382. * @param taskName defines the name of the new task
  128383. * @param url defines the url of the file to load
  128384. * @param size defines the size you want for the cubemap (can be null)
  128385. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128386. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128387. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128388. * @returns a new EquiRectangularCubeTextureAssetTask object
  128389. */
  128390. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  128391. /**
  128392. * Remove a task from the assets manager.
  128393. * @param task the task to remove
  128394. */
  128395. removeTask(task: AbstractAssetTask): void;
  128396. private _decreaseWaitingTasksCount;
  128397. private _runTask;
  128398. /**
  128399. * Reset the AssetsManager and remove all tasks
  128400. * @return the current instance of the AssetsManager
  128401. */
  128402. reset(): AssetsManager;
  128403. /**
  128404. * Start the loading process
  128405. * @return the current instance of the AssetsManager
  128406. */
  128407. load(): AssetsManager;
  128408. /**
  128409. * Start the loading process as an async operation
  128410. * @return a promise returning the list of failed tasks
  128411. */
  128412. loadAsync(): Promise<void>;
  128413. }
  128414. }
  128415. declare module BABYLON {
  128416. /**
  128417. * Wrapper class for promise with external resolve and reject.
  128418. */
  128419. export class Deferred<T> {
  128420. /**
  128421. * The promise associated with this deferred object.
  128422. */
  128423. readonly promise: Promise<T>;
  128424. private _resolve;
  128425. private _reject;
  128426. /**
  128427. * The resolve method of the promise associated with this deferred object.
  128428. */
  128429. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  128430. /**
  128431. * The reject method of the promise associated with this deferred object.
  128432. */
  128433. readonly reject: (reason?: any) => void;
  128434. /**
  128435. * Constructor for this deferred object.
  128436. */
  128437. constructor();
  128438. }
  128439. }
  128440. declare module BABYLON {
  128441. /**
  128442. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  128443. */
  128444. export class MeshExploder {
  128445. private _centerMesh;
  128446. private _meshes;
  128447. private _meshesOrigins;
  128448. private _toCenterVectors;
  128449. private _scaledDirection;
  128450. private _newPosition;
  128451. private _centerPosition;
  128452. /**
  128453. * Explodes meshes from a center mesh.
  128454. * @param meshes The meshes to explode.
  128455. * @param centerMesh The mesh to be center of explosion.
  128456. */
  128457. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  128458. private _setCenterMesh;
  128459. /**
  128460. * Get class name
  128461. * @returns "MeshExploder"
  128462. */
  128463. getClassName(): string;
  128464. /**
  128465. * "Exploded meshes"
  128466. * @returns Array of meshes with the centerMesh at index 0.
  128467. */
  128468. getMeshes(): Array<Mesh>;
  128469. /**
  128470. * Explodes meshes giving a specific direction
  128471. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  128472. */
  128473. explode(direction?: number): void;
  128474. }
  128475. }
  128476. declare module BABYLON {
  128477. /**
  128478. * Class used to help managing file picking and drag'n'drop
  128479. */
  128480. export class FilesInput {
  128481. /**
  128482. * List of files ready to be loaded
  128483. */
  128484. static readonly FilesToLoad: {
  128485. [key: string]: File;
  128486. };
  128487. /**
  128488. * Callback called when a file is processed
  128489. */
  128490. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  128491. private _engine;
  128492. private _currentScene;
  128493. private _sceneLoadedCallback;
  128494. private _progressCallback;
  128495. private _additionalRenderLoopLogicCallback;
  128496. private _textureLoadingCallback;
  128497. private _startingProcessingFilesCallback;
  128498. private _onReloadCallback;
  128499. private _errorCallback;
  128500. private _elementToMonitor;
  128501. private _sceneFileToLoad;
  128502. private _filesToLoad;
  128503. /**
  128504. * Creates a new FilesInput
  128505. * @param engine defines the rendering engine
  128506. * @param scene defines the hosting scene
  128507. * @param sceneLoadedCallback callback called when scene is loaded
  128508. * @param progressCallback callback called to track progress
  128509. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  128510. * @param textureLoadingCallback callback called when a texture is loading
  128511. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  128512. * @param onReloadCallback callback called when a reload is requested
  128513. * @param errorCallback callback call if an error occurs
  128514. */
  128515. 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);
  128516. private _dragEnterHandler;
  128517. private _dragOverHandler;
  128518. private _dropHandler;
  128519. /**
  128520. * Calls this function to listen to drag'n'drop events on a specific DOM element
  128521. * @param elementToMonitor defines the DOM element to track
  128522. */
  128523. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  128524. /**
  128525. * Release all associated resources
  128526. */
  128527. dispose(): void;
  128528. private renderFunction;
  128529. private drag;
  128530. private drop;
  128531. private _traverseFolder;
  128532. private _processFiles;
  128533. /**
  128534. * Load files from a drop event
  128535. * @param event defines the drop event to use as source
  128536. */
  128537. loadFiles(event: any): void;
  128538. private _processReload;
  128539. /**
  128540. * Reload the current scene from the loaded files
  128541. */
  128542. reload(): void;
  128543. }
  128544. }
  128545. declare module BABYLON {
  128546. /**
  128547. * Defines the root class used to create scene optimization to use with SceneOptimizer
  128548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128549. */
  128550. export class SceneOptimization {
  128551. /**
  128552. * Defines the priority of this optimization (0 by default which means first in the list)
  128553. */
  128554. priority: number;
  128555. /**
  128556. * Gets a string describing the action executed by the current optimization
  128557. * @returns description string
  128558. */
  128559. getDescription(): string;
  128560. /**
  128561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128562. * @param scene defines the current scene where to apply this optimization
  128563. * @param optimizer defines the current optimizer
  128564. * @returns true if everything that can be done was applied
  128565. */
  128566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128567. /**
  128568. * Creates the SceneOptimization object
  128569. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128570. * @param desc defines the description associated with the optimization
  128571. */
  128572. constructor(
  128573. /**
  128574. * Defines the priority of this optimization (0 by default which means first in the list)
  128575. */
  128576. priority?: number);
  128577. }
  128578. /**
  128579. * Defines an optimization used to reduce the size of render target textures
  128580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128581. */
  128582. export class TextureOptimization extends SceneOptimization {
  128583. /**
  128584. * Defines the priority of this optimization (0 by default which means first in the list)
  128585. */
  128586. priority: number;
  128587. /**
  128588. * 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
  128589. */
  128590. maximumSize: number;
  128591. /**
  128592. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128593. */
  128594. step: number;
  128595. /**
  128596. * Gets a string describing the action executed by the current optimization
  128597. * @returns description string
  128598. */
  128599. getDescription(): string;
  128600. /**
  128601. * Creates the TextureOptimization object
  128602. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128603. * @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
  128604. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128605. */
  128606. constructor(
  128607. /**
  128608. * Defines the priority of this optimization (0 by default which means first in the list)
  128609. */
  128610. priority?: number,
  128611. /**
  128612. * 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
  128613. */
  128614. maximumSize?: number,
  128615. /**
  128616. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128617. */
  128618. step?: number);
  128619. /**
  128620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128621. * @param scene defines the current scene where to apply this optimization
  128622. * @param optimizer defines the current optimizer
  128623. * @returns true if everything that can be done was applied
  128624. */
  128625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128626. }
  128627. /**
  128628. * Defines an optimization used to increase or decrease the rendering resolution
  128629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128630. */
  128631. export class HardwareScalingOptimization extends SceneOptimization {
  128632. /**
  128633. * Defines the priority of this optimization (0 by default which means first in the list)
  128634. */
  128635. priority: number;
  128636. /**
  128637. * Defines the maximum scale to use (2 by default)
  128638. */
  128639. maximumScale: number;
  128640. /**
  128641. * Defines the step to use between two passes (0.5 by default)
  128642. */
  128643. step: number;
  128644. private _currentScale;
  128645. private _directionOffset;
  128646. /**
  128647. * Gets a string describing the action executed by the current optimization
  128648. * @return description string
  128649. */
  128650. getDescription(): string;
  128651. /**
  128652. * Creates the HardwareScalingOptimization object
  128653. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128654. * @param maximumScale defines the maximum scale to use (2 by default)
  128655. * @param step defines the step to use between two passes (0.5 by default)
  128656. */
  128657. constructor(
  128658. /**
  128659. * Defines the priority of this optimization (0 by default which means first in the list)
  128660. */
  128661. priority?: number,
  128662. /**
  128663. * Defines the maximum scale to use (2 by default)
  128664. */
  128665. maximumScale?: number,
  128666. /**
  128667. * Defines the step to use between two passes (0.5 by default)
  128668. */
  128669. step?: number);
  128670. /**
  128671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128672. * @param scene defines the current scene where to apply this optimization
  128673. * @param optimizer defines the current optimizer
  128674. * @returns true if everything that can be done was applied
  128675. */
  128676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128677. }
  128678. /**
  128679. * Defines an optimization used to remove shadows
  128680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128681. */
  128682. export class ShadowsOptimization extends SceneOptimization {
  128683. /**
  128684. * Gets a string describing the action executed by the current optimization
  128685. * @return description string
  128686. */
  128687. getDescription(): string;
  128688. /**
  128689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128690. * @param scene defines the current scene where to apply this optimization
  128691. * @param optimizer defines the current optimizer
  128692. * @returns true if everything that can be done was applied
  128693. */
  128694. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128695. }
  128696. /**
  128697. * Defines an optimization used to turn post-processes off
  128698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128699. */
  128700. export class PostProcessesOptimization extends SceneOptimization {
  128701. /**
  128702. * Gets a string describing the action executed by the current optimization
  128703. * @return description string
  128704. */
  128705. getDescription(): string;
  128706. /**
  128707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128708. * @param scene defines the current scene where to apply this optimization
  128709. * @param optimizer defines the current optimizer
  128710. * @returns true if everything that can be done was applied
  128711. */
  128712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128713. }
  128714. /**
  128715. * Defines an optimization used to turn lens flares off
  128716. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128717. */
  128718. export class LensFlaresOptimization extends SceneOptimization {
  128719. /**
  128720. * Gets a string describing the action executed by the current optimization
  128721. * @return description string
  128722. */
  128723. getDescription(): string;
  128724. /**
  128725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128726. * @param scene defines the current scene where to apply this optimization
  128727. * @param optimizer defines the current optimizer
  128728. * @returns true if everything that can be done was applied
  128729. */
  128730. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128731. }
  128732. /**
  128733. * Defines an optimization based on user defined callback.
  128734. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128735. */
  128736. export class CustomOptimization extends SceneOptimization {
  128737. /**
  128738. * Callback called to apply the custom optimization.
  128739. */
  128740. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  128741. /**
  128742. * Callback called to get custom description
  128743. */
  128744. onGetDescription: () => string;
  128745. /**
  128746. * Gets a string describing the action executed by the current optimization
  128747. * @returns description string
  128748. */
  128749. getDescription(): string;
  128750. /**
  128751. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128752. * @param scene defines the current scene where to apply this optimization
  128753. * @param optimizer defines the current optimizer
  128754. * @returns true if everything that can be done was applied
  128755. */
  128756. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128757. }
  128758. /**
  128759. * Defines an optimization used to turn particles off
  128760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128761. */
  128762. export class ParticlesOptimization extends SceneOptimization {
  128763. /**
  128764. * Gets a string describing the action executed by the current optimization
  128765. * @return description string
  128766. */
  128767. getDescription(): string;
  128768. /**
  128769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128770. * @param scene defines the current scene where to apply this optimization
  128771. * @param optimizer defines the current optimizer
  128772. * @returns true if everything that can be done was applied
  128773. */
  128774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128775. }
  128776. /**
  128777. * Defines an optimization used to turn render targets off
  128778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128779. */
  128780. export class RenderTargetsOptimization extends SceneOptimization {
  128781. /**
  128782. * Gets a string describing the action executed by the current optimization
  128783. * @return description string
  128784. */
  128785. getDescription(): string;
  128786. /**
  128787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128788. * @param scene defines the current scene where to apply this optimization
  128789. * @param optimizer defines the current optimizer
  128790. * @returns true if everything that can be done was applied
  128791. */
  128792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128793. }
  128794. /**
  128795. * Defines an optimization used to merge meshes with compatible materials
  128796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128797. */
  128798. export class MergeMeshesOptimization extends SceneOptimization {
  128799. private static _UpdateSelectionTree;
  128800. /**
  128801. * Gets or sets a boolean which defines if optimization octree has to be updated
  128802. */
  128803. /**
  128804. * Gets or sets a boolean which defines if optimization octree has to be updated
  128805. */
  128806. static UpdateSelectionTree: boolean;
  128807. /**
  128808. * Gets a string describing the action executed by the current optimization
  128809. * @return description string
  128810. */
  128811. getDescription(): string;
  128812. private _canBeMerged;
  128813. /**
  128814. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128815. * @param scene defines the current scene where to apply this optimization
  128816. * @param optimizer defines the current optimizer
  128817. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  128818. * @returns true if everything that can be done was applied
  128819. */
  128820. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  128821. }
  128822. /**
  128823. * Defines a list of options used by SceneOptimizer
  128824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128825. */
  128826. export class SceneOptimizerOptions {
  128827. /**
  128828. * Defines the target frame rate to reach (60 by default)
  128829. */
  128830. targetFrameRate: number;
  128831. /**
  128832. * Defines the interval between two checkes (2000ms by default)
  128833. */
  128834. trackerDuration: number;
  128835. /**
  128836. * Gets the list of optimizations to apply
  128837. */
  128838. optimizations: SceneOptimization[];
  128839. /**
  128840. * Creates a new list of options used by SceneOptimizer
  128841. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  128842. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  128843. */
  128844. constructor(
  128845. /**
  128846. * Defines the target frame rate to reach (60 by default)
  128847. */
  128848. targetFrameRate?: number,
  128849. /**
  128850. * Defines the interval between two checkes (2000ms by default)
  128851. */
  128852. trackerDuration?: number);
  128853. /**
  128854. * Add a new optimization
  128855. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  128856. * @returns the current SceneOptimizerOptions
  128857. */
  128858. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  128859. /**
  128860. * Add a new custom optimization
  128861. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  128862. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  128863. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128864. * @returns the current SceneOptimizerOptions
  128865. */
  128866. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  128867. /**
  128868. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  128869. * @param targetFrameRate defines the target frame rate (60 by default)
  128870. * @returns a SceneOptimizerOptions object
  128871. */
  128872. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  128873. /**
  128874. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  128875. * @param targetFrameRate defines the target frame rate (60 by default)
  128876. * @returns a SceneOptimizerOptions object
  128877. */
  128878. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  128879. /**
  128880. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  128881. * @param targetFrameRate defines the target frame rate (60 by default)
  128882. * @returns a SceneOptimizerOptions object
  128883. */
  128884. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  128885. }
  128886. /**
  128887. * Class used to run optimizations in order to reach a target frame rate
  128888. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128889. */
  128890. export class SceneOptimizer implements IDisposable {
  128891. private _isRunning;
  128892. private _options;
  128893. private _scene;
  128894. private _currentPriorityLevel;
  128895. private _targetFrameRate;
  128896. private _trackerDuration;
  128897. private _currentFrameRate;
  128898. private _sceneDisposeObserver;
  128899. private _improvementMode;
  128900. /**
  128901. * Defines an observable called when the optimizer reaches the target frame rate
  128902. */
  128903. onSuccessObservable: Observable<SceneOptimizer>;
  128904. /**
  128905. * Defines an observable called when the optimizer enables an optimization
  128906. */
  128907. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  128908. /**
  128909. * Defines an observable called when the optimizer is not able to reach the target frame rate
  128910. */
  128911. onFailureObservable: Observable<SceneOptimizer>;
  128912. /**
  128913. * Gets a boolean indicating if the optimizer is in improvement mode
  128914. */
  128915. readonly isInImprovementMode: boolean;
  128916. /**
  128917. * Gets the current priority level (0 at start)
  128918. */
  128919. readonly currentPriorityLevel: number;
  128920. /**
  128921. * Gets the current frame rate checked by the SceneOptimizer
  128922. */
  128923. readonly currentFrameRate: number;
  128924. /**
  128925. * Gets or sets the current target frame rate (60 by default)
  128926. */
  128927. /**
  128928. * Gets or sets the current target frame rate (60 by default)
  128929. */
  128930. targetFrameRate: number;
  128931. /**
  128932. * Gets or sets the current interval between two checks (every 2000ms by default)
  128933. */
  128934. /**
  128935. * Gets or sets the current interval between two checks (every 2000ms by default)
  128936. */
  128937. trackerDuration: number;
  128938. /**
  128939. * Gets the list of active optimizations
  128940. */
  128941. readonly optimizations: SceneOptimization[];
  128942. /**
  128943. * Creates a new SceneOptimizer
  128944. * @param scene defines the scene to work on
  128945. * @param options defines the options to use with the SceneOptimizer
  128946. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  128947. * @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)
  128948. */
  128949. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  128950. /**
  128951. * Stops the current optimizer
  128952. */
  128953. stop(): void;
  128954. /**
  128955. * Reset the optimizer to initial step (current priority level = 0)
  128956. */
  128957. reset(): void;
  128958. /**
  128959. * Start the optimizer. By default it will try to reach a specific framerate
  128960. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  128961. */
  128962. start(): void;
  128963. private _checkCurrentState;
  128964. /**
  128965. * Release all resources
  128966. */
  128967. dispose(): void;
  128968. /**
  128969. * Helper function to create a SceneOptimizer with one single line of code
  128970. * @param scene defines the scene to work on
  128971. * @param options defines the options to use with the SceneOptimizer
  128972. * @param onSuccess defines a callback to call on success
  128973. * @param onFailure defines a callback to call on failure
  128974. * @returns the new SceneOptimizer object
  128975. */
  128976. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  128977. }
  128978. }
  128979. declare module BABYLON {
  128980. /**
  128981. * Class used to serialize a scene into a string
  128982. */
  128983. export class SceneSerializer {
  128984. /**
  128985. * Clear cache used by a previous serialization
  128986. */
  128987. static ClearCache(): void;
  128988. /**
  128989. * Serialize a scene into a JSON compatible object
  128990. * @param scene defines the scene to serialize
  128991. * @returns a JSON compatible object
  128992. */
  128993. static Serialize(scene: Scene): any;
  128994. /**
  128995. * Serialize a mesh into a JSON compatible object
  128996. * @param toSerialize defines the mesh to serialize
  128997. * @param withParents defines if parents must be serialized as well
  128998. * @param withChildren defines if children must be serialized as well
  128999. * @returns a JSON compatible object
  129000. */
  129001. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129002. }
  129003. }
  129004. declare module BABYLON {
  129005. /**
  129006. * Class used to host texture specific utilities
  129007. */
  129008. export class TextureTools {
  129009. /**
  129010. * Uses the GPU to create a copy texture rescaled at a given size
  129011. * @param texture Texture to copy from
  129012. * @param width defines the desired width
  129013. * @param height defines the desired height
  129014. * @param useBilinearMode defines if bilinear mode has to be used
  129015. * @return the generated texture
  129016. */
  129017. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129018. }
  129019. }
  129020. declare module BABYLON {
  129021. /**
  129022. * This represents the different options available for the video capture.
  129023. */
  129024. export interface VideoRecorderOptions {
  129025. /** Defines the mime type of the video. */
  129026. mimeType: string;
  129027. /** Defines the FPS the video should be recorded at. */
  129028. fps: number;
  129029. /** Defines the chunk size for the recording data. */
  129030. recordChunckSize: number;
  129031. /** The audio tracks to attach to the recording. */
  129032. audioTracks?: MediaStreamTrack[];
  129033. }
  129034. /**
  129035. * This can help with recording videos from BabylonJS.
  129036. * This is based on the available WebRTC functionalities of the browser.
  129037. *
  129038. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129039. */
  129040. export class VideoRecorder {
  129041. private static readonly _defaultOptions;
  129042. /**
  129043. * Returns whether or not the VideoRecorder is available in your browser.
  129044. * @param engine Defines the Babylon Engine.
  129045. * @returns true if supported otherwise false.
  129046. */
  129047. static IsSupported(engine: Engine): boolean;
  129048. private readonly _options;
  129049. private _canvas;
  129050. private _mediaRecorder;
  129051. private _recordedChunks;
  129052. private _fileName;
  129053. private _resolve;
  129054. private _reject;
  129055. /**
  129056. * True when a recording is already in progress.
  129057. */
  129058. readonly isRecording: boolean;
  129059. /**
  129060. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129061. * @param engine Defines the BabylonJS Engine you wish to record.
  129062. * @param options Defines options that can be used to customize the capture.
  129063. */
  129064. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129065. /**
  129066. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129067. */
  129068. stopRecording(): void;
  129069. /**
  129070. * Starts recording the canvas for a max duration specified in parameters.
  129071. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129072. * If null no automatic download will start and you can rely on the promise to get the data back.
  129073. * @param maxDuration Defines the maximum recording time in seconds.
  129074. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129075. * @return A promise callback at the end of the recording with the video data in Blob.
  129076. */
  129077. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129078. /**
  129079. * Releases internal resources used during the recording.
  129080. */
  129081. dispose(): void;
  129082. private _handleDataAvailable;
  129083. private _handleError;
  129084. private _handleStop;
  129085. }
  129086. }
  129087. declare module BABYLON {
  129088. /**
  129089. * Class containing a set of static utilities functions for screenshots
  129090. */
  129091. export class ScreenshotTools {
  129092. /**
  129093. * Captures a screenshot of the current rendering
  129094. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129095. * @param engine defines the rendering engine
  129096. * @param camera defines the source camera
  129097. * @param size This parameter can be set to a single number or to an object with the
  129098. * following (optional) properties: precision, width, height. If a single number is passed,
  129099. * it will be used for both width and height. If an object is passed, the screenshot size
  129100. * will be derived from the parameters. The precision property is a multiplier allowing
  129101. * rendering at a higher or lower resolution
  129102. * @param successCallback defines the callback receives a single parameter which contains the
  129103. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129104. * src parameter of an <img> to display it
  129105. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129106. * Check your browser for supported MIME types
  129107. */
  129108. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129109. /**
  129110. * Captures a screenshot of the current rendering
  129111. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129112. * @param engine defines the rendering engine
  129113. * @param camera defines the source camera
  129114. * @param size This parameter can be set to a single number or to an object with the
  129115. * following (optional) properties: precision, width, height. If a single number is passed,
  129116. * it will be used for both width and height. If an object is passed, the screenshot size
  129117. * will be derived from the parameters. The precision property is a multiplier allowing
  129118. * rendering at a higher or lower resolution
  129119. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129120. * Check your browser for supported MIME types
  129121. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129122. * to the src parameter of an <img> to display it
  129123. */
  129124. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129125. /**
  129126. * Generates an image screenshot from the specified camera.
  129127. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129128. * @param engine The engine to use for rendering
  129129. * @param camera The camera to use for rendering
  129130. * @param size This parameter can be set to a single number or to an object with the
  129131. * following (optional) properties: precision, width, height. If a single number is passed,
  129132. * it will be used for both width and height. If an object is passed, the screenshot size
  129133. * will be derived from the parameters. The precision property is a multiplier allowing
  129134. * rendering at a higher or lower resolution
  129135. * @param successCallback The callback receives a single parameter which contains the
  129136. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129137. * src parameter of an <img> to display it
  129138. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129139. * Check your browser for supported MIME types
  129140. * @param samples Texture samples (default: 1)
  129141. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129142. * @param fileName A name for for the downloaded file.
  129143. */
  129144. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129145. /**
  129146. * Generates an image screenshot from the specified camera.
  129147. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129148. * @param engine The engine to use for rendering
  129149. * @param camera The camera to use for rendering
  129150. * @param size This parameter can be set to a single number or to an object with the
  129151. * following (optional) properties: precision, width, height. If a single number is passed,
  129152. * it will be used for both width and height. If an object is passed, the screenshot size
  129153. * will be derived from the parameters. The precision property is a multiplier allowing
  129154. * rendering at a higher or lower resolution
  129155. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129156. * Check your browser for supported MIME types
  129157. * @param samples Texture samples (default: 1)
  129158. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129159. * @param fileName A name for for the downloaded file.
  129160. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129161. * to the src parameter of an <img> to display it
  129162. */
  129163. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129164. /**
  129165. * Gets height and width for screenshot size
  129166. * @private
  129167. */
  129168. private static _getScreenshotSize;
  129169. }
  129170. }
  129171. declare module BABYLON {
  129172. /**
  129173. * A cursor which tracks a point on a path
  129174. */
  129175. export class PathCursor {
  129176. private path;
  129177. /**
  129178. * Stores path cursor callbacks for when an onchange event is triggered
  129179. */
  129180. private _onchange;
  129181. /**
  129182. * The value of the path cursor
  129183. */
  129184. value: number;
  129185. /**
  129186. * The animation array of the path cursor
  129187. */
  129188. animations: Animation[];
  129189. /**
  129190. * Initializes the path cursor
  129191. * @param path The path to track
  129192. */
  129193. constructor(path: Path2);
  129194. /**
  129195. * Gets the cursor point on the path
  129196. * @returns A point on the path cursor at the cursor location
  129197. */
  129198. getPoint(): Vector3;
  129199. /**
  129200. * Moves the cursor ahead by the step amount
  129201. * @param step The amount to move the cursor forward
  129202. * @returns This path cursor
  129203. */
  129204. moveAhead(step?: number): PathCursor;
  129205. /**
  129206. * Moves the cursor behind by the step amount
  129207. * @param step The amount to move the cursor back
  129208. * @returns This path cursor
  129209. */
  129210. moveBack(step?: number): PathCursor;
  129211. /**
  129212. * Moves the cursor by the step amount
  129213. * If the step amount is greater than one, an exception is thrown
  129214. * @param step The amount to move the cursor
  129215. * @returns This path cursor
  129216. */
  129217. move(step: number): PathCursor;
  129218. /**
  129219. * Ensures that the value is limited between zero and one
  129220. * @returns This path cursor
  129221. */
  129222. private ensureLimits;
  129223. /**
  129224. * Runs onchange callbacks on change (used by the animation engine)
  129225. * @returns This path cursor
  129226. */
  129227. private raiseOnChange;
  129228. /**
  129229. * Executes a function on change
  129230. * @param f A path cursor onchange callback
  129231. * @returns This path cursor
  129232. */
  129233. onchange(f: (cursor: PathCursor) => void): PathCursor;
  129234. }
  129235. }
  129236. declare module BABYLON {
  129237. /** @hidden */
  129238. export var blurPixelShader: {
  129239. name: string;
  129240. shader: string;
  129241. };
  129242. }
  129243. declare module BABYLON {
  129244. /** @hidden */
  129245. export var pointCloudVertexDeclaration: {
  129246. name: string;
  129247. shader: string;
  129248. };
  129249. }
  129250. // Mixins
  129251. interface Window {
  129252. mozIndexedDB: IDBFactory;
  129253. webkitIndexedDB: IDBFactory;
  129254. msIndexedDB: IDBFactory;
  129255. webkitURL: typeof URL;
  129256. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  129257. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  129258. WebGLRenderingContext: WebGLRenderingContext;
  129259. MSGesture: MSGesture;
  129260. CANNON: any;
  129261. AudioContext: AudioContext;
  129262. webkitAudioContext: AudioContext;
  129263. PointerEvent: any;
  129264. Math: Math;
  129265. Uint8Array: Uint8ArrayConstructor;
  129266. Float32Array: Float32ArrayConstructor;
  129267. mozURL: typeof URL;
  129268. msURL: typeof URL;
  129269. VRFrameData: any; // WebVR, from specs 1.1
  129270. DracoDecoderModule: any;
  129271. setImmediate(handler: (...args: any[]) => void): number;
  129272. }
  129273. interface HTMLCanvasElement {
  129274. requestPointerLock(): void;
  129275. msRequestPointerLock?(): void;
  129276. mozRequestPointerLock?(): void;
  129277. webkitRequestPointerLock?(): void;
  129278. /** Track wether a record is in progress */
  129279. isRecording: boolean;
  129280. /** Capture Stream method defined by some browsers */
  129281. captureStream(fps?: number): MediaStream;
  129282. }
  129283. interface CanvasRenderingContext2D {
  129284. msImageSmoothingEnabled: boolean;
  129285. }
  129286. interface MouseEvent {
  129287. mozMovementX: number;
  129288. mozMovementY: number;
  129289. webkitMovementX: number;
  129290. webkitMovementY: number;
  129291. msMovementX: number;
  129292. msMovementY: number;
  129293. }
  129294. interface Navigator {
  129295. mozGetVRDevices: (any: any) => any;
  129296. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129297. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129298. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129299. webkitGetGamepads(): Gamepad[];
  129300. msGetGamepads(): Gamepad[];
  129301. webkitGamepads(): Gamepad[];
  129302. }
  129303. interface HTMLVideoElement {
  129304. mozSrcObject: any;
  129305. }
  129306. interface Math {
  129307. fround(x: number): number;
  129308. imul(a: number, b: number): number;
  129309. }
  129310. interface WebGLRenderingContext {
  129311. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  129312. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  129313. vertexAttribDivisor(index: number, divisor: number): void;
  129314. createVertexArray(): any;
  129315. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  129316. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  129317. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  129318. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  129319. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  129320. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  129321. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  129322. // Queries
  129323. createQuery(): WebGLQuery;
  129324. deleteQuery(query: WebGLQuery): void;
  129325. beginQuery(target: number, query: WebGLQuery): void;
  129326. endQuery(target: number): void;
  129327. getQueryParameter(query: WebGLQuery, pname: number): any;
  129328. getQuery(target: number, pname: number): any;
  129329. MAX_SAMPLES: number;
  129330. RGBA8: number;
  129331. READ_FRAMEBUFFER: number;
  129332. DRAW_FRAMEBUFFER: number;
  129333. UNIFORM_BUFFER: number;
  129334. HALF_FLOAT_OES: number;
  129335. RGBA16F: number;
  129336. RGBA32F: number;
  129337. R32F: number;
  129338. RG32F: number;
  129339. RGB32F: number;
  129340. R16F: number;
  129341. RG16F: number;
  129342. RGB16F: number;
  129343. RED: number;
  129344. RG: number;
  129345. R8: number;
  129346. RG8: number;
  129347. UNSIGNED_INT_24_8: number;
  129348. DEPTH24_STENCIL8: number;
  129349. MIN: number;
  129350. MAX: number;
  129351. /* Multiple Render Targets */
  129352. drawBuffers(buffers: number[]): void;
  129353. readBuffer(src: number): void;
  129354. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  129355. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  129356. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  129357. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  129358. // Occlusion Query
  129359. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  129360. ANY_SAMPLES_PASSED: number;
  129361. QUERY_RESULT_AVAILABLE: number;
  129362. QUERY_RESULT: number;
  129363. }
  129364. interface WebGLProgram {
  129365. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  129366. }
  129367. interface EXT_disjoint_timer_query {
  129368. QUERY_COUNTER_BITS_EXT: number;
  129369. TIME_ELAPSED_EXT: number;
  129370. TIMESTAMP_EXT: number;
  129371. GPU_DISJOINT_EXT: number;
  129372. QUERY_RESULT_EXT: number;
  129373. QUERY_RESULT_AVAILABLE_EXT: number;
  129374. queryCounterEXT(query: WebGLQuery, target: number): void;
  129375. createQueryEXT(): WebGLQuery;
  129376. beginQueryEXT(target: number, query: WebGLQuery): void;
  129377. endQueryEXT(target: number): void;
  129378. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  129379. deleteQueryEXT(query: WebGLQuery): void;
  129380. }
  129381. interface WebGLUniformLocation {
  129382. _currentState: any;
  129383. }
  129384. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  129385. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  129386. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  129387. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129388. interface WebGLRenderingContext {
  129389. readonly RASTERIZER_DISCARD: number;
  129390. readonly DEPTH_COMPONENT24: number;
  129391. readonly TEXTURE_3D: number;
  129392. readonly TEXTURE_2D_ARRAY: number;
  129393. readonly TEXTURE_COMPARE_FUNC: number;
  129394. readonly TEXTURE_COMPARE_MODE: number;
  129395. readonly COMPARE_REF_TO_TEXTURE: number;
  129396. readonly TEXTURE_WRAP_R: number;
  129397. readonly HALF_FLOAT: number;
  129398. readonly RGB8: number;
  129399. readonly RED_INTEGER: number;
  129400. readonly RG_INTEGER: number;
  129401. readonly RGB_INTEGER: number;
  129402. readonly RGBA_INTEGER: number;
  129403. readonly R8_SNORM: number;
  129404. readonly RG8_SNORM: number;
  129405. readonly RGB8_SNORM: number;
  129406. readonly RGBA8_SNORM: number;
  129407. readonly R8I: number;
  129408. readonly RG8I: number;
  129409. readonly RGB8I: number;
  129410. readonly RGBA8I: number;
  129411. readonly R8UI: number;
  129412. readonly RG8UI: number;
  129413. readonly RGB8UI: number;
  129414. readonly RGBA8UI: number;
  129415. readonly R16I: number;
  129416. readonly RG16I: number;
  129417. readonly RGB16I: number;
  129418. readonly RGBA16I: number;
  129419. readonly R16UI: number;
  129420. readonly RG16UI: number;
  129421. readonly RGB16UI: number;
  129422. readonly RGBA16UI: number;
  129423. readonly R32I: number;
  129424. readonly RG32I: number;
  129425. readonly RGB32I: number;
  129426. readonly RGBA32I: number;
  129427. readonly R32UI: number;
  129428. readonly RG32UI: number;
  129429. readonly RGB32UI: number;
  129430. readonly RGBA32UI: number;
  129431. readonly RGB10_A2UI: number;
  129432. readonly R11F_G11F_B10F: number;
  129433. readonly RGB9_E5: number;
  129434. readonly RGB10_A2: number;
  129435. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  129436. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  129437. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  129438. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  129439. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  129440. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  129441. 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;
  129442. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  129443. readonly TRANSFORM_FEEDBACK: number;
  129444. readonly INTERLEAVED_ATTRIBS: number;
  129445. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  129446. createTransformFeedback(): WebGLTransformFeedback;
  129447. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  129448. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  129449. beginTransformFeedback(primitiveMode: number): void;
  129450. endTransformFeedback(): void;
  129451. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  129452. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129453. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129454. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129455. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  129456. }
  129457. interface ImageBitmap {
  129458. readonly width: number;
  129459. readonly height: number;
  129460. close(): void;
  129461. }
  129462. interface WebGLQuery extends WebGLObject {
  129463. }
  129464. declare var WebGLQuery: {
  129465. prototype: WebGLQuery;
  129466. new(): WebGLQuery;
  129467. };
  129468. interface WebGLSampler extends WebGLObject {
  129469. }
  129470. declare var WebGLSampler: {
  129471. prototype: WebGLSampler;
  129472. new(): WebGLSampler;
  129473. };
  129474. interface WebGLSync extends WebGLObject {
  129475. }
  129476. declare var WebGLSync: {
  129477. prototype: WebGLSync;
  129478. new(): WebGLSync;
  129479. };
  129480. interface WebGLTransformFeedback extends WebGLObject {
  129481. }
  129482. declare var WebGLTransformFeedback: {
  129483. prototype: WebGLTransformFeedback;
  129484. new(): WebGLTransformFeedback;
  129485. };
  129486. interface WebGLVertexArrayObject extends WebGLObject {
  129487. }
  129488. declare var WebGLVertexArrayObject: {
  129489. prototype: WebGLVertexArrayObject;
  129490. new(): WebGLVertexArrayObject;
  129491. };
  129492. // Type definitions for WebVR API
  129493. // Project: https://w3c.github.io/webvr/
  129494. // Definitions by: six a <https://github.com/lostfictions>
  129495. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129496. interface VRDisplay extends EventTarget {
  129497. /**
  129498. * Dictionary of capabilities describing the VRDisplay.
  129499. */
  129500. readonly capabilities: VRDisplayCapabilities;
  129501. /**
  129502. * z-depth defining the far plane of the eye view frustum
  129503. * enables mapping of values in the render target depth
  129504. * attachment to scene coordinates. Initially set to 10000.0.
  129505. */
  129506. depthFar: number;
  129507. /**
  129508. * z-depth defining the near plane of the eye view frustum
  129509. * enables mapping of values in the render target depth
  129510. * attachment to scene coordinates. Initially set to 0.01.
  129511. */
  129512. depthNear: number;
  129513. /**
  129514. * An identifier for this distinct VRDisplay. Used as an
  129515. * association point in the Gamepad API.
  129516. */
  129517. readonly displayId: number;
  129518. /**
  129519. * A display name, a user-readable name identifying it.
  129520. */
  129521. readonly displayName: string;
  129522. readonly isConnected: boolean;
  129523. readonly isPresenting: boolean;
  129524. /**
  129525. * If this VRDisplay supports room-scale experiences, the optional
  129526. * stage attribute contains details on the room-scale parameters.
  129527. */
  129528. readonly stageParameters: VRStageParameters | null;
  129529. /**
  129530. * Passing the value returned by `requestAnimationFrame` to
  129531. * `cancelAnimationFrame` will unregister the callback.
  129532. * @param handle Define the hanle of the request to cancel
  129533. */
  129534. cancelAnimationFrame(handle: number): void;
  129535. /**
  129536. * Stops presenting to the VRDisplay.
  129537. * @returns a promise to know when it stopped
  129538. */
  129539. exitPresent(): Promise<void>;
  129540. /**
  129541. * Return the current VREyeParameters for the given eye.
  129542. * @param whichEye Define the eye we want the parameter for
  129543. * @returns the eye parameters
  129544. */
  129545. getEyeParameters(whichEye: string): VREyeParameters;
  129546. /**
  129547. * Populates the passed VRFrameData with the information required to render
  129548. * the current frame.
  129549. * @param frameData Define the data structure to populate
  129550. * @returns true if ok otherwise false
  129551. */
  129552. getFrameData(frameData: VRFrameData): boolean;
  129553. /**
  129554. * Get the layers currently being presented.
  129555. * @returns the list of VR layers
  129556. */
  129557. getLayers(): VRLayer[];
  129558. /**
  129559. * Return a VRPose containing the future predicted pose of the VRDisplay
  129560. * when the current frame will be presented. The value returned will not
  129561. * change until JavaScript has returned control to the browser.
  129562. *
  129563. * The VRPose will contain the position, orientation, velocity,
  129564. * and acceleration of each of these properties.
  129565. * @returns the pose object
  129566. */
  129567. getPose(): VRPose;
  129568. /**
  129569. * Return the current instantaneous pose of the VRDisplay, with no
  129570. * prediction applied.
  129571. * @returns the current instantaneous pose
  129572. */
  129573. getImmediatePose(): VRPose;
  129574. /**
  129575. * The callback passed to `requestAnimationFrame` will be called
  129576. * any time a new frame should be rendered. When the VRDisplay is
  129577. * presenting the callback will be called at the native refresh
  129578. * rate of the HMD. When not presenting this function acts
  129579. * identically to how window.requestAnimationFrame acts. Content should
  129580. * make no assumptions of frame rate or vsync behavior as the HMD runs
  129581. * asynchronously from other displays and at differing refresh rates.
  129582. * @param callback Define the eaction to run next frame
  129583. * @returns the request handle it
  129584. */
  129585. requestAnimationFrame(callback: FrameRequestCallback): number;
  129586. /**
  129587. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  129588. * Repeat calls while already presenting will update the VRLayers being displayed.
  129589. * @param layers Define the list of layer to present
  129590. * @returns a promise to know when the request has been fulfilled
  129591. */
  129592. requestPresent(layers: VRLayer[]): Promise<void>;
  129593. /**
  129594. * Reset the pose for this display, treating its current position and
  129595. * orientation as the "origin/zero" values. VRPose.position,
  129596. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  129597. * updated when calling resetPose(). This should be called in only
  129598. * sitting-space experiences.
  129599. */
  129600. resetPose(): void;
  129601. /**
  129602. * The VRLayer provided to the VRDisplay will be captured and presented
  129603. * in the HMD. Calling this function has the same effect on the source
  129604. * canvas as any other operation that uses its source image, and canvases
  129605. * created without preserveDrawingBuffer set to true will be cleared.
  129606. * @param pose Define the pose to submit
  129607. */
  129608. submitFrame(pose?: VRPose): void;
  129609. }
  129610. declare var VRDisplay: {
  129611. prototype: VRDisplay;
  129612. new(): VRDisplay;
  129613. };
  129614. interface VRLayer {
  129615. leftBounds?: number[] | Float32Array | null;
  129616. rightBounds?: number[] | Float32Array | null;
  129617. source?: HTMLCanvasElement | null;
  129618. }
  129619. interface VRDisplayCapabilities {
  129620. readonly canPresent: boolean;
  129621. readonly hasExternalDisplay: boolean;
  129622. readonly hasOrientation: boolean;
  129623. readonly hasPosition: boolean;
  129624. readonly maxLayers: number;
  129625. }
  129626. interface VREyeParameters {
  129627. /** @deprecated */
  129628. readonly fieldOfView: VRFieldOfView;
  129629. readonly offset: Float32Array;
  129630. readonly renderHeight: number;
  129631. readonly renderWidth: number;
  129632. }
  129633. interface VRFieldOfView {
  129634. readonly downDegrees: number;
  129635. readonly leftDegrees: number;
  129636. readonly rightDegrees: number;
  129637. readonly upDegrees: number;
  129638. }
  129639. interface VRFrameData {
  129640. readonly leftProjectionMatrix: Float32Array;
  129641. readonly leftViewMatrix: Float32Array;
  129642. readonly pose: VRPose;
  129643. readonly rightProjectionMatrix: Float32Array;
  129644. readonly rightViewMatrix: Float32Array;
  129645. readonly timestamp: number;
  129646. }
  129647. interface VRPose {
  129648. readonly angularAcceleration: Float32Array | null;
  129649. readonly angularVelocity: Float32Array | null;
  129650. readonly linearAcceleration: Float32Array | null;
  129651. readonly linearVelocity: Float32Array | null;
  129652. readonly orientation: Float32Array | null;
  129653. readonly position: Float32Array | null;
  129654. readonly timestamp: number;
  129655. }
  129656. interface VRStageParameters {
  129657. sittingToStandingTransform?: Float32Array;
  129658. sizeX?: number;
  129659. sizeY?: number;
  129660. }
  129661. interface Navigator {
  129662. getVRDisplays(): Promise<VRDisplay[]>;
  129663. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  129664. }
  129665. interface Window {
  129666. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  129667. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  129668. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  129669. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  129670. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  129671. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  129672. }
  129673. interface Gamepad {
  129674. readonly displayId: number;
  129675. }
  129676. type XRSessionMode =
  129677. | "inline"
  129678. | "immersive-vr"
  129679. | "immersive-ar";
  129680. type XRReferenceSpaceType =
  129681. | "viewer"
  129682. | "local"
  129683. | "local-floor"
  129684. | "bounded-floor"
  129685. | "unbounded";
  129686. type XREnvironmentBlendMode =
  129687. | "opaque"
  129688. | "additive"
  129689. | "alpha-blend";
  129690. type XRVisibilityState =
  129691. | "visible"
  129692. | "visible-blurred"
  129693. | "hidden";
  129694. type XRHandedness =
  129695. | "none"
  129696. | "left"
  129697. | "right";
  129698. type XRTargetRayMode =
  129699. | "gaze"
  129700. | "tracked-pointer"
  129701. | "screen";
  129702. type XREye =
  129703. | "none"
  129704. | "left"
  129705. | "right";
  129706. interface XRSpace extends EventTarget {
  129707. }
  129708. interface XRRenderState {
  129709. depthNear?: number;
  129710. depthFar?: number;
  129711. inlineVerticalFieldOfView?: number;
  129712. baseLayer?: XRWebGLLayer;
  129713. }
  129714. interface XRInputSource {
  129715. handedness: XRHandedness;
  129716. targetRayMode: XRTargetRayMode;
  129717. targetRaySpace: XRSpace;
  129718. gripSpace: XRSpace | undefined;
  129719. gamepad: Gamepad | undefined;
  129720. profiles: Array<string>;
  129721. }
  129722. interface XRSession {
  129723. addEventListener: Function;
  129724. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  129725. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  129726. requestAnimationFrame: Function;
  129727. end(): Promise<void>;
  129728. renderState: XRRenderState;
  129729. inputSources: Array<XRInputSource>;
  129730. }
  129731. interface XRReferenceSpace extends XRSpace {
  129732. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  129733. onreset: any;
  129734. }
  129735. interface XRFrame {
  129736. session: XRSession;
  129737. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  129738. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  129739. }
  129740. interface XRViewerPose extends XRPose {
  129741. views: Array<XRView>;
  129742. }
  129743. interface XRPose {
  129744. transform: XRRigidTransform;
  129745. emulatedPosition: boolean;
  129746. }
  129747. declare var XRWebGLLayer: {
  129748. prototype: XRWebGLLayer;
  129749. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  129750. };
  129751. interface XRWebGLLayer {
  129752. framebuffer: WebGLFramebuffer;
  129753. framebufferWidth: number;
  129754. framebufferHeight: number;
  129755. getViewport: Function;
  129756. }
  129757. interface XRRigidTransform {
  129758. position: DOMPointReadOnly;
  129759. orientation: DOMPointReadOnly;
  129760. matrix: Float32Array;
  129761. inverse: XRRigidTransform;
  129762. }
  129763. interface XRView {
  129764. eye: XREye;
  129765. projectionMatrix: Float32Array;
  129766. transform: XRRigidTransform;
  129767. }
  129768. interface XRInputSourceChangeEvent {
  129769. session: XRSession;
  129770. removed: Array<XRInputSource>;
  129771. added: Array<XRInputSource>;
  129772. }